#! /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 == "pgi" ) then
    module unload PrgEnv-cray
    module unload PrgEnv-gnu
    module unload PrgEnv-intel
    module unload PrgEnv-pgi
#    module load PrgEnv-pgi/4.0.46
#    module load PrgEnv-pgi/4.1.40
    module load PrgEnv-pgi/4.2.34
    module unload pgi
    module load pgi/13.6.0
    module unload xt-mpich2
    module unload cray-mpich
    module unload cray-mpich2
#    module load cray-mpich2/5.6.5
    module load cray-mpich/6.0.0
    module unload netcdf
#    module load netcdf/4.3.0
    module load cray-netcdf/4.3.0
    module load PrgEnv-test
#    module list
endif

#-------------------------------------------------------------------------------
# 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

# 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

setenv WRFIO_NCD_LARGE_FILE_SUPPORT 1
setenv WRF_EM_CORE 1

