To: J3 J3/18-253r3 From: Dan Nagle Subject: line length and/or statement length Date: 2018-October-17 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 __FILE__, 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 256 characters, or 33792 characters, for the whole statement length. Note that C/C+-+- allows 4095 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 the 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 processor dependent to remove line wrapping, but must be at least 10K processor characters per line. 2. Maximum statement lengths be lengthened to 1M processor characters per statement. 3. The maximum number of continuations is unspecified (but the clever student can deduce a limit from the above limits). This allows rather long lines while bounding overall statement length. This changes the way compilers are required to diagnose excessively long lines. IV (Rough) Requirements The maximum line lengths are processor dependent, but must be to 10K processor characters. The maximum statement length be increased to 1M processor characters. Line continuation remains specified but the maximum number of continuations is unspecified.