Skip to content

Commit a7f56e0

Browse files
committed
Bug fix for 1st time-step with CORDEX output in run_ccam.py
1 parent 047513d commit a7f56e0

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

run_ccam.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ def prep_iofiles():
10111011
d['ozone'] = dict2str('{stdat}/{cmip}/{rcp}/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-{rcp}-1-0_gn_205001-209912.nc')
10121012
else:
10131013
print("ERROR: Unknown cmip option")
1014-
sys.exit(1)
1014+
sys.exit(1)
10151015
# Check ozone file exisits
10161016
check_file_exists(d['ozone'])
10171017

@@ -1176,12 +1176,21 @@ def config_initconds():
11761176
cname = newpath+".000000"
11771177
if not os.path.exists(cname):
11781178
raise ValueError(dict2str('Cannot locate file {bcdir}/{mesonest}'))
1179+
# update calendar
11791180
if d['leap'] == "auto":
11801181
d['leap'] = check_calendar_in_file(cname, d['leap'])
11811182
if d['leap'] == "auto":
11821183
print('Check calendar in ',cname)
11831184
raise ValueError("ERROR: Cannot assign calendar for leap=auto")
11841185
print(dict2str('Assign calendar {leap}'))
1186+
# check match with emission scenario
1187+
gendata = check_attributevalue_in_file(cname, 'driving_experiment_name')
1188+
if gendata != "":
1189+
if gendata != d['rcp']:
1190+
print("ERROR: Mismatch between host dataset and specified emission scenario")
1191+
print("mesonest "+gendata)
1192+
print("script "+d['rcp'])
1193+
sys.exit(1)
11851194

11861195
# prepare ifile
11871196
fname = d['ifile']
@@ -2318,7 +2327,9 @@ def check_attribute_in_file(fname, vname, aname, vdata):
23182327
def check_timestep_in_file(fname):
23192328
"Checks the time-step in output file"
23202329

2321-
timestep = subprocess.getoutput('ncdump -c '+fname+' | grep time | tail -1 | cut -d= -f2 | cut -d, -f2')
2330+
timestep = subprocess.getoutput('ncdump -c '+fname+' | grep time | tail -1 | cut -d= -f2 | cut -d, -f1')
2331+
if timestep == 0:
2332+
timestep = subprocess.getoutput('ncdump -c '+fname+' | grep time | tail -1 | cut -d= -f2 | cut -d, -f2')
23222333
return timestep
23232334

23242335

@@ -2368,23 +2379,31 @@ def calc_drs_host(fname):
23682379
d['drs_host_name'] = "error"
23692380
d['drs_host_institution'] = "error"
23702381

2371-
driving_model_id_test = subprocess.getoutput('ncdump -c '+fname+' | grep driving_model_id | cut -d\" -f2')
2382+
driving_model_id_test = check_attributevalue_in_file(fname,'driving_model_id')
23722383
if driving_model_id_test != "":
23732384
d['drs_host_name'] = driving_model_id_test
23742385

2375-
driving_model_ensemble_number_test = subprocess.getoutput('ncdump -c '+fname+' | grep driving_model_ensemble_number | cut -d\" -f2')
2386+
driving_model_ensemble_number_test = check_attributevalue_in_file(fname,'driving_model_ensemble_number')
23762387
if driving_model_ensemble_number_test != "":
23772388
d['drs_host_ensemble'] = driving_model_ensemble_number_test
23782389

2379-
driving_experiment_name_test = subprocess.getoutput('ncdump -c '+fname+' | grep driving_experiment_name | cut -d\" -f2')
2390+
driving_experiment_name_test = check_attributevalue_in_file(fname,'driving_experiment_name')
23802391
if driving_experiment_name_test != "":
23812392
d['drs_host_scenario'] = driving_experiment_name_test
23822393

2383-
driving_institution_id_test = subprocess.getoutput('ncdump -c '+fname+' | grep driving_institution_id | cut -d\" -f2')
2394+
driving_institution_id_test = check_attributevalue_in_file(fname,'driving_institution_id')
23842395
if driving_institution_id_test != "":
23852396
d['drs_host_institution'] = driving_institution_id_test
23862397

23872398

2399+
def check_attributevalue_in_file(fname, attname):
2400+
"Return value of attribute"
2401+
2402+
attdata = subprocess.getoutput('ncdump -c '+fname+' | grep '+attname+' | cut -d\\" -f2')
2403+
print(attdata)
2404+
return attdata
2405+
2406+
23882407
#===============================================================================
23892408
# Namelist templates
23902409
#===============================================================================
@@ -2669,7 +2688,7 @@ def input_template_c2014():
26692688
nevapls=0 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
26702689
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
26712690
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2672-
qlg_max=1.e-3 qfg_max=1.e-3
2691+
qlg_max=1.e-5 qfg_max=1.e-5
26732692
&end
26742693
"""
26752694

@@ -2695,7 +2714,7 @@ def input_template_c2015a():
26952714
nevapls=0 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
26962715
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
26972716
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2698-
qlg_max=1.e-3 qfg_max=1.e-3
2717+
qlg_max=1.e-5 qfg_max=1.e-5
26992718
&end
27002719
"""
27012720

@@ -2721,7 +2740,7 @@ def input_template_c2015m():
27212740
nevapls=0 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
27222741
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
27232742
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2724-
qlg_max=1.e-3 qfg_max=1.e-3
2743+
qlg_max=1.e-5 qfg_max=1.e-5
27252744
&end
27262745
"""
27272746

@@ -2741,7 +2760,7 @@ def input_template_c2015b():
27412760
nevapls=0 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
27422761
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
27432762
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2744-
qlg_max=1.e-3 qfg_max=1.e-3
2763+
qlg_max=1.e-5 qfg_max=1.e-5
27452764
&end
27462765
"""
27472766

@@ -2762,7 +2781,7 @@ def input_template_c2017():
27622781
nevapls=0 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
27632782
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
27642783
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2765-
qlg_max=1.e-3 qfg_max=1.e-3
2784+
qlg_max=1.e-5 qfg_max=1.e-5
27662785
&end
27672786
"""
27682787

@@ -2788,7 +2807,7 @@ def input_template_c2021():
27882807
nevapls=-4 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
27892808
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
27902809
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2791-
qlg_max=1.e-3 qfg_max=1.e-3
2810+
qlg_max=1.e-5 qfg_max=1.e-5
27922811
&end
27932812
"""
27942813

@@ -2802,7 +2821,7 @@ def input_template_grell():
28022821
nevapls=0 ncloud={ncloud} tiedtke_form=1 acon={acon} bcon={bcon}
28032822
rcrit_l={rcrit_l} rcrit_s={rcrit_s}
28042823
lin_aerosolmode={lin_aerosolmode} lin_adv=1
2805-
qlg_max=1.e-3 qfg_max=1.e-3
2824+
qlg_max=1.e-5 qfg_max=1.e-5
28062825
&end
28072826
"""
28082827

0 commit comments

Comments
 (0)