#!/bin/bash

# Modify key_nproci and key_nprocj in the following "fcm"
# file according to no. of proc to be used.
# vi ORCA2_LIM/cpp_ORCA2_LIM.fcm 

# Modify compiler options in the appropriat
# file located at the following path.
# vi ../ARCH/arch-*.fcm

source /opt/modules/default/init/bash
module load xtpe-mc12
module load netcdf

compile=pgf90_linux
config=ORCA2_LIM
tools="REBUILD"

cat<<EOJ>job
#!/bin/bash

which ftn
which ncdump
cat ../ARCH/*$compile*
cat $config/cpp_$config.fcm
./makenemo clean
./makenemo -m $compile -n $config

cd ../TOOLS
for l in $tools; do
 ./maketools -m $compile -n \$l
done
EOJ

chmod 775 job
nohup ./job >& compilation_$1.log &

