#!/bin/ksh

nemo_i=4
nemo_j=4

while getopts i:j: option
do
 case $option in
  i) nemo_i=$OPTARG;;
  j) nemo_j=$OPTARG;;
  \?) exit 1;;
 esac
done

source /opt/modules/default/etc/modules.sh
module swap PrgEnv-pgi PrgEnv-intel
module load xt-libsci fftw

set -xuve
date

MPI=/opt/cray/mpt/5.5.1/gni/mpich2-intel/120
NetCDF=/cfs/klemming/nobackup/a/asifsami/opt/netcdf-3.6.3/intel-12.0
UDUNITS=

settings=settings.orca1.lindgren

cd ..
ECEARTH=`pwd`
cd -

cat > $settings <<EOF
# General settings
export MPIDIR=$MPI
export NETCDFDIR=$NetCDF
export NETCDFLIBS="-lnetcdf"
export UDUNITSDIR=$UDUNITS
which ftn

# settings for EC-Earth
export ECEARTH=$ECEARTH

# Settings for OASIS3
export OASIS3ARCH=lindgren
export PSMILE=\$ECEARTH/oasis3/prism_2-5/prism/\$OASIS3ARCH

# Settings of IFS
export ARCH=ifortmpich2
export IFSROOT=\$ECEARTH/ifs
PATH=\$IFSROOT/scripts:\$PATH

# Settings for NEMO
export NEMOARCH=lindgren
export NEMOPROCX=$nemo_i
export NEMOPROCY=$nemo_j
export NEMOGRID=ORCA1
export NEMOCLEAN=no

# Settings for FOcean and SlabOcean models
export FORTRANCOMPILER=ftn
export FORTRANFLAGS=''
export FORTRANLINK=''
export FOCEANARCH=lindgren
export FOCEANCLEAN=yes
export SLABOCEANARCH=lindgren
export SLABOCEANCLEAN=yes
EOF
cat $settings

ln -sf $ECEARTH/build/$settings settings

#./cleanoasis3.ksh
./makeoasis3.ksh

#./cleannemo.ksh
./makenemo.ksh

#./cleanifs.ksh
./makeifs.ksh

date
