Skip to content

Commit

Permalink
Make ts bash file more concise (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 authored Apr 7, 2022
1 parent fe5d728 commit 307234b
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions zppy/templates/ts.bash
Original file line number Diff line number Diff line change
Expand Up @@ -113,65 +113,65 @@ if [ $? != 0 ]; then
exit 2
fi
{%- if ts_fmt != 'ts_only' %}
tmp_dir=tmp_{{ prefix }}
# Generate CMIP ts
cat > default_metadata.json << EOF
{% include cmip_metadata %}
EOF
{
if [ "$ts_fmt" != "ts_only" ]; then
export cmortables_dir=/lcrc/group/acme/public_html/diagnostics/cmip6-cmor-tables/Tables
input_dir={{ output }}/post/{{ component }}/{{ grid }}/ts/{{ frequency }}/{{ '%dyr' % (ypf) }}
dest_cmip={{ output }}/post/{{ component }}/{{ grid }}/cmip_ts/{{ frequency }}
mkdir -p ${dest_cmip}
e3sm_to_cmip \
--output-path \
${dest_cmip}/${tmp_dir} \
{% if input_files == 'elm.h0' -%}
--var-list \
'mrsos, mrso, mrfso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, tsl, lai, cLitter, cProduct, cSoilFast,cSoilMedium,cSoilSlow fFire, fHarvest, cVeg, nbp, gpp, ra, rh' \
--realm \
lnd \
{% endif -%}
{% if input_files == 'eam.h0' -%}
--var-list \
'pr, tas, rsds, rlds, rsus' \
--realm \
atm \
{% endif -%}
--input-path \
${input_dir}\
--user-metadata \
{{ scriptDir }}/${workdir}/default_metadata.json \
--num-proc \
12 \
--tables-path \
${cmortables_dir}
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo 'ERROR (3)' > {{ prefix }}.status
exit 3
fi
# Move output ts files to final destination
mv ${dest_cmip}/${tmp_dir}/CMIP6/CMIP/*/*/*/*/*/*/*/*/*.nc ${dest_cmip}
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo 'ERROR (4)' > {{ prefix }}.status
exit 4
fi
export cmortables_dir=/lcrc/group/acme/public_html/diagnostics/cmip6-cmor-tables/Tables
input_dir={{ output }}/post/{{ component }}/{{ grid }}/ts/{{ frequency }}/{{ '%dyr' % (ypf) }}
dest_cmip={{ output }}/post/{{ component }}/{{ grid }}/cmip_ts/{{ frequency }}
mkdir -p ${dest_cmip}
e3sm_to_cmip \
--output-path \
${dest_cmip}/${tmp_dir} \
{% if input_files == 'elm.h0' -%}
--var-list \
'mrsos, mrso, mrfso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, tsl, lai, cLitter, cProduct, cSoilFast,cSoilMedium,cSoilSlow fFire, fHarvest, cVeg, nbp, gpp, ra, rh' \
--realm \
lnd \
{% endif -%}
{% if input_files == 'eam.h0' -%}
--var-list \
'pr, tas, rsds, rlds, rsus' \
--realm \
atm \
{% endif -%}
--input-path \
${input_dir}\
--user-metadata \
{{ scriptDir }}/${workdir}/default_metadata.json \
--num-proc \
12 \
--tables-path \
${cmortables_dir}
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo 'ERROR (3)' > {{ prefix }}.status
exit 3
fi
# Move output ts files to final destination
mv ${dest_cmip}/${tmp_dir}/CMIP6/CMIP/*/*/*/*/*/*/*/*/*.nc ${dest_cmip}
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo 'ERROR (4)' > {{ prefix }}.status
exit 4
fi
rm -r ${dest_cmip}/${tmp_dir}
fi
}
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo 'ERROR (5)' > {{ prefix }}.status
exit 5
fi
{%- endif %}
# Delete temporary workdir
cd ..
Expand Down

0 comments on commit 307234b

Please sign in to comment.