Skip to content

Refactoring of average_utils.f90#432

Open
mpaiao wants to merge 4 commits intoEDmodel:masterfrom
mpaiao:mpaiao-pr-avg-split
Open

Refactoring of average_utils.f90#432
mpaiao wants to merge 4 commits intoEDmodel:masterfrom
mpaiao:mpaiao-pr-avg-split

Conversation

@mpaiao
Copy link
Contributor

@mpaiao mpaiao commented Mar 13, 2026

Description

This refactoring is an attempt to prevent compilation crashes. @sdeherto mentioned to me offline that the compilation was crashing at average_utils.f90 in some systems. From the error description, it seems the problem is that we reach some internal memory limit when compiling with ifort. I recall a similar error a long time ago in ed_state_vars.F90, and the solution back then was to reduce the size of sub-routines.

This pull request splits the very long sub-routines in average_utils.f90, by separating integration, normalisation and flushing by hierarchical level (polygons, sites, patches, cohorts). I used a nested approach to preserve the same logic. This means that the subroutine that integrates/normalises/flushes polygon-level variables call the site-level counterpart, which then calls the patch-level equivalent, which in turn calls the cohort-level one.

In the process I found one minor bug in the integration of LAI, which I fixed.

Collaborators

@sdeherto who pointed out the problem.

Types of changes

  • Hot fix (emergential bug fix to make ED2 run again)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (fix or feature that would cause existing functionality to change)

Changes in Settings, Input Files or Output Files

  • This feature requires changes in ED2IN
  • This feature requires changes in the XML parameter file
  • This feature requires changes in other input files
  • This feature will change output files

Expectation of Answer Changes:

  • No changes expected (bit-for-bit compatibility)
  • Changes expected with specific configurations (see details below)
  • Changes expected in all simulations (see details below)

Or nearly bit-for-bit, because of the minor bug fix. But this would affect reporting only, no ecologically meaningful difference expected.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • ED2 Wiki update:

Testing :

  • All new and existing tests passed.

mpaiao added 4 commits March 13, 2026 13:45
…hunks. This was in

response to some exchanges with @sdeherto, he found that compilation with intel is
sometimes failing. I recall a similar issue in the past with ed_state_vars.F90, and the
solution was to make sub-routines smaller.
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.

1 participant