Index: /branches/2017/dev_r7864_XIOS_defs/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/2017/dev_r7864_XIOS_defs/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7866)
+++ /branches/2017/dev_r7864_XIOS_defs/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7867)
@@ -170,10 +170,4 @@
       ENDIF
 
-      ! vertical grid definition
-      CALL iom_set_axis_attr( "deptht", gdept_1d )
-      CALL iom_set_axis_attr( "depthu", gdept_1d )
-      CALL iom_set_axis_attr( "depthv", gdept_1d )
-      CALL iom_set_axis_attr( "depthw", gdepw_1d )
-
       ! Add vertical grid bounds
       jkmin = MIN(2,jpk)  ! in case jpk=1 (i.e. sas2D)
@@ -184,8 +178,8 @@
       zw_bnds(2,1:jpkm1  ) = gdepw_1d(jkmin:jpk)
       zw_bnds(2,jpk:     ) = gdepw_1d(jpk) + e3t_1d(jpk)
-      CALL iom_set_axis_attr( "deptht", bounds=zt_bnds )
-      CALL iom_set_axis_attr( "depthu", bounds=zt_bnds )
-      CALL iom_set_axis_attr( "depthv", bounds=zt_bnds )
-      CALL iom_set_axis_attr( "depthw", bounds=zw_bnds )
+      CALL iom_set_axis_attr( "deptht", paxis=gdept_1d, bounds=zt_bnds )
+      CALL iom_set_axis_attr( "depthu", paxis=gdept_1d, bounds=zt_bnds )
+      CALL iom_set_axis_attr( "depthv", paxis=gdept_1d, bounds=zt_bnds )
+      CALL iom_set_axis_attr( "depthw", paxis=gdepw_1d, bounds=zw_bnds )
 
 
@@ -1256,14 +1250,44 @@
 
       IF ( xios_is_valid_domain     (cdid) ) THEN
-         CALL xios_set_domain_attr     ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   &
-            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   &
-            &    lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon,      &
-            &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear')
+         CALL xios_set_domain_attr     ( cdid, type='curvilinear')
+         IF(PRESENT (ni_glo))        CALL xios_set_domain_attr     ( cdid, ni_glo=ni_glo)
+         IF(PRESENT (nj_glo))        CALL xios_set_domain_attr     ( cdid, nj_glo=nj_glo)
+         IF(PRESENT (ibegin))        CALL xios_set_domain_attr     ( cdid, ibegin=ibegin)
+         IF(PRESENT (jbegin))        CALL xios_set_domain_attr     ( cdid, jbegin=jbegin)
+         IF(PRESENT (ni))            CALL xios_set_domain_attr     ( cdid, ni=ni)
+         IF(PRESENT (nj))            CALL xios_set_domain_attr     ( cdid, nj=nj)
+         IF(PRESENT (data_dim))      CALL xios_set_domain_attr     ( cdid, data_dim=data_dim)
+         IF(PRESENT (data_ibegin))   CALL xios_set_domain_attr     ( cdid, data_ibegin=data_ibegin)
+         IF(PRESENT (data_ni))       CALL xios_set_domain_attr     ( cdid, data_ni=data_ni)
+         IF(PRESENT (data_jbegin))   CALL xios_set_domain_attr     ( cdid, data_jbegin=data_jbegin)
+         IF(PRESENT (data_nj))       CALL xios_set_domain_attr     ( cdid, data_nj=data_nj)
+         IF(PRESENT (lonvalue))   CALL xios_set_domain_attr     ( cdid, lonvalue_1D=lonvalue)
+         IF(PRESENT (latvalue))   CALL xios_set_domain_attr     ( cdid, latvalue_1D=latvalue)
+         IF(PRESENT (mask))       CALL xios_set_domain_attr     ( cdid, mask_1D=mask)
+         IF(PRESENT (nvertex))       CALL xios_set_domain_attr     ( cdid, nvertex=nvertex)
+         IF(PRESENT (bounds_lon)) CALL xios_set_domain_attr     ( cdid, bounds_lon_1D=bounds_lon )
+         IF(PRESENT (bounds_lat)) CALL xios_set_domain_attr     ( cdid, bounds_lat_1D=bounds_lat)
+         IF(PRESENT (area))          CALL xios_set_domain_attr     ( cdid, area=area)
      ENDIF
       IF ( xios_is_valid_domaingroup(cdid) ) THEN
-         CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   &
-            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   &
-            &    lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon,      &
-            &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear' )
+         CALL xios_set_domaingroup_attr     ( cdid, type='curvilinear')
+         IF(PRESENT (ni_glo))        CALL xios_set_domaingroup_attr     ( cdid, ni_glo=ni_glo )
+         IF(PRESENT (nj_glo))        CALL xios_set_domaingroup_attr     ( cdid, nj_glo=nj_glo )
+         IF(PRESENT (ibegin))        CALL xios_set_domaingroup_attr     ( cdid, ibegin=ibegin )
+         IF(PRESENT (jbegin))        CALL xios_set_domaingroup_attr     ( cdid, jbegin=jbegin )
+         IF(PRESENT (ni))            CALL xios_set_domaingroup_attr     ( cdid, ni=ni )
+         IF(PRESENT (nj))            CALL xios_set_domaingroup_attr     ( cdid, nj=nj )
+         IF(PRESENT (data_dim))      CALL xios_set_domaingroup_attr     ( cdid, data_dim=data_dim )
+         IF(PRESENT (data_ibegin))   CALL xios_set_domaingroup_attr     ( cdid, data_ibegin=data_ibegin )
+         IF(PRESENT (data_ni))       CALL xios_set_domaingroup_attr     ( cdid, data_ni=data_ni )
+         IF(PRESENT (data_jbegin))   CALL xios_set_domaingroup_attr     ( cdid, data_jbegin=data_jbegin )
+         IF(PRESENT (data_nj))       CALL xios_set_domaingroup_attr     ( cdid, data_nj=data_nj )
+         IF(PRESENT (lonvalue))   CALL xios_set_domaingroup_attr     ( cdid, lonvalue_1D=lonvalue )
+         IF(PRESENT (latvalue))   CALL xios_set_domaingroup_attr     ( cdid, latvalue_1D=latvalue )
+         IF(PRESENT (mask))       CALL xios_set_domaingroup_attr     ( cdid, mask_1D=mask )
+         IF(PRESENT (nvertex))       CALL xios_set_domaingroup_attr     ( cdid, nvertex=nvertex )
+         IF(PRESENT (bounds_lon)) CALL xios_set_domaingroup_attr     ( cdid, bounds_lon_1D=bounds_lon )
+         IF(PRESENT (bounds_lat)) CALL xios_set_domaingroup_attr     ( cdid, bounds_lat_1D=bounds_lat )
+         IF(PRESENT (area))          CALL xios_set_domaingroup_attr     ( cdid, area=area )
       ENDIF
 
@@ -1278,6 +1302,8 @@
 
       IF ( xios_is_valid_zoom_domain     (cdid) ) THEN
-          CALL xios_set_zoom_domain_attr     ( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni,    &
-            &   nj=nj)
+          IF(PRESENT(ibegin)) CALL xios_set_zoom_domain_attr     ( cdid, ibegin=ibegin)
+          IF(PRESENT(jbegin)) CALL xios_set_zoom_domain_attr     ( cdid, jbegin=jbegin)
+          IF(PRESENT(nj)) CALL xios_set_zoom_domain_attr     ( cdid, ni=ni)
+          IF(PRESENT(ni)) CALL xios_set_zoom_domain_attr     ( cdid, nj=nj)
      ENDIF
    END SUBROUTINE iom_set_zoom_domain_attr
@@ -1293,6 +1319,8 @@
          IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis )
       ENDIF
-      IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds )
-      IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds )
+      IF ( PRESENT(bounds) ) THEN
+         IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds )
+         IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds )
+      ENDIF
       CALL xios_solve_inheritance()
    END SUBROUTINE iom_set_axis_attr
@@ -1303,8 +1331,12 @@
       TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_op
       TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_offset
-      IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr       &
-    &     ( cdid, freq_op=freq_op, freq_offset=freq_offset )
-      IF ( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr  &
-    &                    ( cdid, freq_op=freq_op, freq_offset=freq_offset )
+      IF ( PRESENT(freq_op) ) THEN
+         IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr( cdid, freq_op=freq_op )
+         IF ( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr( cdid, freq_op=freq_op )
+      ENDIF
+      IF ( PRESENT(freq_offset) ) THEN
+         IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr( cdid, freq_offset=freq_offset )
+         IF ( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr( cdid, freq_offset=freq_offset )
+      ENDIF
       CALL xios_solve_inheritance()
    END SUBROUTINE iom_set_field_attr
@@ -1314,6 +1346,12 @@
       CHARACTER(LEN=*)          , INTENT(in) ::   cdid
       CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   name, name_suffix
-      IF ( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name, name_suffix=name_suffix )
-      IF ( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix )
+      IF ( PRESENT(name) ) THEN
+         IF ( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name )
+         IF ( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name )
+      ENDIF
+      IF ( PRESENT(name_suffix) ) THEN
+         IF ( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name_suffix=name_suffix )
+         IF ( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name_suffix=name_suffix )
+      ENDIF
       CALL xios_solve_inheritance()
    END SUBROUTINE iom_set_file_attr
@@ -1349,6 +1387,8 @@
       CHARACTER(LEN=*)                   , INTENT(in) ::   cdid
       LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) ::   mask
-      IF ( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask_3D=mask )
-      IF ( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask_3D=mask )
+      IF( PRESENT(mask)) THEN
+         IF ( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask_3D=mask )
+         IF ( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask_3D=mask )
+      ENDIF
       CALL xios_solve_inheritance()
    END SUBROUTINE iom_set_grid_attr
