Index: trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90	(revision 3054)
+++ trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90	(revision 3055)
@@ -17,4 +17,5 @@
   ! For a surface field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -30,5 +31,8 @@
   call writediagfi(ngrid,field_name,title,units,0,field)
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,field)
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,field)
+  endif
 #endif
   
@@ -38,4 +42,5 @@
   ! For a surface field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -51,5 +56,8 @@
   call writediagfi(ngrid,field_name,title,units,2,field)
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,field)
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,field)
+  endif
 #endif
   
@@ -59,4 +67,5 @@
   ! For a "3D" horizontal-vertical field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -78,5 +87,8 @@
   endif
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,field)
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,field)
+  endif
 #endif
   
@@ -86,4 +98,5 @@
   ! For a surface field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -99,5 +112,8 @@
   call writediagfi(ngrid,field_name,title,units,0,real(field))
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,real(field))
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,real(field))
+  endif
 #endif
   
@@ -107,4 +123,5 @@
   ! For a surface field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -120,5 +137,8 @@
   call writediagfi(ngrid,field_name,title,units,2,real(field))
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,real(field))
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,real(field))
+  endif
 #endif
   
@@ -128,4 +148,5 @@
   ! For a "3D" horizontal-vertical field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -147,5 +168,8 @@
   endif
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,real(field))
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,real(field))
+  endif
 #endif
   
@@ -155,4 +179,5 @@
   ! For a surface field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -173,5 +198,8 @@
   call writediagfi(ngrid,field_name,title,units,0,field_real)
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,field_real)
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,field_real)
+  endif
 #endif
   
@@ -181,4 +209,5 @@
   ! For a surface field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -202,5 +231,8 @@
   call writediagfi(ngrid,field_name,title,units,2,field_real(:))
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,field_real)
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,field_real)
+  endif
 #endif
   
@@ -210,4 +242,5 @@
   ! For a "3D" horizontal-vertical field
 #ifdef CPP_XIOS
+  use xios_output_mod, only: xios_is_active_field
   use xios_output_mod, only: send_xios_field
 #endif
@@ -242,5 +275,8 @@
 
 #ifdef CPP_XIOS 
-  call send_xios_field(field_name,field_real)
+  if (xios_is_active_field(field_name)) then
+    ! only send the field to xios if the user asked for it
+    call send_xios_field(field_name,field_real)
+  endif
 #endif
   
Index: trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90	(revision 3054)
+++ trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90	(revision 3055)
@@ -293,4 +293,22 @@
   END SUBROUTINE histwrite3d_xios
 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ FUNCTION xios_is_active_field(field_id)
+ USE xios, only: xios_field_is_active
+ USE mod_phys_lmdz_para, only: bcast_omp
+ IMPLICIT NONE
+   LOGICAL ::  xios_is_active_field
+   CHARACTER(LEN=*) :: field_id
+ 
+ ! check with XIOS if "field_id" is requested by the user
+ ! to be in the output file(s)
+
+!$OMP MASTER 
+   xios_is_active_field = xios_field_is_active(field_id)
+!$OMP END MASTER
+   CALL bcast_omp(xios_is_active_field)
+ END FUNCTION xios_is_active_field
+
 #endif
 
