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

Use of prep_code

prep_code used in check_commit_mesonh.sh
--expand option to expand array-syntax into do loops
preparation for other test cases inclusion
parent f95ce1f1
No related branches found
No related tags found
No related merge requests found
...@@ -16,4 +16,7 @@ Instructions can be found in INSTALL file. ...@@ -16,4 +16,7 @@ Instructions can be found in INSTALL file.
Help on check_commit_ial.sh, check_commit_mesonh.sh and prep_code.sh can be printed with the '-h' option. Help on check_commit_ial.sh, check_commit_mesonh.sh and prep_code.sh can be printed with the '-h' option.
For check_commit_mesonh.sh, it is mandatory to source the env.sh file For check_commit_mesonh.sh the following environment variables can be set:
* MNHPACK: directory in which MNH pack will be created (default is $HOME/MesoNH/PHYEX)
* REFDIR: directory in which reference pack can be found (default is the pack directory near the check_commit_mesonh.sh file)
* TARGZDIR: directory in which the tar.gz file can be found (default is the pack directory near the check_commit_mesonh.sh file)
...@@ -218,11 +218,11 @@ if [ $compilation -eq 1 ]; then ...@@ -218,11 +218,11 @@ if [ $compilation -eq 1 ]; then
reftree='local' reftree='local'
subs="" #There is nothing to exclude from compilation because (normally) only needed files are copied into the pack subs="" #There is nothing to exclude from compilation because (normally) only needed files are copied into the pack
fi fi
cd $HOMEPACK/$name/src/local/phyex
MNH_EXPAND_DIR=$PHYEXTOOLSDIR/mnh_expand MNH_EXPAND_DIR=$PHYEXTOOLSDIR/mnh_expand
export PATH=$MNH_EXPAND_DIR/filepp:$MNH_EXPAND_DIR/MNH_Expand_Array:$PATH export PATH=$MNH_EXPAND_DIR/filepp:$MNH_EXPAND_DIR/MNH_Expand_Array:$PATH
cd $HOMEPACK/$name/src/local/phyex
if [ $useexpand == 1 ]; then if [ $useexpand == 1 ]; then
expand_options="-D MNH_EXPAND -D MNH_EXPAND_LOOP" expand_options="-D MNH_EXPAND -D MNH_EXPAND_LOOP"
else else
......
...@@ -8,19 +8,27 @@ set -e ...@@ -8,19 +8,27 @@ set -e
# Repertoire où MNH-V5-5-0_PHYEX.tar.gz modifie pour accueillir PHYEX se trouve # Repertoire où MNH-V5-5-0_PHYEX.tar.gz modifie pour accueillir PHYEX se trouve
#TARGZDIR=$HOME #TARGZDIR=$HOME
MNHPACK=${MNHPACK:=$HOME/MesoNH/PHYEX} availTests="007_16janvier/008_run2"
PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" defaultTest="007_16janvier/008_run2"
separator='_' #- be carrefull, gmkpack (at least on belenos) has multiple allergies (':', '.', '@')
#- seprator must be in sync with prep_code.sh separator
PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function usage { function usage {
echo "Usage: $0 [-h] [-c] [-r] [-C] commit reference" echo "Usage: $0 [-h] [-c] [-r] [-C] [-s] [--expand] commit reference"
echo "commit commit hash" echo "commit commit hash (or a directory)"
echo "reference commit hash or nothing for ref" echo "reference commit hash or a directory or nothing for ref"
echo "-s suppress compilation pack" echo "-s suppress compilation pack"
echo "-c performs compilation" echo "-c performs compilation"
echo "-r runs the tests, if option appears twice, run is also executed on only 2 procs (instead of 4 procs)" echo "-r runs the tests"
echo "-C checks the result against the reference" echo "-C checks the result against the reference"
echo "--expand use mnh_expand (code will use do loops)"
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 "The directory (for commit only, not ref) can take the form server:directory"
echo
echo "If using a directory (for commit or reference) it must contain at least one '/'"
} }
compilation=0 compilation=0
...@@ -28,7 +36,9 @@ run=0 ...@@ -28,7 +36,9 @@ run=0
check=0 check=0
commit="" commit=""
reference="" reference=""
tests=""
suppress=0 suppress=0
useexpand=0
while [ -n "$1" ]; do while [ -n "$1" ]; do
case "$1" in case "$1" in
...@@ -37,6 +47,7 @@ while [ -n "$1" ]; do ...@@ -37,6 +47,7 @@ while [ -n "$1" ]; do
'-c') compilation=1;; '-c') compilation=1;;
'-r') run=$(($run+1));; '-r') run=$(($run+1));;
'-C') check=1;; '-C') check=1;;
'--expand') useexpand=1;;
#-b) param="$2"; shift ;; #-b) param="$2"; shift ;;
#--) shift; break ;; #--) shift; break ;;
*) if [ -z "${commit-}" ]; then *) if [ -z "${commit-}" ]; then
...@@ -53,6 +64,17 @@ while [ -n "$1" ]; do ...@@ -53,6 +64,17 @@ while [ -n "$1" ]; do
shift shift
done done
[ "$reference" == 'REF' ] && reference="" #Compatibility with check_commit_arome.sh
MNHPACK=${MNHPACK:=$HOME/MesoNH/PHYEX}
REFDIR=${REFDIR:=$PHYEXTOOLSDIR/pack/}
TARGZDIR=${TARGZDIR:=$PHYEXTOOLSDIR/pack/}
if [ -z "${tests-}" ]; then
tests=$defaultTest
elif [ $tests == 'ALL' ]; then
tests=$availTests
fi
if [ $compilation -eq 0 -a \ if [ $compilation -eq 0 -a \
$run -eq 0 -a \ $run -eq 0 -a \
$check -eq 0 ]; then $check -eq 0 ]; then
...@@ -66,42 +88,53 @@ if [ -z "${commit-}" ]; then ...@@ -66,42 +88,53 @@ if [ -z "${commit-}" ]; then
exit 2 exit 2
fi fi
#if [ $check -eq 1 -a -z "${reference-}" ]; then
# echo "To perform a comparison two commit hashes are mandatory on the command line"
# exit 3
#fi
if echo $commit | grep '/' > /dev/null; then
name=MNH-V5-5-0-$(echo $commit | sed 's/\//_/g')
[ $suppress -eq 1 -a -d $MNHPACK/$name ] && rm -rf $MNHPACK/$name
else
name=MNH-V5-5-0-$commit
[ $suppress -eq 1 -a -d $MNHPACK/$name ] && rm -rf $MNHPACK/$name
fi
#Two possibilities are supported for the simulations #Two possibilities are supported for the simulations
# - they can be done in the the pack we are currently checking # - they can be done in the the pack we are currently checking
# - they can be done in the reference pack # - they can be done in the reference pack
#They are done in the current pack except if the reference pack #They are done in the current pack except if the reference pack
#already contains a tested simulation #already contains a tested simulation
run_in_ref=$(ls -d $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_* | tail -1 |wc -l) run_in_ref=$(ls -d $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_* 2> /dev/null | tail -1 |wc -l)
#Name and directory for compiling and executing user pack
fromdir=''
if echo $commit | grep '/' > /dev/null; then
fromdir=$commit
tag=$(echo $commit | sed 's/\//'${separator}'/g' | sed 's/:/'${separator}'/g' | sed 's/\./'${separator}'/g')
else
tag=$commit
fi
name=MNH-V5-5-0-$tag
[ $suppress -eq 1 -a -d $MNHPACK/$name ] && rm -rf $MNHPACK/$name
if [ $run_in_ref -eq 1 ]; then
path_user_beg=$REFDIR/MNH-V5-5-0 #pack directory containing the simulation
path_user_end=_$tag #to be appended to the 'run' simulation directory
else
path_user_beg=$MNHPACK/$name #pack directory containing the simulation
path_user_end= #to be appended to the 'run' simulation directory
fi
#Name and directory for the reference
reffromdir=''
if echo $reference | grep '/' > /dev/null; then
reffromdir=$reference
reftag=$(echo $reference | sed 's/\//'${separator}'/g' | sed 's/:/'${separator}'/g' | sed 's/\./'${separator}'/g')
else
reftag=$reference
fi
refname=MNH-V5-5-0-$reftag
if [ $run_in_ref -eq 1 ]; then if [ $run_in_ref -eq 1 ]; then
path_user_beg=$REFDIR/MNH-V5-5-0
path_user_end=_$commit
path_ref_beg=$REFDIR/MNH-V5-5-0 path_ref_beg=$REFDIR/MNH-V5-5-0
if [ "$reference" == "" ]; then if [ "$reference" == "" ]; then
path_ref_end= path_ref_end=
else else
path_ref_end=_$reference path_ref_end=_$reftag
fi fi
else else
path_user_beg=$MNHPACK/$name
path_user_end=
path_ref_end= path_ref_end=
if [ "$reference" == "" ]; then if [ "$reference" == "" ]; then
path_ref_beg=$REFDIR/MNH-V5-5-0 path_ref_beg=$REFDIR/MNH-V5-5-0
else else
path_ref_beg=$MNHPACK/MNH-V5-5-0-$reference path_ref_beg=$MNHPACK/MNH-V5-5-0-$reftag
fi fi
fi fi
...@@ -116,48 +149,42 @@ if [ $compilation -eq 1 ]; then ...@@ -116,48 +149,42 @@ if [ $compilation -eq 1 ]; then
# Prepare the pack # Prepare the pack
cd $MNHPACK cd $MNHPACK
cp $TARGZDIR/MNH-V5-5-0_PHYEX.tar.gz . cp $TARGZDIR/MNH-V5-5-0_PHYEX.tar.gz .
tar xvfz MNH-V5-5-0_PHYEX.tar.gz tar xfz MNH-V5-5-0_PHYEX.tar.gz
rm MNH-V5-5-0_PHYEX.tar.gz rm MNH-V5-5-0_PHYEX.tar.gz
mv MNH-V5-5-0 $name mv MNH-V5-5-0 $name
cd $name/src cd $name/src
rm -rf PHYEX
cd $MNHPACK MNH_EXPAND_DIR=$PHYEXTOOLSDIR/mnh_expand
echo "Clone repository, and checkout commit $commit" export PATH=$MNH_EXPAND_DIR/filepp:$MNH_EXPAND_DIR/MNH_Expand_Array:$PATH
git clone https://github.com/QuentinRodier/PHYEX.git
cd PHYEX
git checkout $commit
cd src/common/turb
# Rename all *.F90 to *.f90
for rep in turb micro aux; do
cd ../$rep
for f in *.F90; do
mv -- "$f" "${f%.F90}.f90"
done
done
cd ../../../
for rep in turb micro conv ext aux; do if [ $useexpand == 1 ]; then
[ ! -d ../$rep ] && mkdir ../$rep expand_options="-D MNH_EXPAND -D MNH_EXPAND_LOOP"
[ -d src/common/$rep ] && mv -f src/common/$rep/* ../$rep/ else
[ -d src/mesonh/$rep ] && mv -f src/mesonh/$rep/* ../$rep/ expand_options=""
touch ../$rep/* fi
done subs="-s turb -s micro -s aux -s ext -s conv"
cd .. prep_code=$PHYEXTOOLSDIR/prep_code.sh
# Move PHYEX files inside MNH/src/PHYEX if [ "$fromdir" == '' ]; then
for rep in turb micro conv aux; do echo "Clone repository, and checkout commit $commit (using prep_code.sh)"
mv $rep/* $name/src/PHYEX/$rep/. if [[ $commit == mesonh${separator}* ]]; then
rmdir $rep $prep_code --renameFf -c $commit PHYEX #This commit is ready for inclusion
done else
$prep_code --renameFf -c $commit $expand_options $subs -m mesonh PHYEX
fi
else
echo "Copy $fromdir"
scp -q -r $fromdir PHYEX
$prep_code --renameFf $expand_options $subs -m mesonh PHYEX
fi
rm -rf PHYEX/.git
find PHYEX -type f -exec touch {} \; #to be sure a recompilation occurs
# Move manually ext/ files in src/MNH # Move manually ext/ files in src/MNH
mv -f ext/* $name/src/MNH/. mv -f PHYEX/ext/* MNH/
rmdir PHYEX/ext
# Clean folder
rmdir ext
rm -Rf PHYEX
cd $name/src/PHYEX/turb cd $MNHPACK/$name/src/PHYEX/turb
# Delete files of MNH-V5-5-0/src/MNH and MNH/src/LIB/SURCOUCHE/src with same name # Delete files of MNH-V5-5-0/src/MNH and MNH/src/LIB/SURCOUCHE/src with same name
for rep in turb micro conv aux ; do for rep in turb micro conv aux ; do
cd ../$rep cd ../$rep
...@@ -185,76 +212,87 @@ if [ $compilation -eq 1 ]; then ...@@ -185,76 +212,87 @@ if [ $compilation -eq 1 ]; then
#Configure and compilation #Configure and compilation
./configure ./configure
set +e #file ends with a test that can return false set +e #file ends with a test that can return false
. ../conf/profile_mesonh-LXgfortran-R8I4-MNH-V5-5-0-MPIAUTO-DEBUG . ../conf/profile_mesonh-*
set -e set -e
make -j 8 make -j 8 | tee ../Output_compilation
make installmaster make installmaster | tee -a ../Output_compilation
fi fi
if [ $run -ge 1 ]; then if [ $run -ge 1 ]; then
echo "### Running of commit $commit" echo "### Running of commit $commit"
echo $commit
if [ ! -f $MNHPACK/$name/exe/MESONH* ]; then if [ ! -f $MNHPACK/$name/exe/MESONH* ]; then
echo "Pack does not exist ($MNHPACK/$name) or compilation has failed, please check" echo "Pack does not exist ($MNHPACK/$name) or compilation has failed, please check"
exit 6 exit 6
fi fi
if [ $run_in_ref -eq 1 ]; then for t in $(echo $tests | sed 's/,/ /g'); do
cd $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/ case=$(echo $t | cut -d / -f 1)
[ ! -d 008_run2_$commit ] && cp -R 008_run2 008_run2_$commit exedir=$(echo $t | cut -d / -f 2)
cd $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_$commit if [ $run_in_ref -eq 1 ]; then
else cd $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/$case/
cd $MNHPACK/$name/MY_RUN/KTEST/007_16janvier/ [ ! -d ${exedir}_$commit ] && cp -R ${exedir} ${exedir}_$commit
for rep in ???_*; do cd $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/$case/${exedir}_$commit
if [ $rep != 008_run2 ]; then else
rm -rf $rep cd $MNHPACK/$name/MY_RUN/KTEST/$case/
ln -s $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/$rep . for rep in ???_*; do
fi if [ $rep != ${exedir} ]; then
done rm -rf $rep
[ -d 008_run2 ] && rm -rf 008_run2 ln -s $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/$case/$rep .
cp -R $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2 . fi
cd 008_run2 done
fi [ -d ${exedir} ] && rm -rf ${exedir}
cp -R $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/$case/${exedir} .
set +e #file ends with a test that can return false cd ${exedir}
[ $compilation -eq 0 ] && . $MNHPACK/$name/conf/profile_mesonh-LXgfortran-R8I4-MNH-V5-5-0-MPIAUTO-DEBUG fi
set -e
./clean_mesonh_xyz
./run_mesonh_xyz
fi
set +e #file ends with a test that can return false
[ $compilation -eq 0 ] && . $MNHPACK/$name/conf/profile_mesonh-*
set -e
./clean_mesonh_xyz
./run_mesonh_xyz | tee Output_run
done
fi
if [ $check -eq 1 ]; then if [ $check -eq 1 ]; then
allt=0
echo "### Check commit $commit against commit $reference" echo "### Check commit $commit against commit $reference"
path_user=$path_user_beg/MY_RUN/KTEST/007_16janvier/008_run2$path_user_end
path_ref=$path_ref_beg/MY_RUN/KTEST/007_16janvier/008_run2$path_ref_end
if [ ! -d $path_user ]; then allt=0
echo "$path_user is missing, please run the simulation" for t in $(echo $tests | sed 's/,/ /g'); do
exit 7 case=$(echo $t | cut -d / -f 1)
fi exedir=$(echo $t | cut -d / -f 2)
if [ ! -d $path_ref ]; then
echo "$path_ref is missing, please run the reference simulation"
exit 8
fi
echo "Compare with python..." path_user=$path_user_beg/MY_RUN/KTEST/007_16janvier/008_run2$path_user_end
# Compare variable of both Synchronous and Diachronic files with printing difference path_ref=$path_ref_beg/MY_RUN/KTEST/007_16janvier/008_run2$path_ref_end
set +e if [ ! -d $path_user ]; then
$PHYEXTOOLSDIR/compare.py $path_user $path_ref echo "$path_user is missing, please run the simulation"
t=$? exit 7
set -e fi
allt=$(($allt+$t)) if [ ! -d $path_ref ]; then
echo "$path_ref is missing, please run the reference simulation"
#Check bit-repro before date of creation of Synchronous file from ncdump of all values (pb with direct .nc file checks) exit 8
file1=$path_user/16JAN.1.12B18.001.nc fi
file2=$path_ref/16JAN.1.12B18.001.nc
echo "Compare with ncdump..." if [ $case == 007_16janvier ]; then
set +e echo "Compare with python..."
diff <(ncdump $file1 | head -c 62889) <(ncdump $file2 | head -c 62889) # Compare variable of both Synchronous and Diachronic files with printing difference
t=$? set +e
set -e $PHYEXTOOLSDIR/compare.py $path_user $path_ref
allt=$(($allt+$t)) t=$?
set -e
allt=$(($allt+$t))
#Check bit-repro before date of creation of Synchronous file from ncdump of all values (pb with direct .nc file checks)
file1=$path_user/16JAN.1.12B18.001.nc
file2=$path_ref/16JAN.1.12B18.001.nc
echo "Compare with ncdump..."
set +e
diff <(ncdump $file1 | head -c 62889) <(ncdump $file2 | head -c 62889)
t=$?
set -e
allt=$(($allt+$t))
fi
done
if [ $allt -eq 0 ]; then if [ $allt -eq 0 ]; then
status="OK" status="OK"
......
...@@ -2,6 +2,3 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ...@@ -2,6 +2,3 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MNH_EXPAND_DIR=$DIR/mnh_expand MNH_EXPAND_DIR=$DIR/mnh_expand
export PATH=$DIR:$MNH_EXPAND_DIR/filepp:$MNH_EXPAND_DIR/MNH_Expand_Array:$PATH export PATH=$DIR:$MNH_EXPAND_DIR/filepp:$MNH_EXPAND_DIR/MNH_Expand_Array:$PATH
export REFDIR=$DIR/pack/
export TARGZDIR=$DIR/pack/
...@@ -111,6 +111,14 @@ else ...@@ -111,6 +111,14 @@ else
from='git' from='git'
fi fi
###### RENAME .F90 into .f90
if [ $renameFf -eq 1 ]; then
find . -type f -name \*.F90 -print0 | \
while IFS= read -r -d '' file; do
mv -- "$file" "${file%.F90}.f90"
done
fi
###### MERGE ###### MERGE
if [ -n "${model-}" ]; then if [ -n "${model-}" ]; then
if [ ! -d src/$model ]; then if [ ! -d src/$model ]; then
...@@ -129,8 +137,8 @@ if [ -n "${model-}" ]; then ...@@ -129,8 +137,8 @@ if [ -n "${model-}" ]; then
for sub in $subs; do for sub in $subs; do
[ $verbose -gt 1 ] && echo "Merging $sub directory/file" [ $verbose -gt 1 ] && echo "Merging $sub directory/file"
if [ -e $sub ]; then if [ -e $sub ]; then
echo "$sub must not exist in the repository, this is a limitation of the script" echo "$sub must not exist in the repository root, this is a limitation of the script"
exit 7 exit 7
fi fi
[ -e src/common/$sub ] && mv src/common/$sub . [ -e src/common/$sub ] && mv src/common/$sub .
[ -e src/$model/$sub ] && cp -rlf src/$model/$sub . && rm -rf src/$model/$sub [ -e src/$model/$sub ] && cp -rlf src/$model/$sub . && rm -rf src/$model/$sub
...@@ -179,14 +187,6 @@ if [ -n "${mnh_expand_options-}" ]; then ...@@ -179,14 +187,6 @@ if [ -n "${mnh_expand_options-}" ]; then
done done
fi fi
###### RENAME .F90 into .f90
if [ $renameFf -eq 1 ]; then
find . -type f -name \*.F90 -print0 | \
while IFS= read -r -d '' file; do
mv -- "$file" "${file%.F90}.f90"
done
fi
###### PUSH ###### PUSH
if [ -n "${branch-}" ]; then if [ -n "${branch-}" ]; then
[ $verbose -gt 0 ] && echo "commit and push" [ $verbose -gt 0 ] && echo "commit and push"
......
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