@@ -92,7 +92,7 @@ def __init__(self, cmdLineArgs):
9292 self .nSegments = 1
9393 self .perturb = 0
9494 self .first_ens_id = 0
95- self .in_rstfile = None
95+ self .in_rstdir = None
9696 self .in_tilefile = None # default string
9797 self .ens_id_width = 6 # _eXXXX
9898 self .bcs_dir_land = ''
@@ -231,6 +231,7 @@ def __init__(self, cmdLineArgs):
231231 self .tile_types = self .ExeInputs .get ('TILE_TYPES' ,"100" ).split ()
232232 if "100" in self .tile_types :
233233 self .with_land = True
234+ assert int (self .ExeInputs ['LSM_CHOICE' ]) <= 2 , "\n LSM_CHOICE=3 (Catchment-CN4.5) is no longer supported. Please set LSM_CHOICE to 1 (Catchment) or 2 (Catchment-CN4.0)"
234235 if "20" in self .tile_types :
235236 self .with_landice = True
236237
@@ -268,7 +269,7 @@ def __init__(self, cmdLineArgs):
268269 # make sure catchment and vegdyn restart files ( at least one for each) exist
269270 if 'CATCH_DEF_FILE' not in self .ExeInputs :
270271 self .ExeInputs ['CATCH_DEF_FILE' ]= self .bcs_dir_land + 'clsm/catchment.def'
271- if ( self .with_land ) :
272+ if self .with_land :
272273 assert os .path .isfile (self .ExeInputs ['CATCH_DEF_FILE' ]),"[%s] file does not exist " % self .ExeInputs ['CATCH_DEF_FILE' ]
273274
274275 # assigning BC files
@@ -373,51 +374,44 @@ def __init__(self, cmdLineArgs):
373374 in_tilefiles_ = glob .glob (inpdir + '/*.nc4' )
374375 self .in_tilefile = os .path .realpath (in_tilefiles_ [0 ])
375376
376- if self .with_land :
377- assert int (self .ExeInputs ['LSM_CHOICE' ]) <= 2 , "\n LSM_CHOICE=3 (Catchment-CN4.5) is no longer supported. Please set LSM_CHOICE to 1 (Catchment) or 2 (Catchment-CN4.0)"
378- if RESTART_str in ['1' , '2' ]:
379- y4m2 = 'Y%4d/M%02d' % (self .begDates [0 ].year , self .begDates [0 ].month )
380- y4m2d2_h2m2 = '%4d%02d%02d_%02d%02d' % (self .begDates [0 ].year , self .begDates [0 ].month ,
381- self .begDates [0 ].day ,self .begDates [0 ].hour ,self .begDates [0 ].minute )
382- tmpFile = self .ExeInputs ['RESTART_ID' ]+ '.' + self .catch + '_internal_rst.' + y4m2d2_h2m2
383- tmpRstDir = self .ExeInputs ['RESTART_PATH' ]+ '/' .join ([self .ExeInputs ['RESTART_ID' ],'output' ,
377+ if RESTART_str in ['1' , '2' ]:
378+ y4m2 = 'Y%4d/M%02d' % (self .begDates [0 ].year , self .begDates [0 ].month )
379+ y4m2d2_h2m2 = '%4d%02d%02d_%02d%02d' % (self .begDates [0 ].year , self .begDates [0 ].month ,
380+ self .begDates [0 ].day ,self .begDates [0 ].hour ,self .begDates [0 ].minute )
381+ self .in_rstdir = self .ExeInputs ['RESTART_PATH' ]+ '/' .join ([self .ExeInputs ['RESTART_ID' ],'output' ,
384382 self .ExeInputs ['RESTART_DOMAIN' ],'rs' ,self .ensdirs [0 ],y4m2 ])
385- catchRstFile = tmpRstDir + '/' + tmpFile
386-
383+ if self .with_land :
384+ tmpFile = self .ExeInputs ['RESTART_ID' ]+ '.' + self .catch + '_internal_rst.' + y4m2d2_h2m2
385+ catchRstFile = self .in_rstdir + '/' + tmpFile
387386 assert os .path .isfile (catchRstFile ), self .catch + '_internal_rst file [%s] does not exist!' % (catchRstFile )
388- self .in_rstfile = catchRstFile
389-
390- if RESTART_str == '1' :
391- tmpFile = self .ExeInputs ['RESTART_ID' ]+ '.vegdyn_internal_rst'
392- tmpRstDir = self .ExeInputs ['RESTART_PATH' ]+ '/' .join ([self .ExeInputs ['RESTART_ID' ],'output' ,
393- self .ExeInputs ['RESTART_DOMAIN' ],'rs' ,self .ensdirs [0 ]])
394- vegdynRstFile = tmpRstDir + '/' + tmpFile
395- # if not os.path.isfile(vegdynRstFile):
396- # assert int(self.ExeInputs['RST_FROM_GLOBAL']) == 1, 'restart from LDASsa should be global'
397-
398- tmpFile = self .ExeInputs ['RESTART_ID' ]+ '.landpert_internal_rst.' + y4m2d2_h2m2
399- tmpRstDir = self .ExeInputs ['RESTART_PATH' ]+ '/' .join ([self .ExeInputs ['RESTART_ID' ],'output' ,
400- self .ExeInputs ['RESTART_DOMAIN' ],'rs' ,self .ensdirs [0 ],y4m2 ])
401- landpertRstFile = tmpRstDir + '/' + tmpFile
402- if ( os .path .isfile (landpertRstFile )) :
403- self .has_geos_pert = True
404-
405- if RESTART_str == '0' :
406- if (self .catch == 'catch' ):
407- self .in_rstfile = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandRestarts_for_Regridding' \
408- '/Catch/M09/20170101/catch_internal_rst'
409- self .in_tilefile = '/discover/nobackup/projects/gmao/ssd/land/l_data/geos5/bcs/CLSM_params' \
410- '/mkCatchParam_SMAP_L4SM_v002/SMAP_EASEv2_M09/SMAP_EASEv2_M09_3856x1624.til'
411- elif (self .catch == 'catchcnclm40' ):
412- self .in_rstfile = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandRestarts_for_Regridding' \
413- '/CatchCN/M36/20150301_0000/catchcnclm40_internal_dummy'
414- self .in_tilefile = '/discover/nobackup/projects/gmao/bcs_shared/legacy_bcs/Heracles-NL/SMAP_EASEv2_M36/SMAP_EASEv2_M36_964x406.til'
415- elif (self .catch == 'catchcnclm45' ):
416- self .in_rstfile = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandRestarts_for_Regridding' \
417- '/CatchCN/M36/19800101_0000/catchcnclm45_internal_dummy'
418- self .in_tilefile = '/discover/nobackup/projects/gmao/bcs_shared/legacy_bcs/Icarus-NLv3/Icarus-NLv3_EASE/SMAP_EASEv2_M36/SMAP_EASEv2_M36_964x406.til'
419- else :
420- sys .exit ('need to provide at least dummy files' )
387+ if RESTART_str == '1' :
388+ tmpFile = self .ExeInputs ['RESTART_ID' ]+ '.landpert_internal_rst.' + y4m2d2_h2m2
389+ landpertRstFile = self .in_rstdir + '/' + tmpFile
390+ if ( os .path .isfile (landpertRstFile )) :
391+ self .has_geos_pert = True
392+
393+ if self .with_landice :
394+ tmpFile = self .ExeInputs ['RESTART_ID' ]+ '.landice_internal_rst.' + y4m2d2_h2m2
395+ landiceRstFile = self .in_rstdir + '/' + tmpFile
396+ assert os .path .isfile (landiceRstFile ), 'landice_internal_rst file [%s] does not exist!' % (landiceRstFile )
397+
398+ if RESTART_str == '0' :
399+ assert ( self .with_land and not self .with_landice ), "RESTART = 0 is only for land"
400+ if (self .catch == 'catch' ):
401+ self .in_rstdir = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandRestarts_for_Regridding' \
402+ '/Catch/M09/20170101/' #catch_internal_rst
403+ self .in_tilefile = '/discover/nobackup/projects/gmao/ssd/land/l_data/geos5/bcs/CLSM_params' \
404+ '/mkCatchParam_SMAP_L4SM_v002/SMAP_EASEv2_M09/SMAP_EASEv2_M09_3856x1624.til'
405+ elif (self .catch == 'catchcnclm40' ):
406+ self .in_rstdir = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandRestarts_for_Regridding' \
407+ '/CatchCN/M36/20150301_0000/' #catchcnclm40_internal_dummy
408+ self .in_tilefile = '/discover/nobackup/projects/gmao/bcs_shared/legacy_bcs/Heracles-NL/SMAP_EASEv2_M36/SMAP_EASEv2_M36_964x406.til'
409+ elif (self .catch == 'catchcnclm45' ):
410+ self .in_rstdir = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandRestarts_for_Regridding' \
411+ '/CatchCN/M36/19800101_0000/' #catchcnclm45_internal_dummy
412+ self .in_tilefile = '/discover/nobackup/projects/gmao/bcs_shared/legacy_bcs/Icarus-NLv3/Icarus-NLv3_EASE/SMAP_EASEv2_M36/SMAP_EASEv2_M36_964x406.til'
413+ else :
414+ sys .exit ('need to provide at least dummy files' )
421415
422416 # DEAL WITH mwRTM input from exec
423417 self .assim = True if self .ExeInputs .get ('LAND_ASSIM' , 'NO' ).upper () == 'YES' and self .with_land else False
@@ -851,7 +845,7 @@ def createLnRstBc(self) :
851845 config ['input' ]['shared' ]['expid' ] = self .ExeInputs ['RESTART_ID' ]
852846 config ['input' ]['shared' ]['yyyymmddhh' ] = YYYYMMDDHH
853847 if RESTART_str != 'M' :
854- config ['input' ]['shared' ]['rst_dir' ] = os . path . dirname ( self .in_rstfile ) + '/'
848+ config ['input' ]['shared' ]['rst_dir' ] = self .in_rstdir
855849 config ['input' ]['surface' ]['wemin' ] = wemin_in
856850 config ['input' ]['surface' ]['catch_model' ] = self .catch
857851
@@ -919,83 +913,84 @@ def createLnRstBc(self) :
919913 pertRstFile = ''
920914 print ("restart: " + self .ExeInputs ['RESTART' ])
921915
922- if self .ExeInputs ['RESTART' ].isdigit () :
923-
924- if int (self .ExeInputs ['RESTART' ]) == 0 or int (self .ExeInputs ['RESTART' ]) == 2 :
925- vegdynRstFile = glob .glob (self .bcs_dir_land + 'vegdyn_*.dat' )[0 ]
926- catchRstFile = glob .glob (self .exphome + '/' + exp_id + '/mk_restarts/*' + self .catch + '_internal_rst.' + YYYYMMDD + '*' )[0 ]
927- else : # RESTART == 1
928- catchRstFile = rstpath + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['RESTART_ID' ]+ '.' + self .catch + '_internal_rst.' + y4m2d2_h2m2
929- vegdynRstFile = rstpath + ensdir + '/' + self .ExeInputs ['RESTART_ID' ]+ '.vegdyn_internal_rst'
930- if not os .path .isfile (vegdynRstFile ): # no vegdyn restart from LDASsa
931- if not os .path .isfile (vegdynRstFile0 ):
932- vegdynRstFile = glob .glob (self .bcs_dir_land + 'vegdyn_*.dat' )[0 ]
933- else :
934- vegdynRstFile = glob .glob (self .bcs_dir_land + 'vegdyn_*.dat' )[0 ]
935- if self .with_land :
936- catchRstFile = glob .glob (self .exphome + '/' + exp_id + '/mk_restarts/*' + self .catch + '_internal_rst.' + YYYYMMDD + '*' )[0 ]
937-
938- # catchment restart file
939- if os .path .isfile (catchRstFile ) and self .with_land :
940- catchLocal = self .rstdir + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['EXP_ID' ]+ '.' + self .catch + '_internal_rst.' + y4m2d2_h2m2
941- if self .isZoomIn :
942- print ( "Creating local catchment restart file... \n " )
943- cmd = self .bindir + '/preprocess_ldas.x zoomin_catchrst ' + catchRstFile + ' ' + catchLocal + ' ' + tmp_f2g_file .name
944- print ("cmd: " + cmd )
945- sp .call (shlex .split (cmd ))
946- else :
947- shutil .copy (catchRstFile ,catchLocal )
948-
949- catchRstFile = catchLocal
950-
951- if '0000' in ensdir :
952- catchRstFile0 = catchRstFile
953- else : # re-use 0000 catch file
954- catchRstFile = catchRstFile0
955-
956- # vegdyn restart file
957- if os .path .isfile (vegdynRstFile ) and self .with_land :
958- vegdynLocal = self .rstdir + ensdir + '/' + self .ExeInputs ['EXP_ID' ]+ '.vegdyn_internal_rst'
959- if self .isZoomIn :
960- print ("Creating the local veg restart file... \n " )
961- cmd = self .bindir + '/preprocess_ldas.x zoomin_vegrst ' + vegdynRstFile + ' ' + vegdynLocal + ' ' + tmp_f2g_file .name
962- print ("cmd: " + cmd )
963- sp .call (shlex .split (cmd ))
964- else :
965- shutil .copy (vegdynRstFile ,vegdynLocal )
966-
967- vegdynRstFile = vegdynLocal
968-
969- if '0000' in ensdir :
970- vegdynRstFile0 = vegdynRstFile
971- else :
972- vegdynRstFile = vegdynRstFile0
916+ if self .with_land :
917+ if self .ExeInputs ['RESTART' ].isdigit () :
918+
919+ if int (self .ExeInputs ['RESTART' ]) == 0 or int (self .ExeInputs ['RESTART' ]) == 2 :
920+ vegdynRstFile = glob .glob (self .bcs_dir_land + 'vegdyn_*.dat' )[0 ]
921+ catchRstFile = glob .glob (self .exphome + '/' + exp_id + '/mk_restarts/*' + self .catch + '_internal_rst.' + YYYYMMDD + '*' )[0 ]
922+ else : # RESTART == 1
923+ catchRstFile = rstpath + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['RESTART_ID' ]+ '.' + self .catch + '_internal_rst.' + y4m2d2_h2m2
924+ vegdynRstFile = rstpath + ensdir + '/' + self .ExeInputs ['RESTART_ID' ]+ '.vegdyn_internal_rst'
925+ if not os .path .isfile (vegdynRstFile ): # no vegdyn restart from LDASsa
926+ if not os .path .isfile (vegdynRstFile0 ):
927+ vegdynRstFile = glob .glob (self .bcs_dir_land + 'vegdyn_*.dat' )[0 ]
928+ else :
929+ vegdynRstFile = glob .glob (self .bcs_dir_land + 'vegdyn_*.dat' )[0 ]
930+ if self .with_land :
931+ catchRstFile = glob .glob (self .exphome + '/' + exp_id + '/mk_restarts/*' + self .catch + '_internal_rst.' + YYYYMMDD + '*' )[0 ]
932+
933+ # catchment restart file
934+ if os .path .isfile (catchRstFile ) :
935+ catchLocal = self .rstdir + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['EXP_ID' ]+ '.' + self .catch + '_internal_rst.' + y4m2d2_h2m2
936+ if self .isZoomIn :
937+ print ( "Creating local catchment restart file... \n " )
938+ cmd = self .bindir + '/preprocess_ldas.x zoomin_catchrst ' + catchRstFile + ' ' + catchLocal + ' ' + tmp_f2g_file .name
939+ print ("cmd: " + cmd )
940+ sp .call (shlex .split (cmd ))
941+ else :
942+ shutil .copy (catchRstFile ,catchLocal )
943+
944+ catchRstFile = catchLocal
945+
946+ if '0000' in ensdir :
947+ catchRstFile0 = catchRstFile
948+ else : # re-use 0000 catch file
949+ catchRstFile = catchRstFile0
950+
951+ # vegdyn restart file
952+ if os .path .isfile (vegdynRstFile ) :
953+ vegdynLocal = self .rstdir + ensdir + '/' + self .ExeInputs ['EXP_ID' ]+ '.vegdyn_internal_rst'
954+ if self .isZoomIn :
955+ print ("Creating the local veg restart file... \n " )
956+ cmd = self .bindir + '/preprocess_ldas.x zoomin_vegrst ' + vegdynRstFile + ' ' + vegdynLocal + ' ' + tmp_f2g_file .name
957+ print ("cmd: " + cmd )
958+ sp .call (shlex .split (cmd ))
959+ else :
960+ shutil .copy (vegdynRstFile ,vegdynLocal )
961+
962+ vegdynRstFile = vegdynLocal
963+
964+ if '0000' in ensdir :
965+ vegdynRstFile0 = vegdynRstFile
966+ else :
967+ vegdynRstFile = vegdynRstFile0
973968
974969 landiceRstFile = ''
975970 if self .with_landice :
976- if self . ExeInputs [ 'RESTART' ]. isdigit () :
977- if int ( self . ExeInputs [ ' RESTART' ]) == 0 or int ( self . ExeInputs [ 'RESTART' ]) == 2 :
978- print ( "RESTART=0 and RESTART=2 not supported for landice tiles. Please use RESTART=M (MERRA-2)." )
971+ if RESTART_str == '0' :
972+ exit ( " RESTART=0 not supported for landice tiles. Please use RESTART=M, 1, or 2" )
973+ if RESTART_str == '1' :
979974 landiceRstFile = rstpath + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['RESTART_ID' ]+ '.' + 'landice_internal_rst.' + y4m2d2_h2m2
980- else :
975+ if RESTART_str == '2' or RESTART_str == 'M' :
981976 landiceRstFile = glob .glob (self .exphome + '/' + exp_id + '/mk_restarts/*' + 'landice_internal_rst.' + YYYYMMDD + '*' )[0 ]
982977
983- if os .path .isfile (landiceRstFile ) :
984- landiceLocal = self .rstdir + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['EXP_ID' ]+ '.landice_internal_rst.' + y4m2d2_h2m2
985- if self .isZoomIn :
986- print ("Creating zoom-in of landice restart file... \n " )
987- cmd = self .bindir + '/preprocess_ldas.x zoomin_landicerst ' + landiceRstFile + ' ' + landiceLocal + ' ' + tmp_f2g_file .name
988- print ("cmd: " + cmd )
989- sp .call (shlex .split (cmd ))
990- else :
991- shutil .copy (landiceRstFile ,landiceLocal )
978+ if os .path .isfile (landiceRstFile ) :
979+ landiceLocal = self .rstdir + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['EXP_ID' ]+ '.landice_internal_rst.' + y4m2d2_h2m2
980+ if self .isZoomIn :
981+ print ("Creating zoom-in of landice restart file... \n " )
982+ cmd = self .bindir + '/preprocess_ldas.x zoomin_landicerst ' + landiceRstFile + ' ' + landiceLocal + ' ' + tmp_f2g_file .name
983+ print ("cmd: " + cmd )
984+ sp .call (shlex .split (cmd ))
985+ else :
986+ shutil .copy (landiceRstFile ,landiceLocal )
992987
993- landiceRstFile = landiceLocal
988+ landiceRstFile = landiceLocal
994989
995- if '0000' in ensdir :
996- landiceRstFile0 = landiceRstFile
997- else :
998- landiceRstFile = landiceRstFile0
990+ if '0000' in ensdir :
991+ landiceRstFile0 = landiceRstFile
992+ else :
993+ landiceRstFile = landiceRstFile0
999994
1000995 if (self .has_geos_pert and self .perturb == 1 ) :
1001996 pertRstFile = rstpath + ensdir + '/' + y4m2 + '/' + self .ExeInputs ['RESTART_ID' ]+ '.landpert_internal_rst.' + y4m2d2_h2m2
0 commit comments