3434# Set Current Working Path to fv3_setup
3535# -------------------------------------
3636setenv ARCH ` uname -s`
37+ setenv NODE ` uname -n`
38+
3739if ($ARCH == Darwin) then
3840 set FINDPATH = realpath
3941else
@@ -52,6 +54,56 @@ if (! -x ${BINDIR}/StandAlone_FV3_Dycore.x) then
5254 exit 1
5355endif
5456
57+ # #####################################################################
58+ # Singularity Sandbox
59+ # ######################################################################
60+
61+ # This section is to determine if we are running in a Singularity
62+ # sandbox by looking for the .singularity.d directory. If we are,
63+ # then we set the SINGULARITY_SANDBOX environment variable to the
64+ # path to the sandbox. If we are not, then we set it to an empty
65+ # string.
66+ #
67+ # We also set the REAL_BIND_PATH environment variable. This is used
68+ # to set the bind paths for Singularity runs. REAL_BIND_PATH is the
69+ # physical path to the NOBACKUP directory
70+
71+ setenv KEYFILE " .singularity.d"
72+ setenv singstat 0
73+ setenv ORIGPATH ` pwd -P`
74+ cd $GEOSDEF
75+ while ($singstat == 0)
76+ if (-d $KEYFILE ) then
77+ setenv singstat 1
78+ setenv SINGPATH ` pwd -P`
79+ endif
80+ if ($singstat == 0) then
81+ if (" $cwd " == " /" ) then
82+ break
83+ else
84+ cd ..
85+ endif
86+ endif
87+ end
88+
89+ if ($singstat == 1) then
90+ setenv SINGULARITY_SANDBOX $SINGPATH
91+ setenv REAL_BIND_PATH ` realpath $NOBACKUP `
92+
93+ set USING_SINGULARITY = TRUE
94+ set SINGULARITY_BUILD = " "
95+ set NATIVE_BUILD = " #DELETE"
96+ else
97+ setenv SINGULARITY_SANDBOX " "
98+ setenv REAL_BIND_PATH " "
99+
100+ set USING_SINGULARITY = FALSE
101+ set SINGULARITY_BUILD = " #DELETE"
102+ set NATIVE_BUILD = " "
103+ endif
104+
105+ cd $ORIGPATH
106+
55107# Set TMPDIR to /tmp due to issues with heredocs in Singularity sandboxes
56108# -----------------------------------------------------------------------
57109
@@ -61,7 +113,24 @@ setenv TMPDIR /tmp
61113# Test for Command Line Flags
62114# ######################################################################
63115
64- set USER_SITE = " "
116+ set SINGULARITY_RUN_SITE = " "
117+ if ($singstat == 1) then
118+ set USING_SINGULARITY = TRUE
119+
120+ # If we are using Singularity, then where the image was built (say
121+ # AWS) might not match where we run. We at least know NCCS and NAS,
122+ # so we can use that to set the site.
123+
124+ if (( $NODE =~ discover* ) || ($NODE =~ borg* ) || ($NODE =~ warp* )) then
125+ set SINGULARITY_RUN_SITE = " NCCS"
126+ else if (( $NODE =~ pfe* ) || \
127+ ($NODE =~ r[0 -9 ]*i[0 -9 ]*n[0 -9 ]*) || \
128+ ($NODE =~ r[0 -9 ]*c[0 -9 ]*t[0 -9 ]*n[0 -9 ]*)) then
129+ set SINGULARITY_RUN_SITE = " NAS"
130+ endif
131+ else
132+ set USING_SINGULARITY = FALSE
133+ endif
65134while ( $# argv > 0 )
66135 set arg = $argv [1]
67136 shift argv
@@ -71,23 +140,6 @@ while ( $#argv > 0 )
71140 case --[Cc][Oo][Ll][Oo][Rr]:
72141 goto SETCOLOR
73142
74- # Testing with singularity found we need the ability to override
75- # the SITE variable below because images might be built on, say,
76- # AWS and thus "block" us from running at NCCS.
77- #
78- # So, we make a --site flag that allows us to override the SITE
79- # variable
80- case -[Ss]:
81- case --[Ss][Ii][Tt][Ee]:
82- set USER_SITE = $1
83- # if USER_SITE is empty, then we error out
84- if ( " $USER_SITE " == " " ) then
85- echo " ERROR: --site flag requires a site name"
86- exit 1
87- endif
88- shift argv
89- breaksw
90-
91143 # Here any string not above will trigger USAGE
92144 case -[Hh]:
93145 case --[Hh][Ee][Ll][Pp]:
@@ -100,12 +152,10 @@ end
100152# Determine site
101153# ######################################################################
102154
103- setenv NODE ` uname -n`
104- setenv ARCH ` uname -s`
105- if ($USER_SITE == " " ) then
155+ if ($SINGULARITY_RUN_SITE == " " ) then
106156 setenv SITE ` awk ' {print $2}' $ETCDIR /SITE.rc`
107157else
108- setenv SITE $USER_SITE
158+ setenv SITE $SINGULARITY_RUN_SITE
109159endif
110160
111161# ######################################################################
@@ -257,7 +307,6 @@ ASKPROC:
257307
258308if ( $SITE == ' NCCS' ) then
259309 echo " Enter the ${C1} Processor Type${CN} you wish to run on:"
260- echo " ${C2} hasw (Haswell)${CN} "
261310 echo " ${C2} sky (Skylake)${CN} "
262311 echo " ${C2} cas (Cascade Lake)${CN} (default)"
263312 echo " "
@@ -267,13 +316,10 @@ if ( $SITE == 'NCCS' ) then
267316 set MODEL = ' cas'
268317 endif
269318
270- if( $MODEL ! = ' hasw' & \
271- $MODEL ! = ' sky' & \
319+ if( $MODEL ! = ' sky' & \
272320 $MODEL ! = ' cas' ) goto ASKPROC
273321
274- if ( $MODEL == ' hasw' ) then
275- set NCPUS_PER_NODE = 28
276- else if ($MODEL == ' sky' ) then
322+ if ($MODEL == ' sky' ) then
277323 set NCPUS_PER_NODE = 40
278324 else if ($MODEL == ' cas' ) then
279325 # NCCS currently recommends that users do not run with
@@ -608,38 +654,6 @@ echo $EXPDIRroot > $HOME/.EXPDIRroot
608654
609655set GEOSDIR = $GEOSDEF
610656
611- # #####################################################################
612- # Singularity Sandbox
613- # ######################################################################
614-
615- setenv KEYFILE " .singularity.d"
616- setenv singstat 0
617- setenv ORIGPATH ` pwd -P`
618- cd $GEOSDIR
619- while ($singstat == 0)
620- if (-d $KEYFILE ) then
621- setenv singstat 1
622- setenv SINGPATH ` pwd -P`
623- endif
624- if ($singstat == 0) then
625- if (" $cwd " == " /" ) then
626- break
627- else
628- cd ..
629- endif
630- endif
631- end
632- if ($singstat == 1) then
633- setenv SINGULARITY_SANDBOX $SINGPATH
634- else
635- setenv SINGULARITY_SANDBOX " "
636- endif
637-
638- cd $ORIGPATH
639-
640- setenv REAL_BIND_PATH ` realpath $NOBACKUP `
641-
642-
643657#
644658# GEOSBIN does point to the bin/ directory in each
645659#
@@ -751,10 +765,19 @@ if ( $SITE == 'NCCS' ) then
751765cat >> $EXPDIR /SETENV.commands << EOF
752766setenv I_MPI_SHM_HEAP_VSIZE 512
753767setenv PSM2_MEMORY large
768+ EOF
769+
770+ # Testing at NCCS showed these caused crash at higher res
771+ # Crashed at restart read
772+ if ( $USING_SINGULARITY == FALSE ) then
773+
774+ cat >> $EXPDIR /SETENV.commands << EOF
754775setenv I_MPI_EXTRA_FILESYSTEM 1
755776setenv I_MPI_EXTRA_FILESYSTEM_FORCE gpfs
756777EOF
757778
779+ endif # if NOT Singularity
780+
758781endif # if NCCS
759782
760783endif # if mpi
@@ -790,6 +813,8 @@ s?@GEOSSRC?$GEOSSRC?g
790813s?@GEOSBIN?$GEOSBIN ?g
791814s?@GEOSETC?$GEOSETC ?g
792815s?@GEOSUTIL?$GEOSUTIL ?g
816+ s?@SINGULARITY_BUILD?$SINGULARITY_BUILD ?g
817+ s?@NATIVE_BUILD?$NATIVE_BUILD ?g
793818s?@SINGULARITY_SANDBOX?$SINGULARITY_SANDBOX ?g
794819s?@REAL_BIND_PATH?$REAL_BIND_PATH ?g
795820
0 commit comments