#! /bin/csh -f

#===============================================================================
# Build time settings
#===============================================================================

if (-e /opt/modules/default/init/csh) then
  source /opt/modules/default/init/csh
#  module purge
#  module load subversion
else
  echo "ERROR: Failed to initialize modules"
  exit -1
endif

# invoking modules sets $MPICH_DIR and $CRAY_NETCDF_DIR

if ( $COMPILER == "intel" ) then
    module unload craype-mic-knl
    module load craype-broadwell

    module unload PrgEnv-cray
    module unload PrgEnv-gnu
    module unload PrgEnv-intel
    module unload PrgEnv-pgi
    module load PrgEnv-intel/6.0.4

    module unload intel
    module load intel/18.0.3.222

    module unload cray-mpich
    module load cray-mpich/7.7.7

    module unload cray-hdf5
    module unload cray-hdf5-parallel
    module unload cray-netcdf-hdf5parallel
    module unload cray-parallel-netcdf
    module unload netcdf
    module load cray-netcdf/4.6.1.3
    module load cray-hdf5/1.10.2.0
    module load cray-parallel-netcdf/1.8.1.4
#    module load netcdf/intel-17.0.1.132/4.4.1.1

    module unload cray-libsci
endif

# set by modules
#setenv NETCDF_DIR /p/app/unsupported/netcdf/4.4.1.1-intel-17.0.1.132
#setenv NETCDF_DIR /opt/cray/pe/netcdf/4.4.1.1/intel/15.0
#setenv NETCDF_DIR /opt/cray/pe/netcdf/4.6.1.3/intel/16.0
#-------------------------------------------------------------------------------
# Runtime environment variables
#-------------------------------------------------------------------------------

#setenv PATH /usr/local/usp/subversion/1.6.13-gnu/bin:$PATH
#setenv LD_LIBRARY_PATH /usr/local/usp/openssl/lib:$LD_LIBRARY_PATH
#setenv LD_LIBRARY_PATH /usr/local/usp/subversion/1.6.13-gnu/lib:$LD_LIBRARY_PATH

setenv MPICH_ENV_DISPLAY 1
setenv MPICH_VERSION_DISPLAY 1

limit coredumpsize unlimited
limit stacksize unlimited

# The environment variable below increase the stack size, which is necessary for
# CICE to run threaded on this machine.  
setenv OMP_STACKSIZE 64M

setenv WRFIO_NCD_LARGE_FILE_SUPPORT 1
setenv WRF_EM_CORE 1
