42.1 Writing a Makefile.h

To reflect your system, you must modify the different macros defined in Makefile:

FCOMP
: the name of the Fortran 90 compiler

CCOMP
: the name of the C compiler

CPPCOMP
: the name of the C++ compiler

LINK
: the name of the linker (usually the Fortran compiler should serve as the linker)

PP
: a flag (if any) that should precede a preprocessor directive (typically -D)

FFLAGS_OPT
: the Fortran compilation flags to produce an optimized executable. These are the flags used when -auto is given to setup.

FFLAGS_DEBUG
: the Fortran compilation flags to produce an executable that can be used with a debugger (e.g. totalview). These flags are used when -debug is passed to setup.

FFLAGS_TEST
: Fortran compilation flags to produce an executable suitable for testing. These usually involve less optimization. These flags are used when -test is passed to setup.

CFLAGS_OPT
: the optimized set of compilation flags for C/C++ code.

CFLAGS_DEBUG
: the debug compilation flags for C/C++ code.

CFLAGS_TEST
: the test compilation flags for C/C++ code.

LFLAGS_OPT
: linker flags used with the _OPT compilation flags. This usually ends in '-o' to rename the executable.

LFLAGS_DEBUG
: linker flags used with the _DEBUG compilation.

LFLAGS_TEST
: linker flags used with the _TEST compilation.

LIB_OPT
: libraries to link in with the _OPT compilation. This should include the MPI library if an MPI wrapper for the linker was not used (e.g. mpif90).

LIB_DEBUG
: libraries to link in the with the _DEBUG compilation.

LIB_TEST
: libraries to link in with the _TEST compilation.

LIB_HDF5
the necessary link line required to link in the HDF5 library. This will look something like
-L /path/to/library -lhdf5

For example, here's how you might modify the macros defined in the Makefile.h for code.rochester.edu. The first part of Makefile.h defines the paths for the MPI wrapper script and various I/O and numerical libraries.  

MPI_PATH   = /opt/mpich2/intel/1.4.1p1
HDF5_PATH  = /opt/hdf5/intel/1.8.7
HYPRE_PATH = /opt/hypre/intel/2.7.0b
NCMPI_PATH = /opt/netcdf/intel/1.2.0
These should be modified to reflect the locations on your system. Next we setup the compilers and linker. We almost always use the Fortran 90 compiler as the linker, so the Fortran libraries are automatically linked in.
FCOMP   = ${MPI_PATH}/bin/mpif90
CCOMP   = ${MPI_PATH}/bin/mpicc
CPPCOMP = ${MPI_PATH}/bin/mpicxx
LINK    = ${MPI_PATH}/bin/mpif90

# pre-processor flag
PP     = -D
These commands will need to be changed if your compiler names are different. You are encouraged to use the compiler wrapper scripts instead of the compilers directly. Note that some older versions of MPICH do not recognize .F90 as a valid extension. For these, you can either update MPICH to a later version or edit mpif90 and add .F90 to the line that checks for a valid extension. The PP macro refers to the pre-processor and should be set to the flag that the compiler uses to pass information to the C preprocessor (usually -D).

We define three different setups of compiler flags as described earlier: the “_OPT” set for normal, fully optimized code, the “_DEBUG” set for debugging FLASH, and the “_TEST” set for regression testing. This latter set usually has less optimization. These three sets are picked with the -auto, -debug, and -test flags to setup respectively.

FFLAGS_OPT   = -c -g -r8 -i4 -O3 -real_size 64 -diag-disable 10120
FFLAGS_DEBUG = -c -g -r8 -i4 -O0 -check bounds -check format \
-check output_conversion -warn all -warn error -real_size 64 -check uninit \
-traceback -fp-stack-check -diag-disable 10120 -fpe0 -check pointers
FFLAGS_TEST  = ${FFLAGS_OPT} -fp-model precise
F90FLAGS =

CFLAGS_OPT   = -c -O3 -g -D_LARGEFILE64_SOURCE -D_FORTIFY_SOURCE=2 \
-diag-disable 10120
CFLAGS_DEBUG = -c -O0 -g -traceback -debug all -debug extended \
-D_LARGEFILE64_SOURCE -diag-disable 10120 -ftrapuv -fp-stack-check
CFLAGS_TEST  = ${CFLAGS_OPT} -fp-model precise

Next come the linker flags. Typically, these have only -o to rename the executable, and some debug flags (e.g., -g) for the “_DEBUG” set.

LFLAGS_OPT   = -diag-disable 10120 -O3 -o
LFLAGS_DEBUG = -diag-disable 10120 -o
LFLAGS_TEST  = ${LFLAGS_OPT}

Then there are macros for additional flags that may be required by various libraries used by FLASH, e.g., HDF5. Macros beginning with CFLAGS_ are used for compiling C source files to object files; macros beginning with FFLAGS_ are used for compiling Fortran source files to object files; and macros beginning with LIB_ are used for the command (see LINK macro above) that links object files into the FLASH executable. Note that LIB_ macros need to be specified explicitly even if they have empty contents (as shown for LIB_MPI), if the corresponding library has been configured into FLASH.

CFLAGS_MPI   = -I$(MPI_PATH)/include
CFLAGS_HDF5  = -I${HDF5_PATH}/include -DH5_USE_16_API
CFLAGS_NCMPI = -I$(NCMPI_PATH)/include
FFLAGS_HYPRE = -I${HYPRE_PATH}/include

LIB_MPI   =
LIB_HDF5 = -L$(HDF5_PATH)/lib -lhdf5_fortran -lhdf5 -lz
LIB_NCMPI = -L$(NCMPI_PATH)/lib -lpnetcdf
LIB_HYPRE = -L${HYPRE_PATH}/lib -lHYPRE

Finally, we have a macro to specify any platform dependent code and some macros for basic file manipulation and library tools.  

MACHOBJ =


MV = mv -f
AR = ar -r
RM = rm -f
CD = cd
RL = ranlib
ECHO = echo
On most platforms, these will not need to be modified.