Index: /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8296)
+++ /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8297)
@@ -41,5 +41,5 @@
    USE dianam          ! build name of file
    USE xios
-   USE iom_def, ONLY : max_rst_fields, rst_fields, wxioso
+   USE iom_def, ONLY : wxioso
 # endif
    USE ioipsl, ONLY :  ju2ymds    ! for calendar
@@ -68,5 +68,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_update_file_name, iom_sdate
-   PRIVATE set_rst_vars, set_rstw_active
+   PRIVATE set_rstw_active
 # endif
 
@@ -241,6 +241,4 @@
       ! automatic definitions of some of the xml attributs
       IF( TRIM(cdname) == TRIM(wxios_context)) THEN
-!set names of the fields in restart file IF using XIOS to read/write data
-       CALL set_rst_vars()
 !set which fields are to be read from restart file
        CALL set_rstw_active(filename, it)
@@ -263,105 +261,4 @@
 
    END SUBROUTINE iom_init
-
-   
-   SUBROUTINE set_rst_vars()
-!set names for variables in restart file
-
-        rst_fields(:)%vname="NO_NAME";         rst_fields(:)%grid="NO_GRID"
-
-        rst_fields(1)%vname="rdt";             rst_fields(1)% grid="grid_scalar"
-        rst_fields(2)%vname="rdttra1";         rst_fields(2)% grid="grid_scalar"      
-        rst_fields(3)%vname="un";              rst_fields(3)% grid="grid_N_3D"
-        rst_fields(4)%vname="ub";              rst_fields(4)% grid="grid_N_3D"
-        rst_fields(5)%vname="vn";              rst_fields(5)% grid="grid_N_3D"
-        rst_fields(6)%vname="vb";              rst_fields(6)% grid="grid_N_3D"  
-        rst_fields(7)%vname="tn";              rst_fields(7)% grid="grid_N_3D"
-        rst_fields(8)%vname="tb";              rst_fields(8)% grid="grid_N_3D"
-        rst_fields(9)%vname="sn";              rst_fields(9)% grid="grid_N_3D"
-        rst_fields(10)%vname="sb";             rst_fields(10)%grid="grid_N_3D"
-        rst_fields(11)%vname="sshn";           rst_fields(11)%grid="grid_N"
-        rst_fields(12)%vname="sshb";           rst_fields(12)%grid="grid_N"
-        rst_fields(13)%vname="hdivn";          rst_fields(13)%grid="grid_N_3D"
-        rst_fields(14)%vname="hdivb";          rst_fields(14)%grid="grid_N_3D"
-        rst_fields(15)%vname="rhop";           rst_fields(15)%grid="grid_N_3D"
-        rst_fields(16)%vname="rotn";           rst_fields(16)%grid="grid_N_3D"
-        rst_fields(17)%vname="rotb";           rst_fields(17)%grid="grid_N_3D"
-        rst_fields(18)%vname="kt";             rst_fields(18)%grid="grid_scalar"
-        rst_fields(19)%vname="ndastp";         rst_fields(19)%grid="grid_scalar"
-        rst_fields(20)%vname="adatrj";         rst_fields(20)%grid="grid_scalar"
-        rst_fields(21)%vname="utau_b";         rst_fields(21)%grid="grid_N"
-        rst_fields(22)%vname="vtau_b";         rst_fields(22)%grid="grid_N"
-        rst_fields(23)%vname="qns_b";          rst_fields(23)%grid="grid_N"
-        rst_fields(24)%vname="emp_b";          rst_fields(24)%grid="grid_N"
-        rst_fields(25)%vname="sfx_b";          rst_fields(25)%grid="grid_N"
-        rst_fields(26)%vname="en" ;            rst_fields(26)%grid="grid_N_3D" 
-        rst_fields(27)%vname="avt";            rst_fields(27)%grid="grid_N_3D"
-        rst_fields(28)%vname="avm";            rst_fields(28)%grid="grid_N_3D"
-        rst_fields(29)%vname="avmu";           rst_fields(29)%grid="grid_N_3D"
-        rst_fields(30)%vname="avmv";           rst_fields(30)%grid="grid_N_3D"
-        rst_fields(31)%vname="dissl";          rst_fields(31)%grid="grid_N_3D"
-        rst_fields(32)%vname="sbc_hc_b";       rst_fields(32)%grid="grid_N"
-        rst_fields(33)%vname="sbc_sc_b";       rst_fields(33)%grid="grid_N"
-        rst_fields(34)%vname="qsr_hc_b";       rst_fields(34)%grid="grid_N_3D"
-        rst_fields(35)%vname="gcx";            rst_fields(35)%grid="grid_N"
-        rst_fields(36)%vname="gcxb";           rst_fields(36)%grid="grid_N"
-        rst_fields(37)%vname="fraqsr_1lev";    rst_fields(37)%grid="grid_N"
-        rst_fields(38)%vname="greenland_icesheet_mass"
-                                               rst_fields(38)%grid="grid_scalar"
-        rst_fields(39)%vname="greenland_icesheet_timelapsed"
-                                               rst_fields(39)%grid="grid_scalar"
-        rst_fields(40)%vname="greenland_icesheet_mass_roc"
-                                               rst_fields(40)%grid="grid_scalar"
-        rst_fields(41)%vname="antarctica_icesheet_mass"
-                                               rst_fields(41)%grid="grid_scalar"
-        rst_fields(42)%vname="antarctica_icesheet_timelapsed"
-                                               rst_fields(42)%grid="grid_scalar"
-        rst_fields(43)%vname="antarctica_icesheet_mass_roc"
-                                               rst_fields(43)%grid="grid_scalar"
-        rst_fields(44)%vname="rhd";            rst_fields(44)%grid="grid_N_3D"
-        rst_fields(45)%vname="frc_v";          rst_fields(45)%grid="grid_scalar"
-        rst_fields(46)%vname="frc_t";          rst_fields(46)%grid="grid_scalar"
-        rst_fields(47)%vname="frc_s";          rst_fields(47)%grid="grid_scalar"
-        rst_fields(48)%vname="frc_wn_t";       rst_fields(48)%grid="grid_scalar"
-        rst_fields(49)%vname="frc_wn_s";       rst_fields(49)%grid="grid_scalar"
-        rst_fields(50)%vname="ssh_ini";        rst_fields(50)%grid="grid_N"
-        rst_fields(51)%vname="e3t_ini";        rst_fields(51)%grid="grid_N_3D"
-        rst_fields(52)%vname="hc_loc_ini";     rst_fields(52)%grid="grid_N_3D"
-        rst_fields(53)%vname="sc_loc_ini";     rst_fields(53)%grid="grid_N_3D"
-        rst_fields(54)%vname="ssh_hc_loc_ini"; rst_fields(54)%grid="grid_N"
-        rst_fields(55)%vname="ssh_sc_loc_ini"; rst_fields(55)%grid="grid_N"
-        rst_fields(56)%vname="fse3t_b";        rst_fields(56)%grid="grid_N_3D"
-        rst_fields(57)%vname="fse3t_n";        rst_fields(57)%grid="grid_N_3D"
-        rst_fields(58)%vname="tilde_e3t_b";    rst_fields(58)%grid="grid_N"
-        rst_fields(59)%vname="tilde_e3t_n";    rst_fields(59)%grid="grid_N"
-        rst_fields(60)%vname="hdiv_lf";        rst_fields(60)%grid="grid_N"
-        rst_fields(61)%vname="ub2_b";          rst_fields(61)%grid="grid_N"
-        rst_fields(62)%vname="vb2_b";          rst_fields(62)%grid="grid_N"
-        rst_fields(63)%vname="sshbb_e";        rst_fields(63)%grid="grid_N"
-        rst_fields(64)%vname="ubb_e";          rst_fields(64)%grid="grid_N"
-        rst_fields(65)%vname="vbb_e";          rst_fields(65)%grid="grid_N"
-        rst_fields(66)%vname="sshb_e";         rst_fields(66)%grid="grid_N"
-        rst_fields(67)%vname="ub_e";           rst_fields(67)%grid="grid_N"
-        rst_fields(68)%vname="vb_e";           rst_fields(68)%grid="grid_N"
-        rst_fields(69)%vname="fwf_isf_b";      rst_fields(69)%grid="grid_N"
-        rst_fields(70)%vname="isf_sc_b";       rst_fields(70)%grid="grid_N"
-        rst_fields(71)%vname="isf_hc_b";       rst_fields(71)%grid="grid_N"
-        rst_fields(72)%vname="ssh_ibb";        rst_fields(72)%grid="grid_N"
-        rst_fields(73)%vname="rnf_b";          rst_fields(73)%grid="grid_N"
-        rst_fields(74)%vname="rnf_hc_b";       rst_fields(74)%grid="grid_N"
-        rst_fields(75)%vname="rnf_sc_b";       rst_fields(75)%grid="grid_N"
-        rst_fields(76)%vname="nn_fsbc";        rst_fields(76)%grid="grid_scalar"
-        rst_fields(77)%vname="ssu_m";          rst_fields(77)%grid="grid_N"
-        rst_fields(78)%vname="ssv_m";          rst_fields(78)%grid="grid_N"
-        rst_fields(79)%vname="sst_m";          rst_fields(79)%grid="grid_N"
-        rst_fields(80)%vname="sss_m";          rst_fields(80)%grid="grid_N"
-        rst_fields(81)%vname="ssh_m";          rst_fields(81)%grid="grid_N"
-        rst_fields(82)%vname="e3t_m";          rst_fields(82)%grid="grid_N"
-        rst_fields(83)%vname="frq_m";          rst_fields(83)%grid="grid_N"
-        rst_fields(84)%vname="avmb";           rst_fields(84)%grid="Vgrid"
-        rst_fields(85)%vname="avtb";           rst_fields(85)%grid="Vgrid"
-
-   END SUBROUTINE set_rst_vars
-
 
    SUBROUTINE set_rstw_active(rst_file, it)
@@ -372,5 +269,4 @@
    TYPE(xios_file) :: file_hdl
    TYPE(xios_filegroup) :: filegroup_hdl
-   INTEGER :: i
 
 !set then name of the restart file (OUTPUT!) and enable available fields
@@ -389,126 +285,260 @@
 
         CALL xios_set_file_attr( "wrestart", name=trim(rst_file))
-        call flush(numout) 
-!      CALL xios_update_calendar(it+1)       ! + one because we open restart file 
-                                              ! 1 timestep before write
-
-!define fields for restart write context
-!in restart.F90
-        DO i= 1, 17
-           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+
+        CALL xios_add_child(file_hdl, field_hdl, "rdt")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "rdttra1")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "un")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "ub")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "vn")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "vb")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "tn")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "tb")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "sn")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "sb")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "sshn")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "sshb")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "hdivn")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "hdivb")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "rhop")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "rotn")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+        CALL xios_add_child(file_hdl, field_hdl, "rotb")
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+
+!in daymod.F90
+           CALL xios_add_child(file_hdl, field_hdl, "kt")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
-!in daymod.F90
-        DO i= 18, 20
-                      CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                     grid_ref = "grid_scalar", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "ndastp")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
+                     grid_ref = "grid_scalar", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "adatrj")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_scalar", operation = "instant")
 !end daymod.F90
 !sbcmod.F90
-        DO i= 21, 25
-           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_add_child(file_hdl, field_hdl, "utau_b")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "vtau_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "qns_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "emp_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "sfx_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
 !end sbcmod.F90
 !ALL FIELDS ABOUVE ALWAYS
 !zdftke.F90
 #if defined key_zdftke   ||   defined key_esopa
-        DO i= 26, 31
-           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_add_child(file_hdl, field_hdl, "en")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
+                     grid_ref = "grid_N_3D", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "avt")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N_3D", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "avm")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N_3D", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "avmu")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N_3D", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "avmv")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N_3D", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "dissl")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N_3D", operation = "instant")
 #endif
 !end zdftke.F90
 !traqsr.F90
-       i = 34
-       CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+       CALL xios_add_child(file_hdl, field_hdl, "qsr_hc_b")
        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")        
-       if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-       i = 37
-       CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                     grid_ref = "grid_N_3D" , operation = "instant")        
+
+       CALL xios_add_child(file_hdl, field_hdl, "fraqsr_1lev")
        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")        
-       if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+                     grid_ref = "grid_N", operation = "instant")        
 !END traqsr.F90
 #if defined key_dynspg_flt   ||   defined key_esopa 
 !dynspg_flt.F90
-        DO i= 35, 36
-           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_add_child(file_hdl, field_hdl, "gcx")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "gcxb")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
 !end dynspg_flt.F90
 #endif
 !trasbc.F90 START
-        DO i= 32, 33
-           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_add_child(file_hdl, field_hdl, "sbc_hc_b")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
-        DO i= 69, 71
-           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "sbc_sc_b")
            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-        ENDDO
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "fwf_isf_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "isf_sc_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
+
+           CALL xios_add_child(file_hdl, field_hdl, "isf_hc_b")
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
 !trasbc.F90 END
         IF( lk_oasis) THEN
         ! ln_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true
           IF( ln_coupled_iceshelf_fluxes ) THEN
-             DO i= 38, 43
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
+             CALL xios_add_child(file_hdl, field_hdl, "greenland_icesheet_mass")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "greenland_icesheet_timelapsed")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "greenland_icesheet_mass_roc")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "antarctica_icesheet_mass")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "antarctica_icesheet_timelapsed")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "antarctica_icesheet_mass_roc")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
           ENDIF
         ENDIF
 #if defined key_zdfkpp
-        i = 44
-        CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+        CALL xios_add_child(file_hdl, field_hdl, "rhd")
         CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-             grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-        if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             grid_ref = "grid_N_3D", operation = "instant")
 #endif
 !dia_hsb_rst
 #if defined key_diadct
         IF( lk_diadct     ) THEN
-             DO i= 45, 47
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+             CALL xios_add_child(file_hdl, field_hdl, "frc_v")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "frc_t")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "frc_s")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "ssh_ini")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "e3t_ini")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "hc_loc_ini")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "sc_loc_ini")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+
+             IF( .NOT. lk_vvl ) THEN
+                CALL xios_add_child(file_hdl, field_hdl, "frc_wn_t")
                 CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
-
-             DO i= 50, 53
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                     grid_ref = "grid_scalar", operation = "instant")
+
+                CALL xios_add_child(file_hdl, field_hdl, "frc_wn_s")
                 CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
-             IF( .NOT. lk_vvl ) THEN
-             DO i= 48, 48
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                     grid_ref = "grid_scalar", operation = "instant")
+
+                CALL xios_add_child(file_hdl, field_hdl, "ssh_hc_loc_ini")
                 CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
-             DO i= 54, 55
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                     grid_ref = "grid_N", operation = "instant")
+
+                CALL xios_add_child(file_hdl, field_hdl, "ssh_sc_loc_ini")
                 CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
+                     grid_ref = "grid_N", operation = "instant")
+
+
              ENDIF
         ENDIF
@@ -517,24 +547,25 @@
 !domvvl.F90
         IF( lk_vvl ) THEN
-             DO i= 56, 57
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
+             CALL xios_add_child(file_hdl, field_hdl, "fse3t_b")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "fse3t_n")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N_3D", operation = "instant")
+
            IF( lr_vvl_ztilde .OR. lr_vvl_layer ) THEN  ! z_tilde and layer cases !
-             DO i= 58, 59
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
+             CALL xios_add_child(file_hdl, field_hdl, "tilde_e3t_b")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "tilde_e3t_n")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
             END IF
             IF( lr_vvl_ztilde ) THEN                    ! z_tilde case !
-            i=60
-            CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+            CALL xios_add_child(file_hdl, field_hdl, "hdiv_lf")
             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-            if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+                     grid_ref = "grid_N", operation = "instant")
             ENDIF
          ENDIF
@@ -542,27 +573,48 @@
 !dynspg_ts.F90
 #if defined key_dynspg_ts   ||   defined key_esopa
-         DO i= 61, 62
-            CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+         CALL xios_add_child(file_hdl, field_hdl, "ub2_b")
+         CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+              grid_ref = "grid_N", operation = "instant")
+
+         CALL xios_add_child(file_hdl, field_hdl, "vb2_b")
+         CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+              grid_ref = "grid_N", operation = "instant")
+
+
+         IF (.NOT.ln_bt_av) THEN
+            CALL xios_add_child(file_hdl, field_hdl, "sshbb_e")
             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                 grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-            if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-         ENDDO
-         IF (.NOT.ln_bt_av) THEN
-            DO i= 63, 68
-               CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-               CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                    grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-               if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-            ENDDO
+                 grid_ref = "grid_N", operation = "instant")
+
+            CALL xios_add_child(file_hdl, field_hdl, "ubb_e")
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                 grid_ref = "grid_N", operation = "instant")
+
+            CALL xios_add_child(file_hdl, field_hdl, "vbb_e")
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                 grid_ref = "grid_N", operation = "instant")
+
+            CALL xios_add_child(file_hdl, field_hdl, "sshb_e")
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                 grid_ref = "grid_N", operation = "instant")
+
+            CALL xios_add_child(file_hdl, field_hdl, "ub_e")
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                 grid_ref = "grid_N", operation = "instant")
+
+            CALL xios_add_child(file_hdl, field_hdl, "vb_e")
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                 grid_ref = "grid_N", operation = "instant")
          ENDIF
 #if defined key_agrif
          ! Save time integrated fluxes
          IF ( .NOT.Agrif_Root() ) THEN
-            DO i= 84, 85
-               CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+               CALL xios_add_child(file_hdl, field_hdl, "ub2_i_b")
                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                    grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-               if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-            ENDDO
+                    grid_ref = "GRID_N", operation = "instant")
+
+               CALL xios_add_child(file_hdl, field_hdl, "vb2_i_b")
+               CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                    grid_ref = "grid_N", operation = "instant")
          ENDIF
 #endif
@@ -571,50 +623,69 @@
 !sbcapr.F90
           IF( ln_apr_dyn) THEN
-             i = 72
-             CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-             if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             CALL xios_add_child(file_hdl, field_hdl, "ssh_ibb")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
           ENDIF
 !end sbcapr.F90
 !sbcrnf.F90
         IF( ln_rnf      ) THEN
-             DO i= 73, 75
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
+             CALL xios_add_child(file_hdl, field_hdl, "rnf_b")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "rnf_hc_b")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "rnf_sc_b")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
         ENDIF 
 !end sbcrnf.F90
 !sbcssm.F90
         IF( nn_components /= jp_iam_sas .AND. nn_fsbc .NE. 1) THEN
-             DO i= 76, 81
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+             CALL xios_add_child(file_hdl, field_hdl, "nn_fsbc")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_scalar", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "ssu_m")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "ssv_m")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "sst_m")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "sss_m")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "ssh_m")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                  grid_ref = "grid_N", operation = "instant")
+
+             CALL xios_add_child(file_hdl, field_hdl, "frq_m")
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = "grid_N", operation = "instant")
+
+             IF( lk_vvl )  THEN
+                CALL xios_add_child(file_hdl, field_hdl, "e3t_m")
                 CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
-             i = 83
-             CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-             if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             IF( lk_vvl )  THEN
-                i = 82
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+                     grid_ref = "grid_N", operation = "instant")
              ENDIF 
         ENDIF
 !end sbcssm.F90
        IF( lr_traadv_cen2   ) THEN
-            DO i= 84, 85
-                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
-                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
-                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
-                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
-             ENDDO
+          CALL xios_add_child(file_hdl, field_hdl, "avmb")
+          CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+               grid_ref = "Vgrid", operation = "instant")
+
+          CALL xios_add_child(file_hdl, field_hdl, "avtb")
+          CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+               grid_ref = "Vgrid", operation = "instant")
        ENDIF
 
Index: /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90
===================================================================
--- /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8296)
+++ /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8297)
@@ -75,14 +75,4 @@
    END TYPE file_descriptor
    TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
-
-   INTEGER, PARAMETER, PUBLIC                   :: max_rst_fields = 85  
-
-
-   TYPE, PUBLIC :: RST_FIELD  
-    CHARACTER(len=30) :: vname ! names of variables in restart file
-    CHARACTER(len=30) :: grid
-   END TYPE RST_FIELD
-   TYPE(RST_FIELD), PUBLIC :: rst_fields(max_rst_fields)
-   !  values needed to set correctlyfiles in reast file when using XIOS for writing
 !$AGRIF_END_DO_NOT_TREAT
    !!=====================================================================
