Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion couplings/echam/coupling_echam2ice.functions
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ iterative_coupling_echam6_ice_make_forcing() {
fi
#add_to $(pwd)/atmosphere_file_for_ice.nc atmosphere_file_for_ice.nc couple
cp $(pwd)/atmosphere_file_for_ice.nc ${COUPLE_DIR}/atmosphere_file_for_ice.nc

cp $(pwd)/atmosphere_file_for_ice.nc ${COUPLE_DIR}/atmosphere_file_for_ice_${END_YEAR_echam}.nc
echo; echo " ...done."; echo
}

Expand Down
628 changes: 518 additions & 110 deletions couplings/echam/coupling_ice2echam.functions

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion couplings/echam/env_echam.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
def prepare_environment(config):
# Get PISM domain from configuration
# Try multiple paths to find the domain:
# 1. From model2 config (iterative coupling)
# 2. From pism config directly
# 3. From echam config (user-specified override)
# 4. Default to "greenland"
pism_domain = None

# Try model2 (iterative coupling configuration)
if "model2" in config:
model2_setup = config["model2"].get("setup_name", "pism")
if model2_setup in config:
pism_domain = config[model2_setup].get("domain")

# Try pism directly
if not pism_domain and "pism" in config:
pism_domain = config["pism"].get("domain")

# Try echam config (user override)
if not pism_domain:
pism_domain = config["echam"].get("pism_domain")

# Default to greenland
if not pism_domain:
pism_domain = "greenland"

environment_dict = {
"ICE_TO_ECHAM": int(config["general"]["first_run_in_chunk"]),
"ECHAM_TO_ICE": int(config["general"]["last_run_in_chunk"]),
Expand All @@ -7,7 +33,9 @@ def prepare_environment(config):
"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"],
"RES_echam": config["echam"]["resolution"],
# === FIX: Add DOMAIN_pism for Greenland GLAC update ===
"DOMAIN_pism": pism_domain,
"EXP_ID": config["general"]["command_line_config"]["expid"],
"RESTART_DIR_echam": config["echam"]["experiment_restart_out_dir"],
"DATA_DIR_echam": config["echam"]["experiment_outdata_dir"],
Expand Down
18 changes: 11 additions & 7 deletions couplings/pism/coupling_atmosphere2pism.functions
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ atmosphere2pism() {
which cdo
echo -e "\t\t---> Preparing to couple generic atmosphere to specific ice sheet model PISM"
ic_atm2pism_prepare

#iterative_coupling_atmosphere_pism_regrid_method="INTERPOLATE"
iterative_coupling_atmosphere_pism_regrid_method=${iterative_coupling_atmosphere_pism_regrid_method:-DOWNSCALE}
bool_atm2pism_regrid_dyn_downscaling=${bool_atm2pism_regrid_dyn_downscaling:-0}
echo -e "\t\t--> Regrid method >>> ${GREEN}${iterative_coupling_atmosphere_pism_regrid_method}${NOCOLOR} <<<"
Expand Down Expand Up @@ -520,7 +520,7 @@ ic_atm2pism_regrid_dyn_downscale_generate_elevation_difference() {
ncrename -v $atmosphere_name_elevation,usurf ${COUPLE_DIR}/elev_lo.nc ${COUPLE_DIR}/tmp.nc
cdo settbounds,1mon -setreftime,1850-01-01,00:00:00 -setunit,m tmp.nc surface_altitude_coarse_resolution.nc

cleanup_list="$cleanup_list ${COUPLE_DIR}/elev_hi.nc ${COUPLE_DIR}/elev_lo.nc ${COUPLE_DIR}/elev_hi_minus_lo.nc"
#cleanup_list="$cleanup_list ${COUPLE_DIR}/elev_hi.nc ${COUPLE_DIR}/elev_lo.nc ${COUPLE_DIR}/elev_hi_minus_lo.nc"
}

ic_atm2pism_regrid_dyn_downscale_temperature_below_firn() {
Expand Down Expand Up @@ -646,9 +646,9 @@ ic_atm2pism_regrid_downscale_split_names() {
${COUPLE_DIR}/atmosphere_file_for_ice_for_downscaling_ 2>> ${COUPLE_DIR}/cdo_stderr_atm2pism
##atmosphere_file_at_ice.${INTERPOL_TYPE_ATM}.nc # && rm atmosphere_file_for_ice.nc

for varname in $(cdo -s vardes ${COUPLE_DIR}/atmosphere_file_for_ice.nc | tr -s ' ' | awk -F ' ' '{print $2}'); do
cleanup_list="$cleanup_list ${COUPLE_DIR}/atmosphere_file_for_ice_for_downscaling_${varname}.nc"
done
#for varname in $(cdo -s vardes ${COUPLE_DIR}/atmosphere_file_for_ice.nc | tr -s ' ' | awk -F ' ' '{print $2}'); do
#cleanup_list="$cleanup_list ${COUPLE_DIR}/atmosphere_file_for_ice_for_downscaling_${varname}.nc"
#done
}

## @fn ic_atm2pism_regrid_downscale_generate_elevation_difference()
Expand Down Expand Up @@ -732,7 +732,9 @@ ic_atm2pism_regrid_downscale_temperature() {
if [ "x${DOWNSCALE_TEMP}" == "x1" ]; then
echo ""; echo " * downscaling temperature"
DOWNSCALING_LAPSE_RATE=${DOWNSCALING_LAPSE_RATE:-"-0.005"}
if [ ${DOWNSCALING_LAPSE_RATE} -gt 0 ]; then
#if [ ${DOWNSCALING_LAPSE_RATE} -gt 0 ]; then
#if (( ${DOWNSCALING_LAPSE_RATE} > 0 )); then
if [ $(echo "${DOWNSCALING_LAPSE_RATE} > 0" | bc) -eq 1 ]; then
echo "YOUR DOWNSCALING LAPSE RATE IS POSITIVE!"
echo "IT WAS: $DOWNSCALING_LAPSE_RATE"
exit 6
Expand Down Expand Up @@ -763,7 +765,9 @@ ic_atm2pism_regrid_downscale_temperature_below_firn() {
if [ "x${DOWNSCALE_TEMP}" == "x1" ]; then
echo ""; echo " * downscaling temperature_below_firn"
DOWNSCALING_LAPSE_RATE=${DOWNSCALING_LAPSE_RATE:-"-0.005"} #old value = -0.007
if [ ${DOWNSCALING_LAPSE_RATE} -gt 0 ]; then
#if (( ${DOWNSCALING_LAPSE_RATE} > 0 )); then
if [ $(echo "${DOWNSCALING_LAPSE_RATE} > 0" | bc) -eq 1 ]; then
#if [ ${DOWNSCALING_LAPSE_RATE} > 0 ]; then
echo "YOUR DOWNSCALING LAPSE RATE IS POSITIVE!"
echo "IT WAS: $DOWNSCALING_LAPSE_RATE"
exit 6
Expand Down
29 changes: 27 additions & 2 deletions couplings/pism/coupling_pism2atmosphere.functions
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,34 @@ function pism_atmosphere_get_newest_output {
fi
done

echo; echo " * Concatenating these files: ${PISM_OFILE_LIST} "
#echo; echo " * Concatenating these files: ${PISM_OFILE_LIST} "
#cdo cat ${PISM_OFILE_LIST} ${OUTPUT_DIR_pism}/latest_ex_file_pism.CHUNK.nc 2>> ${COUPLE_DIR}/cdo_stderr_pism2awiesm
#cdo timmean ${OUTPUT_DIR_pism}/latest_ex_file_pism.CHUNK.nc ${OUTPUT_DIR_pism}/latest_ex_file_pism.nc 2>> ${COUPLE_DIR}/cdo_stderr_pism2awiesm
echo; echo " * Concatenating these 100 files: ${PISM_OFILE_LIST} "
cdo cat ${PISM_OFILE_LIST} ${OUTPUT_DIR_pism}/latest_ex_file_pism.CHUNK.nc 2>> ${COUPLE_DIR}/cdo_stderr_pism2awiesm
cdo timmean ${OUTPUT_DIR_pism}/latest_ex_file_pism.CHUNK.nc ${OUTPUT_DIR_pism}/latest_ex_file_pism.nc 2>> ${COUPLE_DIR}/cdo_stderr_pism2awiesm

# --- 修改开始 ---
# 计算最后100年的起始年份 (例如: 结束年=2000, 2000-100+1 = 1901. 即 1901-2000)
AVG_START_YEAR_CALC=$((CHUNK_END_YEAR_pism - 100 + 1))

# 检查计算出的起始年是否早于该 chunk 的实际起始年
# (防止 chunk 不足100年)
if [ ${AVG_START_YEAR_CALC} -lt ${CHUNK_START_YEAR_pism} ]; then
AVG_START_YEAR=${CHUNK_START_YEAR_pism}
echo " * Note: Chunk is shorter than 100 years. Averaging over available years."
else
AVG_START_YEAR=${AVG_START_YEAR_CALC}
fi

echo " * Calculating time mean over the last 100 years (range: ${AVG_START_YEAR} to ${CHUNK_END_YEAR_pism})"

# 在 timmean 之前使用 selyear 选择年份范围
cdo timmean \
-selyear,${AVG_START_YEAR}/${CHUNK_END_YEAR_pism} \
${OUTPUT_DIR_pism}/latest_ex_file_pism.CHUNK.nc \
${OUTPUT_DIR_pism}/latest_ex_file_pism.nc 2>> ${COUPLE_DIR}/cdo_stderr_pism2awiesm
# --- 修改结束 ---


#rm ${PISM_OFILE_LIST} ${PISM_cleanup_list}
else
Expand Down
Loading
Loading