Skip to content

Commit

Permalink
first pass at setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
jdha committed Mar 2, 2023
1 parent 9e47a59 commit e3b5b9a
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 85 deletions.
245 changes: 245 additions & 0 deletions scripts/setup/AMM7_setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
#!/bin/bash
# Lightweight script to set up AMM7 on ARCHER2

display_usage() {
echo
echo " Auto-Config: AMM7 on ARCHER2"
echo " ***************************************"
echo
echo " usage: ${0##*/} -w path_to_install_nemo -x path_to_intall_xios -s path_to_repo"
echo " -m machine -v version -c compiler -a mpi_build"
echo
echo " flags: -w full path to where nemo will be installed"
echo " -x full path to where xios will be installed"
echo " -s full path to where SE-NEMO repository resides"
echo " -v NEMO vserion"
echo " -m machine name"
echo " -c compiler"
echo " -a MPI build [mpich|mpich4|ompi]"
echo
exit 1
}
# if less than three arguments supplied, display usage
if [ $# -le 13 ]
then
display_usage
exit 1
fi
# if less than two arguments supplied, display usage
if [ $# -ge 15 ]
then
display_usage
exit 1
fi
# check whether user had supplied -h or --help . If yes display usage
if [[ ( $# == "--help") || $# == "-h" ]]
then
display_usage
exit 0
fi

while getopts w:x:s:m:v:c:a: option
do
case "${option}"
in
w) export WORK_DIR=${OPTARG};;
x) export XIOS_DIR=${OPTARG};;
s) export REPO_DIR=${OPTARG};;
m) export HPC_TARG=${OPTARG};;
v) export NEMO_VER=${OPTARG};;
c) export COMPILER=${OPTARG};;
a) export MPI_TARG=${OPTARG};;
esac
done

if [ ${WORK_DIR:0:1} != "/" ]; then
echo "WORK_DIR must use full path"
exit 1
fi

if [ ${XIOS_DIR:0:1} != "/" ]; then
echo "XIOS_DIR must use full path"
exit 1
fi

if [ ${REPO_DIR:0:1} != "/" ]; then
echo "REPO_DIR must use full path"
exit 1
fi

# Change to some working directory of choice
if [ ! -d "$WORK_DIR" ]; then
mkdir $WORK_DIR
fi
cd $WORK_DIR

echo "Making sure that the correct modules are loaded"

case "${HPC_TARG}"
in
archer2) . $REPO_DIR/scripts/env/${HPC_TARG}-${COMPILER}-${MPI_TARG}
;;
*) echo "Machine not recognised"
echo "Machines available: archer2"
exit 1
esac

export LD_LIBRARY_PATH=$CRAY_LD_LIBRARY_PATH:$LD_LIBRARY_PATH

case "${NEMO_VER}"
in
4.0.2) echo "NEMO Version 4.0.2 will be checked out"
;;
4.2.0) echo "NEMO Version 4.2.0 will be checked out"
;;
4.2) echo "NEMO Head of branch 4.2 will be checked out"
;;
*) echo "NEMO Version not recognised"
echo "Versions available: 4.0.2, 4.2.0, branch 4.2"
exit 1
esac

# Checkout the NEMO code from the SVN Paris repository
echo "Checking out NEMO repository"
case "${NEMO_VER}"
in
4.2) git clone --branch branch_4.2 https://forge.nemo-ocean.eu/nemo/nemo.git nemo
;;
4.2.0) git clone --branch 4.2.0 https://forge.nemo-ocean.eu/nemo/nemo.git nemo
;;
*) svn co http://forge.ipsl.jussieu.fr/nemo/svn/NEMO/releases/r4.0/r$NEMO_VER --depth empty nemo
svn co http://forge.ipsl.jussieu.fr/nemo/svn/NEMO/releases/r4.0/r$NEMO_VER/src --depth infinity nemo/src
svn co http://forge.ipsl.jussieu.fr/nemo/svn/NEMO/releases/r4.0/r$NEMO_VER/cfgs/SHARED nemo/cfgs/SHARED
svn export http://forge.ipsl.jussieu.fr/nemo/svn/NEMO/releases/r4.0/r$NEMO_VER/cfgs/ref_cfgs.txt nemo/cfgs/ref_cfgs.txt
;;
esac

cd nemo

# Now check EXTERNALS revision number before checking out the rest
case "${NEMO_VER}"
in
4.2) echo "Nothing to do as EXTERNALS are integral to 4.2"
;;
4.0.2) echo "Nothing to do as EXTERNALS are integral to 4.2.0"
;;
*) for ext_name in mk FCM IOIPSL
do
ext=`svn propget svn:externals | grep $ext_name | cut -c2-`
svn co http://forge.ipsl.jussieu.fr/nemo/svn/$ext
done
ext=`svn propget svn:externals | grep makenemo | cut -c2-`
svn export http://forge.ipsl.jussieu.fr/nemo/svn/$ext
;;
esac

mkdir arch

# Setup the directory structure
mkdir $WORK_DIR/nemo/cfgs/AMM7

# Define the location of where the forcing files are to be downloaded
export DOWNLOAD_DIR="$WORK_DIR/nemo/cfgs/AMM7/EXPREF/"

echo $XIOS_DIR
# Choose an appropriate directory for your XIOS installation
if [ ! -d "$XIOS_DIR" ]; then
mkdir $XIOS_DIR
fi

# Checkout the XIOS code from the SVN repository
cd $XIOS_DIR

echo "Checking out xios repository"

case "${NEMO_VER}"
in
4.2) svn checkout http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/trunk@2379 xios
;;
*) svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5@1964 xios
;;
esac


cd xios
cp $REPO_DIR/arch/xios/* ./arch

echo "Compiling xios"
./make_xios --full --prod --arch ${HPC_TARG}-${COMPILER}-${MPI_TARG} --netcdf_lib netcdf4_par --job 10

# Let's update the path to xios
export XIOS_DIR=$XIOS_DIR/xios

[ -f $XIOS_DIR/bin/xios_server.exe ] || exit 1

cd $WORK_DIR/nemo
cp $REPO_DIR/arch/nemo/* ./arch
# Dirty fix to hard wire path otherwise user will have to set XIOS_DIR in every new shell session
sed -i "s?XXX_XIOS_DIR_XXX?$XIOS_DIR?" ./arch/arch-${HPC_TARG}-${COMPILER}-${MPI_TARG}.fcm

echo 'AMM7 OCE' >> $WORK_DIR/nemo/cfgs/work_cfgs.txt

echo "Gathering forcing data"

export CONFIG_DIR=$WORK_DIR/nemo/cfgs/AMM7

cd $CONFIG_DIR

## Download the input data
case "${HPC_TARG}"
in
archer2) ln -s /work/n01/n01/shared/CO_AMM7 INPUTS
;;
*) wget http://gws-access.ceda.ac.uk/public/jmmp/CO9_AMM7/inputs.tar.gz
tar xvfz inputs.tar.gz
;;
esac

cp -r $REPO_DIR/EXPREF/$NEMO_VER/ EXPREF
cd $CONFIG_DIR/EXPREF

## Add ENV into runscipts
case "${HPC_TARG}"
in
archer2) sed -i "s?XXX_ENV_XXX?$REPO_DIR/scripts/env/${HPC_TARG}-${COMPILER}-${MPI_TARG}?" runscript.slurm
sed -i "s?XXX_ENV_XXX?$REPO_DIR/scripts/env/${HPC_TARG}-${COMPILER}-${MPI_TARG}?" runscript.mpirun
;;
*) sed -i "s?XXX_ENV_XXX??" runscript.slurm
sed -i "s?XXX_ENV_XXX??" runscript.mpirun
;;
esac

mkdir meta_out
mkdir RESTARTS
mkdir OUTPUTS
mkdir OUTPUTS_PROCESSED
mkdir OUTPUTS_ZIP

ln -s $XIOS_DIR/bin/xios_server.exe $CONFIG_DIR/EXPREF/xios_server.exe


# Copy remaining information
cp -r $REPO_DIR/MY_SRC/$NEMO_VER $CONFIG_DIR/MY_SRC
cp $REPO_DIR/CPP/$NEMO_VER/cpp_AMM7.fcm $CONFIG_DIR/
cp $REPO_DIR/scripts/run/* $CONFIG_DIR/EXPREF

cd $WORK_DIR/nemo

echo "Compiling nemo AMM7 Config"
./makenemo -m ${HPC_TARG}-${COMPILER}-${MPI_TARG} -r AMM7 -j 10

echo
echo " Auto-Config: AMM7"
echo " **********************"
echo
echo " To run the AMM7 Configuration:"
echo
echo " - cp -rP EXPREF EXP_MYRUN "
echo " - link the correct domain_cfg.nc "
echo " - update the runscript accordingly "
echo " (project code, nodes, modules, etc)"
echo

echo " - submit via the sbatch command"

echo
85 changes: 0 additions & 85 deletions scripts/setup/amm7_setup_light

This file was deleted.

0 comments on commit e3b5b9a

Please sign in to comment.