Accueil > Informatique [computer science] > Fortran > GNU Fortran compiler (gfortran)

GNU Fortran compiler (gfortran)

jeudi 21 mars 2013, par Vincent MAGNIN

The gfortran compiler is part of GCC (GNU Compiler Collection).

Documentation

- http://gcc.gnu.org/onlinedocs/
- http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
- http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html

Compiler options

- To compile a project :
gfortran file1.f90 file2.f90
- To print all warnings :
gfortran -Wall -Wextra file1.f90 file2.f90
- To optimize speed :
gfortran -O3 -march=native file1.f90 file2.f90
- To optimize size (can sometimes optimize speed if program+data are a little bigger than the processor cache) :
gfortran -Os -march=native file1.f90 file2.f90
- To verify Fortran 2008 standard compliance (also f2003, f95, f90...) :
gfortran -std=f2008 -pedantic file1.f90 file2.f90
- To profile and optimize your code, use the -pg options and the gprof utility :

gfortran -pg file1.f90 file2.f90
./a.out
gprof


- To count the number of code lines in a project (using various languages) :
sloccount .

On a distant machine

- To login :
ssh -p 2222 login@server.fr
- To obtains infos on the CPU :
cat /proc/cpuinfo
- To launch and logout without stopping the process :

nice -19 ./a.out > /dev/null &
exit


- To automatically send a e-mail with the results files. The e-mail subject (-s option) is your login and the host name. The two .dat files are attached (-a option). The body is taken from "message.txt" :
mutt -s $(whoami)"@"$(hostname) myname@myemail.fr -a results.dat results2.dat < message.txt