#! /bin/csh -f

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

if (-e /opt/modules/default/init/csh) then
  source /opt/modules/default/init/csh
  module rm PrgEnv-intel
  module rm PrgEnv-pgi
  module rm PrgEnv-cray 
  module rm PrgEnv-gnu
  module rm PrgEnv-pathscale
  module rm intel
  module rm pgi
  module rm cray
  module rm pathscale
  module rm netcdf
#  module load subversion
else
  echo "ERROR: Failed to initialize modules"
  exit -1
endif

# invoking modules sets $MPICH_DIR and $CRAY_NETCDF_DIR

if ( $COMPILER == "pgi" ) then
    module load PrgEnv-pgi
    module switch pgi       pgi/12.4.0
    #odule switch xt-mpt    xt-mpt/5.3.4
    #odule switch xt-libsci xt-libsci/11.0.06
    module load netcdf/3.6.2
endif

#-------------------------------------------------------------------------------
# Runtime environment variables
#-------------------------------------------------------------------------------

# fix for file system problem with empty namelists, june 2011
setenv DVS_MAXNODES 1

setenv MPICH_MAX_SHORT_MSG_SIZE  8000  # default is 128000 bytes
setenv MPICH_PTL_UNEX_EVENTS    960000 # default is  90000 (unexpected recv queue size)
#etenv MPICH_UNEX_BUFFER_SIZE    1000M # default is    60M (unexpected short msgs buff size)
setenv MPICH_MSGS_PER_PROC      160000 # default is  32768
setenv MPICH_PTL_SEND_CREDITS       -1
setenv MPICH_ENV_DISPLAY 1
setenv MPICH_VERSION_DISPLAY 1

# The environment variables below produce corefiles and maybe (?) should be
# moved to DEBUG mode at some point
setenv MPICH_DBMASK 0x200
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 MPSTKZ 64M
setenv OMP_STACKSIZE 64M

