Fortran: difference between f and F extension

后端 未结 4 1577
再見小時候
再見小時候 2021-02-02 16:27

I\'m a bloody beginner in Fortran.

I wonder: what is the difference between the .f and .F extensions of Fortran files. I know that muc

相关标签:
4条回答
  • 2021-02-02 16:57

    This is compiler dependent and should maybe not relied on. Usually capital suffixes indicate, that pre-processing should be used. The distinction between free and fixed format is usually made by .f90 (free) vs. .f (fixed).

    As this is compiler dependent, a good documentation would be the one of your compiler. If you happen to use gfortran, you might have a look at its options and the section on preprocessing.

    0 讨论(0)
  • 2021-02-02 16:59

    In gfortran, free-form (no special meaning for cols 7, 72) is set by the compiler switch -ffree-form and has nothing to do with .f or .F file suffixes. The difference between .f and .F is that the latter goes through a pre-processor, the most common use of which is allowing 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 讨论(0)
  • 2021-02-02 17:03

    The capital F denotes that a C-like compiler should be used.

    http://fortranwiki.org/fortran/show/File+extensions

    0 讨论(0)
  • 2021-02-02 17:17

    As far as I know, .f and .F are both extensions associated with the FORTRAN 77 fixed format. Fixed format is limitted to 72 columns, where the first six columns serve special purposes. E.g. a & at position 6 indicates a line continuation from the previous line.

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

    Capital letters in the file extension usually turn the pre-processor on.

    Note that these are conventions that can be overridden with compile options for most compilers.

    0 讨论(0)
提交回复
热议问题