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

S. Riette 14 Apr 2023: bf for compilation from within the repository

parent c731ceb3
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
set -e set -e
#set -x
fcm_version=tags/2021.05.0 fcm_version=tags/2021.05.0
fiat_version=1295120464c3905e5edcbb887e4921686653eab8 fiat_version=1295120464c3905e5edcbb887e4921686653eab8
...@@ -11,6 +12,8 @@ function parse_args() { ...@@ -11,6 +12,8 @@ function parse_args() {
ARCH= ARCH=
GMKFILE= GMKFILE=
MESONHPROFILE= MESONHPROFILE=
useexpand=1
commit=""
# pass unrecognized arguments to fcm # pass unrecognized arguments to fcm
FCM_ARGS="" FCM_ARGS=""
...@@ -25,6 +28,8 @@ $0 [options] ...@@ -25,6 +28,8 @@ $0 [options]
--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) --mesonhprofile FILE build using Méso-NH profile and rules (--arch must be used to give a name to the build dir)
--noexpand do not use mnh_expand (code will be in array-syntax)"
--commit commit hash (or a directory) to test; do not use this option from within a repository
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
...@@ -44,6 +49,8 @@ EOF ...@@ -44,6 +49,8 @@ EOF
GMKFILE=$1 ; shift ;; GMKFILE=$1 ; shift ;;
"--mesonhprofile") "--mesonhprofile")
MESONHPROFILE=$1 ; shift ;; MESONHPROFILE=$1 ; shift ;;
'--noexpand') useexpand=0;;
'--commit') commit=$1; shift;;
*) *)
FCM_ARGS="$FCM_ARGS $OPTION" ;; FCM_ARGS="$FCM_ARGS $OPTION" ;;
esac esac
...@@ -250,7 +257,7 @@ check_install_fcm ...@@ -250,7 +257,7 @@ check_install_fcm
# Check the fiat installation # Check the fiat installation
check_install_fiat check_install_fiat
# Create the build directory and populate it # Create the build directory and set up the build system
builddir=arch_$ARCH builddir=arch_$ARCH
if [ -d $builddir ]; then if [ -d $builddir ]; then
echo "$builddir already exists. To rerun compilation, please enter this directory and use the compilation.sh script." echo "$builddir already exists. To rerun compilation, please enter this directory and use the compilation.sh script."
...@@ -270,26 +277,52 @@ else ...@@ -270,26 +277,52 @@ else
fi fi
cp fcm-make.cfg $builddir cp fcm-make.cfg $builddir
cd $builddir cd $builddir
mkdir src
cd src # Populate the source directory with (modified) PHYEX source code
if [ -d ../../../../src/common ]; then [ "$commit" == "" ] && commit=$PWD/../../.. #Current script run from within a PHYEX repository
#We compile directly from a PHYEX repository if echo $commit | grep '/' | grep -v '^tags/' > /dev/null; then
ln -s ../../../../src/common/* . # We get the source code directly from a directory
ln -s ../../../../src/testprogs/* . fromdir=$commit
else
# We use a commit to checkout
fromdir=''
fi
#Expand options
if [ $useexpand == 1 ]; then
expand_options="-D MNH_EXPAND -D MNH_EXPAND_LOOP"
else else
#We compile after an execution of prep_code expand_options=""
ln -s ../../../../src/* .
fi fi
PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/../../../tools #if run from within a PHYEX repository
UPDATEDPATH=$PATH
which prep_code.sh > /dev/null || export UPDATEDPATH=$PHYEXTOOLSDIR:$PATH
subs="$subs -s turb -s shallow -s turb_mnh -s micro -s aux -s ice_adjust -s rain_ice -s rain_ice_old -s support"
if [ "$fromdir" == '' ]; then
echo "Clone repository, and checkout commit $commit (using prep_code.sh)"
if [[ $commit == testprogs${separator}* ]]; then
PATH=$UPDATEDPATH prep_code.sh -c $commit src #This commit is ready for inclusion
else
PATH=$UPDATEDPATH prep_code.sh -c $commit $expand_options $subs -m testprogs src
fi
else
echo "Copy $fromdir"
mkdir src
scp -q -r $fromdir/src src/
PATH=$UPDATEDPATH prep_code.sh $expand_options $subs -m testprogs src
fi
# Add some code
cd src
ln -s ../../fiat/src fiat ln -s ../../fiat/src fiat
cat <<EOF > dummyprog.F90 cat <<EOF > dummyprog.F90
PROGRAM DUMMYPROG PROGRAM DUMMYPROG
PRINT*, "CREATED TO FORCE FCM TO LINK SOMETHING" PRINT*, "CREATED TO FORCE FCM TO LINK SOMETHING"
END PROGRAM DUMMYPROG END PROGRAM DUMMYPROG
EOF EOF
# Build the compilation script and run it
cd .. cd ..
build_compilation_script src build_compilation_script src
# Run the compilation
./compilation.sh ./compilation.sh
ln -s build/bin/libphyex.so . ln -s build/bin/libphyex.so .
......
...@@ -78,7 +78,7 @@ commit="" ...@@ -78,7 +78,7 @@ commit=""
reference="" reference=""
tests="" tests=""
suppress=0 suppress=0
useexpand=1 useexpand=""
archfile=$defaultarchfile archfile=$defaultarchfile
refarchfile=$defaultarchfile refarchfile=$defaultarchfile
...@@ -90,7 +90,7 @@ while [ -n "$1" ]; do ...@@ -90,7 +90,7 @@ while [ -n "$1" ]; do
'-r') run=$(($run+1));; '-r') run=$(($run+1));;
'-C') check=1;; '-C') check=1;;
'-t') tests="$2"; shift;; '-t') tests="$2"; shift;;
'--noexpand') useexpand=0;; '--noexpand') useexpand=$1;;
'--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') archfile="$2"; shift;;
...@@ -149,9 +149,7 @@ if [ $check -eq 1 -a -z "${reference-}" ]; then ...@@ -149,9 +149,7 @@ if [ $check -eq 1 -a -z "${reference-}" ]; then
exit 3 exit 3
fi fi
fromdir=''
if echo $commit | grep '/' | grep -v '^tags/' > /dev/null; then if echo $commit | grep '/' | grep -v '^tags/' > /dev/null; then
fromdir=$commit
name=$(echo $commit | sed 's/\//'${separator}'/g' | sed 's/:/'${separator}'/g' | sed 's/\./'${separator}'/g') name=$(echo $commit | sed 's/\//'${separator}'/g' | sed 's/:/'${separator}'/g' | sed 's/\./'${separator}'/g')
[ $suppress -eq 1 -a -d $TESTDIR/$name ] && rm -rf $TESTDIR/$name [ $suppress -eq 1 -a -d $TESTDIR/$name ] && rm -rf $TESTDIR/$name
elif echo $specialName | grep -w $commit > /dev/null; then elif echo $specialName | grep -w $commit > /dev/null; then
...@@ -187,36 +185,14 @@ if [ $compilation -eq 1 ]; then ...@@ -187,36 +185,14 @@ if [ $compilation -eq 1 ]; then
fi fi
mkdir $TESTDIR/$name mkdir $TESTDIR/$name
cd $TESTDIR/$name/ cd $TESTDIR/$name/
cp -r $PHYEXTOOLSDIR/../build . #We use the compilation system from the same commit as the current script
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=$PHYEXTOOLSDIR:$MNH_EXPAND_DIR/filepp:$MNH_EXPAND_DIR/MNH_Expand_Array:$PATH
if [ $useexpand == 1 ]; then
expand_options="-D MNH_EXPAND -D MNH_EXPAND_LOOP"
else
expand_options=""
fi
subs="$subs -s turb -s shallow -s turb_mnh -s micro -s aux -s ice_adjust -s rain_ice -s rain_ice_old -s support"
prep_code=$PHYEXTOOLSDIR/prep_code.sh
if [ "$fromdir" == '' ]; then
echo "Clone repository, and checkout commit $commit (using prep_code.sh)"
if [[ $commit == testprogs${separator}* ]]; then
$prep_code -c $commit src #This commit is ready for inclusion
else
$prep_code -c $commit $expand_options $subs -m testprogs src
fi
else
echo "Copy $fromdir"
mkdir src
scp -q -r $fromdir/src src/
$prep_code $expand_options $subs -m testprogs src
fi
cp -r $PHYEXTOOLSDIR/../build . #We use the compilation system from the same commit as the current script
cd $TESTDIR/$name/build/with_fcm/ cd $TESTDIR/$name/build/with_fcm/
rm -rf arch_* rm -rf arch_*
./make_fcm.sh --arch $archfile 2>&1 | tee Output_compilation ./make_fcm.sh $useexpand --commit $commit --arch $archfile 2>&1 | tee Output_compilation
fi fi
if [ $run -ge 1 ]; then if [ $run -ge 1 ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment