Output Coupling#
The output coupling feature provides a generic interface for connecting ICON to external output components using the YAC (Yet Another Coupler) library. This allows users to develop custom output components that run independently of ICON, enabling flexible post-processing, analysis, and visualization workflows.
Key Features#
Generic Interface: Works with any YAC-compatible output component
Flexible Grid Interpolation: YAC provides various interpolation methods
Temporal Interpolation: YAC handles temporal coupling automatically
Metadata: Transfers CF conventions and GRIB2 metadata defined in ICON to the output component
3D Field Support: Handles multi-level atmospheric and oceanic data with collection sizes
Fractional Masking: Optional validity masks for handling ocean data
Configuration#
Enabling Output Coupling#
ICON must be compiled with YAC support enabled:
./configure --enable-coupling
Add to your ICON namelist (atmosphere or ocean):
&coupling_mode_nml
coupled_to_output = .TRUE.
/
Running in MPI MPMD Mode#
The output coupling requires running ICON and the output component together in MPI MPMD (Multiple Program Multiple Data) mode. This allows both executables to run simultaneously and communicate via YAC.
Basic MPMD Execution#
The general syntax for running ICON with an output component is:
mpirun -n <N_ICON> <icon_executable> : \
-n <N_OUTPUT> <output_component> <output_args>
Where:
<N_ICON>: Number of MPI ranks for ICON<icon_executable>: Path to ICON executable (e.g.,icon)<N_OUTPUT>: Number of MPI ranks for the output component (typically 1)<output_component>: Path to output component executable (e.g.,python simple_output.py)<output_args>: Arguments for the output component
Example: ICON with simple_output.py#
mpirun -n 4 ./icon : \
-n 1 python run/checksuite.clm/simple_output.py output.nc \
atm,icon_grid,temp \
atm,icon_grid,u \
atm,icon_grid,v \
--bounds -180 180 -90 90 \
--res 360 180 \
--output-interval PT1H
This runs ICON on 4 MPI ranks and the output component on 1 rank.
MPI Implementation Specifics#
Different MPI implementations have slightly different MPMD syntax:
OpenMPI:
mpirun -n 4 ./icon : -n 1 python simple_output.py [args]
SLURM with srun:
srun --multi-prog mpmd.conf
Where mpmd.conf contains:
0-3 ./icon
4 python simple_output.py output.nc atm,icon_grid,temp [...]
Component Naming Convention#
For example, in simple_output.py:
python simple_output.py output.nc \
atm_output,icon_grid,temp \
atm_output,icon_grid,u \
atm_output,icon_grid,v
Note the use of atm_output instead of atm.
Field Selection Criteria#
Variables in the ICON variable list (add_var) are automatically exposed if they meet ALL of the following criteria:
Output flag set:
info%loutput = .TRUE.Not a container: Container variables (tracer collections) are excluded
Correct data type: Only
REAL_T(floating-point) variablesValid horizontal grid: Either
GRID_UNSTRUCTURED_CELL(cell-centered data)GRID_UNSTRUCTURED_VERT(vertex-centered data)
Correct dimensions:
First dimension must be
nproma(blocking factor)For 2D variables: 2nd dimension must be
≥ nblksFor 3D variables: 3rd dimension must be
≥ nblks
Vertical Grid Types#
The coupling supports multiple vertical coordinate systems, identified by prefixes:
(no prefix): Model levels (
level_type_ml)pl::: Pressure levels (level_type_pl)hl::: Height levels (level_type_hl)il::: Isentropic levels (level_type_il)
Example: A temperature field on pressure levels would be exposed as pl::temp.
Metadata#
The coupling automatically transfers metadata to output components in JSON format. For more details on metadata handling in YAC, see the YAC metadata documentation.
CF Conventions#
standard_name: CF standard nameunits: Physical unitsshort_name: Abbreviated namelong_name: Descriptive name
GRIB2 Information#
discipline: GRIB2 discipline codecategory: Parameter categorynumber: Parameter numberbits: Number of bits for packinggridtype: Grid type identifiersubgridtype: Sub-grid type identifieradditional_keys: Any extra GRIB2 key-value pairs
Variable Groups#
Variables are tagged with their group memberships for easier filtering in output components.
Fractional Masking#
Three standard mask fields are automatically created:
valid_mask_sfc: Surface (2D) land-sea maskvalid_mask: Full model levels (nlev)valid_mask_half: Half levels (nlev+1)
Mask Values#
1.0: valid cells0.0: invalid cellsFor vertex-centered data: A vertex is valid if ANY adjacent cell is valid
Performance Considerations#
Timers#
The coupling tracks performance with these timers:
timer_coupling_output: Total coupling timetimer_coupling_output_buf_prep: Buffer preparationtimer_coupling_output_1stput: First put operationtimer_coupling_output_put: Subsequent put operations
Check these in ICON’s timing output to assess coupling overhead.
Example Output Component#
ICON includes run/checksuite.clm/simple_output.py as a basic reference implementation:
python simple_output.py output.nc \
atm,icon_grid,temp \
atm,icon_grid,u \
atm,icon_grid,v \
--bounds -180 180 -90 90 \
--res 360 180 \
--output-interval PT1H
This interpolates ICON fields to a regular lat-lon grid and writes NetCDF output.
Command-line Arguments:
output.nc: Output filenamePositional:
component,grid,fieldtuples of source fields (component name, grid name, field name)--bounds: Lon/lat bounds (min_lon, max_lon, min_lat, max_lat)--res: Resolution (n_lon, n_lat)--output-interval: ISO 8601 duration string
Common Issues and Solutions#
Custom Output Components#
To create your own output component:
Initialize YAC and define your component
Define grids and points where you want to receive data
Define the target fields
Call
yac_fdef_couple()to establish connections (optional, couplings can also be defined in a yaml file)Call
yac_fenddef()to finalize setupIn your time loop, call
yac_fget()to receive data from ICON
See the YAC documentation for details.
Limitations#
Single patch only: Currently only
patch_id = 1is supported
References#
YAC Documentation: https://dkrz-sw.gitlab-pages.dkrz.de/yac/