Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/test/generic_testcase.f90
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/test/generic_testcase.f90	(revision 1941)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/test/generic_testcase.f90	(revision 1942)
@@ -33,6 +33,8 @@
     CHARACTER(len_str)  :: init_field2D=""
     DOUBLE PRECISION    :: pressure_factor
-    LOGICAL :: domain_mask
-    CHARACTER(len_str) :: domain_mask_type="cross"
+    LOGICAL             :: domain_mask 
+    CHARACTER(len_str)  :: domain_mask_type=""
+    LOGICAL             :: scalar_mask
+    CHARACTER(len_str) :: scalar_mask_type=""
     LOGICAL :: axis_mask
     LOGICAL :: mask3d
@@ -132,4 +134,5 @@
     INTEGER, POINTER          :: domain_index(:)
     LOGICAL, POINTER          :: axis_mask(:)
+    LOGICAL                   :: scalar_mask
     INTEGER, POINTER          :: axis_index(:)
     DOUBLE PRECISION, POINTER :: ensemble_value(:)
@@ -151,4 +154,5 @@
 
     DOUBLE PRECISION, POINTER :: field2D(:), other_field2D(:)
+    DOUBLE PRECISION          :: field0D, other_field0D
     DOUBLE PRECISION, POINTER :: field_X(:), other_field_X(:)
     DOUBLE PRECISION, POINTER :: field_Y(:), other_field_Y(:)
@@ -166,4 +170,5 @@
 
     DOUBLE PRECISION, POINTER :: field2D_W(:,:), other_field2D_W(:,:)
+    DOUBLE PRECISION, POINTER :: field0D_W(:), other_field0D_W(:)
     DOUBLE PRECISION, POINTER :: field_XW(:,:), other_field_XW(:,:)
     DOUBLE PRECISION, POINTER :: field_YW(:,:), other_field_YW(:,:)
@@ -190,12 +195,12 @@
     INTEGER :: ierr      
 
-    LOGICAL :: ok_field2D, ok_field3D, ok_pressure, ok_field2D_sub, ok_field3D_sub,ok_field3D_recv, ok_field3D_send
+    LOGICAL :: ok_field0D, ok_field2D, ok_field3D, ok_pressure, ok_field2D_sub, ok_field3D_sub,ok_field3D_recv, ok_field3D_send
     LOGICAL :: ok_field_X, ok_field_Y, ok_field_XY, ok_field_Z, ok_field_XYZ, ok_field_XZ, ok_field_YZ
-    LOGICAL :: ok_field2D_W, ok_field3D_W, ok_pressure_W, ok_field2D_sub_W, ok_field3D_sub_W,ok_field3D_recv_W, ok_field3D_send_W
+    LOGICAL :: ok_field0D_W, ok_field2D_W, ok_field3D_W, ok_pressure_W, ok_field2D_sub_W, ok_field3D_sub_W,ok_field3D_recv_W, ok_field3D_send_W
     LOGICAL :: ok_field_XW, ok_field_YW, ok_field_XYW, ok_field_ZW, ok_field_XYZW, ok_field_XZW, ok_field_YZW
 
-    LOGICAL :: ok_other_field2D, ok_other_field3D, ok_other_pressure, ok_other_field2D_sub, ok_other_field3D_sub,ok_other_field3D_recv, ok_other_field3D_send
+    LOGICAL :: ok_other_field0D, ok_other_field2D, ok_other_field3D, ok_other_pressure, ok_other_field2D_sub, ok_other_field3D_sub,ok_other_field3D_recv, ok_other_field3D_send
     LOGICAL :: ok_other_field_X, ok_other_field_Y, ok_other_field_XY, ok_other_field_Z, ok_other_field_XYZ, ok_other_field_XZ, ok_other_field_YZ
-    LOGICAL :: ok_other_field2D_W, ok_other_field3D_W, ok_other_pressure_W, ok_other_field2D_sub_W, ok_other_field3D_sub_W,ok_other_field3D_recv_W, ok_other_field3D_send_W
+    LOGICAL :: ok_other_field0D_W, ok_other_field2D_W, ok_other_field3D_W, ok_other_pressure_W, ok_other_field2D_sub_W, ok_other_field3D_sub_W,ok_other_field3D_recv_W, ok_other_field3D_send_W
     LOGICAL :: ok_other_field_XW, ok_other_field_YW, ok_other_field_XYW, ok_other_field_ZW, ok_other_field_XYZW, ok_other_field_XZW, ok_other_field_YZW
     
@@ -235,4 +240,5 @@
                                                      
     CALL init_axis("axis", comm, params, axis_value, axis_mask, axis_index)
+    CALL init_scalar("scalar", comm, params,  scalar_mask)
     CALL init_ensemble("ensemble", comm, params, ensemble_value)
 
@@ -311,4 +317,5 @@
     ALLOCATE(field_XZW(0:x-1,0:z-1,0:w-1))
     ALLOCATE(field_YZW(0:y-1,0:z-1,0:w-1))
+    ALLOCATE(field0D_W(0:w-1))
     
 
@@ -367,4 +374,5 @@
     ENDDO
     
+    field0D=1
 
 
@@ -379,5 +387,5 @@
     field_XZW(:,:,0) = field_XZ(:,:)*(1+0.1*ensemble_value(0))
     field_YZW(:,:,0) = field_YZ(:,:)*(1+0.1*ensemble_value(0))
-    
+    field0D_W(0) = field0D*(1+0.1*ensemble_value(0))
     
     ok_field2D=xios_is_valid_field("field2D") ;
@@ -393,4 +401,5 @@
     ok_field_XZ=xios_is_valid_field("field_XZ") ;
     ok_field_YZ=xios_is_valid_field("field_YZ") ;
+    ok_field0D=xios_is_valid_field("field0D") ;
 
     ok_field2D_W=xios_is_valid_field("field2D_W") ;
@@ -406,4 +415,5 @@
     ok_field_XZW=xios_is_valid_field("field_XZW") ;
     ok_field_YZW=xios_is_valid_field("field_YZW") ;
+    ok_field0D_W=xios_is_valid_field("field0D_W") ;
 
 
@@ -440,4 +450,5 @@
                                                      
     CALL init_axis("other_axis", comm, other_params, axis_value, axis_mask, axis_index)
+    CALL init_scalar("other_scalar", comm, params, scalar_mask)
     CALL init_ensemble("other_ensemble", comm, other_params, ensemble_value)
 
@@ -516,4 +527,5 @@
     ALLOCATE(other_field_XZW(0:x-1,0:z-1,0:w-1))
     ALLOCATE(other_field_YZW(0:y-1,0:z-1,0:w-1))
+    ALLOCATE(other_field0D_W(0:w-1))
     
 
@@ -572,4 +584,5 @@
     ENDDO
     
+    other_field0D = 1
 
 
@@ -584,4 +597,5 @@
     other_field_XZW(:,:,0) = other_field_XZ(:,:)*(1+0.1*ensemble_value(0))
     other_field_YZW(:,:,0) = other_field_YZ(:,:)*(1+0.1*ensemble_value(0))
+    other_field0D_W(0) = other_field0D*(1+0.1*ensemble_value(0))
     
     
@@ -598,4 +612,5 @@
     ok_other_field_XZ=xios_is_valid_field("other_field_XZ") ;
     ok_other_field_YZ=xios_is_valid_field("other_field_YZ") ;
+    ok_other_field0D=xios_is_valid_field("other_field0D") ;
 
     ok_other_field2D_W=xios_is_valid_field("other_field2D_W") ;
@@ -611,4 +626,5 @@
     ok_other_field_XZW=xios_is_valid_field("other_field_XZW") ;
     ok_other_field_YZW=xios_is_valid_field("other_field_YZW") ;
+    ok_other_field0D_W=xios_is_valid_field("other_field0D_W") ;
 
 
@@ -636,4 +652,5 @@
       IF (ok_field_XZ) CALL xios_send_field("field_XZ",field_XZ)
       IF (ok_field_YZ) CALL xios_send_field("field_YZ",field_YZ)
+      IF (ok_field0D)  CALL xios_send_field("field0D",field0D)
       
       IF ( MOD(params%field_sub_offset+ts-1,params%field_sub_freq)==0) THEN
@@ -660,4 +677,5 @@
       IF (ok_field_XZW) CALL xios_send_field("field_XZW",field_XZW)
       IF (ok_field_YZW) CALL xios_send_field("field_YZW",field_YZW)
+      IF (ok_field0D_W) CALL xios_send_field("field0D_W",field0D_W)
       
       IF ( MOD(params%field_sub_offset+ts-1,params%field_sub_freq)==0) THEN
@@ -675,4 +693,5 @@
       field2D=field2D+1
       field3D=field3D+1
+      field0D=field0D+1
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -691,4 +710,5 @@
       IF (ok_other_field_XY) CALL xios_send_field("other_field_XZ", other_field_XZ)
       IF (ok_other_field_XY) CALL xios_send_field("other_field_YZ", other_field_YZ)
+      IF (ok_other_field0D)  CALL xios_send_field("other_field0D", other_field0D)
       
       IF ( MOD(other_params%field_sub_offset+ts-1,other_params%field_sub_freq)==0) THEN
@@ -708,11 +728,12 @@
       IF (ok_other_field3D_W) CALL xios_send_field("other_field3D_W",other_field3D_W)
       IF (ok_other_pressure_W) CALL xios_send_field("other_pressure_W",other_pressure_W)
-      IF (ok_other_field_XW) CALL xios_send_field("other_field_XW",other_field_XW)
-      IF (ok_other_field_YW) CALL xios_send_field("other_field_YW",other_field_YW)
+      IF (ok_other_field_XW)  CALL xios_send_field("other_field_XW",other_field_XW)
+      IF (ok_other_field_YW)  CALL xios_send_field("other_field_YW",other_field_YW)
       IF (ok_other_field_XYW) CALL xios_send_field("other_field_XYW",other_field_XYW)
-      IF (ok_other_field_ZW) CALL xios_send_field("other_field_ZW",other_field_ZW)
+      IF (ok_other_field_ZW)  CALL xios_send_field("other_field_ZW",other_field_ZW)
       IF (ok_other_field_XYW) CALL xios_send_field("other_field_XYZW",other_field_XYZW)
       IF (ok_other_field_XYW) CALL xios_send_field("other_field_XZW",other_field_XZW)
       IF (ok_other_field_XYW) CALL xios_send_field("other_field_YZW",other_field_YZW)
+      IF (ok_other_field0D_W)   CALL xios_send_field("other_field0D_W",other_field0D_W)
       
       IF ( MOD(other_params%field_sub_offset+ts-1,other_params%field_sub_freq)==0) THEN
@@ -730,4 +751,5 @@
       other_field2D=other_field2D+1
       other_field3D=other_field3D+1
+      other_field0D=other_field0D+1
 
 
@@ -757,4 +779,6 @@
     IF (.NOT. xios_getvar(prefix//"domain_mask", params%domain_mask) )   params%domain_mask=.FALSE.
     IF (.NOT. xios_getvar(prefix//"domain_mask_type", params%domain_mask_type) )   params%domain_mask_type="cross"
+    IF (.NOT. xios_getvar(prefix//"scalar_mask", params%scalar_mask) )   params%scalar_mask=.FALSE.
+    IF (.NOT. xios_getvar(prefix//"scalar_mask_type", params%scalar_mask_type) )   params%scalar_mask_type="none"
     IF (.NOT. xios_getvar(prefix//"axis", params%axis) )                 params%axis="pressure"
     IF (.NOT. xios_getvar(prefix//"axis_mask", params%axis_mask) )       params%axis_mask=.FALSE.
@@ -2078,4 +2102,41 @@
   END SUBROUTINE set_axis_mask  
 
+  SUBROUTINE init_scalar(scalar_id, comm, params,  return_mask)
+  IMPLICIT NONE 
+     CHARACTER(LEN=*) :: scalar_id
+     TYPE(tmodel_params) :: params
+     INTEGER             :: comm
+     LOGICAL             :: return_mask
+     DOUBLE PRECISION    :: value =10.
+
+    CALL set_scalar_mask(comm, params, return_mask)    
+    CALL xios_set_scalar_attr(scalar_id, value=value, mask=return_mask) 
+
+  END SUBROUTINE init_scalar
+
+  SUBROUTINE set_scalar_mask(comm, params, mask)
+   IMPLICIT NONE 
+     TYPE(tmodel_params) :: params
+     INTEGER             :: comm
+     LOGICAL             :: mask
+     INTEGER             :: ierr,rank
+
+     mask=.TRUE.
+     IF (params%scalar_mask) THEN
+       IF (params%scalar_mask_type=="none") THEN
+         mask=.TRUE.
+       ELSE IF (params%scalar_mask_type=="full") THEN
+         mask=.FALSE.
+       ELSE IF (params%scalar_mask_type=="root") THEN
+         CALL MPI_COMM_RANK(comm,rank,ierr)
+         mask = (rank==0)
+       ELSE IF (params%scalar_mask_type=="sparse") THEN
+         CALL MPI_COMM_RANK(comm,rank,ierr)
+         mask = (MOD(rank,2)==0)
+      ENDIF 
+     ENDIF
+
+  END SUBROUTINE set_scalar_mask
+
   SUBROUTINE init_field2D_academic(comm,params, lon, lat, mask, return_field,            &
                                    X_lon, X_lat, X_mask, return_fieldX,                  &
