Skip to content

Commit

Permalink
Update shell scripts for better spack integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Aug 20, 2024
1 parent e967a6f commit 5c9ec64
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
6 changes: 5 additions & 1 deletion scripts/fv3.j
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ set RUN_CMD = "$GEOSBIN/esma_mpirun -np "

setenv ARCH `uname`
source $GEOSBIN/g5_modules
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${BASEDIR}/${ARCH}/lib:${GEOSDIR}/lib
setenv @LD_LIBRARY_PATH_CMD ${LD_LIBRARY_PATH}:${GEOSDIR}/lib
# We only add BASEDIR to the @LD_LIBRARY_PATH_CMD if BASEDIR is defined (i.e., not running with Spack)
if ( $?BASEDIR ) then
setenv @LD_LIBRARY_PATH_CMD ${@LD_LIBRARY_PATH_CMD}:${BASEDIR}/${ARCH}/lib
endif
module list

#########################################
Expand Down
66 changes: 40 additions & 26 deletions scripts/fv3_setup
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ setenv NODE `uname -n`

if ($ARCH == Darwin) then
set FINDPATH = realpath
set PRELOAD_COMMAND = 'DYLD_INSERT_LIBRARIES'
set LD_LIBRARY_PATH_CMD = 'DYLD_LIBRARY_PATH'
# On macOS we seem to need to call mpirun directly and not use esma_mpirun
# For some reason SIP does not let the libraries be preloaded
set RUN_CMD = 'mpirun -np '
else
set FINDPATH = 'readlink -f'
set PRELOAD_COMMAND = 'LD_PRELOAD'
set LD_LIBRARY_PATH_CMD = 'LD_LIBRARY_PATH'
set RUN_CMD = '$GEOSBIN/esma_mpirun -np '
endif
set FV3SETUP = `$FINDPATH $0`
set BINDIR = `dirname $FV3SETUP`
Expand All @@ -64,9 +72,11 @@ endif
# path to the sandbox. If we are not, then we set it to an empty
# string.
#
# We also set the REAL_BIND_PATH environment variable. This is used
# to set the bind paths for Singularity runs. REAL_BIND_PATH is the
# physical path to the NOBACKUP directory
# We also set the REAL_BIND_PATH and BASE_BIND_PATH environment
# variables. These are used to set the bind paths for Singularity
# runs. REAL_BIND_PATH is the physical path to the NOBACKUP directory
# and BASE_BIND_PATH is the physical path to the /gpfsm directory
# (needed for boundary conditions)

setenv KEYFILE ".singularity.d"
setenv singstat 0
Expand All @@ -85,34 +95,25 @@ while ($singstat == 0)
endif
endif
end

if ($singstat == 1) then
setenv SINGULARITY_SANDBOX $SINGPATH
setenv REAL_BIND_PATH `realpath $NOBACKUP`

set USING_SINGULARITY = TRUE
set SINGULARITY_BUILD = ""
set NATIVE_BUILD = "#DELETE"
setenv BASE_BIND_PATH "/gpfsm"
else
setenv SINGULARITY_SANDBOX ""
setenv REAL_BIND_PATH ""

set USING_SINGULARITY = FALSE
set SINGULARITY_BUILD = "#DELETE"
set NATIVE_BUILD = ""
setenv BASE_BIND_PATH ""
endif

cd $ORIGPATH

# Set TMPDIR to /tmp due to issues with heredocs in Singularity sandboxes
# -----------------------------------------------------------------------

setenv TMPDIR /tmp

#######################################################################
# Test for Command Line Flags
#######################################################################

# Set default behavior of switches
set LINKX = FALSE
set EXE_VERB = "copied"
set SINGULARITY_RUN_SITE = ""
if ($singstat == 1) then
set USING_SINGULARITY = TRUE
Expand All @@ -131,6 +132,7 @@ if ($singstat == 1) then
else
set USING_SINGULARITY = FALSE
endif

while ( $#argv > 0 )
set arg = $argv[1]
shift argv
Expand All @@ -140,6 +142,17 @@ while ( $#argv > 0 )
case --[Cc][Oo][Ll][Oo][Rr]:
goto SETCOLOR

# Symlink StandAlone_FV3_Dycore.x
case --link:
set LINKX = TRUE
set EXE_VERB = "linked"
breaksw

# Avoid Symlink StandAlone_FV3_Dycore.x
case --nolink:
set LINKX = FALSE
breaksw

# Here any string not above will trigger USAGE
case -[Hh]:
case --[Hh][Ee][Ll][Pp]:
Expand Down Expand Up @@ -342,6 +355,7 @@ else if ( $SITE == 'NAS' ) then
echo " ${C2}sky (Skylake)${CN} (default)"
echo " ${C2}cas (Cascade Lake)${CN}"
echo " ${C2}rom (AMD Rome)${CN}"
echo " ${C2}mil (AMD Milan)${CN}"
echo " "
echo " NOTE Due to how FV3 is compiled by default, Sandy Bridge"
echo " and Ivy Bridge are not supported by current GEOS"
Expand All @@ -356,7 +370,8 @@ else if ( $SITE == 'NAS' ) then
$MODEL != 'bro' & \
$MODEL != 'sky' & \
$MODEL != 'cas' & \
$MODEL != 'rom' ) goto ASKPROC
$MODEL != 'rom' & \
$MODEL != 'mil' ) goto ASKPROC

# Some processors have weird names at NAS
# ---------------------------------------
Expand All @@ -367,13 +382,11 @@ else if ( $SITE == 'NAS' ) then
set MODEL = 'cas_ait'
else if ($MODEL == rom) then
set MODEL = 'rom_ait'
else if ($MODEL == mil) then
set MODEL = 'mil_ait'
endif

if ( $MODEL == 'san') then
set NCPUS_PER_NODE = 16
else if ($MODEL == 'ivy') then
set NCPUS_PER_NODE = 20
else if ($MODEL == 'has') then
if ($MODEL == 'has') then
set NCPUS_PER_NODE = 24
else if ($MODEL == 'bro') then
set NCPUS_PER_NODE = 28
Expand All @@ -383,6 +396,8 @@ else if ( $SITE == 'NAS' ) then
set NCPUS_PER_NODE = 40
else if ($MODEL == 'rom_ait') then
set NCPUS_PER_NODE = 128
else if ($MODEL == 'mil_ait') then
set NCPUS_PER_NODE = 128
endif

else if( $SITE == 'AWS' | $SITE == 'Azure' ) then
Expand Down Expand Up @@ -780,7 +795,6 @@ EOF
else if( $MPI_STACK == intelmpi ) then

cat > $EXPDIR/SETENV.commands << EOF
#setenv MPS_STAT_LEVEL 4
setenv I_MPI_ADJUST_ALLREDUCE 12
setenv I_MPI_ADJUST_GATHERV 3
Expand All @@ -798,8 +812,8 @@ setenv I_MPI_SHM_HEAP_VSIZE 512
setenv PSM2_MEMORY large
EOF

#Testing at NCCS showed these caused crash at higher res
#Crashed at restart read
# Testing at NCCS showed these caused a crash at higher resolutions at
# restart read
if ( $USING_SINGULARITY == FALSE ) then

cat >> $EXPDIR/SETENV.commands << EOF
Expand Down

0 comments on commit 5c9ec64

Please sign in to comment.