Index: NEMO/branches/2020/test_12905_xios_restart/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2020/test_12905_xios_restart/src/OCE/IOM/iom.F90	(revision 13022)
+++ NEMO/branches/2020/test_12905_xios_restart/src/OCE/IOM/iom.F90	(revision 13023)
@@ -67,5 +67,5 @@
    PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr
    PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_sdate
-   PRIVATE iom_set_rst_context, iom_set_rstr_active
+   PRIVATE iom_set_rst_context, iom_set_vars_active
 # endif
    PRIVATE iom_set_rstw_active
@@ -280,5 +280,5 @@
              CALL iom_set_rst_context(.TRUE.)
 !set which fields will be read from restart file
-             CALL iom_set_rstr_active(fname, idfp)
+             CALL iom_set_vars_active(fname, idfp)
           ELSE
              CALL ctl_stop( 'iom_init:', 'restart read with XIOS: missing pointer to NETCDF file' )
@@ -342,13 +342,13 @@
    END SUBROUTINE iom_init_closedef
 
-   SUBROUTINE iom_set_rstr_active(cdfname, idnum)
+   SUBROUTINE iom_set_vars_active(cdfname, idnum)
       !!---------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_set_rstr_active  ***
-      !!
-      !! ** Purpose :  define file name in XIOS context for reading restart file,
-      !!               enable variables present in restart file for reading with XIOS 
+      !!                   ***  SUBROUTINE  iom_set_vars_active  ***
+      !!
+      !! ** Purpose :  define filename in XIOS context for reading file,
+      !!               enable variables present in a file for reading with XIOS 
+      !!               id of the file is assumed to be rrestart.
       !!---------------------------------------------------------------------
 
-!sets enabled = .TRUE. for each field in restart file
    CHARACTER(len=*), INTENT(IN) :: cdfname
    INTEGER         , INTENT(IN) :: idnum 
@@ -365,10 +365,4 @@
    LOGICAL                                    :: lmeta
 
-!failed to build with AGRIF
-!      meta(1:NMETA) = ["nav_lat",        &
-!            "nav_lon", "nav_lev", "time_instant",                  &
-!            "time_instant_bounds", "time_counter",                 &
-!            "time_counter_bounds", "x", "y", "numcat"]
-
         meta(1) = "nav_lat"
         meta(2) = "nav_lon"
@@ -382,5 +376,5 @@
         meta(10) = "numcat"
 
-        clinfo = '          iom_set_rstr_active, file: '//TRIM(cdfname)
+        clinfo = '          iom_set_vars_active, file: '//TRIM(cdfname)
 
         IF(lwp) write(numout, *) TRIM(clinfo)
@@ -413,6 +407,4 @@
             IF(.NOT.lmeta) THEN
                CALL xios_add_child(file_hdl, field_hdl, TRIM(varname))
-               if(lwp) write(numout, *) 'ADD field: ', TRIM(varname)
-               IF(lwp) CALL FLUSH(numout)
                mdims = ndims
 
@@ -422,34 +414,19 @@
 
                IF(mdims == 3) THEN
-                      if(lwp) write(numout, *) '3D', indimlens(ndims)
-                      IF(lwp) CALL FLUSH(numout)
-
                       CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname),   &
-                                   domain_ref="grid_N", axis_ref=TRIM(iom_axis(indimlens(ndims))), &
+                                   domain_ref="grid_N", axis_ref=TRIM(iom_axis(indimlens(dimids(mdims)))), &
                                    prec = 8, operation = "instant")
                ELSEIF(mdims == 2) THEN
-                      if(lwp) write(numout, *) '2D'
-                      IF(lwp) CALL FLUSH(numout)
-
                       CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), &
                                           domain_ref="grid_N", prec = 8, operation = "instant") 
                ELSEIF(mdims == 1) THEN
-                      if(lwp) write(numout, *) '1D', indimlens(ndims)
-                      IF(lwp) CALL FLUSH(numout)
-
                       CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), &
-                                          axis_ref=TRIM(iom_axis(indimlens(ndims))), prec = 8, operation = "instant")
+                                          axis_ref=TRIM(iom_axis(indimlens(dimids(mdims)))), prec = 8, operation = "instant")
                ELSEIF(mdims == 0) THEN
-                      if(lwp) write(numout, *) '0D'
-                      IF(lwp) CALL FLUSH(numout)
-
                       CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), &
                                                 scalar_ref = "grid_scalar", prec = 8, operation = "instant")
                ELSE
-                      if(lwp) write(numout, *) 'WAHT?'
-                      IF(lwp) CALL FLUSH(numout)
-
-                      WRITE(ctmp1,*) 'iom_set_rstr_active: variable ', TRIM(varname) ,' incorrect number of dimensions' 
-                      CALL ctl_stop( 'iom_set_rstr_active:', ctmp1 )
+                      WRITE(ctmp1,*) 'iom_set_vars_active: variable ', TRIM(varname) ,' incorrect number of dimensions' 
+                      CALL ctl_stop( 'iom_set_vars_active:', ctmp1 )
                ENDIF
             ENDIF
@@ -457,5 +434,5 @@
         DEALLOCATE(indimlens, indimnames)
 #endif
-   END SUBROUTINE iom_set_rstr_active
+   END SUBROUTINE iom_set_vars_active
 
    SUBROUTINE iom_set_rstw_file(cdrst_file)
