Skip to content

Fix/pism jsbach vegetation coupling#1427

Open
YugengChen wants to merge 5 commits intoesm-tools:releasefrom
YugengChen:fix/pism-jsbach-vegetation-coupling
Open

Fix/pism jsbach vegetation coupling#1427
YugengChen wants to merge 5 commits intoesm-tools:releasefrom
YugengChen:fix/pism-jsbach-vegetation-coupling

Conversation

@YugengChen
Copy link

Summary

This PR fixes multiple issues preventing vegetation recovery in deglaciated areas during PISM-AWI-ESM coupled simulations.

Changes

1. Export DOMAIN_pism to ECHAM environment

  • The DOMAIN_pism variable was not exported, causing Greenland GLAC mask updates to fail

2. Add Python helper scripts for restart synchronization

  • fix_jsbach_restart_cover_fract.py: Sync cover_fract after deglaciation
  • fix_veg_restart_pot_fpc.py: Sync pot_fpc with cover_fract
  • fix_veg_restart_act_fpc.py: Initialize act_fpc for deglaciated points
  • fix_jsbach_tiny_values.py: Remove 1e-10 artifacts
  • fix_desert_fpc_safe.py: Set desert_fpc=0 for deglaciated areas

3. Multiple fixes in coupling_ice2echam.functions

  • Fix target_orography file order issue
  • Fix WORK_DIR synchronization timing
  • Fix monthly restart handling (don't copy jsbachm.nc/vegm.nc)
  • Add Greenland GLAC mask update support

4. PISM output averaging

  • Average last 100 years instead of full chunk for atmosphere coupling

5. Minor fixes

  • Fix floating-point comparison in lapse rate check

Testing

Tested with PISM-AWI-ESM Greenland simulation (tidal_veg experiment).
Successfully ran 50+ years with active vegetation recovery in deglaciated areas.

Related Issues

Fixes vegetation not growing in newly ice-free Greenland regions.

The DOMAIN_pism variable was not being exported to ECHAM-side coupling
scripts, causing the Greenland GLAC mask update conditional to never
execute. This fix:

- Extracts DOMAIN_pism from various config paths (model2, pism, echam)
- Exports it to the ECHAM environment
- Defaults to 'greenland' if not found

Fixes deglaciation detection always returning zero changed cells.
Add utility scripts to fix restart file inconsistencies during
PISM-JSBACH coupling:

- fix_jsbach_restart_cover_fract.py: Sync cover_fract in restart with
  jsbach.nc after deglaciation updates
- fix_veg_restart_pot_fpc.py: Sync pot_fpc with cover_fract to prevent
  dynveg module state mismatch
- fix_veg_restart_act_fpc.py: Initialize act_fpc for deglaciated points
  using pot_fpc values (critical for vegetation growth)
- fix_jsbach_tiny_values.py: Remove 1e-10 artifacts from jsbach_init_file
- fix_desert_fpc_safe.py: Set desert_fpc=0 for deglaciated areas

These fixes prevent 'malloc(): invalid size' crashes and enable
vegetation recovery in newly ice-free areas.
This commit includes several interrelated fixes:

1. Fix target_orography file order:
   - Check file existence before using target_orography
   - Fall back to latest_target_orography.nc from previous iteration
   - Prevents 'No such file' errors on first coupling iteration

2. Fix WORK_DIR synchronization:
   - Copy modified restart files to WORK_DIR after coupling updates
   - esm_runscripts copies files BEFORE coupling runs, so explicit
     sync is required

3. Fix monthly restart handling:
   - Add ensure_echam_restart_aliases_for_m_streams() function
   - Do NOT copy jsbachm.nc/vegm.nc (accumulated monthly means)
   - Create correct symlinks: jsbachm.nc -> jsbach.nc
   - Prevents 'cover_fract sum = 450' corruption

4. Greenland GLAC mask update:
   - Add DOMAIN_pism == 'greenland' conditional (matching nhem)
   - Update unit.24 GLAC in multiple locations
   - Fix deglaciated area GLAC to use ice_mask directly

5. Integration of Python helper scripts for restart fixes

6. Force lgfw=.false. in namelist.echam to prevent IO errors
…ll chunk

When coupling PISM to atmosphere, use the last 100 years of PISM output
for time averaging instead of the entire chunk. This provides more
relevant boundary conditions for the atmosphere model when running
long PISM integrations.

- Calculate averaging start year as max(chunk_start, chunk_end - 99)
- Add selyear filter before timmean
- Handle chunks shorter than 100 years gracefully
- Fix lapse rate comparison: Use 'bc' for floating-point comparison
  instead of bash integer comparison (-gt), which fails for decimals
- Disable some cleanup_list entries to preserve intermediate files
  for debugging
@ackerlar ackerlar self-assigned this Feb 3, 2026
# === FINAL FIX: Force lgfw=.false. in namelist.echam ===
# Even with namelist modification files, lgfw sometimes persists as .true.
# causing IO_read_stream failures for 'gfw'. We patch it directly here.
if [ -n "${WORK_DIR}" ] && [ -f "${WORK_DIR}/namelist.echam" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

why would you want lgfw=.false.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants