I understand gfortran can compile f90 or f95? How does it know which one it is compiling? Also can it compile f77 code? Does ubuntu already have a fortran compiler or do I need to download gfortran?
相关问题
- CABS(x) function for complex(8)
- Upper bound of random number generator
- Finding number of lines of a data file using comma
- When do Fortran module allocatable arrays go out o
- How are these double precision values accurate to
相关文章
- Does gfortran take advantage of DO CONCURRENT?
- Fortran 90 - “Segmentation fault - invalid memory
- Reading records from a Fortran binary file in Pyth
- expand a dense matrix
- Unable to use f2py to link large PETSc/SLEPc Fortr
- Fortran compiler error installing PyOptSparse
- How to read comma delimited data file if some data
- getting Cygwin to know about microsoft cl and nmak
Yes, gfortran can compile FORTRAN 77 and Fortran 90,95 etc. It has many features of 2003 & 2008 implemented. For Fortran 90/95/2003/2008 code a good extension to use is .f90. Some other compilers don't recognize .f95, .f2003, etc. And do you really want to rename your files when a new standard comes out? Use .f or .for for FORTRAN 77. The main difference is the source layout that the compiler will expect: free form for .f90, fixed form for .f or .for. (Upper-case filetypes will cause the preprocessor to be run.) You can force fixed-form layout with the options -ffixed-form -ffixed-line-length-none.
gfortran can guess certain things from the file extension; if the file has an extension of .f, .f90, f95, .f03, or .f08 it will assume fixed (.f) or free format with the appropriate standards. But you can force it to compile (say) fortran2003 code with the option -std=f2003. Eg, from the documentation,
Note that, with a few exceptions, the fortran standards are highly backwards-compatable, so that much "nice", standard conforming, fortran-77 code is also valid fortran 2003 code. The main problem with that is that much fortran code from the 80s and earlier is neither "nice" nor standard-conforming.