Personal tools
You are here: Home User Support User Documentation DEISA Common Production Environment 6 Compiling and linking

6 Compiling and linking

6.1 Compiler wrappers

In the DEISA environment, the default behaviour is that the C, C++ and Fortran compilers are not directly invoked; compiler wrappers are called instead.

For instance, in the AIX IBM environment, the wrapper script for the Fortran compiler (xlf, xlf_r, f90, etc.) uses two environment variables called $DEISA_FFLAGS (for the compilation and link steps) and $DEISA_LDFLAGS (for the link steps). With the C and C++ compilers, the variables for compilation steps are called $DEISA_CFLAGS and DEISA_CXXFLAGS, whereas $DEISA_LDFLAGS is also used for link steps. You are advised not to change these variables, as it can generate unwanted side effects.

If you do not want to use the default behaviour with the compiler/linker wrappers, you will first have to ask not use them by switching to the no version of the compilerwrappers modulefile (see also the next paragraph):

> module switch compilerwrappers/yes compilerwrappers/no

unload usage of the compiler wrappers
...
load non usage of the compiler wrappers

 

6.2 Compiling and linking with libraries

With the default approach, compiling and linking your codes is very simple: you will just need to load the modulefiles of the desired libraries and call the compiler. For instance, if you want to compile a code with the NAG Fortran library:

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            3) fortran/ibm/12.1      5) mode/64
2) c++/ibm/10.0          4) compilerwrappers/yes  6) deisa
> module load nag

load ESSL Library 4 in 32/64-bit mode (DEISA_LDFLAGS)
load NAG Library Mark 21 in 64-bit mode (DEISA_FFLAGS, DEISA_LDFLAGS)

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            4) compilerwrappers/yes  7) essl/4
2) c++/ibm/10.0          5) mode/64               8) nag/21
3) fortran/ibm/12.1      6) deisa
> f90 -o test-nag test-nag.f90
Fortran command: /usr/bin/f90 -q64 -I/usr/local/prod/nag/nag21/include/q64 \
                         -L/usr/local/prod/nag/nag21/lib/q64 -lnag_use_essl –lessl test-nag.f90
/usr/bin/f90:
** test_nag   === End of Compilation 1 ===
1501-510  Compilation successful for file test-nag.f90.

> ./test-nag
 Test of Fortran 90 NAG interfaces correct

As explained in the previous paragraph, the Fortran compiler wrapper (which replaces the real compiler with the same name, just allowing to invoke it with special options) uses the two environment variables $DEISA_FFLAGS and $DEISA_LDFLAGS for the compilation and linking. A similar approach is used for the C/C++ compiler wrapper with the exception that the two environment variables are called $DEISA_CFLAGS and $DEISA_LDFLAGS. These environment variables are updated each time a modulefile is loaded/unloaded:

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            3) fortran/ibm/12.1      5) mode/64
2) c++/ibm/10.0          4) compilerwrappers/yes  6) deisa
> module load nag
load ESSL Library 4 in 32/64-bit mode (DEISA_LDFLAGS)
load NAG Library Mark 21 in 64-bit mode (DEISA_FFLAGS, DEISA_LDFLAGS)

> echo $DEISA_FFLAGS
-q64 -I/usr/local/prod/nag/nag21/include/q64

> echo $DEISA_LDFLAGS
-lessl -L/usr/local/prod/nag/nag21/lib/q64 -lnag_use_essl

 

If the compiler/linker wrappers are not used (see the previous paragraph), you can either use explicitly the compilers and linker global variables:

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            3) fortran/ibm/12.1      5) mode/64
2) c++/ibm/10.0          4) compilerwrappers/no   6) deisa

> module load nag

load ESSL Library 4 in 32/64-bit mode (DEISA_LDFLAGS, DEISA_ESSL_LDFLAGS)
load NAG Library Mark 21 in 64-bit mode (DEISA_FFLAGS, DEISA_NAG_FFLAGS, DEISA_LDFLAGS, \
                                         DEISA_NAG_LDFLAGS)

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            4) compilerwrappers/no   7) essl/4
2) c++/ibm/10.0          5) mode/64               8) nag/21
3) fortran/ibm/12.1      6) deisa

> f90 $DEISA_FFLAGS $DEISA_LDFLAGS -o test-nag test-nag.f90
Fortran command: /usr/bin/f90 -q64 -I/usr/local/prod/nag/nag21/include/q64 -lessl \
                       -L/usr/local/prod/nag/nag21/lib/q64 -lnag_use_essl test-nag.f90
/usr/bin/f90:
** test_nag   === End of Compilation 1 ===
1501-510  Compilation successful for file test-nag.f90.

> ./test-nag
 Test of Fortran 90 NAG interfaces correct

or either use explicitly the independent variables defined for each library:

> f90 $DEISA_NAG_FFLAGS $DEISA_ESSL_LDFLAGS $DEISA_NAG_LDFLAGS -o test-nag test-nag.f90
Fortran command: /usr/bin/f90 -q64 -I/usr/local/prod/nag/nag21/include/q64 -lessl \
                              -L/usr/local/prod/nag/nag21/lib/q64 -lnag_use_essl test-nag.f90
/usr/bin/f90:
** test_nag   === End of Compilation 1 ===
1501-510  Compilation successful for file test-nag.f90.

> ./test-nag
 Test of Fortran 90 NAG interfaces correct

 

6.3 More detailed example of a working session

 

> module load deisa
...
> module load essl fftw

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            4) compilerwrappers/yes  7) essl/4
2) c++/ibm/10.0          5) mode/64               8) fftw/2.1.5
3) fortran/ibm/12.1      6) deisa

> f90 –L $DEISA_HOME/model/libraries –llib1 –llib2 –o model model.f90

> ./model
Segmentation fault.
core dump.

> module load totalview
load TotalView Debugger 8 (PATH, MANPATH)

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            4) compilerwrappers/yes  7) essl/4
2) c++/ibm/10.0          5) mode/64               8) fftw/2.1.5
3) fortran/ibm/12.1      6) deisa                 9) totalview/8

> totalview ./model &

 

6.4 Error messages, known problems, and side effects

If you try to load two versions of the same software, an error message is printed and the corresponding modulefile is not loaded. The only possibility is to change one version by another one using the switch version.

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0            3) fortran/ibm/12.1      5) mode/64
2) c++/ibm/10.0          4) compilerwrappers/yes  6) deisa

> module load fortran/11.1
WARNING: fortran/11.1 cannot be loaded due to a conflict.
HINT: Might try "module unload fortran" first.

Some modulefiles require other ones to be loaded. If they are not present, an error message is printed:

> module switch mode/64 mode/32

unload 64-bit mode (OBJECT_MODE, DEISA_FFLAGS, DEISA_CFLAGS, DEISA_CXXFLAGS) (default)
...
load 32-bit mode (OBJECT_MODE, DEISA_FFLAGS, DEISA_CFLAGS, DEISA_CXXFLAGS)
...

> module list

Currently Loaded Modulefiles:
1) c/ibm/10.0             3) fortran/ibm/12.1      5) mode/32
2) c++/ibm/10.0           4) compilerwrappers/yes  6) deisa

> module load fftw
WARNING: fftw/2.1.5 cannot be loaded due to missing prereq.
HINT: the following modules must be loaded first: mode/64 ...

 

Document Actions