Index: /trunk/LMDZ.MARS/changelog.txt
===================================================================
--- /trunk/LMDZ.MARS/changelog.txt	(revision 3224)
+++ /trunk/LMDZ.MARS/changelog.txt	(revision 3225)
@@ -4507,2 +4507,6 @@
 Follow-up of r3217, remove some unused "use ..." in leapfrog_nogcm which
 cause problems when compiling gcm in parallel mode
+
+== 19/02/2024 == EM
+Remove interactive checking with XIOS whether a field should be sent to it;
+some yet unresolved issues arise when using this in mixed MPI-OpenMP mode...
Index: /trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90	(revision 3224)
+++ /trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90	(revision 3225)
@@ -35,8 +35,12 @@
 real,         intent(in) :: field
 
+logical :: is_active ! For XIOS, should this field be sent or not
+
 call writediagfi(ngrid,field_name,title,units,0,(/field/))
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,field)
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
 #endif
 
@@ -63,8 +67,12 @@
 real, dimension(:), intent(in) :: field
 
+logical :: is_active ! For XIOS, should this field be sent or not
+
 call writediagfi(ngrid,field_name,title,units,2,field)
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,field)
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
 #endif
 
@@ -93,4 +101,6 @@
 character(*),         intent(in) :: units
 real, dimension(:,:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
 
 if (size(field,2) == nsoilmx) then
@@ -101,6 +111,8 @@
 
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,field)
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
 #endif
 
@@ -127,8 +139,12 @@
 integer,      intent(in) :: field
 
+logical :: is_active ! For XIOS, should this field be sent or not
+
 call writediagfi(ngrid,field_name,title,units,0,(/real(field)/))
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,(/real(field)/))
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,(/real(field)/))
 #endif
 
@@ -155,8 +171,12 @@
 integer, dimension(:), intent(in) :: field
 
+logical :: is_active ! For XIOS, should this field be sent or not
+
 call writediagfi(ngrid,field_name,title,units,2,real(field))
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,real(field))
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,real(field))
 #endif
 
@@ -185,4 +205,6 @@
 character(*),            intent(in) :: units
 integer, dimension(:,:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
 
 if (size(field,2) == nsoilmx) then
@@ -192,6 +214,8 @@
 endif
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,real(field))
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,real(field))
 #endif
 
@@ -219,4 +243,5 @@
 ! Local argument used to convert logical to real array
 real, dimension(1) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
 
 field_real = 0.
@@ -225,6 +250,8 @@
 call writediagfi(ngrid,field_name,title,units,0,field_real)
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,field_real)
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
 #endif
 
@@ -252,4 +279,5 @@
 ! Local argument used to convert logical to real
 real, dimension(ngrid) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
 
 field_real = 0.
@@ -258,6 +286,8 @@
 call writediagfi(ngrid,field_name,title,units,2,field_real)
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,field_real)
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
 #endif
 
@@ -288,4 +318,5 @@
 ! Local argument used to convert logical to real
 real, allocatable, dimension(:,:) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
 
 allocate(field_real(size(field,1),size(field,2)))
@@ -300,6 +331,8 @@
 
 #ifdef CPP_XIOS
-    ! only send the field to xios if the user asked for it
-    if (xios_is_active_field(field_name)) call send_xios_field(field_name,field_real)
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
 #endif
 
Index: /trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90	(revision 3224)
+++ /trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90	(revision 3225)
@@ -309,5 +309,5 @@
  FUNCTION xios_is_active_field(field_id)
  USE xios, only: xios_field_is_active
- USE mod_phys_lmdz_para, only: bcast_omp
+ USE mod_phys_lmdz_omp_transfert, only: bcast_omp
  IMPLICIT NONE
    LOGICAL ::  xios_is_active_field
@@ -317,4 +317,5 @@
  ! to be in the output file(s)
 
+!$OMP BARRIER
 !$OMP MASTER 
    xios_is_active_field = xios_field_is_active(field_id)
