Open smalers opened 3 years ago
Code was changed to work around the warning described above. For example, the wsupsum.for
code has many substring comparisons using (1:12)
notation. This should be unnecessary if the character variables are properly defined. Fortran compares strings by comparing the left-most characters and all else is treated as spaces.
These changes should be straightforward.
With older code, string variables of different length might be declared in one place such as the main program and passed to subroutines that declare the strings with an array size. If the arrays are then compared in the subroutine, the following error can result.
The following explains how string comparisons are done (strings are padded with spaces in the comparison): https://michaelgoerz.net/notes/some-fortran-string-gotchas.html
The best practice is to use something like the following in the subroutine:
For more information, here is a main program and makefile used to test. It is confusing that
trim
does not seem to impact arrays with fixed dimensions, but maybe that is because Fortran string length is set at the dimensioned length. See the comments incompare1
subroutine for examples of what works and what does not work.Program
Makefile
Output