Skip to content
Snippets Groups Projects
Commit 41381174 authored by RIETTE Sébastien's avatar RIETTE Sébastien
Browse files

S. Riette 03/06/2022 First version of the build system based on fcm

Mechanism and external dependencies (fiat) seem OK
Some modules are missing to enable the compilation
parent 435674c0
No related branches found
No related tags found
No related merge requests found
# Ignore the object directories generated by the fcm compilation
/build/with_fcm/arch_*
# Ignore the content of the fcm directory but not the directory itself
/build/with_fcm/fcm/**
!/build/with_fcm/fcm/.gitkeep
# Ignore the content of the fiat directory but not the directory itself
/build/with_fcm/fiat/**
!/build/with_fcm/fiat/.gitkeep
Directory organisation:
- the fcm subdirectory contains the fcm tool. In the PHYEX git repository, this directory is empty.
It will be populated on first call to the make\_fcm.sh script and content is not tracked by git.
- the fiat subdirectory contains the fiat package from the ECMWF. In the PHYEX git repository, this directory is empty.
It will be populated on first call to the make\_fcm.sh script and content is not tracked by git.
- the arch subdirectory contains architecture specific files. An alternative arch directory can be
provided on the command line when calling the make\_fcm.sh script
- arch\_\* subdirectories are automatically created by the make\_fcm.sh script and are tracked by git.
- the make\_fcm.sh script will:
- populate the fcm and fiat directories on first call
- create the arch\_$ARCH directory, poulate it with arch specific files and a compilation script
- execute the newly created compilation script
Note: full cleaning is achieved by removing the arch\_\* subdirectories.
Note: documentation of the make\_fcm.sh script can be obtained with the -h option
#Fichier configuration
comment avoir un .so comme cible
#Script make_fcm
revoir les options disponibles --full? --jobs N? --ignore-lock?: sont-elles les mêmes avec le passage à la dernière version de fcm (make)?
faire un ticket fcm à propos du pb de compilation fiat (toto.F90 avec toto.c)
utiliser les configurations spécifiques aux architectures dans le fichier de config fcm
module purge
module load gcc/9.1.0
module load intel-all
module load gcc/9.1.0
module load hdf5/1.10.5-mpi
module load netcdf/4.7.2-mpi
module load netcdf-fortran/4.5.2-mpi
source $I_MPI_ROOT/intel64/bin/mpivars.sh release_mt
%COMPILER mpiifort
%LINK mpiifort
%FPP mpiifort -E
%AR ar
%MAKE gmake
%FPP_FLAGS -P
%FPP_DEF KEY_NONE CPP_NETCDF4
%BASE_FFLAGS -fPIC -i4 -r8 -auto -align all -fp-model strict
%PROD_FFLAGS -g -traceback -O3 -xHost -qopt-zmm-usage=high
%DEV_FFLAGS -g -O1 -traceback
%DEBUG_FFLAGS -g -traceback -check bounds
%MPI_FFLAGS
%OMP_FFLAGS -qopenmp -qopenmp-threadprivate=compat
%BASE_LD -fPIC -i4 -r8 -auto
%MPI_LD
%OMP_LD -qopenmp -qopenmp-threadprivate=compat
%COMPILER gfortran
%LINK gfortran
%FPP gfortran -E
%AR ar
%MAKE gmake
%FPP_FLAGS -P
%FPP_DEF
%BASE_FFLAGS -c -fPIC -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none
%PROD_FFLAGS -O3
%DEV_FFLAGS -O1
%DEBUG_FFLAGS -check bounds
%MPI_FFLAGS
%OMP_FFLAGS
%BASE_LD -fPIC -fdefault-real-8 -fdefault-double-8
%MPI_LD
%OMP_LD
steps = build
#inc arch.fcm
#inc config.fcm
#
#%FFLAGS %BASE_FFLAGS %COMPIL_FFLAGS
#bld::tool::fc %COMPILER
#bld::tool::ld %LINK
#bld::tool::ldflags %LD_FLAGS %LIB
#bld::tool::fflags %FFLAGS
#bld::tool::fppkeys %CPP_KEY %FPP_DEF
#bld::tool::fpp %FPP
#bld::tool::fppflags %FPP_FLAGS
#
## Pre-process code before analysing dependencies
#bld::pp false
## Set Fortran compiler/linker
#build.prop{fc} = ifort
## Set Fortran compiler options
#build.prop{fc.flags} = -i8 -r8 -O3
## Add include paths to Fortran compiler
#build.prop{fc.include-paths} = /a/path/to/include /more/path/to/include
## Set link libraries for Fortran executables
#build.prop{fc.lib-paths} = /path/to/my-lib
#build.prop{fc.libs} = mine
## Set C compiler/linker
#build.prop{cc} = icc
## Set C compiler options
#build.prop{cc.flags} = -O3
## Set C++ compiler options
#build.prop{cxx.flags} = -O2
## Set link libraries for C executables
#build.prop{cc.lib-paths} = /path/to/my-lib /path/to/your-lib
#build.prop{cc.libs} = mine yours
## Set linker, if compiler cannot be used as linker
##build.prop{ld} = ld
#build.prop{fc.defs} = DEFS TO BUILD THIS # 4
#A terme, c'est un .so qu'il faut générérer avec des points d'entrée à définir
build.target = libo.a
#build.target-rename = libo.a:libphyex.a
build.source[common] = src/common/
#It would be easier to put the entire fiat directory but there are issues
#with entry points declared twice: in C and in fortran
#FCM hate this
#build.source[fiat] = src/fiat/
build.source[parkind] = src/fiat/parkind
build.source[drhook] = src/fiat/fiat/drhook
build.source[include] = src/fiat/fiat/include/fiat
build.source[ec_parkind] = src/fiat/fiat/util/ec_parkind.F90
build.source[ec_args_mod] = src/fiat/fiat/util/ec_args_mod.F90
build.source[ec_lun] = src/fiat/fiat/util/ec_lun.F90
build.source[ec_env_mod] = src/fiat/fiat/util/ec_env_mod.F90
build.source[mpif] = src/fiat/mpi_serial/mpif.h
build.source[mpl] = src/fiat/fiat/mpl/internal
build.source[oml] = src/fiat/fiat/oml
build.source[yomgstats] = src/fiat/fiat/gstats/yomgstats.F90
#!/bin/bash
fcm_version=tags/2021.05.0
fiat_version=1295120464c3905e5edcbb887e4921686653eab8
function parse_args()
{
# default values
ARCH_PATH=$PWD/arch
ARCH=gnu
# pass unrecognized arguments to fcm
FCM_ARGS=""
while (($# > 0))
do
OPTION="$1" ; shift
case "$OPTION" in
"-h") cat <<EOF
Usage :
$0 [options]
--help -h help
--arch-path ARCH_PATH directory for architecture specific files (see below) [./arch]
--arch ARCH build using arch files $ARCH_PATH/arch-ARCH.* [gnu]
Unrecognized options are passed to the fcm build command. Useful options include :
--full clean build tree before building
--jobs N parallel build, similar to make -j N
--ignore-lock ignore lock indicating another build is ongoing, useful after an interrupted build
For details on FCM, see
http://metomi.github.io/fcm/doc/user_guide/build.html
http://metomi.github.io/fcm/doc/user_guide/command_ref.html#fcm-build
EOF
exit;;
"--arch")
ARCH=$1 ; shift ;;
"--arch-path")
ARCH_PATH=$1 ; shift ;;
*)
FCM_ARGS="$FCM_ARGS $OPTION"
;;
esac
done
}
function check_install_fcm()
{
if [ ! -f fcm/bin/fcm ]; then
echo "Performing FCM installation..."
cd fcm
rm -f .gitkeep
git clone https://github.com/metomi/fcm.git .
git checkout tags/$fcm_version
touch .gitkeep
cd ..
echo "...FCM installation done"
fi
}
function check_install_fiat()
{
if [ ! -d fiat/src ]; then
echo "Performing fiat cloning..."
cd fiat
rm -f .gitkeep
git clone https://github.com/ecmwf-ifs/fiat.git .
git checkout $fiat_version
touch .gitkeep
cd ..
echo "...fiat cloning done"
fi
echo
}
function build_compilation_script()
{
cat <<EOF > compilation.sh
#!/bin/bash
. arch.env
COMPIL_FFLAGS="%PROD_FFLAGS"
COMPIL_FFLAGS="\$COMPIL_FFLAGS %OMP_FFLAGS"
LD_FLAGS="%BASE_LD"
LD_FLAGS="\$LD_FLAGS %OMP_LD"
#DEPS_LIB="\$NETCDF_LIBDIR \$NETCDF_LIB \$HDF5_LIBDIR \$HDF5_LIB"
FCM_ARGS=$FCM_ARGS
echo "%COMPIL_FFLAGS \$COMPIL_FFLAGS" > config.fcm
echo "%LD_FLAGS \$LD_FLAGS" >> config.fcm
echo "%CPP_KEY \$CPP_KEY" >> config.fcm
echo "%LIB">> config.fcm
export PATH=$PWD/../fcm/bin/:\$PATH
echo "This script has generated config.fcm which is included by bld.cfg, the FCM configuration file."
echo "Running : fcm build \$FCM_ARGS"
echo "Be patient while FCM first pre-processes all .F90 source files which may take about 30s."
fcm make \$FCM_ARGS
EOF
chmod +x compilation.sh
}
####################################
# Parse command line arguments
parse_args $*
# Change current working dir
cd -P $(dirname $0)
# Check the fcm installation
check_install_fcm
# Check the fiat installation
check_install_fiat
# Create the build directory and populate it
builddir=arch_$ARCH
if [ -d $builddir ]; then
echo "$builddir already exists. To rerun compilation, please enter this directory and use the compilation.sh script."
echo "Otherwise, you can remove the $builddir directory and execute again this script."
exit 1
fi
mkdir $builddir
cp ${ARCH_PATH}/arch-${ARCH}.env $builddir/arch.env
cp ${ARCH_PATH}/arch-${ARCH}.fcm $builddir/arch.fcm
cp fcm-make.cfg $builddir
cd $builddir
mkdir src
cd src
ln -s ../../../../src/common .
ln -s ../../fiat/src fiat
cd ..
build_compilation_script
# Run the compilation
./compilation.sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment