How to use compiler options¶
Good coding practise involves that software is tested with different compiler
options and even with different compilers in order to minimize the probability
for bugs. In QDYN, you can use the configure
script to quickly change
between different sets of compiler options, necessary for different stages of
development or data aquisition.
Run ./configure --help
to get additional details about the options
mentioned in this how to.
Note that changes in the compiler options only affect the executables after
recompiling a program (by running make
).
How to switch between different compilers¶
The compiler can be choosen with the --fc
option of the configure script. For
example, to use the GNU Fortran compiler run
./configure --fc=gfortran
If the --fc
option is not specified, the configure script will default to
ifort or alternatively gfortran if ifort is not available.
How to switch between debug flags and to control the level of compiler optimization¶
While you are developing your code, it is best to use debug flags. These can be selected by running
./configure --debug
. An even higher level of debugging can be enabled by using./configure --debug-level=3
. The runtime of your program will increase with the debug level. Only use them during development.When you are using a program to produce meaningful data, it is best to enable compiler optimization. This will in general yield a significant performance boost. This is the default behaviour of the configure script, i.e. you can simply run
./configure
without further options.If performance matters, you can enable the most aggresive compiler optimization by running
./configure --fast
. This can yield another increase in performance. However, you should cross check your results with the results obtained with a different optimization level before moving on to producing huge amounts of data. This is because aggressive optimization flags can affect numerical precision in rare circumstances.