def initialise_stuff(self): if not os.path.exists(self.restart_dir): os.makedirs(self.restart_dir) if not os.path.exists(self.output_dir): os.makedirs(self.output_dir) if not os.path.exists(self.log_dir): os.makedirs(self.log_dir) if not os.path.exists(self.namelist_dir): os.makedirs(self.namelist_dir) # Run all the met files in the directory if len(self.met_subset) == 0: met_files = glob.glob(os.path.join(self.met_dir, "*.nc")) else: met_files = [os.path.join(self.met_dir, i) for i in self.met_subset] cwd = os.getcwd() (url, rev) = get_svn_info(cwd, self.cable_src) # delete local executable, copy a local copy and use that local_exe = "cable" if os.path.isfile(local_exe): os.remove(local_exe) shutil.copy(self.cable_exe, local_exe) self.cable_exe = local_exe return (met_files, url, rev)
def initialise_stuff(self): if not os.path.exists(self.restart_dir): os.makedirs(self.restart_dir) if not os.path.exists(self.output_dir): os.makedirs(self.output_dir) if not os.path.exists(self.log_dir): os.makedirs(self.log_dir) if not os.path.exists(self.namelist_dir): os.makedirs(self.namelist_dir) # Run all the met files in the directory if len(self.met_subset) == 0: met_files = glob.glob(os.path.join(self.met_dir, "*.nc")) else: met_files = [ os.path.join(self.met_dir, i) for i in self.met_subset ] cwd = os.getcwd() (url, rev) = get_svn_info(cwd, self.cable_src) return (met_files, url, rev)
def initial_setup(self, st_yr_spin, en_yr_spin, st_yr, en_yr): """ Setup CABLE namelist file for spinup from zero """ if not os.path.exists(self.restart_dir): os.makedirs(self.restart_dir) if not os.path.exists(self.output_dir): os.makedirs(self.output_dir) if not os.path.exists(self.log_dir): os.makedirs(self.log_dir) if not os.path.exists(self.dump_dir): os.makedirs(self.dump_dir) base_nml_fn = os.path.join(self.grid_dir, "%s" % (self.nml_fname)) if os.path.isfile(self.nml_fname): os.remove(self.nml_fname) shutil.copy(base_nml_fn, self.nml_fname) #shutil.copyfile(os.path.join(self.driver_dir, "cable.nml"), # self.nml_fname) shutil.copyfile(os.path.join(self.driver_dir, "site.nml"), self.site_nml_fname) self.out_fname = os.path.join( self.output_dir, "%s_out_cable_zero.nc" % (self.experiment_id)) if os.path.isfile(self.out_fname): os.remove(self.out_fname) self.out_fname_CASA = os.path.join( self.output_dir, "%s_out_CASA_zero.nc" % (self.experiment_id)) if os.path.isfile(self.out_fname_CASA): os.remove(self.out_fname_CASA) out_log_fname = os.path.join(self.log_dir, "%s_log_zero.txt" % (self.experiment_id)) if os.path.isfile(out_log_fname): os.remove(out_log_fname) replace_dict = { "RunType": '"spinup"', "CO2NDepFile": "'%s'" % (self.co2_ndep_fname), "spinstartyear": "%d" % (st_yr), "spinendyear": "%d" % (en_yr), "spinCO2": "284.7", "spinNdep": "0.79", "spinPdep": "0.144", } adjust_nml_file(self.site_nml_fname, replace_dict) replace_dict = { "filename%met": "'%s'" % (self.met_fname), "filename%out": "'%s'" % (self.out_fname), "casafile%out": "'%s'" % (self.out_fname_CASA), "filename%log": "'%s'" % (out_log_fname), "filename%restart_out": "'%s'" % (self.cable_restart_fname), "cable_user%climate_restart_out": "'%s'" % (self.climate_restart_fname), "cable_user%POP_restart_out": "'%s'" % (self.pop_restart_fname), "casafile%cnpepool": "'%s'" % (self.casa_restart_fname), "filename%restart_in": "''", "cable_user%climate_restart_in": "''", "cable_user%POP_restart_in": "''", "filename%type": "'%s'" % self.grid_fname, "filename%veg": "'%s'" % (self.veg_fname), "filename%soil": "'%s'" % (self.soil_fname), "output%restart": ".TRUE.", "casafile%phen": "'%s'" % (self.phen_fname), "casafile%cnpbiome": "'%s'" % (self.cnpbiome_fname), "cable_user%RunIden": "'%s'" % (self.experiment_id), "cable_user%POP_out": "'ini'", "cable_user%POP_rst": "'./'", "cable_user%POP_fromZero": ".T.", "cable_user%CASA_fromZero": ".T.", "cable_user%CLIMATE_fromZero": ".T.", "cable_user%CALL_CLIMATE": "%s" % (self.clim_flag), "cable_user%SOIL_STRUC": "'%s'" % (self.soil_flag), "cable_user%vcmax": "'%s'" % (self.vcmax), "cable_user%YearStart": "%d" % (st_yr_spin), "cable_user%YearEnd": "%d" % (en_yr_spin), "cable_user%CASA_SPIN_STARTYEAR": "%d" % (st_yr_spin), "cable_user%CASA_SPIN_ENDYEAR": "%d" % (en_yr_spin), "cable_user%CALL_POP": "%s" % (self.pop_flag), "output%averaging": "'monthly'", "icycle": "%d" % (self.biogeochem), "l_vcmaxFeedbk": "%s" % (self.vcmax_feedback), "spinup": ".FALSE.", "cable_user%FWSOIL_SWITCH": "'Haverd2013'", "cable_user%GS_SWITCH": "'medlyn'", "cable_user%limit_labile": ".F.", "cable_user%SSNOW_POTEV": "'P-M'", "cable_user%CASA_NREP": "0", # number of times to repeat CASA forcing "delsoilM": "0.01", "delsoilT": "0.1", "output%casa": ".TRUE.", "output%grid": "'land'", "leaps": ".FALSE.", "cable_user%litter": ".true.", "cable_user%CASA_OUT_FREQ": "'monthly'", "cable_user%MetType": "'site'", "cable_user%PHENOLOGY_SWITCH": "'modis'", } adjust_nml_file(self.nml_fname, replace_dict) cwd = os.getcwd() (url, rev) = get_svn_info(cwd, self.cable_src) # delete local executable, copy a local copy and use that local_exe = "cable" if os.path.isfile(local_exe): os.remove(local_exe) shutil.copy(self.cable_exe, local_exe) self.cable_exe = local_exe return (url, rev)