Skip to content

Commit d527e31

Browse files
committed
Move code from ts to e3sm_to_cmip
1 parent dff9099 commit d527e31

File tree

3 files changed

+35
-95
lines changed

3 files changed

+35
-95
lines changed

zppy/defaults/default.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,16 @@ input_component = string(default="")
123123

124124
[ts]
125125
area_nm = string(default="area")
126-
cmip_metadata = string(default="inclusions/e3sm_to_cmip/default_metadata.json")
127-
cmip_plevdata = string(default="inclusions/e3sm_to_cmip/vrt_remap_plev19.nc")
128126
# Days per file
129127
dpf = integer(default=30)
130128
extra_vars = string(default="")
131-
interp_vars = string(default="U,V,T,Q,RELHUM,OMEGA,Z3")
132129
# Time-steps per day
133130
tpd = integer(default=1)
134131
# Model component having generated input files (eam, eamxx, elm, mosart, ...)
135132
input_component = string(default="")
136133

137134
[[__many__]]
138135
area_nm = string(default=None)
139-
cmip_metadata = string(default=None)
140-
cmip_plevdata = string(default=None)
141136
dpf = integer(default=None)
142137
extra_vars = string(default=None)
143138
tpd = integer(default=None)
@@ -146,13 +141,18 @@ input_component = string(default="")
146141
[e3sm_to_cmip]
147142
# Metadata json file
148143
cmip_metadata = string(default="inclusions/e3sm_to_cmip/default_metadata.json")
144+
# Pressure level nc file
145+
cmip_plevdata = string(default="inclusions/e3sm_to_cmip/vrt_remap_plev19.nc")
149146
# variables to run e3sm_to_cmip on
150147
cmip_vars = string(default="")
151148
# Model component having generated input files (eam, eamxx, elm, mosart, ...)
152149
input_component = string(default="")
150+
# TBD: description here
151+
interp_vars = string(default="U,V,T,Q,RELHUM,OMEGA,Z3")
153152

154153
[[__many__]]
155154
cmip_metadata = string(default=None)
155+
cmip_plevdata = string(default=None)
156156
cmip_vars = string(default=None)
157157
input_component = string(default=None)
158158
interp_vars = string(default=None)

zppy/templates/e3sm_to_cmip.bash

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,47 @@ cat > default_metadata.json << EOF
1919
{% include cmip_metadata %}
2020
EOF
2121
{
22-
export cmortables_dir={{ cmor_tables_prefix }}/e3sm_to_cmip_data/cmip6-cmor-tables/Tables
22+
export cmortables_dir={{ cmor_tables_prefix }}/cmip6-cmor-tables/Tables
2323
input_dir=${dest}/{{ '%04d' % (yr_start) }}_{{ '%04d' % (yr_end) }}
2424
mkdir -p $input_dir
2525

2626
cp -s $dest/*_{{ '%04d' % (yr_start) }}??_{{ '%04d' % (yr_end) }}??.nc $input_dir
27-
dest_cmip={{ output }}/post/{{ component }}/{{ ts_grid }}/cmip_ts/{{ frequency }}
27+
dest_cmip={{ output }}/post/{{ component }}/{{ grid }}/cmip_ts/{{ frequency }}
2828
mkdir -p ${dest_cmip}
2929

30+
{% if input_files.split(".")[0] == 'cam' or input_files.split(".")[0] == 'eam' -%}
31+
#add code to do vertical interpolation variables at model levels before e3sm_to_cmip
32+
IFS=',' read -ra mlvars <<< "{{ interp_vars }}"
33+
for var in "${mlvars[@]}"
34+
do
35+
for file in ${input_dir}/${var}_{{ '%04d' % (yr_start) }}??_{{ '%04d' % (yr_end) }}??.nc
36+
do
37+
if [ -f ${file} ]; then
38+
#ncks --rgr xtr_mth=mss_val --vrt_fl='{{cmip_plevdata}}' ${file} ${file}.plev
39+
ncremap -p mpi --vrt_ntp=log --vrt_xtr=mss_val --vrt_out='{{cmip_plevdata}}' ${file} ${file}.plev
40+
#overwrite the model level data
41+
mv ${file}.plev ${file}
42+
fi
43+
done
44+
done
45+
{% endif -%}
46+
47+
#call e3sm_to_cmip
3048
srun -N 1 e3sm_to_cmip \
3149
--output-path \
3250
${dest_cmip}/${tmp_dir} \
51+
{% if input_files.split(".")[0] == 'clm2' or input_files.split(".")[0] == 'elm' -%}
52+
--var-list \
53+
'snd, mrsos, mrso, mrfso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, tsl, lai, cLitter, cProduct, cSoilFast, cSoilMedium, cSoilSlow, fFire, fHarvest, cVeg, nbp, gpp, ra, rh' \
54+
--realm \
55+
lnd \
56+
{% endif -%}
57+
{% if input_files.split(".")[0] == 'cam' or input_files.split(".")[0] == 'eam' -%}
3358
--var-list \
34-
{{ cmip_vars }} \
59+
'ua, va, ta, wa, zg, hur, pr, prc, prsn, ts, tas, prw, psl, sfcWind, tasmax, tasmin, tauu, tauv, rtmt, rsdt, rsds, rsdscs, rlds, rldscs, rsus, rsuscs, rsut, rsutcs, rlus, rlut, rlutcs, clivi, clwvi, clt, evspsbl, hfls, hfss, huss' \
3560
--realm \
36-
{{ component }} \
61+
atm \
62+
{% endif -%}
3763
--input-path \
3864
${input_dir} \
3965
--user-metadata \

zppy/templates/ts.bash

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -117,92 +117,6 @@ if [ $? != 0 ]; then
117117
exit 3
118118
fi
119119
120-
{%- if ts_fmt != 'ts_only' %}
121-
tmp_dir=tmp_{{ prefix }}
122-
123-
# Generate CMIP ts
124-
cat > default_metadata.json << EOF
125-
{% include cmip_metadata %}
126-
EOF
127-
{
128-
export cmortables_dir={{ cmor_tables_prefix }}/cmip6-cmor-tables/Tables
129-
#input_dir={{ output }}/post/{{ component }}/{{ grid }}/ts/{{ frequency }}/{{ '%dyr' % (ypf) }}
130-
input_dir=${dest}/{{ '%04d' % (yr_start) }}_{{ '%04d' % (yr_end) }}
131-
mkdir -p $input_dir
132-
133-
cp -s $dest/*_{{ '%04d' % (yr_start) }}??_{{ '%04d' % (yr_end) }}??.nc $input_dir
134-
dest_cmip={{ output }}/post/{{ component }}/{{ grid }}/cmip_ts/{{ frequency }}
135-
mkdir -p ${dest_cmip}
136-
137-
{{ e3sm_to_cmip_environment_commands }}
138-
139-
{% if input_files.split(".")[0] == 'cam' or input_files.split(".")[0] == 'eam' -%}
140-
#add code to do vertical interpolation variables at model levels before e3sm_to_cmip
141-
IFS=',' read -ra mlvars <<< "{{ interp_vars }}"
142-
for var in "${mlvars[@]}"
143-
do
144-
for file in ${input_dir}/${var}_{{ '%04d' % (yr_start) }}??_{{ '%04d' % (yr_end) }}??.nc
145-
do
146-
if [ -f ${file} ]; then
147-
#ncks --rgr xtr_mth=mss_val --vrt_fl='{{cmip_plevdata}}' ${file} ${file}.plev
148-
ncremap -p mpi --vrt_ntp=log --vrt_xtr=mss_val --vrt_out='{{cmip_plevdata}}' ${file} ${file}.plev
149-
#overwrite the model level data
150-
mv ${file}.plev ${file}
151-
fi
152-
done
153-
done
154-
{% endif -%}
155-
156-
#call e3sm_to_cmip
157-
srun -N 1 e3sm_to_cmip \
158-
--output-path \
159-
${dest_cmip}/${tmp_dir} \
160-
{% if input_files.split(".")[0] == 'clm2' or input_files.split(".")[0] == 'elm' -%}
161-
--var-list \
162-
'snd, mrsos, mrso, mrfso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, tsl, lai, cLitter, cProduct, cSoilFast, cSoilMedium, cSoilSlow, fFire, fHarvest, cVeg, nbp, gpp, ra, rh' \
163-
--realm \
164-
lnd \
165-
{% endif -%}
166-
{% if input_files.split(".")[0] == 'cam' or input_files.split(".")[0] == 'eam' -%}
167-
--var-list \
168-
'ua, va, ta, wa, zg, hur, pr, prc, prsn, ts, tas, prw, psl, sfcWind, tasmax, tasmin, tauu, tauv, rtmt, rsdt, rsds, rsdscs, rlds, rldscs, rsus, rsuscs, rsut, rsutcs, rlus, rlut, rlutcs, clivi, clwvi, clt, evspsbl, hfls, hfss, huss' \
169-
--realm \
170-
atm \
171-
{% endif -%}
172-
--input-path \
173-
${input_dir} \
174-
--user-metadata \
175-
{{ scriptDir }}/${workdir}/default_metadata.json \
176-
--num-proc \
177-
12 \
178-
--tables-path \
179-
${cmortables_dir}
180-
181-
if [ $? != 0 ]; then
182-
cd {{ scriptDir }}
183-
echo 'ERROR (4)' > {{ prefix }}.status
184-
exit 4
185-
fi
186-
{{ environment_commands }}
187-
188-
# Move output ts files to final destination
189-
mv ${dest_cmip}/${tmp_dir}/CMIP6/CMIP/*/*/*/*/*/*/*/*/*.nc ${dest_cmip}
190-
if [ $? != 0 ]; then
191-
cd {{ scriptDir }}
192-
echo 'ERROR (5)' > {{ prefix }}.status
193-
exit 5
194-
fi
195-
196-
rm -r ${dest_cmip}/${tmp_dir}
197-
198-
}
199-
if [ $? != 0 ]; then
200-
cd {{ scriptDir }}
201-
echo 'ERROR (6)' > {{ prefix }}.status
202-
exit 6
203-
fi
204-
{%- endif %}
205-
206120
# Delete temporary workdir
207121
cd ..
208122
if [[ "${debug,,}" != "true" ]]; then

0 commit comments

Comments
 (0)