Reputation: 9057
I need to know, for a public domain package, if given Fortran code is free of fixed formatted code and it is, unfortunately, not possible to use the extension for this. Is there a reliable way to do this / is there example code that does this?
Upvotes: 3
Views: 479
Reputation: 60018
You would have to write your own program/script that checks the form.
Is there any &
before column 72 outside of character strings? -> free form
Is there any non-number in the first columns outside of comments? -> free form
There other possibilities, but they would generally have to be able to decide if the statement is valid and that is more difficult:
Deciding if the character in column is a continuation character or a part of a statement in the free-form.
Deciding if a non-!
character in the first column is a comment in the fixed form or a valid statement in the free form.
There may be files that conform to both, but that shouldn't be a problem.
Upvotes: 3
Reputation: 3381
Silverfrost FTN95 uses the file extension:
.for, .f or .fix - fixed format
.f90 .f95 - free format
If the user wants to override the default they use a command line option (which they can also turn on-off as a default)
You could use these extensions as a first guess and then look at the first few lines and see if they match
Upvotes: 0