From 672e35195026c1bbbbc0389e9e4c912bdb51d0cd Mon Sep 17 00:00:00 2001 From: Sebastien Masson <sebastien.masson@locean.ipsl.fr> Date: Fri, 23 Sep 2022 14:22:18 +0000 Subject: [PATCH] Resolve "error in coupled model initialization" --- src/OCE/SBC/cpl_oasis3.F90 | 25 ++++++++++++++++++------- tests/CPL_OASIS/EXPREF/iodef.xml | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/OCE/SBC/cpl_oasis3.F90 b/src/OCE/SBC/cpl_oasis3.F90 index 0147ffdac..111343f97 100644 --- a/src/OCE/SBC/cpl_oasis3.F90 +++ b/src/OCE/SBC/cpl_oasis3.F90 @@ -25,6 +25,9 @@ MODULE cpl_oasis3 !!---------------------------------------------------------------------- #if defined key_oasis3 USE mod_oasis ! OASIS3-MCT module +#endif +#if defined key_xios + USE xios ! I/O server #endif USE par_oce ! ocean parameters USE dom_oce ! ocean space and time domain @@ -137,8 +140,9 @@ CONTAINS ! INTEGER :: id_part INTEGER :: paral(5) ! OASIS3 box partition - INTEGER :: ishape(4) ! shape of arrays passed to PSMILe + INTEGER :: ishape(4) ! shape of arrays passed to PSMILe INTEGER :: ji,jc,jm ! local loop indicees + LOGICAL :: llenddef ! should we call xios_oasis_enddef and oasis_enddef? CHARACTER(LEN=64) :: zclname CHARACTER(LEN=2) :: cli2 !!-------------------------------------------------------------------- @@ -292,14 +296,21 @@ CONTAINS !------------------------------------------------------------------ ! #if defined key_agrif - ! Warning: Agrif_Nb_Fine_Grids not yet defined at this stage for Agrif_Root -> must use Agrif_Root_Only() - IF( Agrif_Root_Only() .OR. agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN -#endif - CALL oasis_enddef(nerror) - IF( nerror /= OASIS_Ok ) CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef') -#if defined key_agrif + IF( Agrif_Root() ) THEN ! Warning: Agrif_Nb_Fine_Grids not yet defined -> must use Agrif_Root_Only() + llenddef = Agrif_Root_Only() ! true of no nested grid + ELSE ! Is it the last nested grid? + llenddef = agrif_fixed() == Agrif_Nb_Fine_Grids() ENDIF +#else + llenddef = .TRUE. +#endif + IF( llenddef ) THEN +#if defined key_xios + CALL xios_oasis_enddef() ! see "Joint_usage_OASIS3-MCT_XIOS.pdf" on XIOS wiki page #endif + CALL oasis_enddef(nerror) + IF( nerror /= OASIS_Ok ) CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef') + ENDIF ! END SUBROUTINE cpl_define diff --git a/tests/CPL_OASIS/EXPREF/iodef.xml b/tests/CPL_OASIS/EXPREF/iodef.xml index dda919bd7..a76b6d811 100644 --- a/tests/CPL_OASIS/EXPREF/iodef.xml +++ b/tests/CPL_OASIS/EXPREF/iodef.xml @@ -13,7 +13,7 @@ <variable id="using_server" type="bool">true</variable> <variable id="using_oasis" type="bool">true</variable> <variable id="oasis_codes_id" type="string" >oceanx</variable> - <variable id="call_oasis_enddef" type="bool">false</variable> + <variable id="call_oasis_enddef" type="bool">true</variable> </variable_definition> </context> -- GitLab