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

S. Riette 10 Nov 2022: build system update

add -a and -A options to check_commit_testprogs to choose the architecture
add -mesonhprofile to make_fcm.sh to convert a Méso-NH rules into a fcm configuration file
add architecture files for ifort and a new one for gfortran derived from the Méso-NH rules
parent 8478d8dd
No related branches found
No related tags found
No related merge requests found
...@@ -24,10 +24,3 @@ $LD_EXE_TO_SHARED = ...@@ -24,10 +24,3 @@ $LD_EXE_TO_SHARED =
# Other # Other
$AR = ar $AR = ar
#Kept for latter use
#$FPP = mpiifort -E
#$MAKE = gmake
#$FPP_FLAGS = -P
#$FPP_DEF = KEY_NONE CPP_NETCDF4
#$MPI_LD
#$MPI_FFLAGS
...@@ -24,10 +24,3 @@ $LD_EXE_TO_SHARED = -shared ...@@ -24,10 +24,3 @@ $LD_EXE_TO_SHARED = -shared
# Other # Other
$AR = ar $AR = ar
#Kept for latter use
#$FPP = gfortran -E
#$MAKE = gmake
#$FPP_FLAGS = -P
#$FPP_DEF =
#$MPI_LD
#$MPI_FFLAGS
# Compilation
$FCOMPILER = ifort
$BASE_FFLAGS = -c -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
$CCOMPILER = icc
$BASE_CFLAGS = -c -fpic
$PROD_CFLAGS = -O3
$DEV_CFLAGS = -O1
$DEBUG_CFLAGS = -check bounds
$OMP_FFLAGS = -qopenmp -qopenmp-threadprivate=compat
# Preprocessor
$FPP_FLAGS = LINUX LITTLE_ENDIAN LITTLE REPRO48
$CPP_FLAGS = LINUX LITTLE_ENDIAN LITTLE
# Linker
$LINK = ifort
$BASE_LD = -fPIC -i4 -r8 -auto -qopenmp -qopenmp-threadprivate compat
$OMP_LD =
$LD_EXE_TO_SHARED = -shared
# Other
$AR = ar
# This file has been produced automatically from a mesonh profile on ubuntu22
export PATH=~rodierq/UBUNTU22/GCC940:$PATH
# This file has been produced automatically from a mesonh profile on ubuntu22
# Then, the file has been modified (-ffree-line-length-none -fopenmp -fconvert=swap -fPIC -shared)
# Compilation
$FCOMPILER = mpif90
$BASE_FFLAGS = -c -g -fno-second-underscore -fPIC -ffpe-trap=overflow,zero,invalid -fbacktrace -fdefault-real-8 -fdefault-double-8 -O0 -fbounds-check -finit-real=nan -ffree-line-length-none -fopenmp -fconvert=swap
$PROD_FFLAGS =
$DEV_FFLAGS =
$DEBUG_FFLAGS =
$CCOMPILER = gcc
$BASE_CFLAGS = -c -g -O0 -fPIC
$PROD_CFLAGS =
$DEV_CFLAGS =
$DEBUG_CFLAGS =
$OMP_FFLAGS =
# Preprocessor
$FPP_FLAGS = MNH SFX_MNH MNH_IOLFI MNH_IOCDF4 REPRO55 MNH_INT=4 MNH_REAL=8 LEN_HREC=16 REPRO55 MNH_PARALLEL in_surfex MNH_USE_MPI_STATUSES_IGNORE DEV_NULL SWAPIO LINUX LFI_INT=8 LITTLE_endian
$CPP_FLAGS = MNH SFX_MNH MNH_IOLFI MNH_IOCDF4 REPRO55 MNH_INT=4 MNH_REAL=8 LEN_HREC=16 REPRO55 MNH_PARALLEL in_surfex MNH_USE_MPI_STATUSES_IGNORE DEV_NULL SWAPIO LINUX LFI_INT=8 LITTLE_endian
# Linker
$LINK = gfortran
$BASE_LD = -fopenmp
$OMP_LD =
$LD_EXE_TO_SHARED = -shared
# Other
$AR = ar
...@@ -10,6 +10,7 @@ function parse_args() { ...@@ -10,6 +10,7 @@ function parse_args() {
ARCH_PATH=$PWD/arch ARCH_PATH=$PWD/arch
ARCH= ARCH=
GMKFILE= GMKFILE=
MESONHPROFILE=
# pass unrecognized arguments to fcm # pass unrecognized arguments to fcm
FCM_ARGS="" FCM_ARGS=""
...@@ -23,6 +24,7 @@ $0 [options] ...@@ -23,6 +24,7 @@ $0 [options]
--arch-path ARCH_PATH directory for architecture specific files (see below) [./arch] --arch-path ARCH_PATH directory for architecture specific files (see below) [./arch]
--arch ARCH build using arch files $ARCH_PATH/arch-ARCH.* [gnu] --arch ARCH build using arch files $ARCH_PATH/arch-ARCH.* [gnu]
--gmkfile FILE build using a gmkpack configuration file (--arch must be used to give a name to the build dir) --gmkfile FILE build using a gmkpack configuration file (--arch must be used to give a name to the build dir)
--mesonhprofile FILE build using Méso-NH profile and rules (--arch must be used to give a name to the build dir)
Unrecognized options are passed to the fcm build command. Useful options include : Unrecognized options are passed to the fcm build command. Useful options include :
--new clean build tree before building --new clean build tree before building
...@@ -40,15 +42,21 @@ EOF ...@@ -40,15 +42,21 @@ EOF
ARCH_PATH=$1 ; shift ;; ARCH_PATH=$1 ; shift ;;
"--gmkfile") "--gmkfile")
GMKFILE=$1 ; shift ;; GMKFILE=$1 ; shift ;;
"--mesonhprofile")
MESONHPROFILE=$1 ; shift ;;
*) *)
FCM_ARGS="$FCM_ARGS $OPTION" ;; FCM_ARGS="$FCM_ARGS $OPTION" ;;
esac esac
done done
[ "$GMKFILE" == "" -a "$ARCH" == "" ] && ARCH=gnu [ "$GMKFILE" == "" -a "$MESONHPROFILE" == "" -a "$ARCH" == "" ] && ARCH=gnu
if [ "$GMKFILE" != "" -a "$ARCH" == "" ]; then if [ "$GMKFILE" != "" -a "$ARCH" == "" ]; then
echo "--arch option is mandatory if --gmkfile option is used" echo "--arch option is mandatory if --gmkfile option is used"
exit 2 exit 2
fi fi
if [ "$MESONHPROFILE" != "" -a "$ARCH" == "" ]; then
echo "--arch option is mandatory if --mesonhprofile option is used"
exit 3
fi
} }
function check_install_fcm() { function check_install_fcm() {
...@@ -110,6 +118,73 @@ cat <<EOF > $ARCHFILE ...@@ -110,6 +118,73 @@ cat <<EOF > $ARCHFILE
EOF EOF
} }
function mesonhprofile2archenv() {
MESONHPROFILE=$1
ARCHFILE=$2
ENVFILE=$3
echo "
You are trying to produce a configuration file for fcm from a Meso-NH configuration.
The resulting file is certainly incomplete and must be modified as follows:
Optimisation level:
The opt level is set in the mesonh profile file; as a consequence, the BASE_FFLAGS contains
the base *and* the opt flags.
To compile with other opt level, the profile file must be modified before executing this function.
Long lines:
Meso-NH rules does not allow the compilation of long lines. Depending on compilers, it might be needed to
manually add an option to allow long lines.
For gfortran: add '-ffree-line-length-none' to BASE_FFLAGS
OpenMP:
Meso-NH does not use OpenMP but testprogs do; as a consequence, openmp flags are not included in the
Meso-NH rules, they must be manually added.
For gfortran: add '-fopenmp' to BASE_FFLAGS and to BASE_LD
Position Independent Code:
Meso-NH does not need to build position independent code, flags must be set manually.
For gfortran ('-fPIC' already in BASE_FFLAGS): add '-fPIC' to BASE_CFLAGS
Shared lib:
Flags needed to build shared lib are not defined in Meso-NH rules, only hard coded in Makefile to build a
specific lib. The flags to set for building a shared lib, in addition to flags used to build an object, must
be manually set.
For gfortran: add '-shared' to LD_EXE_TO_SHARED
Swap:
Meso-NH rules does not swap IO byte order (litle-/big-endian). Depending on your endianess, the
corresponding flag may have to be set manually.
For gfortran: add '-fconvert=swap' to BASE_FFLAGS"
tac $MESONHPROFILE | grep -m1 '#' -B $(cat $MESONHPROFILE | wc -l) | tac | grep -v '#' > $ENVFILE
MAKEFILE='
include Rules.$(ARCH)$(F).mk
archfile :
echo "# Compilation"
echo "\$$FCOMPILER = $(F90)"
echo "\$$BASE_FFLAGS = -c $(F90FLAGS)"
echo "\$$PROD_FFLAGS = "
echo "\$$DEV_FFLAGS = "
echo "\$$DEBUG_FFLAGS = "
echo "\$$CCOMPILER = $(CC)"
echo "\$$BASE_CFLAGS = -c $(CFLAGS)"
echo "\$$PROD_CFLAGS = "
echo "\$$DEV_CFLAGS = "
echo "\$$DEBUG_CFLAGS = "
echo "\$$OMP_FFLAGS ="
echo ""
echo "# Preprocessor"
echo "\$$FPP_FLAGS = $(CPPFLAGS)"
echo "\$$CPP_FLAGS = $(CPPFLAGS)"
echo ""
echo "# Linker"
echo "\$$LINK = $(FC)"
echo "\$$BASE_LD = $(LDFLAGS)"
echo "\$$OMP_LD ="
echo "\$$LD_EXE_TO_SHARED = "
echo ""
echo "# Other"
echo "\$$AR = $(AR)"
'
(. $MESONHPROFILE; make -f <(echo -e "$MAKEFILE") -s -I $(dirname $MESONHPROFILE)/../src archfile) | sed 's/-D//g' > $ARCHFILE
}
function build_compilation_script() { function build_compilation_script() {
cat <<EOF > compilation.sh cat <<EOF > compilation.sh
#!/bin/bash #!/bin/bash
...@@ -175,6 +250,9 @@ mkdir $builddir ...@@ -175,6 +250,9 @@ mkdir $builddir
if [ "$GMKFILE" != "" ]; then if [ "$GMKFILE" != "" ]; then
touch $builddir/arch.env touch $builddir/arch.env
gmkfile2arch $GMKFILE $builddir/arch.fcm gmkfile2arch $GMKFILE $builddir/arch.fcm
elif [ "$MESONHPROFILE" != "" ]; then
touch $builddir/arch.env
mesonhprofile2archenv $MESONHPROFILE $builddir/arch.fcm $builddir/arch.env
else else
cp ${ARCH_PATH}/arch-${ARCH}.env $builddir/arch.env cp ${ARCH_PATH}/arch-${ARCH}.env $builddir/arch.env
cp ${ARCH_PATH}/arch-${ARCH}.fcm $builddir/arch.fcm cp ${ARCH_PATH}/arch-${ARCH}.fcm $builddir/arch.fcm
......
...@@ -7,28 +7,35 @@ Some offline test programs are provided with the package and a library suitable ...@@ -7,28 +7,35 @@ Some offline test programs are provided with the package and a library suitable
## Compilation ## Compilation
The build/with\_fcm directory contains a build system. The build/with\_fcm directory in the master branch contains a build system.
This build system has two dependencies (installation is done automatically by the compilation script): This build system has two dependencies (installation is done automatically by the compilation script):
- [fcm](https://metomi.github.io/fcm/doc/user_guide/) - [fcm](https://metomi.github.io/fcm/doc/user_guide/)
- [fiat](https://github.com/ecmwf-ifs/fiat) - [fiat](https://github.com/ecmwf-ifs/fiat)
The script build/with\_fcm/make\_fcm.sh uses a configuration file and build the library and test programs. The script build/with\_fcm/make\_fcm.sh uses a configuration file and build the library and test programs.
They can be found in the build/bin subdirectory in the architecture specific directory arch\_\<architecture name\>. These executables can be found in the build/bin subdirectory in the architecture specific directory arch\_\<architecture name\>.
Some more details on the build system can be found in [build/with\_fcm/README.md file](../build/with_fcm/README.md). Some more details on the build system can be found in [build/with\_fcm/README.md file](../build/with_fcm/README.md).
### Compilation in the repository ### Compilation directly in the repository without execution (or manual execution)
When on a master commit, the build/with\_fcm/make\_fcm.sh script can be used to compile the offline tools. When on a master commit, the build/with\_fcm/make\_fcm.sh script can be used to compile the offline tools.
### Compilation of a testprogs specific commit ### Compilation and execution
When on a master commit, the tools/check\_commit\_testprogs.sh script can be used to compile a testprogs\_\<commit\_hash\> commit already available in the PHYEX repository. When on a master commit, the tools/check\_commit\_testprogs.sh script can be used to compile and execute the testprogs.
The check\_commit\_testprogs.sh script uses the PHYEX source code:
### Modification of a testprogs specific commit - of a specific commit on the master branch available on a remote repository
- or, the last commit of a testprogs\_\<commit\_hash\> branch available on a remote repository
- or, the content of a local repository.
In the latter case, it can be interesting to clone the PHYEX repository twice.
A first one to have the build tools on the master branch, and a second one to checkout the source code version to use.
This solution is especially useful when working on a testprogs\_\<commit\_hash\> branch (because these branches does not
contain the build tools).
The idea is to use two clones of PHYEX: one to provide the building tools, the another one to provide the source code.
Something like this can be used: Something like this can be used:
- cd $HOME; git clone \<PHYEX url\> PHYEXtools - cd $HOME; git clone \<PHYEX url\> PHYEXtools
...@@ -37,7 +44,7 @@ Something like this can be used: ...@@ -37,7 +44,7 @@ Something like this can be used:
- cd PHYEX; git checkout arome\_\<commit\_hash\>; source code moddifications... - cd PHYEX; git checkout arome\_\<commit\_hash\>; source code moddifications...
- . PHYEXtools/tools/env.sh; check\_commit\_testprogs.sh $HOME/PHYEX REF - . PHYEXtools/tools/env.sh; check\_commit\_testprogs.sh $HOME/PHYEX REF
The last step will creates a directory (in $HOME/TESTPROGS) with a copy of your source code and the build system, builds the testprogs and executes them. The last step will create a directory (in $HOME/TESTPROGS) with a copy of your source code and the build system, builds the testprogs and executes them.
## Test program ## Test program
......
...@@ -72,9 +72,6 @@ Nettoyage ultérieur : ...@@ -72,9 +72,6 @@ Nettoyage ultérieur :
Une fois toutes les routines de la turbulence ont leur dimension horizontale packée et Une fois toutes les routines de la turbulence ont leur dimension horizontale packée et
utilisent LES_MEAN_SUBGRID_PHY a la place de LES_MEAN_SUBGRID_PHY : renommer les routines arome/turb et mesonh/turb en les_mean_subgrid.F90 et remplacer partout dans le code les appels (enlever le _PHY) + supprimer les anciennes routines utilisent LES_MEAN_SUBGRID_PHY a la place de LES_MEAN_SUBGRID_PHY : renommer les routines arome/turb et mesonh/turb en les_mean_subgrid.F90 et remplacer partout dans le code les appels (enlever le _PHY) + supprimer les anciennes routines
Enable mnh_expand with fcm build
Reprendre les différents outils en deux scripts principaux: Reprendre les différents outils en deux scripts principaux:
- outil pour reprendre toutes les fonctionnalités sur le code: filepp, MNH_Expand_Array, correct_indent.py, verify_mnh_expand.py et renommage - outil pour reprendre toutes les fonctionnalités sur le code: filepp, MNH_Expand_Array, correct_indent.py, verify_mnh_expand.py et renommage
- outil prep_code débarrassé du renommage pour ne faire que la gestion des commit et lancer la manipulation sur le code - outil prep_code débarrassé du renommage pour ne faire que la gestion des commit et lancer la manipulation sur le code
......
...@@ -21,10 +21,10 @@ PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ...@@ -21,10 +21,10 @@ PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dirdata=$PHYEXTOOLSDIR/testprogs_data dirdata=$PHYEXTOOLSDIR/testprogs_data
if [ $(hostname | cut -c 1-7) == 'belenos' -o $(hostname | cut -c 1-7) == 'taranis' ]; then if [ $(hostname | cut -c 1-7) == 'belenos' -o $(hostname | cut -c 1-7) == 'taranis' ]; then
HPC=1 HPC=1
archfile=MIMPIIFC1805.EPONA defaultarchfile=MIMPIIFC1805.EPONA
else else
HPC=0 HPC=0
archfile=gnu defaultarchfile=gnu
fi fi
defaultRef=ref defaultRef=ref
...@@ -32,7 +32,7 @@ function usage { ...@@ -32,7 +32,7 @@ function usage {
echo "Usage: $0 [-h] [-c] [-r] [-C] [-s] [-f] [--noexpand] [-t test] commit reference" echo "Usage: $0 [-h] [-c] [-r] [-C] [-s] [-f] [--noexpand] [-t test] commit reference"
echo "commit commit hash (or a directory, or among $specialName) to test" echo "commit commit hash (or a directory, or among $specialName) to test"
echo "reference commit hash (or a directory, or among $specialName) REF to use as a reference" echo "reference commit hash (or a directory, or among $specialName) REF to use as a reference"
echo "-s suppress compilation pack" echo "-s suppress compilation directory"
echo "-c performs compilation" echo "-c performs compilation"
echo "-r runs the tests" echo "-r runs the tests"
echo "-C checks the result against the reference" echo "-C checks the result against the reference"
...@@ -43,6 +43,8 @@ function usage { ...@@ -43,6 +43,8 @@ function usage {
echo " defaults to the env variable PHYEXREOuser (=$PHYEXREOuser)" echo " defaults to the env variable PHYEXREOuser (=$PHYEXREOuser)"
echo "--repo-protocol protocol (https or ssh) to reach the PHYEX repository on github," echo "--repo-protocol protocol (https or ssh) to reach the PHYEX repository on github,"
echo " defaults to the env variable PHYEXREOprotocol (=$PHYEXREOprotocol)" echo " defaults to the env variable PHYEXREOprotocol (=$PHYEXREOprotocol)"
echo "-a arch architecture name to use to build and run the commit (=$defaultarchfile)"
echo "-A arch architecture name to use for the reference simulation (=$defaultarchfile)"
echo "" echo ""
echo "If nothing is asked (compilation, running, check) everything is done" echo "If nothing is asked (compilation, running, check) everything is done"
echo echo
...@@ -63,6 +65,8 @@ reference="" ...@@ -63,6 +65,8 @@ reference=""
tests="" tests=""
suppress=0 suppress=0
useexpand=1 useexpand=1
archfile=$defaultarchfile
refarchfile=$defaultarchfile
while [ -n "$1" ]; do while [ -n "$1" ]; do
case "$1" in case "$1" in
...@@ -75,6 +79,8 @@ while [ -n "$1" ]; do ...@@ -75,6 +79,8 @@ while [ -n "$1" ]; do
'--noexpand') useexpand=0;; '--noexpand') useexpand=0;;
'--repo-user') export PHYEXREPOuser=$2; shift;; '--repo-user') export PHYEXREPOuser=$2; shift;;
'--repo-protocol') export PHYEXREPOprotocol=$2; shift;; '--repo-protocol') export PHYEXREPOprotocol=$2; shift;;
'-a') archfile="$2"; shift;;
'-A') refarchfile="$2"; shift;;
#--) shift; break ;; #--) shift; break ;;
*) if [ -z "${commit-}" ]; then *) if [ -z "${commit-}" ]; then
commit=$1 commit=$1
...@@ -129,7 +135,6 @@ if [ $check -eq 1 -a -z "${reference-}" ]; then ...@@ -129,7 +135,6 @@ if [ $check -eq 1 -a -z "${reference-}" ]; then
exit 3 exit 3
fi fi
#Name is choosen such as it can be produced with a main pack: PHYEX/48t1_XXXXXXXXX.01.${gmkpack_l}.${gmkpack_o}
fromdir='' fromdir=''
if echo $commit | grep '/' > /dev/null; then if echo $commit | grep '/' > /dev/null; then
fromdir=$commit fromdir=$commit
...@@ -163,7 +168,7 @@ if [ $compilation -eq 1 ]; then ...@@ -163,7 +168,7 @@ if [ $compilation -eq 1 ]; then
fi fi
if [ -d $TESTDIR/$name ]; then if [ -d $TESTDIR/$name ]; then
echo "Pack already exists ($TESTDIR/$name), suppress it to be able to compile it again (or use the -s option to automatically suppress it)" echo "Directory already exists ($TESTDIR/$name), suppress it to be able to compile it again (or use the -s option to automatically suppress it)"
exit 5 exit 5
fi fi
mkdir $TESTDIR/$name mkdir $TESTDIR/$name
...@@ -205,7 +210,7 @@ if [ $run -ge 1 ]; then ...@@ -205,7 +210,7 @@ if [ $run -ge 1 ]; then
for t in $(echo $tests | sed 's/,/ /g'); do for t in $(echo $tests | sed 's/,/ /g'); do
if [ ! -f $TESTDIR/$name/build/with_fcm/arch_${archfile}/build/bin/main_${t}.exe ]; then if [ ! -f $TESTDIR/$name/build/with_fcm/arch_${archfile}/build/bin/main_${t}.exe ]; then
echo "Pack does not exist ($TESTDIR/$name) or compilation has failed, please check" echo "Directory does not exist ($TESTDIR/$name) or compilation has failed, please check"
exit 6 exit 6
fi fi
done done
...@@ -213,16 +218,16 @@ if [ $run -ge 1 ]; then ...@@ -213,16 +218,16 @@ if [ $run -ge 1 ]; then
#Cleaning to suppress old results that may be confusing in case of a crash during the run #Cleaning to suppress old results that may be confusing in case of a crash during the run
for t in $(echo $tests | sed 's/,/ /g'); do for t in $(echo $tests | sed 's/,/ /g'); do
cd $TESTDIR/$name cd $TESTDIR/$name
if [ -d tests/$t ]; then if [ -d tests/with_fcm/arch_${archfile}/$t ]; then
rm -rf tests/$t rm -rf tests/with_fcm/arch_${archfile}/$t
fi fi
done done
#Run the tests one after the other #Run the tests one after the other
for t in $(echo $tests | sed 's/,/ /g'); do for t in $(echo $tests | sed 's/,/ /g'); do
cd $TESTDIR/$name cd $TESTDIR/$name
mkdir -p tests/$t mkdir -p tests/with_fcm/arch_${archfile}/$t
cd tests/$t cd tests/with_fcm/arch_${archfile}/$t
ln -s $dirdata/$t data ln -s $dirdata/$t data
$TESTDIR/$name/build/with_fcm/arch_${archfile}/build/bin/main_${t}.exe --check 2>&1 > Output_run $TESTDIR/$name/build/with_fcm/arch_${archfile}/build/bin/main_${t}.exe --check 2>&1 > Output_run
done done
...@@ -234,8 +239,8 @@ if [ $check -eq 1 ]; then ...@@ -234,8 +239,8 @@ if [ $check -eq 1 ]; then
alltests=0 alltests=0
message="" message=""
for t in $(echo $tests | sed 's/,/ /g'); do for t in $(echo $tests | sed 's/,/ /g'); do
file1=$TESTDIR/$name/tests/$t/Output_run file1=$TESTDIR/$name/tests/with_fcm/arch_${archfile}/$t/Output_run
file2=$TESTDIR/$refname/tests/$t/Output_run file2=$TESTDIR/$refname/tests/with_fcm/arch_${refarchfile}/$t/Output_run
mess="" mess=""
te=0 te=0
if [ ! -f "$file1" ]; then if [ ! -f "$file1" ]; then
......
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