#!/bin/csh -f # +-======-+ # Copyright (c) 2003-2018 United States Government as represented by # the Admistrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, # REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN # COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS # REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY"). # THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN # INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR # REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, # DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED # HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE # RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. # # Government Agency: National Aeronautics and Space Administration # Government Agency Original Software Designation: GSC-15354-1 # Government Agency Original Software Title: GEOS-5 GCM Modeling Software # User Registration Requested. Please Visit http://opensource.gsfc.nasa.gov # Government Agency Point of Contact for Original Software: # Dale Hithon, SRA Assistant, (301) 286-2691 # # +-======-+ ######################################################################## # # Name: g5_modules # # Purposes - # * provide single location for BASEDIR and module values # * initialize the following: # - set BASEDIR # - update LD_LIBRARY_PATH with BASEDIR lib # - load library modules # * echo expected BASEDIR and library module values when queried # # Notes: # 1. The script will not function correctly if the scriptname # definition within the script is incorrect. # 2. Type "g5_modules help" for usage information. # # Perl Notes: # ========== # 1. You cannot "source" this file from a perl script. # 2. Instead use the following in your perl script: # #-------------------------------- # use Env; # do "g5_modules_perl_wrapper"; # #-------------------------------- # 3. Use the g5_modules_perl_wrapper file located in the build's bin # directory, where a copy of g5_modules also resides. This is important # since g5_modules_perl_wrapper uses g5_modules and expects it to be in # the same directory. # # Bash Notes: # ========== # If you are in a bash shell, then source the g5_modules.sh script. # > source g5_modules.sh # # REVISION HISTORY # 31Aug2007 Stassi Initial version of code # 15Oct2007 Stassi Expand list of machines and include defaults # 15Dec2007 Stassi Added LD_LIBRARY_PATH functionality # 21Jul2008 Takacs New modules and BASEDIR on discover after OS upgrade # 13Apr2009 Stassi Updated for pleiades # 22Apr2010 Kokron Updated for Fortuna-2.1 on pleiades # 21Jul2011 Kokron Overlay older MKL module as on discover to gain reproducible results from dgeev in GSI # 24Aug2012 Stassi Added sh option to write bash source-able file # 03Nov2016 Thompson Remove JIBB ######################################################################## # NOTE: Spell out scriptname--DO NOT SET EQUAL TO $0! #---------------------------------------------------- set scriptname = g5_modules if ( $scriptname == "$0:t" ) then set sourced = 0 else set sourced = 1 endif # check for improper usage #------------------------- if (! $sourced && ! $#argv) goto usage # not sourced and no args if ( $sourced && $#argv) goto usage # sourced with args # get architecture, machine, and node information #------------------------------------------------ set arch = `uname -s` set mach = `uname -m` set node = `uname -n` # Find site # --------- if (($node =~ discover*) || ($node =~ borg*) || \ ($node =~ dali*) || ($node =~ warp*)) then set site = "NCCS" else if (($node =~ pfe*) || ($node =~ p4fe*) || \ ($node =~ r[0-9]*i[0-9]*n[0-9]*) || \ ($node =~ bridge*) || ($node =~ maia*)) then set site = "NAS" else if ($node =~ janus*) then set site = "GMAO.janus" else if ( $node =~ bender* ) then set site = "ACDL.bender" else if ( $node =~ *niteroi* ) then set site = "GMAO.niteroi" else if ( -d /ford1/share/gmao_SIteam/ && -d /ford1/local/ && $arch == Linux ) then set site = "GMAO.desktop" else set site = $node endif alias echo2 "echo \!* > /dev/stderr" # get values #----------- if ($mach == x86_64) goto X86_64 # ERROR -- unknown architecture/machine #-------------------------------------- echo2 "${scriptname}: >>>WARNING<<< unrecognizable arch/machine = $arch/$mach" echo 0 # indicating error condition exit 8 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # X86_64 values (Linux) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# X86_64: #==================# # X86_64 default # #==================# set modinit = DUMMY set loadmodules = 0 set usemodules = 0 #========# # NCCS # #========# if ( $site == NCCS ) then set mod1 = other/comp/gcc-6.3 set mod2 = comp/intel-18.0.1.163 # For IMPI 2018 #set basedir = /discover/nobackup/projects/gmao/share/gmao_ops/Baselibs/v5.1.0_build1/x86_64-unknown-linux-gnu/ifort_18.0.1.163-intelmpi_18.0.1.163 #set mod3 = mpi/impi-18.0.1.163 # For MPT set basedir = /discover/nobackup/projects/gmao/share/gmao_ops/Baselibs/v5.1.0_build1/x86_64-unknown-linux-gnu/ifort_18.0.1.163-mpt_2.17 set mod3 = mpi/sgi-mpt-2.17 # For Open MPI #set basedir = /discover/swdev/mathomp4/Baselibs/ESMA-Baselibs-5.1.0/x86_64-unknown-linux-gnu/ifort_18.0.1.163-openmpi_3.0.0 #set mod3 = other/mpi/openmpi/3.0.0-intel-18.0.1.163 # For MVAPICH2 #set basedir = /discover/swdev/mathomp4/Baselibs/ESMA-Baselibs-5.1.0/x86_64-unknown-linux-gnu/ifort_18.0.1.163-mvapich2_2.3b #set mod3 = other/mpi/mvapich2-2.3b/intel-18.0.1.163 set mod4 = lib/mkl-18.0.1.163 set mod5 = other/SIVO-PyD/spd_1.25.0_gcc-6.3_mkl-17.0.4.196 set mod6 = other/git-2.11.0 set mod7 = other/cmake-3.8.2 set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 $mod6 $mod7 ) set modinit = /usr/share/modules/init/csh set loadmodules = 0 set usemodules = 0 #=======# # NAS # #=======# else if ( $site == NAS ) then set basedir = /nobackup/gmao_SIteam/Baselibs/ESMA-Baselibs-5.1.0/x86_64-unknown-linux-gnu/ifort_2018.1.163-mpt_2.17r4-gcc_6.3.0 set mod1 = comp-gcc/6.3.0 set mod2 = 2018.1.163.modulefile set mod3 = mpi-hpe/mpt.2.17r4 set mod4 = math-mkl/2018.1.163 set mod5 = python/2.7.12 set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 ) set modinit = /usr/share/modules/init/tcsh set loadmodules = 0 set usemodules = 1 #=========# # JANUS # #=========# else if ( $site == GMAO.janus ) then set basedir=/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-5.1.0/x86_64-unknown-linux-gnu/pgfortran_17.10-openmpi_3.0.0-gcc_6.3.0 set mod1 = comp/gcc/6.3.0 set mod2 = comp/pgi/17.10-gcc_6.3.0 set mod3 = mpi/openmpi/3.0.0/pgi-17.10_gcc-6.3.0 set mod4 = lib/mkl/17.0.4.196 set mod5 = other/python/canopy set mod6 = other/git/latest set mod7 = other/cmake/latest setenv ESMA_FC pgfortran setenv GPU_CC_REV cc20 setenv PGI_LOCALRC /ford1/share/gmao_SIteam/PGILocalRC/linux86-64/17.10/bin/localrc.60300 set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 $mod6 $mod7 ) set modinit = /usr/share/Modules/init/tcsh set loadmodules = 0 set usemodules = 1 #===========# # Bender # #===========# else if ( $site == ACDL.bender ) then set basedir=/ford1/share/gmao_SIteam/Baselibs/GMAO-Baselibs-5_0_0/x86_64-unknown-linux-gnu/ifort_13.1.1.163-openmpi_1.8.1 set BASEBIN=$basedir/$arch/bin set PYBIN = /share/dasilva/epd/epd-7.3-2-rh5-x86_64/bin set IFCBIN = /opt/intel/composer_xe_2013.5.192/bin set MPIBIN = /ford1/share/gmao_SIteam/MPI/openmpi-1.8.1-ifort-13.1.1.163/bin source $IFCBIN/ifortvars.csh intel64 setenv MKLPATH $MKLROOT/lib set path = ( $BASEBIN $MPIBIN $PYBIN $path ) set loadmodules = 0 set usemodules = 0 #===========# # Niteroi # #===========# else if ( $site == GMAO.niteroi ) then set basedir = /Users/mathomp4/Baselibs/GMAO-Baselibs-5_0_0/x86_64-apple-darwin14.0.0/ifort_15.0.1.108-openmpi_1.8.3 set BASEBIN = $basedir/$arch/bin set PYBIN = /Library/Frameworks/EPD64.framework/Versions/7.3/bin set IFCPATH = /opt/intel/composer_xe_2015.1.108 set MPIBIN = /Users/mathomp4/MPI/openmpi/1.8.3/ifort-15.0.1.108 source $IFCPATH/bin/compilervars.csh intel64 setenv MKLPATH $MKLROOT/lib set path = ( $BASEBIN $MPIBIN $PYBIN $path ) set loadmodules = 0 set usemodules = 0 #=================# # GMAO DESKTOP # #=================# else if ( $site == GMAO.desktop ) then set basedir=/ford1/share/gmao_SIteam/Baselibs/ESMA-Baselibs-5.1.0/x86_64-unknown-linux-gnu/gfortran_7.3.0-openmpi_3.0.0 set mod1 = comp/gcc/7.3.0 set mod2 = mpi/openmpi/3.0.0/gcc-7.3.0 set mod3 = lib/mkl/18.0.1.163 set mod4 = other/python/canopy set mod5 = other/git/latest set mod6 = other/cmake/latest setenv ESMA_FC gfortran set mods = ( $mod1 $mod2 $mod3 $mod4 $mod5 $mod6 ) set modinit = /usr/share/Modules/init/tcsh set loadmodules = 0 set usemodules = 1 endif goto ACTION #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # perform requested action #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ACTION: #===================# # ECHO VALUE(s) # #===================# set wrapper = 0 if ( $#argv > 0 ) then if ( $1 == basedir ) then echo $basedir else if ( $1 == modules ) then echo $mods else if ( $1 == modinit ) then echo $modinit else if ( $1 == loadmodules ) then echo $loadmodules else if ( $1 == usemodules ) then echo $usemodules else if ( $1 == ESMA_FC ) then echo $ESMA_FC else if ( $1 == site ) then echo $site else if ( $1 == sh ) then set wrapper = 1 goto SETVALUES else if ( $1 == help ) then goto usage else echo2 "${scriptname}: >>>ERROR<<< unrecognizable option -- $1" echo2 Type "$scriptname help" for usage information. echo 0 # indicating error condition exit 9 endif exit endif SETVALUES: #================# # SET VALUES # #================# #------------------------------------------------------------------------- # set environment variables, BASEDIR and LD_LIBRARY_PATH; and load modules #------------------------------------------------------------------------- # setenv BASEDIR #--------------- if ($?basedir) then if (! $wrapper) echo -n "${scriptname}: Setting BASEDIR" setenv BASEDIR $basedir else if ($?BASEDIR) then if (! $wrapper) echo -n "${scriptname}: BASEDIR found in environment" else echo echo "BASEDIR not found in environment or set by ${scriptname}" exit 3 endif # add BASEDIR lib to LD_LIBRARY_PATH, if not already there #--------------------------------------------------------- if ($?LD_LIBRARY_PATH) then echo $LD_LIBRARY_PATH | grep $BASEDIR/$arch/lib > /dev/null if ($status) then # == 1, if not found setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$BASEDIR/$arch/lib endif else setenv LD_LIBRARY_PATH $BASEDIR/$arch/lib endif # add individual $ld_libraries to LD_LIBRARY_PATH, if not already there #---------------------------------------------------------------------- if ($?ld_libraries) then foreach lib ( $ld_libraries ) if ($LD_LIBRARY_PATH !~ *$lib*) then setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$lib endif end endif if ($?LD_LIBRARY64_PATH) then echo $LD_LIBRARY64_PATH | grep $BASEDIR/$arch/lib > /dev/null if ($status) then # == 1, if not found setenv LD_LIBRARY64_PATH ${LD_LIBRARY64_PATH}:$BASEDIR/$arch/lib endif endif # load library modules #--------------------- if (-e $modinit) then if (! $wrapper) echo -n " and modules" source $modinit module purge if ($loadmodules) module load modules if ($usemodules) then if ($site == NCCS) then module use -a /home/mathomp4/modulefiles endif if ($site == NAS) then module use -a /u/scicon/tools/modulefiles module use -a /nobackup/gmao_SIteam/modulefiles module use -a /nasa/intel/Compiler/2018.1.163 endif if ($site =~ "GMAO.*" ) then module use -a /ford1/share/gmao_SIteam/modulefiles endif endif foreach mod ( $mods ) module load $mod end endif if (! $wrapper) echo " for $node" # write sh commands to a .g5_modules.sh file #------------------------------------------- if ($wrapper) then set outfil = ".g5_modules.sh" if ($?BASEDIR) then echo "export BASEDIR=$BASEDIR" >! $outfil endif if ($?LD_LIBRARY_PATH) then echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $outfil endif if ($?LD_LIBRARY64_PATH) then echo "export LD_LIBRARY64_PATH=$LD_LIBRARY64_PATH" >> $outfil endif set modulecmd = `which modulecmd` if ($status) set modulecmd = "/usr/bin/modulecmd" set modinit_sh = `echo $modinit | sed "s|/csh|/sh|"` if (-e $modulecmd) then if (-e $modinit_sh) then echo 'source '$modinit_sh >> $outfil endif echo 'eval `'$modulecmd sh purge'`' >> $outfil if ($loadmodules) then echo 'eval `'$modulecmd sh load modules'`' >> $outfil endif foreach mod ($mods) echo 'eval `'$modulecmd sh load $mod'`' >> $outfil end endif endif exit #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # usage information # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# usage: more < OPTIONS help echo usage basedir echo expected value for BASEDIR environment variable modules echo expected list of modules modinit echo location of csh module initialization script loadmodules echo logical indicating whether "module load modules" is needed prior to loading other modules usemodules echo logical indicating whether "module use directory(s)" is needed prior to loading other modules ESMA_FC echo value of ESMA_FC if set site echo site as detected by $scriptname sh write sh version of g5_modules to file named, ".g5_modules.sh" EOF exit 1