Fortran: difference between extension f and F

I am a bloody newcomer to Fortran.

Interesting: what is the difference between the .f and .F extensions of Fortran files. I know this a lot: f is free and F is fixed.

What do free and fixed really mean and why can they completely ruin the compilation process? (I use gfortran and ifort).

I was looking for the fortran difference between f and F extension. I was unsatisfied with the result, so I move on to stackoverflow.

If you could offer a good link to familiarize yourself with this, I would be very happy to do so.

+8
fortran compilation file-extension
source share
3 answers

As far as I know, .f and .f are both extensions related to the FORTRAN 77 fixed format. The fixed format is limited to 72 columns, where the first six columns are for special purposes. For example. a & at position 6 indicates the continuation of the line from the previous line.

Free form was introduced with Fortran 90 and is usually indicated by .f90 and .f90 . For a free form, you can use up to 132 columns, and no special columns exist. The continuation of the line is indicated by an ampersand at the end of the line.

Capital letters in a file extension usually include a preprocessor.

Note that these are conventions that can be overridden by compilation options for most compilers.

+9
source share

It depends on the compiler and may not be relied upon. Typically, capital suffixes indicate that preprocessing should be used. The distinction between free and fixed format is usually made using .f90 (free) vs .. (Fixed).

Since it depends on the compiler, your compiler will be good documentation. If you are using gfortran, you can take a look at options and the preprocessing section.

+6
source share

In gfortran, the free form (which does not really matter for cols 7, 72) is set using the -ffree compiler form command and has nothing to do with the .f or .F file suffix. The difference between .f and .F is that the latter passes through the pre-processor, the most frequent use of which allows the use of C-like #define statements. For example:

 #define MAXN 100 program example integer N(MAXN) end 

will compile if it is .F , but not if it is .f

0
source share

All Articles