@@ -404,6 +404,7 @@ def get_datetime():
404
404
else :
405
405
d ['imthlst' ] = imth - 1
406
406
d ['iyrlst' ] = iyr
407
+ d ['rest_iyrlst' ] = iyr - 1
407
408
408
409
# two-digit versions of previous and current month
409
410
d ['imthlst_2digit' ] = mon_2digit (d ['imthlst' ])
@@ -932,9 +933,6 @@ def prep_iofiles():
932
933
933
934
# This function is called if simulation_test=T
934
935
935
- # Define restart file:
936
- d ['ifile' ] = dict2str ('Rest{name}.{iyrlst}{imthlst_2digit}' )
937
-
938
936
# Define host model fields:
939
937
d ['mesonest' ] = dict2str ('{bcdom}{iyr}{imth_2digit}.nc' )
940
938
fpath = dict2str ('{bcdir}/{mesonest}' )
@@ -1101,14 +1099,52 @@ def set_mlev_params():
1101
1099
def config_initconds ():
1102
1100
"Configure initial condition file"
1103
1101
1102
+ # Default warm start
1103
+ d ['ifile' ] = dict2str ('Rest{name}.{iyrlst}{imthlst_2digit}' )
1104
1104
d ['nrungcm' ] = 0
1105
1105
1106
+ fname = dict2str ('{wdir}/{ifile}.000000' )
1107
+ if not os .path .exists (fname ):
1108
+ fpath = dict2str ('{hdir}/RESTART/{ifile}.tar' )
1109
+ if os .path .exists (fpath ):
1110
+ print ("Missing restart in wdir, but found restart in RESTART directory" )
1111
+ run_cmdline ('tar xvf ' + fpath )
1112
+
1113
+ # Check for cold start
1106
1114
if d ['iyr' ] == d ['iys' ]:
1107
1115
if d ['imth' ] == d ['ims' ]:
1116
+
1117
+ # check for accidental cold start
1118
+ fname = dict2str ('{wdir}/{ifile}.000000' )
1119
+ if os .path .exists (fname ):
1120
+ print ("ERROR: Restart file found with cold start" )
1121
+ print (" " + fname )
1122
+ print (" Remove restart files in wdir and RESTART," )
1123
+ print (" or change iys in run_ccam.sh" )
1124
+ sys .exit (1 )
1125
+
1126
+ rest_ifile = dict2str ('{hdir}/RESTART/Rest{name}.{rest_iyrlst}12.tar' )
1127
+ if os .path .exists (rest_ifile ):
1128
+ print ("ERROR: Suspected warm start due to detection of" )
1129
+ print (" " + rest_ifile )
1130
+ print (" Remove restart file for cold start, or change" )
1131
+ print (" iys in run_ccam.sh" )
1132
+ sys .exit (1 )
1133
+
1134
+ # Configure cold start
1108
1135
if d ['dmode' ] in ["nudging_gcm" , "nudging_ccam" , "sst_6hour" , "nudging_gcm_with_sst" ]:
1109
1136
d .update ({'ifile' : d ['mesonest' ]})
1110
1137
elif d ['dmode' ] == "sst_only" :
1111
1138
d .update ({'ifile' : d ['sstinit' ]})
1139
+ fpath = dict2str ('{sstinit}' )
1140
+ if os .path .exists (fpath ):
1141
+ run_cmdline ('ln -s ' + fpath + ' .' )
1142
+ elif os .path .exists (fpath + '.000000' ):
1143
+ run_cmdline ('ln -s ' + fpath + '.?????? .' )
1144
+ elif os .path .exists (fpath + '.tar' ):
1145
+ run_cmdline ('tar xvf ' + fpath + '.tar' )
1146
+ else :
1147
+ raise ValueError (dict2str ('ERROR: Cannot locate file {sstinit}' ))
1112
1148
else :
1113
1149
d .update ({'ifile' : "error" })
1114
1150
if d ['bcsoil' ] == "constant" :
@@ -1123,7 +1159,7 @@ def config_initconds():
1123
1159
d ['nrungcm' ] = - 4
1124
1160
check_file_exists (d ['bcsoilfile' ]+ '.000000' )
1125
1161
1126
- # prepare ifile
1162
+ # prepare mesonest file
1127
1163
if d ['dmode' ] in ["nudging_gcm" , "nudging_ccam" , "sst_6hour" , "nudging_gcm_with_sst" ]:
1128
1164
fpath = dict2str ('{bcdir}/{mesonest}' )
1129
1165
newpath = dict2str ('{wdir}/{mesonest}' )
@@ -1147,18 +1183,7 @@ def config_initconds():
1147
1183
raise ValueError ("ERROR: Cannot assign calendar for leap=auto" )
1148
1184
print (dict2str ('Assign calendar {leap}' ))
1149
1185
1150
- if (d ['dmode' ]== "sst_only" ) and (d ['iyr' ]== d ['iys' ]) and (d ['imth' ]== d ['ims' ]):
1151
- fpath = dict2str ('{sstinit}' )
1152
- if os .path .exists (fpath ):
1153
- run_cmdline ('ln -s ' + fpath + ' .' )
1154
- elif os .path .exists (fpath + '.000000' ):
1155
- run_cmdline ('ln -s ' + fpath + '.?????? .' )
1156
- elif os .path .exists (fpath + '.tar' ):
1157
- run_cmdline ('tar xvf ' + fpath + '.tar' )
1158
- else :
1159
- raise ValueError (dict2str ('ERROR: Cannot locate file {sstinit}' ))
1160
-
1161
- # Check ifile
1186
+ # prepare ifile
1162
1187
fname = d ['ifile' ]
1163
1188
if not fname == "error" :
1164
1189
if not os .path .exists (fname ):
@@ -3135,13 +3160,14 @@ def cc_template_tracer():
3135
3160
3136
3161
parser .add_argument ("--terread" , type = str , help = " path of terread executable" )
3137
3162
parser .add_argument ("--igbpveg" , type = str , help = " path of igbpveg executable" )
3138
- parser .add_argument ("--sibveg" , type = str , help = "depreciated" )
3139
3163
parser .add_argument ("--ocnbath" , type = str , help = " path of ocnbath executable" )
3140
3164
parser .add_argument ("--casafield" , type = str , help = " path of casafield executable" )
3141
3165
parser .add_argument ("--aeroemiss" , type = str , help = " path of aeroemiss executable" )
3142
3166
parser .add_argument ("--model" , type = str , help = " path of globpea executable" )
3143
3167
parser .add_argument ("--pcc2hist" , type = str , help = " path of pcc2hist executable" )
3144
3168
3169
+ parser .add_argument ("--sibveg" , type = str , help = "depreciated" )
3170
+
3145
3171
args = parser .parse_args ()
3146
3172
3147
3173
main (args )
0 commit comments