To: J3 J3/18-253 From: Dan Nagle Subject: line length and/or statement length Date: 2018-October-01 I Introduction While much Fortran source is written manually, some is prepared by more-or-less automatic means. This comes in several flavors, computer-generated source files, preprocessed source files, and source files (semi-)manually created from snippets generated by other programs (for example, coefficients computed using a workbench program and written to a file are to be made into Fortran parameter statements). For any automatically-generated source and preprocessed source, the current 132 default character source line length limit is problematic. Consider preprocessing as simple as sed -e "s/__FILE__/$FILE/" output.f90 This is intended to add the name in the environment variable to the program source. But in any instance where the length of the value of $FILE is longer than eight characters, the preprocessed line may be longer than the input line, and thus may run afoul of the 132 limit. Note that line wrapping with sed is not possible, so an external extra step is the best that can be done. (Filenames at NCAR are often very long, as they often encode file metadata.) The standard currently allows 132 times 40 characters, or 5280 characters, for the whole statement length. Note that C/C+-+- allows over 4000 characters per line (and so has no practical need of line-wrapping). Since other popular languages do not have, in practice, a line wrapping issue, one wonders what value is added to Fortran by having one. II Use-cases A programmer must write a line-wrapping step into any process for preparing or preprocessing Fortran source. So, Automatic code generation schemes for Fortran must develop and maintain a line-wrapping step. Preprocessors of any kind for Fortran must develop and maintain a line-wrapping step. Code snippets written by other sources must be put into a form for Fortran compilation, and thus be subject to Fortran rules. While not automatic processing, manual line-wrapping may be tedious and error-prone. Even a simple find/replace step while manually editing a source file may result in a line-length violation, which may be unnoticed if the source file is too large to fit on one screen. III What I have in mind When attempting to treat this issue, one wants to address the problem while leaving the strengths of Fortran as-is. So I want to repair the issues of line-wrapping while preserving its benefits. So what are the strengths of line-wrapping? I can't think of any. It really is just a nuisance. And being an arbitrary and pointless nuisance is still a nuisance. So, to make a definite proposal, I'll suggest the following: 1. Maximum line lengths be lengthened to 100x the current limit, to 13200 characters per line. 2. Maximum statement lengths be lengthened to 4x the current limit, to 21120 characters per statement. 3. The maximum number of continuations is unspecified (but the clever student can deduce a limit from the above limits). (This means that, unlike the present, a statement may have only one line of maximum length.) This allows rather long lines while bounding overall statement length. IV (Rough) Requirements The maximum line length be increased 100x to 13200 characters. The maximin statement length be increased 4x to 21120 characters. Line continuation remains specified but the maximum number of continuations is unspecified.