#! /bin/csh -f

# -------------------------------------------------------------------------
# Yellowstone build specific settings
# -------------------------------------------------------------------------


source /glade/apps/opt/lmod/lmod/init/csh

module purge
module load ncarenv/1.0
module load ncarbinlibs/1.0

if ( $COMPILER == "intel" ) then
  module load intel/13.0.1
  module load mkl/11.0.1
# Currently esmf is only supported with the INTEL compiler
  module load esmf
  if ( $MPILIB == "mpi-serial") then
    if ( $DEBUG == "TRUE") then
      module load esmf-5.3.0-ncdfio-uni-g
    else
      module load esmf-5.3.0-ncdfio-uni-O
    endif
  else
    if ( $DEBUG == "TRUE") then
      module load esmf-5.3.0-defio-mpi-g
    else
      module load esmf-5.3.0-defio-mpi-O
    endif
  endif
endif
if ( $COMPILER == "pgi" ) then
  module load pgi/12.5
endif
if ( $COMPILER == "gnu" ) then
  module load gnu/4.7.2
endif
if ( $COMPILER == "pathscale" ) then
  module load pathscale/4.0.12.1
endif
module load ncarcompilers/1.0
module load netcdf/4.2 
module load pnetcdf/1.3.0

#setenv PNETCDF /glade/u/home/jedwards/pnetcdf/svn1106/intel/
# -------------------------------------------------------------------------
# Build and runtime environment variables - edit before the initial build 
# -------------------------------------------------------------------------
limit stacksize unlimited
limit datasize  unlimited

setenv OMP_STACKSIZE 32000K
setenv MP_LABELIO yes

# MPI Environment
setenv MP_INFOLEVEL                   2
setenv MP_SHARED_MEMORY             yes
setenv MP_EUILIB                    us
setenv MP_MPILIB                    $MPILIB
setenv MP_STDOUTMODE                unordered
setenv MP_EAGER_LIMIT               0
setenv MP_RC_USE_LMC                yes

# Set a host file so that mpi can run on login node
if ( $HOSTNAME =~ {*login*} ) then
  echo $HOSTNAME > $CASEROOT/hostfile
  setenv MP_HOSTFILE $CASEROOT/hostfile
  setenv MP_PROCS 1
endif
