Ice suppression on child grid fails when writing restarts through XIOS
Context
Please provide informations on how to reproduce the bug:
Analysis
Franziska reported this bug on NEMO Forum:
For the following I’m applying NEMO 4.2.2 and XIOS2 (rev2634)
I am running a nested configuration consisting of a global parent grid with one child (1) at this level and a therein embedded secondary child (2 ; grandchild) - a nest in a nest.
Both parent and child (1) cover regions where ice can appear while the grandchild (2) is in an ice-free region. Consequently I’d like to suppress the ice model on the gandchild grid (nn_ice =0 in 2_namelist_cfg). This works fine until restarts are written. I’m using xios to read and write restarts and somehow an unknown context for the ice restart for the grandchild is tried to be accessed:
In file "iccontext.cpp", function "void cxios_context_handle_create(xios::CContext **, const char *, int)", line 54 -> Context 2_^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ unknown
I tried to find the correct location in the code to make it dependent from the actual grid’s nn_ice but could not find it yet. Any advice on how to fix this, is very much appreciated.
Notes: setting nn_ice = 2 also for the granchild works fine but reduces performance substantially.
Thank you! Franziska
Fix
The problem comes from these lines in stpmf.F90
IF( kstp + nn_fsbc - 1 == nitrst .AND. lwxios ) THEN
#if defined key_si3
CALL iom_swap( cw_icerst_cxt )
CALL iom_init_closedef( cw_icerst_cxt )
CALL iom_setkt( kstp - nit000 + 1, cw_icerst_cxt )
#endif
That should be replaced by
IF( kstp + nn_fsbc - 1 == nitrst .AND. lwxios ) THEN
#if defined key_si3
IF( nn_ice == 2 ) THEN
CALL iom_swap( cw_icerst_cxt )
CALL iom_init_closedef( cw_icerst_cxt )
CALL iom_setkt( kstp - nit000 + 1, cw_icerst_cxt )
ENDIF
#endif
IF( ln_abl ) THEN
CALL iom_swap( cw_ablrst_cxt )
CALL iom_init_closedef( cw_ablrst_cxt )
CALL iom_setkt( kstp - nit000 + 1, cw_ablrst_cxt )
ENDIF
ENDIF