#! /bin/csh -f

#-------------------------------------------------------------------------------
# Modules and library paths
#-------------------------------------------------------------------------------

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/1.7.2
endif

if ( $COMPILER == "pgi" ) then
    module load PrgEnv-pgi
    module switch pgi       pgi/12.4.0
    setenv PARALLEL_NETCDF_DIR /global/project/projectdirs/ccsm1/pnetcdf/svn1104/pgi/12.5.0
endif    
if ( $COMPILER == "intel" ) then
    module load PrgEnv-intel 
    module switch intel      intel/12.1.5.339
endif    
if ( $COMPILER == "cray" ) then
    module load PrgEnv-cray
    module switch cce      cce/8.0.7
endif    
if ( $COMPILER == "pathscale" ) then
    module load PrgEnv-pathscale
    module switch pathscale       pathscale/4.0.9
endif    
if ( $COMPILER == "gnu" ) then
    module load PrgEnv-gnu
    module switch gcc       gcc/4.7.1
endif    

module switch cray-mpich2 cray-mpich2/5.5.5
module switch cray-libsci cray-libsci/11.1.01
module load netcdf/4.2.0



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

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

# These environment variables were suggested by Helen He to help get around compiler issues
# with pgi9
setenv MALLOC_MMAP_MAX_ 0
setenv MALLOC_TRIM_THRESHOLD_ 536870912

# 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 OMP_STACKSIZE 64M
