I am maintaining a program written mainly in fixed-format Fortran. I recently switched from a Windows PC to a Mac, and I'm now using TextWrangler to edit my code. I noticed that the indentation in the editor window does not always correspond to the actual structure of the code. For example, the following random lines are displayed like this by TextWrangler:
! The following lines start on column 5!
loadnam=dirstate(1:NN)//'updatestate.sav'
open (9876, file=loadnam, status='unknown', form='binary')
close (9876, status='delete')
if ((rank == root) .or. (doParallel == .false.))
* call messagerun (1,'Proceeding with updating!')
include 'updating_opt.inc'
end if
Clearly, this does not reflect the actual structure of the code, as fixed-format Fortran statements may not start before column 7 (with a few exceptions). However, the compiler does not complain, and when I open the file with another editor, the code appears in the correct format.
If I type in a new line, however, the compiler will abort compilation if it starts before column 7 (which is the normal behavior).
I don't really understand this behavior of TextWrangler. Is it intentional? TextWrangler did recognize the language automatically (as Fortran
, not Fortran 9x
), so I'm wondering why it doesn't take into account this important aspect of old Fortran code.
Is there a way to avoid this behavior (while maintaining the Fortran syntax highlighting)? As the program is quite long, I'd like to avoid rewriting it all to free-format Fortran.