Skip to content

Fesom2.7 recom3.1#864

Draft
ogurses wants to merge 39 commits into
mainfrom
fesom2.7-recom3.1
Draft

Fesom2.7 recom3.1#864
ogurses wants to merge 39 commits into
mainfrom
fesom2.7-recom3.1

Conversation

@ogurses
Copy link
Copy Markdown
Collaborator

@ogurses ogurses commented Feb 27, 2026

Update REcoM in FESOM2.7

ogurses and others added 17 commits December 9, 2025 11:42
This commit includes bugfixes, new diagnostics variables for grazing
and code pieces to track BGC tracer budget.
Add recom initialzation and sbc files for recom. Standard setup for recom is

enable_3zoo2det = .true.  and enable_coccos = .false. (namelist.recom)
Build REcoM CI test. Add push trigger and improve debugging.
- namelist.recom and namelist.tra required by REcoM (not auto-generated)
- Updated file paths to use local copies in work directory
- Set REcoM_restart=false for initialization from climatology
- Workflow copies these template files to work_recom/
Added mslp (mean sea level pressure) forcing configuration to enable
CO2 flux calculations in REcoM. Without atmospheric pressure, the CO2
flux calculation fails with NaN values.

Changes:
- Added namelist.forcing section with l_mslp=True
- Configured to read from 'slp.' files with 'slp' variable
- Copy PHC2_salx.nc and runoff.nc to work directory in CI
…orcing

The default namelist.forcing.CORE2 already has mslp (atmospheric
pressure) configured but disabled (l_mslp=.false.). Patch it to
l_mslp=.true. in the workflow to enable reading of slp.*.nc files.

This is needed for REcoM CO2 flux calculations which require
atmospheric pressure (Patm).

Removed unnecessary namelist.forcing section from setup.yml since
we just patch the default config file directly.
Namelist for REcoM3.1 are updated (for albedo)
Grazing diagnostics results in segmentation faulf in 2p1z1d setup.
Macrozooplankton allocation and initialization is revisited. Deallocation
was not an issue.
ESM tools cause problems in coupled model run
If double precision sign is in the namelist.recom.
d0 is removed.
Tracer fields have different numbers depending on configuration. Output routine
is now aware of which configuration we use.

1. **Tracer ID 1001-1022 Base tracers** always present in all configuration:

1. **Tracer ID 1023-1028 have different meanings** depending on configuration:
- In **COCCOS-ONLY**: 1023-1025 are Coccos (N,C,Chl), 1026-1028 are Phaeo (N,C,Chl)
- In **3ZOO2DET configs**: 1023-1024 are Zoo2 (N,C), 1025-1028 are Det2 pool
- In **BASE with rivers**: 1023 is DOCt

2. **Tracer ID 1029-1031** vary by configuration:
- In **FULL model**: Coccos (N,C,Chl)
- In **3ZOO2DET-ONLY**: 1029-1030 are Microzoo (N,C)
- In **COCCOS-ONLY with rivers**: 1029 is DOCt

3. **Tracer ID 1032-1036** only exist in **FULL model**:
- 1032-1034: Phaeocystis (N,C,Chl)
- 1035-1036: Microzooplankton (N,C)

4. **Tracer ID 1037** only in **FULL model with rivers**: DOCt

5. **Added comprehensive comments** explaining which configuration uses which tracer IDs to prevent confusion.
Terrestrial DOC input is added as a new tracer. Input variables are read from a Netcdf file
using a new subroutine as standard FESOM routines do not help in this case. 

Update namelist.config file for various recom setups.
REcoM runs with more than 35 tracer fields. Therefore, we increase maximum number of
allowed restart files.
DIC budget calculations are updated. We have now the correct split.
Budget closes. It is extended to the variables of DIN, All and DSi.
Photosynthesis, respiration, N assimilation and remineralization
diagnostics are added.
…ication and permanent burial of organic matter in marine sediments. Update recom output variables.

- Denitrification: Uses Middelburg et al. (1996) parameterization to calculate nitrogen removal as a function of organic carbon flux
- Permanent Burial: Uses Dunne et al. (2007) formulation to calculate burial efficiency and permanent removal of C, N, Si, and CaCO3
- Calcite Dissolution: Accounts for calcite preservation based on carbonate saturation state (Omega_calcite)
- Update output streams for the REcoM tracer variables (mocsy 3D outputs, missing ballasting outputs and burial)
We hhave either 2p or 4p cases. 3p setup is not needed anymore.
@ogurses
Copy link
Copy Markdown
Collaborator Author

ogurses commented Feb 27, 2026

I am not allowed to add the following yml file.

.github/workflows/fesom2_recom.yml

name: "FESOM2: REcoM Biogeochemistry"

Controls when the action will run. Triggers the workflow on pull request only.

on:
workflow_dispatch: {}
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main

A workflow run is made up of one or more jobs that can run sequentially or in parallel

jobs:
general_test:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
# Docker Hub image that container-job executes in
container: ghcr.io/fesom/fesom2_docker:fesom2_test_refactoring-master

# Service containers to run with `gfortran_ubuntu`
steps:
  # NK: this changes working directory to fesom2
  - uses: actions/checkout@v2

  - name: Git safe directory
    run: |
      git config --global --add safe.directory ${PWD}
  - name: Compile model with REcoM
    run: |
      ./configure.sh ubuntu -DRECOM_COUPLED=ON
  - name: Create REcoM test run
    run: |
      mkrun recom test_pi_recom -m docker

  - name: Add REcoM namelists
    run: |
      # mkrun doesn't create namelist.recom, so copy from config and patch
      # Using 2p3z2d (30 tracers) - more complete/tested than 2p1z1d
      cp config/bin_2p3z2d/namelist.recom work_recom/
      cp config/bin_2p3z2d/namelist.tra work_recom/

      # Patch file paths in namelists to use local files
      cd work_recom

      # Remove nam_rsbc section (not used by code, causes parsing errors)
      sed -i '/^&nam_rsbc/,/^\//d' namelist.recom

      # Set REcoM_restart to false for initialization from climatology
      sed -i "s|REcoM_restart.*=.*\.true\.|REcoM_restart         =.false.|" namelist.recom

      # Patch tracer file list in namelist.tra  
      sed -i "s|fe_pisces_opa_eq_init_3D_changed_name\.nc|fe5deg.nc|" namelist.tra
      sed -i "s|woa18_all_o00_01_mmol_fesom2\.nc|oxy5deg.nc|" namelist.tra
      sed -i "s|woa13_all_i00_01_fesom2\.nc|si5deg.nc|" namelist.tra
      sed -i "s|GLODAPv2\.2016b\.TAlk_fesom2_mmol_fix_z_Fillvalue\.nc|talk5deg.nc|" namelist.tra
      sed -i "s|GLODAPv2\.2016b\.TCO2_fesom2_mmol_fix_z_Fillvalue\.nc|tco2_5deg.nc|" namelist.tra
      sed -i "s|woa13_all_n00_01_fesom2\.nc|din5deg.nc|" namelist.tra
      sed -i "s|phc3\.0_winter\.nc|woa18_netcdf_5deg.nc|g" namelist.tra

      # Enable atmospheric pressure forcing for REcoM CO2 flux calculation
      sed -i "s|l_mslp *= *\.false\.|l_mslp=.true.|" namelist.forcing
     
      echo "--- Verifying patches ---"
      echo "REcoM restart: $(grep 'REcoM_restart' namelist.recom)"
      echo "Atmospheric pressure: $(grep 'l_mslp' namelist.forcing)"
     cd ..

      # Copy REcoM input data files
      cp test/input/recom/*.nc work_recom/

      # Create dust file with expected name in the source directory
      # (code reads from ClimateDataPath, not work directory)
      cd test/input/recom
      ln -s DustClimMonthlyAlbani_pimesh.nc DustClimMonthlyAlbani.nc
      cd ../../..
      
      # Copy forcing data files (from 1948)
      cp test/input/global/*.1948.nc work_recom/
      cp test/input/global/runoff.nc work_recom/
      cp test/input/global/PHC2_salx.nc work_recom/
        
  - name: FESOM2 REcoM test run
    run: |
      cd work_recom
      echo "--- Running REcoM test (32 timesteps, 1 day) ---"
      chmod +x job_docker_new
      ./job_docker_new

  - name: Check REcoM results
    run: |-
      cd work_recom
      fcheck .

@JanStreffing
Copy link
Copy Markdown
Collaborator

Hey @ogurses, & @patrickscholz. I suggest we first merge #863, then #802. Then we update this branch and merge here.

@suvarchal
Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI and others added 3 commits May 5, 2026 13:16
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: suvarchal <15322959+suvarchal@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: suvarchal <15322959+suvarchal@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented May 5, 2026

I am not allowed to add the following yml file.

...

Added the workflow file at .github/workflows/fesom2_recom.yml in commit 9363d33. I also added explicit contents: read permissions to the GITHUB_TOKEN as required by security scanning (commit 4f84f2b).

@copilot resolve the merge conflicts in this pull request

Merge conflicts with origin/main have been resolved in commit 6cffefa. All REcoM 3.1 changes are preserved, and the new changes from main have been integrated. No conflict markers remain.

@ogurses
Copy link
Copy Markdown
Collaborator Author

ogurses commented May 13, 2026

@copilot resolve the merge conflicts in this pull request

I have the following problem now

/albedo/home/ogurses/test_case/trunk/src/io_meandata.F90(4368): error #6457: This derived type name has not been declared. [MEANDATA0D]
type(Meandata0D), pointer :: entry0D
---------^
/albedo/home/ogurses/test_case/trunk/src/io_meandata.F90(4462): error #6457: This derived type name has not been declared. [MEANDATA0D]
type(Meandata0D), intent(inout) :: entry0D
---------^
/albedo/home/ogurses/test_case/trunk/src/io_meandata.F90(4378): error #6404: This name does not have a type, and must have an explicit type. [IO_XIOS_IS_ON]
if (io_xios_is_on()) return
--------^
/albedo/home/ogurses/test_case/trunk/src/io_meandata.F90(4378): error #6341: A logical data type is required in this context. [IO_XIOS_IS_ON]
if (io_xios_is_on()) return
--------^
/albedo/home/ogurses/test_case/trunk/src/io_meandata.F90(4380): error #6404: This name does not have a type, and must have an explicit type. [IO_NSTREAMS0D]
do n = 1, io_NSTREAMS0D
--------------^
/albedo/home/ogurses/test_case/trunk/src/io_meandata.F90(4381): error #6404: This name does not have a type, and must have an explicit type. [ENTRY0D]
entry0D => io_stream0D(n)
--------^

Some module is missing @suvarchal @JanStreffing

Jan Streffing added 2 commits May 13, 2026 10:42
The Copilot merge resolution of origin/main into fesom2.7-recom3.1 kept the
0D writer subroutines (output_0D_streams, create_0D_file) but dropped four
companion pieces that they depend on:

  - use io_xios_module, only: io_xios_is_on, ... (module head import block)
  - def_stream0D in the public list
  - type Meandata0D (the 0D stream record)
  - io_stream0D(50) and io_NSTREAMS0D module-level storage
  - subroutine def_stream0D (the registrar)

Restored verbatim from main so the writers compile against their type
again. No behavioural change beyond restoring main-side 0D scalar output.
…to g_config

gen_surface_forcing.F90 references the switch unconditionally at two
sites (SBC filename pattern in nc_sbc_ini_fillnames; daily-update flag
in sbc_do), but the declaration lived in recom_config, which is only
compiled when __recom is defined. The non-recom builds (fesom2_main,
fesom2_icepack, fesom2_openmp, ...) therefore failed to compile with
'Symbol enable_AWICM has no IMPLICIT type'.

Wrapping every reference in #if defined (__recom) would clutter the SBC
code. Instead the declaration is moved into g_config (always compiled,
default .false.) and recom_config picks it up via use-association so the
&parecomsetup namelist binding still works in recom builds. The two
gen_surface_forcing.F90 reference sites then need no preprocessor guard.

Also renamed because the switch lives in a recom_config namelist and
governs recom <-> atmosphere coupling behaviour (filename pattern of
forcing produced by a coupled atmosphere model, daily SSS/runoff
refresh). It is unrelated to AWICM, which is a FESOM+ECHAM ESM without
REcoM.

Default left at .false. so standard yearly-file forcing remains the
out-of-the-box behaviour. update_daily_flag is now initialised to
.false. so the consumer site (runoff_data_source=='AWICM') is safe when
recom_coupled_to_atmosphere is off. Namelist defaults in config/bin_*/
updated to the new key.
@JanStreffing
Copy link
Copy Markdown
Collaborator

JanStreffing commented May 13, 2026

788d0a3 — restored the 0D scalar-stream infrastructure that the Copilot merge resolution had dropped from src/io_meandata.F90. The merge kept the writer subroutines (output_0D_streams, create_0D_file) but removed (i) the use io_xios_module, only: io_xios_is_on, ... import block, (ii) def_stream0D in the public :: list, (iii) type Meandata0D ... end type Meandata0D, (iv) the module-level storage type(Meandata0D), save, target :: io_stream0D(50) and integer, save :: io_NSTREAMS0D = 0, and (v) the registrar subroutine def_stream0D(...). All five were restored verbatim from main, so the six errors you saw on MEANDATA0D / IO_XIOS_IS_ON / IO_NSTREAMS0D / ENTRY0D are resolved.

c2b4213 — renames enable_AWICM to recom_coupled_to_atmosphere and moves the declaration from recom_config into g_config. recom_config picks it up via use g_config, only: recom_coupled_to_atmosphere, so the &parecomsetup namelist binding in namelist.recom still works in recom builds, and gen_surface_forcing.F90 no longer needs preprocessor guards around its two reference sites. This fixes the 'Symbol enable_AWICM has no IMPLICIT type' errors on the non-recom CI jobs (fesom2_main, fesom2_icepack, fesom2_openmp, ...).

Rename motivation: in our group we typically use "AWICM" for the AOGCM-only coupled setup (FESOM + ECHAM, without biogeochemistry). The switch in &parecomsetup is only read when REcoM is active and controls SBC behaviour when REcoM is forced by a coupled atmosphere model, which is the ESM regime (AWESM3 / AWI-ESM), not the AOGCM regime, so the old name was a bit misleading. Semantics are unchanged and the default is .false., so existing setups continue to work; update_daily_flag is now initialised to .false. so the runoff_data_source=='AWICM' consumer is safe when the switch is off. Namelist defaults in config/bin_2p1z1d/, bin_2p3z2d/, bin_4p3z2d/ updated to the new key.

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.

7 participants