Skip to content

Commit

Permalink
fix orography update in awiesm pism coupling
Browse files Browse the repository at this point in the history
  • Loading branch information
ackerlar committed Feb 6, 2025
1 parent d256dfd commit 5acc00a
Show file tree
Hide file tree
Showing 8 changed files with 362 additions and 111 deletions.
301 changes: 256 additions & 45 deletions couplings/echam/coupling_ice2echam.functions

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions couplings/echam/env_echam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ def prepare_environment(config):
environment_dict = {
"ICE_TO_ECHAM": int(config["general"]["first_run_in_chunk"]),
"ECHAM_TO_ICE": int(config["general"]["last_run_in_chunk"]),
"ECHAM_TO_ISM_multiyear_mean": 1,
"ECHAM_TO_ISM_multiyear_mean": int(config["echam"].get("multi_year_mean", 1)),
"ISM_TO_ECHAM_update_orography": 1,
"ISM_TO_ECHAM_update_glacial_mask": int(config["echam"].get("update_glacial_mask", True)),
"ISM_TO_ECHAM_update_glacial_mask": int(config["echam"].get("update_glacial_mask", True).__bool__()),
"ISM_TO_ECHAM_update_land_runoff": 1,
"COUPLE_DIR": config["general"]["experiment_couple_dir"],
"RES_echam": config["echam"]["resolution"],
Expand All @@ -27,10 +27,11 @@ def prepare_environment(config):
"MACHINE": config["computer"]["name"],
"MESH_PATH_FESOM": config["fesom"]["mesh_dir"],
"HOSING_FILE_LANDICE_LOSS": config["fesom"].get("fwf_path", config["general"]["experiment_couple_dir"]),
"HOSING_CORRECTION": config["echam"].get("hosing_correction", 0), # LA: Not needed anymore with Lu's ECHAM gfw fix
"HOSING_CORRECTION": int(config["echam"].get("hosing_correction", False).__bool__()), # LA: Not needed anymore with Lu's ECHAM gfw fix
"CELL_AREA_FESOM_FILE": config["fesom"].get("fesom_cell_area_file", "fesom.mesh.diag.nc"),
"ECHAM_ALBEDO_ON_GLACIERS": config["echam"].get("albedo_on_glaciers", 0.7),
"ECHAM_GLACIAL_THRESHOLD": config["echam"].get("glacial_threshold", 0.5),
"oro_update_mod": config["echam"].get("oro_update_mod", 2),
}

#if environment_dict["ADD_UNCHANGED_ICE"] == False:
Expand Down
2 changes: 1 addition & 1 deletion couplings/fesom/coupling_ice2fesom.functions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function ice2fesom {
. ${FUNCTION_PATH}/../pism/coupling_ocean2pism.functions

echo "ICE_TO_FESOM=${ICE_TO_FESOM:-0}"
if [[ "x$ICE_TO_FESOM"=="x0" ]]; then
if [[ "x$ICE_TO_FESOM" == "x0" ]]; then
echo " NOT generating ice forcing for ocean model"
echo " since ICE_TO_FESOM=${ICE_TO_FESOM}"
return
Expand Down
3 changes: 1 addition & 2 deletions couplings/fesom/env_fesom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def prepare_environment(config):
environment_dict = {
"ICE_TO_FESOM": config["fesom"].get("use_icebergs", False),
"ICE_TO_FESOM": int(config["fesom"].get("use_icebergs", False).__bool__()),
"FESOM_TO_ICE": int(config["general"]["first_run_in_chunk"]),
"MESH_DIR_fesom": config["fesom"]["mesh_dir"],
"MESH_ROTATED_fesom": config["fesom"]["mesh_rotated"],
Expand All @@ -14,7 +14,6 @@ def prepare_environment(config):
"PYFESOM_PATH": "/pf/a/a270124/pyfesom2/",
"EXP_ID": config["general"]["command_line_config"]["expid"],
"iter_coup_regrid_method_ice2oce": "INTERPOLATE",
"fesom_use_icebergs": config["fesom"].get("use_icebergs", ""),
#"BASIN_FILE": config["fesom"].get("basin_file"),
"MACHINE": config["computer"]["name"],
"ICEBERG_DIR": config["fesom"].get("iceberg_dir", ""),
Expand Down
60 changes: 43 additions & 17 deletions couplings/pism/coupling_atmosphere2pism.functions
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ ic_atm2pism_regrid_dyn_downscale_generate_elevation_difference() {
elev_hi_file="${INPUT_FILE_NAME_BASE_pism%.*}"_thk_plus_topg.nc
echo "UKK1: elev_hi=" ${elev_hi_file}
${cdo} -s -setrtoc,-10000,0,0 \
-add \
-add \
-selvar,thk ${INPUT_FILE_pism} \
-selvar,topg ${INPUT_FILE_pism} \
${COUPLE_DIR}/${elev_hi_file} 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
Expand Down Expand Up @@ -679,9 +679,10 @@ ic_atm2pism_regrid_downscale_generate_elevation_difference() {
echo "UKK2: elev_hi=" ${elev_hi_file}
echo " * LA DEBUG: INPUT_FILE_pism = ${INPUT_FILE_pism}"
echo " * LA DEBUG: INPUT_FILE_NAME_BASE_pism = ${INPUT_FILE_NAME_BASE_pism%.*}"
${cdo} -s -add \
-selvar,thk ${INPUT_FILE_pism} \
${cdo} -s \
-add \
-setrtoc,-10000,0,0 \
-selvar,thk ${INPUT_FILE_pism} \
-selvar,topg ${INPUT_FILE_pism} \
${COUPLE_DIR}/${elev_hi_file} 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
fi
Expand Down Expand Up @@ -1270,7 +1271,12 @@ ic_atm2pism_ablation_pdd_set_time_axis() {
-a \
calendar,time,o,c,${time_calendar} \
${COUPLE_DIR}/atmo_given_file.nc tmp && mv tmp ${COUPLE_DIR}/atmo_given_file.nc
ncks -A ${POOL_DIR_pism}/time_axis/pismr_timeaxis_12_360day.nc ${COUPLE_DIR}/atmo_given_file.nc

${FUNCTION_PATH}/../utils/CreateTimeAxisNC.bash ${nt} ${COUPLE_DIR}/time_axis_pism.nc 0 classic 365_day #${CHUNK_START_YEAR_pism}
#ncks -A ${POOL_DIR_pism}/time_axis/pismr_timeaxis_12_360day.nc ${COUPLE_DIR}/atmo_given_file.nc
ncks -A ${COUPLE_DIR}/time_axis_pism.nc ${COUPLE_DIR}/atmo_given_file.nc
#cdo -s settunits,days -settaxis,0000-01-01,00:00:00,1mon ${COUPLE_DIR}/atmo_given_file.nc tmp
#mv tmp ${COUPLE_DIR}/atmo_given_file.nc

#FAILURE: ncks -A ${POOL_DIR_pism}/grids/${DOMAIN_pism}/pismr_${DOMAIN_pism}_${RES_pism}_xy.nc ${COUPLE_DIR}/atmo_given_file.nc
# Producesses unrealistic x-/y-arrays with a values like: -8.0e+51, 1.7e+161, 1.e-258
Expand Down Expand Up @@ -1854,12 +1860,20 @@ ic_debm2pism_ablation_debm_make_surface_forcing_add_surface_temperature() {
fi
# select air_temperature
#LA: change timmean to ymonmean
cdo -s \
-ymonmean \
-selvar,tsurf \
${COUPLE_DIR}/temperature_below_firn.nc \
tmp0 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
#${COUPLE_DIR}/input_file_for_debm_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc \
if [[ "x${MULTI_YEAR_MEAN_SMB}" == "x1" ]]; then
cdo -s \
-ymonmean \
-selvar,tsurf \
${COUPLE_DIR}/temperature_below_firn.nc \
tmp0 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
#${COUPLE_DIR}/input_file_for_debm_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc \
else
cdo -s \
-selvar,tsurf \
${COUPLE_DIR}/temperature_below_firn.nc \
tmp0 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
#${COUPLE_DIR}/input_file_for_debm_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc \
fi

if [ "x${debug_add_surface_temperature}" == "x1" ]; then
echo -e "\t\t@ DEBUG: Determining temperature scale Kelvin vs Celsius"
Expand Down Expand Up @@ -1896,7 +1910,7 @@ ic_debm2pism_ablation_debm_make_surface_forcing_add_surface_temperature() {
echo -e "\t\t@ DEBUG: Setting time axis"
fi
cdo -s \
-settaxis,1000-01-16,12:00:00,1mon \
-settaxis,${CHUNK_START_YEAR_pism}-01-16,23:55:55,1mon \
tmp12 \
${COUPLE_DIR}/air_temp_copy.nc 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
#rm tmp0 tmp tmp1 tmp6 tmp12
Expand All @@ -1908,11 +1922,18 @@ ic_debm2pism_ablation_debm_make_surface_forcing_add_surface_temperature() {
# merge air_temp with debm output files
# & set time axies
# PG: Why is this set to noon on the year 1000? Does that have any reason?
cdo -s \
-ymonmean \
-settaxis,1000-01-16,12:00:00,1mon \
surface_mass_balance.nc \
tmp 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
if [[ "x${MULTI_YEAR_MEAN_SMB}" == "x1" ]]; then
cdo -s \
-ymonmean \
-settaxis,${CHUNK_START_YEAR_pism}-01-16,23:55:55,1mon \
surface_mass_balance.nc \
tmp 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
else
cdo -s \
-settaxis,${CHUNK_START_YEAR_pism}-01-16,23:55:55,1mon \
surface_mass_balance.nc \
tmp 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
fi

if [ "x${debug_add_surface_temperature}" == "x1" ]; then
echo -e "\t\t@ DEBUG: Merge and clean up"
Expand Down Expand Up @@ -2111,9 +2132,14 @@ ic_debm2pism_ablation_debm_make_surface_forcing_set_time_axis() {
${COUPLE_DIR}/surface_given_file_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc tmp_with_taxis \
&& mv tmp_with_taxis ${COUPLE_DIR}/surface_given_file_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc

${FUNCTION_PATH}/../utils/CreateTimeAxisNC.bash ${nt} ${COUPLE_DIR}/time_axis_pism.nc 0 classic 365_day #${CHUNK_START_YEAR_pism}
ncks -A \
${POOL_DIR_pism}/time_axis/pismr_timeaxis_12_360day.nc \
${COUPLE_DIR}/time_axis_pism.nc \
${COUPLE_DIR}/surface_given_file_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc
#${POOL_DIR_pism}/time_axis/pismr_timeaxis_12_360day.nc \

#cdo -s settunits,days -settaxis,0000-01-01,00:00:00,1mon ${COUPLE_DIR}/surface_given_file_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc tmp
#mv tmp ${COUPLE_DIR}/surface_given_file_${CHUNK_START_DATE_pism}-${CHUNK_END_DATE_pism}.nc

#FAILURE: ncks -A ${POOL_DIR_pism}/grids/${DOMAIN_pism}/pismr_${DOMAIN_pism}_${RES_pism}_xy.nc ${COUPLE_DIR}/atmo_given_file.nc
# Producesses unrealistic x-/y-arrays with a values like: -8.0e+51, 1.7e+161, 1.e-258
Expand Down
Loading

0 comments on commit 5acc00a

Please sign in to comment.