Skip to content

Fesom2.6 recom tra diags and CI test#802

Merged
ogurses merged 75 commits intomainfrom
fesom2.6_recom_tra_diags
Apr 8, 2026
Merged

Fesom2.6 recom tra diags and CI test#802
ogurses merged 75 commits intomainfrom
fesom2.6_recom_tra_diags

Conversation

@ogurses
Copy link
Copy Markdown
Collaborator

@ogurses ogurses commented Oct 29, 2025

No description provided.

ogurses and others added 17 commits October 15, 2024 15:08
Define new variables to track tracer changes
due to advection and diffusion.

We want to save for now diffusion and advection
contribution to the tracer changes. Horizontal and
vertical diffusion includes Redi
parametrization (if it is set .true.).
Fill __ciso directive to ensure that
carbon isotope code works. Medusa interface is
added.
Use __coccos in src/CMakeLists.txt to
include 2 more phytoplankton classes

FESOM2.6-REcoM setup with 4 phytoplankton,
3 zooplankton and 2 detritus functional types.

BREAKING CHANGE: FESOM2.6-REcoM setup with 4p3z2d
Correct temperature function for small phytoplankton and diatoms.

Previous update for the fouth phytoplankton class and
new temperature functions for small phytoplankton and diatoms
resulted in very low Phaeocystis biomass.
We recognised that this is related to missing code lines in the
temperature function which we correct with this update.
…ostics

Use namelist.io to activate diagnostics.

Sinking velocity of particle (fast and slow) are calculated but not written into a file before.
We fix the  missing diagnostics for sinking velocity of detritus classes. Besides we
Extracted the K0, solubility  which is computed
in gasx.F90.
We add __coccos directive to get the correct temperature
function in silicate assimilation.

In the coccos and Phaeocystis version, it should be dependent on the new temperature function, Temp_diatoms.
Use the original Arrhenius function in simpler phytoplankton version. Besides, light limitation diagnostics is corrected.
It does affect only the diatoms related output.
Correct reported salt flux bug in oce_ale_tracer.F90.
#721
We commented out the linear model where degradation is directly
proportional to light intensity and the chlorophyll degradation
rate is capped at a maximum of 0.3. Reason for this is the unrealistic
air2sea co2 fluxes in the 2p3z2d setup.
The reactivated saturation model is more realistic. It accounts for light
saturation effects.
At low light, degradation increases roughly linearly with PAR
At high light, the degradation rate approaches an asymptotic maximum
…tives with namelist parameters

Replace preprocessor directives with namelist parameters:
* `__3Zoo2Det` → `enable_3zoo2det`
* `__coccos` → `enable_coccos`

* Enhanced inline comments with ecological significance and biological context
*Complete variable/parameter documentation with units and descriptions
* Clear sectioning with visual separators and variable definitions
* Equation explanations showing mathematical relationships and biological processes
* Logic documentation for decision trees and conditional blocks
* Comments now explain "why" not just "what"

**Sequence Validation**
* Generates expected tracer ID list based on configuration
* Shows exact ID order and position-by-position comparison

**Configuration-Specific Clash Detection**
* Full Model (both flags): Don't use IDs 1023-1024
* Coccos-only: Use 1023-1028 (NOT 1029-1034)
* 3Zoo2Det-only: Use 1029-1030 for microzoo (NOT 1035-1036)

**Validation Checks**
* Exact sequence matching against expected IDs
* Duplicate ID detection
*Forbidden ID detection per configuration

BREAKING CHANGE: replace  directives with namelist parameter for model configuration
@JanStreffing JanStreffing added this to the FESOM 2.7 milestone Oct 29, 2025
@JanStreffing JanStreffing changed the title Fesom2.6 recom tra diags Fesom2.6 recom tra diags and CI test Oct 29, 2025
@JanStreffing JanStreffing linked an issue Oct 29, 2025 that may be closed by this pull request
@ogurses ogurses requested a review from suvarchal October 29, 2025 14:34
@ogurses
Copy link
Copy Markdown
Collaborator Author

ogurses commented Oct 29, 2025

CI test for recom is on the way. Any help is welcome @suvarchal

@JanStreffing
Copy link
Copy Markdown
Collaborator

! O:G
! Save horizontal and vertical advective fluxes.
! We have the values on the nodes
! We do not know how much each edge contributes
! to the nodes it connects
! Notes from Patrick: del_ttf includes
! Low-order solution. But, del_ttf_advhoriz and
! del_ttf_advvert contain antidiffusive fluxes 
! from the FCT scheme

!if (.FALSE.) then
! O:G - tra_diag
!#if defined (__recom)
!        if (tracers%data(tr_num)%ltra_diag) then
!           do n=1, myDim_nod2D+eDim_nod2D
!              nu1 = ulevels_nod2D(n)
!              nl1 = nlevels_nod2D(n)
!              do nz = nu1, nl1-1
                 ! Horizontal advection part
!                 tracers%work%tra_advhoriz(nz,n,tr_num) = tracers%work%del_ttf_advhoriz(nz,n)
                 ! Vertical advection part
!                 tracers%work%tra_advvert (nz,n,tr_num) = tracers%work%del_ttf_advvert(nz,n)
!              end do
!           end do
!        end if
!#endif
!endif 

Still needed @ogurses?

!#if defined (__recom) ! not necessarily should belong to recom case
! tracers%work%tra_advhoriz = 0.0 ! O:G - tra_diag
! tracers%work%tra_advvert = 0.0
ttf_rhs_bak = 0.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Has no impact on CI test, so probably ok. Just flagging to be checked by @patrickscholz

@suvarchal
Copy link
Copy Markdown
Collaborator

CI test for recom is on the way. Any help is welcome @suvarchal

last-minute working on compute time reporting and proposal, can take a look tomorrow

@JanStreffing JanStreffing force-pushed the fesom2.6_recom_tra_diags branch from e5e0fe2 to 075f709 Compare January 26, 2026 16:00
@JanStreffing JanStreffing modified the milestones: FESOM 2.7.1, FESOM 2.8 Feb 18, 2026
@JanStreffing
Copy link
Copy Markdown
Collaborator

@ogurses, @suvarchal, @patrickscholz
I think we should try to resolve the last issues on the CI test and merge this branch. I'm at AWI to join next week Monday to Wednesday. After that, I'm away for some weeks.

Comment on lines +425 to +433
if (tracers%data(tr_num)%ltra_diag) then
do n=1, myDim_nod2D+eDim_nod2D
nu1 = ulevels_nod2D(n)
nl1 = nlevels_nod2D(n)
do nz = nu1, nl1-1
ttf_rhs_bak(nz,n) = del_ttf(nz,n)
end do
end do
end if
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it would be nice if we could encapsulate this in a subroutine not to make our code messy and unreadable! Especially that this pieces repeat itself

Comment on lines +441 to +451
if (tracers%data(tr_num)%ltra_diag) then
do n=1, myDim_nod2D+eDim_nod2D
nu1 = ulevels_nod2D(n)
nl1 = nlevels_nod2D(n)
do nz = nu1, nl1-1
! horizontal diffusion (w/out Redi)
tracers%work%tra_diff_part_hor_redi(nz,n,tr_num) = (del_ttf(nz,n) - ttf_rhs_bak(nz,n)) / hnode_new(nz,n) ! Unit [Conc]
!if (mype==0) print *, tracers%work%tra_diff_part_hor_redi(nz,n,tr_num)
end do
end do
end if
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here that same this, this structure repeats itself and could be a re-callable subroutine

@patrickscholz
Copy link
Copy Markdown
Contributor

I talked a while a ago with Sergey about this, and we should try to encapsulate as much of RECOM as we can, To achieve that as much of RECOM lives within the recom_...F90 code files and is only called by function and subroutines (e.g boundary conditions, initialisation, ...). We have been a bit sloppy about this with all the iceberg and transient tracer stuff in the past, which made large part of the FESOM code especially the initialisation, tracer and boundary condition part very crowded and messy and more difficult to maintain.

@JanStreffing
Copy link
Copy Markdown
Collaborator

Perfect task for the AI. I had it search for more cases:

Similar repeated-structure cases in REcoM code (candidates for future refactor)

  1. src/int_recom/recom_main.F90

    • Pattern: In the main node loop (do n=1,myDim_nod2D) there is a recurring
      "backup state -> do work -> compute diagnostic delta" idiom.
    • Example: ttf_rhs_bak is filled for all tracers with ltra_diag, and later
      tracers%work%tra_recom_sms(...) is computed as values - ttf_rhs_bak.
    • Why it’s similar: conceptually the same as the backup/delta calculation
      refactored in src/oce_ale_tracer.F90 (just organized differently).
  2. src/int_recom/recom_sinking.F90

    • Pattern: long sequences of if(tracer ID == ...) blocks repeat nearly the same
      update structure for different element pools:
      • update Benthos(n,k)
      • optionally update SinkFlx_tr(n,k,tr_num) when use_MEDUSA
      • optionally update Benthos_tr(n,k,tr_num)
        repeated for N/C/Si/CaCO3 and also isotope variants.
    • Why it’s similar: repetitive boilerplate where only the tracer-ID set and the
      target index (k) changes.
  3. src/int_recom/recom_init.F90

    • Pattern: repeated min/max scanning over nodes for multiple REcoM tracers,
      followed by repeated MPI_Allreduce calls with identical structure.
    • Why it’s similar: repeated blocks of the same operation on different tracer IDs.
  4. src/int_recom/recom_sms.F90 (benthic remineralization section)

    • Pattern: repeated update equations with the same shape:
      decayBenthos(i) = rate(i) * LocBenthos(i)
      LocBenthos(i) = LocBenthos(i) - decayBenthos(i) * dt_b
      repeated across elements and (optionally) isotopes.
    • Why it’s similar: identical structure differing only by indices/parameters.

This was referenced Feb 25, 2026
@JanStreffing
Copy link
Copy Markdown
Collaborator

I tried my hands on this, but I was not able to figure out what is wrong with the DIC_PI file. Could your try this out @ogurses ?

Runs the same steps as the GitHub Actions fesom2_recom workflow
inside the CI container on Levante. Requires pre-pulling the SIF
image on the login node (compute nodes have read-only TMPDIR).
Root cause: copy-paste bug in recom_init.F90 where ErosionTON2D was
initialized twice and ErosionTOC2D was never initialized. Uninitialized
memory (NaN) propagated through bc_surface for DIC via IEEE 754
NaN * 0.0 = NaN, even when erosion input was disabled.

Also adds a guard for nodes with nzmax < 1 in the REcoM main loop and
hardens tracer initialization in gen_ic3d.F90 to clean up NaN values
from CDO/NCO interpolation artifacts.
…ce values

The io_list used explicit "DIN" and "DIC" variable names, but the model
only outputs these via the generic "otracers" keyword. Changed to
"otracers" and updated fcheck reference values from actual CI run output.
@JanStreffing
Copy link
Copy Markdown
Collaborator

JanStreffing commented Apr 8, 2026

Remaining build check failures indicate some YAC issue? Any idea what happened there @nils3er, @suvarchal, @sveta-loza?

Or maybe some change in the docker? @koldunovn

Upstream libfyaml (commit 902a981, March 3 2026) split the monolithic
libfyaml.h into an umbrella header that #includes 13 sub-headers from
libfyaml/. The install command only ran install-includeHEADERS (the
umbrella), not install-libfyamlHEADERS (the sub-headers). When YAC's
configure tested #include <libfyaml.h>, the compiler could not find the
sub-headers and reported "libfyaml.h not found".
@JanStreffing
Copy link
Copy Markdown
Collaborator

Alright, all CI tests pass. Ready to merge when you give the ok @ogurses

@ogurses ogurses merged commit 36c5d41 into main Apr 8, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create REcoM CI test

5 participants