Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CDAT-migrated E3SM Diags #651

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 4 additions & 78 deletions zppy/templates/e3sm_diags.bash
Original file line number Diff line number Diff line change
Expand Up @@ -67,64 +67,6 @@ create_links_climo_diurnal()
cd ..
}

create_links_ts()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We completely remove the create_links functions. No more using cdscan to compile a list of files into an xml.

{
ts_dir_source=$1
ts_dir_destination=$2
begin_year=$3
end_year=$4
error_num=$5
# Create xml files for time series variables
mkdir -p ${ts_dir_destination}
cd ${ts_dir_destination}
# https://stackoverflow.com/questions/27702452/loop-through-a-comma-separated-shell-variable
variables="{{ vars }}"
for v in ${variables//,/ }
do
# Go through the time series files for between year1 and year2, using a step size equal to the number of years per time series file
for year in `seq ${begin_year} {{ ts_num_years }} ${end_year}`;
do
YYYY=`printf "%04d" ${year}`
for file in ${ts_dir_source}/${v}_${YYYY}*.nc
do
# Add this time series file to the list of files for cdscan to use
echo ${file} >> ${v}_files.txt
done
done
# xml file will cover the whole period from year1 to year2
xml_name=${v}_${begin_year}01_${end_year}12.xml
export CDMS_NO_MPI=true
cdscan -x ${xml_name} -f ${v}_files.txt
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo "ERROR (${error_num})" > {{ prefix }}.status
exit ${error_num}
fi
done
cd ..
}

create_links_ts_rof()
{
ts_rof_dir_source=$1
ts_rof_dir_destination=$2
begin_year=$3
end_year=$4
error_num=$5
mkdir -p ${ts_rof_dir_destination}
cd ${ts_rof_dir_destination}
v="RIVER_DISCHARGE_OVER_LAND_LIQ"
xml_name=${v}_${begin_year}01_${end_year}12.xml
cdscan -x ${xml_name} ${ts_rof_dir_source}/${v}_*.nc
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo "ERROR (${error_num})" > {{ prefix }}.status
exit ${error_num}
fi
cd ..
}


{%- if ("lat_lon_land" in sets) %}
{% if run_type == "model_vs_obs" %}
climo_dir_primary_land=climo_land
Expand Down Expand Up @@ -178,18 +120,10 @@ create_links_climo_diurnal ${climo_diurnal_dir_source} ${climo_diurnal_dir_ref}
{%- endif %}

{%- if ("enso_diags" in sets) or ("qbo" in sets) or ("area_mean_time_series" in sets) %}
{% if run_type == "model_vs_obs" %}
ts_dir_primary=ts
{% elif run_type == "model_vs_model" %}
ts_dir_primary=ts_test
{%- endif %}
# Create xml files for time series variables
ts_dir_source={{ output }}/post/atm/{{ grid }}/ts/monthly/{{ '%dyr' % (ts_num_years) }}
create_links_ts ${ts_dir_source} ${ts_dir_primary} ${Y1} ${Y2} 5
ts_dir_primary={{ output }}/post/atm/{{ grid }}/ts/monthly/{{ '%dyr' % (ts_num_years) }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Rather than using the create_links function to populate ts_dir_primary with an xml listing files from ts_dir_source, we just set ts_dir_primary to point the files directly. No more ts_dir_source at all. No more file copying or compiling files into a list. Just pointing zppy directly to the source directory.

{% if run_type == "model_vs_model" %}
ts_dir_source={{ reference_data_path_ts }}/{{ ts_num_years_ref }}yr
ts_dir_ref=ts_ref
create_links_ts ${ts_dir_source} ${ts_dir_ref} ${ref_Y1} ${ref_Y2} 6
ts_dir_ref={{ reference_data_path_ts }}/{{ ts_num_years_ref }}yr
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Same as above, but for model-vs-model's ref

{%- endif %}
{%- endif %}

Expand All @@ -201,17 +135,9 @@ ts_daily_dir_ref={{ reference_data_path_ts_daily }}/{{ ts_num_years_ref }}yr
{%- endif %}

{%- if "streamflow" in sets %}
{% if run_type == "model_vs_obs" %}
ts_rof_dir_primary=rof
{% elif run_type == "model_vs_model" %}
ts_rof_dir_primary=rof_test
{%- endif %}
ts_rof_dir_source="{{ output }}/post/rof/native/ts/monthly/{{ ts_num_years }}yr"
create_links_ts_rof ${ts_rof_dir_source} ${ts_rof_dir_primary} ${Y1} ${Y2} 7
ts_rof_dir_primary="{{ output }}/post/rof/native/ts/monthly/{{ ts_num_years }}yr"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Same as above, but for streamflow

{% if run_type == "model_vs_model" %}
ts_rof_dir_source={{ reference_data_path_ts_rof }}/{{ ts_num_years_ref }}yr
ts_rof_dir_ref=ts_rof_ref
create_links_ts_rof ${ts_rof_dir_source} ${ts_rof_dir_ref} ${ref_Y1} ${ref_Y2} 8
ts_rof_dir_ref={{ reference_data_path_ts_rof }}/{{ ts_num_years_ref }}yr
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Same as above, but for streamflow's model-vs-model ref

{%- endif %}
{%- endif %}

Expand Down
Loading