set -xuve

HPCROOTDIR=%HPCROOTDIR%


# Load the modules
module purge
module load intel mkl python/3.6.1 netcdf/4.2

# Go to the project directory
cd $HPCROOTDIR/python-amip-reader

# Define the content of the make.inc file
CONTENT=$(cat <<EOF
curr_path = \$(dir \$(realpath \$(lastword \$(MAKEFILE_LIST))))
include  \$(curr_path)/make.mn4
EOF
)

# Write the content into the file sources/oasis3-mct/util/make_dir/make.inc
echo "$CONTENT" > sources/oasis3-mct/util/make_dir/make.inc

# Compile OASIS, pyOASIS and the Fortran implementation of this model
(cd ./sources/amip-forcing/src/fortran && make clean)
(cd ./sources/amip-forcing/src/fortran && make oasis)
(cd ./sources/amip-forcing/src/fortran && make)