Skip to content

Commit

Permalink
Merge branch 'develop' into feature/borescan_catchcn_co2
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrabenh authored Jul 3, 2023
2 parents 773990a + b5d5aff commit 80330e6
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 7 deletions.
8 changes: 8 additions & 0 deletions AGCM.rc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,17 @@ PRINTRC: 1
# RESTART_TYPE and or CHECKPOINT_TYPE are set to pbinary or pnc4
#---------------------------------------------------------------
PARALLEL_READFORCING: 0
# The num_readers should be set to multiple of 6 if READ_RESTART_BY_FACE is set to YES
NUM_READERS: @NUM_READERS
# The num_writers should be set to multiple of 6 if WRITE_RESTART_BY_FACE is set to YES
NUM_WRITERS: 1

# If is is set to YES, users should have CS based restarts files split by faces
# The filenames *_rst should be changed to *_face_x_rst ( x is from 1 to 6)
READ_RESTART_BY_FACE: NO
# If it is set to YES, it overwrites WRITE_RESTART_BY_OSERVER to NO
WRITE_RESTART_BY_FACE: NO

# Write restarts by oserver (Default: NO)
WRITE_RESTART_BY_OSERVER: @RESTART_BY_OSERVER

Expand Down
96 changes: 89 additions & 7 deletions gcm_run.j
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,91 @@ set chk_file_names = `grep "CHECKPOINT_FILE" AGCM.rc | grep -v "#" | cut -d ":"

set monthly_chk_names = `cat $EXPDIR/HISTORY.rc | grep -v '^[\t ]*#' | sed -n 's/\([^\t ]\+\).monthly:[\t ]*1.*/\1/p' | sed 's/$/_rst/' `

# Remove possible bootstrap parameters (+/-)
# ------------------------------------------
set dummy = `echo $rst_file_names`
set rst_file_names = ''
set tile_rsts = (catch catchcn route lake landice openwater saltwater seaicethermo)

# check if it resarts by face
# ----------------------------------
set rst_by_face = NO
if( $GCMEMIP == TRUE ) then
if(-e $EXPDIR/restarts/$RSTDATE/fvcore_internal_rst & -e $EXPDIR/restarts/$RSTDATE/fvcore_internal_face_1_rst) then
echo "grid-based internal_rst and internal_face_x_rst should not co-exist"
echo "please remove all *internal_rst except these tile-based restarts :"
foreach rst ( $tile_rsts )
echo ${rst}_internal_rst
end
exit
endif
if(-e $EXPDIR/restarts/$RSTDATE/fvcore_internal_face_1_rst) then
set rst_by_face = YES
endif
else
if(-e $EXPDIR/fvcore_internal_rst & -e $EXPDIR/fvcore_internal_face_1_rst) then
echo "grid-based internal_rst and internal_face_x_rst should not co-exist"
echo "please remove all *internal_rst except these tile-based restarts :"
foreach rst ( $tile_rsts )
echo ${rst}_internal_rst
end
exit
endif
if(-e $EXPDIR/fvcore_internal_face_1_rst) then
set rst_by_face = YES
endif
endif

set Rbyface = `grep READ_RESTART_BY_FACE: AGCM.rc | grep -v "#" | cut -d ":" -f2`
if ($rst_by_face == NO) then
if ($Rbyface == YES) then
sed -i '/READ_RESTART_BY_FACE:/c\READ_RESTART_BY_FACE: NO' AGCM.rc
endif
else
# make sure num_readers is multiple of 6
@ num_readers = `grep NUM_READERS: AGCM.rc | grep -v "#" | cut -d ":" -f2`
@ remainer = $num_readers % 6
if ($remainer != 0) then
sed -i '/NUM_READERS:/c\NUM_READERS: 6' AGCM.rc
endif

if ($Rbyface != YES) then
sed -i '/READ_RESTART_BY_FACE:/c\READ_RESTART_BY_FACE: YES' AGCM.rc
endif
endif

set Wbyface = `grep WRITE_RESTART_BY_FACE: AGCM.rc | grep -v "#" | cut -d ":" -f2`
if ($Wbyface == YES) then
# make sure num_readers is multiple of 6
@ num_writers = `grep NUM_WRITERS: AGCM.rc | grep -v "#" | cut -d ":" -f2`
@ remainer = $num_writers % 6
if ($remainer != 0) then
sed -i '/NUM_WRITERS:/c\NUM_WRITERS: 6' AGCM.rc
endif
endif
# Remove possible bootstrap parameters (+/-)
# ------------------------------------------
foreach rst ( $dummy )
set length = `echo $rst | awk '{print length($0)}'`
set bit = `echo $rst | cut -c1`
if( "$bit" == "+" | \
"$bit" == "-" ) set rst = `echo $rst | cut -c2-$length`
set rst_file_names = `echo $rst_file_names $rst`
set is_tile_rst = FALSE
if ($rst_by_face == YES) then
foreach tile_rst ($tile_rsts)
if ( $rst =~ *$tile_rst* ) then
set is_tile_rst = TRUE
break
endif
end
endif
if ($is_tile_rst == FALSE & $rst_by_face == YES) then
set part1 = `echo $rst:q | sed 's/_rst/ /g'`
foreach n (1 2 3 4 5 6)
set rst = ${part1}_face_${n}_rst
set rst_file_names = `echo $rst_file_names $rst`
end
else
set rst_file_names = `echo $rst_file_names $rst`
endif
end

# Copy Restarts to Scratch Directory
Expand All @@ -558,9 +633,16 @@ wait

# Get proper ridge scheme GWD internal restart
# --------------------------------------------
/bin/rm gwd_internal_rst
/bin/cp @GWDRSDIR/gwd_internal_c${AGCM_IM} gwd_internal_rst

if ( $rst_by_face == YES ) then
echo "WARNING: The generated gwd_internal_face_x_rst are used"
#foreach n (1 2 3 4 5 6)
#/bin/rm gwd_internal_face_${n}_rst
#/bin/cp @GWDRSDIR/gwd_internal_c${AGCM_IM}_face_${n} gwd_internal_face_${n}_rst
#end
else
/bin/rm gwd_internal_rst
/bin/cp @GWDRSDIR/gwd_internal_c${AGCM_IM} gwd_internal_rst
endif
@COUPLED /bin/mkdir INPUT
@COUPLED cp $EXPDIR/RESTART/* INPUT

Expand Down Expand Up @@ -1162,7 +1244,7 @@ end
# Remove Initial RESTARTS
# -----------------------
set restarts = `/bin/ls -1 *_rst`
/bin/rm $restarts
/bin/rm -f $restarts


# Copy Renamed Final Checkpoints to RESTARTS directory
Expand Down

0 comments on commit 80330e6

Please sign in to comment.