Index: branches/NERC/dev_r3874_FASTNEt/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/NERC/dev_r3874_FASTNEt/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 6735)
+++ branches/NERC/dev_r3874_FASTNEt/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 6736)
@@ -7,5 +7,6 @@
    !!            2.0  ! 2006-02  (S. Masson) Adaptation to NEMO
    !!            3.0  ! 2007-07  (D. Storkey) Changes to iom_gettime
-   !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add C1D case  
+   !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add C1D case 
+   !!            3.4  ! 2013-04  (J. Harle)  added real attribute case 
    !!--------------------------------------------------------------------
 
@@ -30,9 +31,9 @@
 #if defined key_iomput
    USE sbc_oce, ONLY :   nn_fsbc         ! ocean space and time domain
-   USE trc_oce, ONLY :   nn_dttrc        !  !: frequency of step on passive tracers
    USE domngb          ! ocean space and time domain
    USE phycst          ! physical constants
    USE dianam          ! build name of file
-   USE xios
+   USE mod_event_client
+   USE mod_attribut
 # endif
 
@@ -52,6 +53,5 @@
    PRIVATE iom_p1d, iom_p2d, iom_p3d
 #if defined key_iomput
-   PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_set_grid_attr
-   PRIVATE set_grid, set_scalar, set_xmlatt, set_mooring
+   PRIVATE set_grid
 # endif
 
@@ -60,5 +60,5 @@
    END INTERFACE
    INTERFACE iom_getatt
-      MODULE PROCEDURE iom_g0d_intatt
+      MODULE PROCEDURE iom_g0d_intatt, iom_g0d_ratt
    END INTERFACE
    INTERFACE iom_rstput
@@ -70,5 +70,5 @@
 #if defined key_iomput
    INTERFACE iom_setkt
-      MODULE PROCEDURE xios_update_calendar
+      MODULE PROCEDURE event__set_timestep
    END INTERFACE
 # endif
@@ -90,38 +90,46 @@
       !!----------------------------------------------------------------------
 #if defined key_iomput
-      TYPE(xios_time)   :: dtime    = xios_time(0, 0, 0, 0, 0, 0)
-      CHARACTER(len=19) :: cldate 
-      CHARACTER(len=10) :: clname
-      INTEGER           ::   ji
-      !!----------------------------------------------------------------------
-
-      clname = "nemo"
-      IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
-      CALL xios_context_initialize(TRIM(clname), mpi_comm_opa)
+      REAL(wp) ::   ztmp
+      !!----------------------------------------------------------------------
+!if defined key_adam
+!     REAL(wp)        ,DIMENSION( 2833) ::   zlon
+!     REAL(wp)        ,DIMENSION( 2833) ::   zlat
+!  include "NA_lons.h90"      
+!  include "NA_lats.h90"      
+!endif
+      ! read the xml file
+      IF( Agrif_Root() ) CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)...
       CALL iom_swap
 
       ! calendar parameters
       SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
-      CASE ( 1)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "Gregorian")
-      CASE ( 0)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "NoLeap")
-      CASE (30)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "D360")
+      CASE ( 1)   ;   CALL event__set_calendar('gregorian')
+      CASE ( 0)   ;   CALL event__set_calendar('noleap'   )
+      CASE (30)   ;   CALL event__set_calendar('360d'     )
       END SELECT
-      WRITE(cldate,"(i4.4,'-',i2.2,'-',i2.2,' 00:00:00')") nyear,nmonth,nday 
-      CALL xios_set_context_attr(TRIM(clname), start_date=cldate )
+      ztmp = fjulday - adatrj
+      IF( ABS(ztmp  - REAL(NINT(ztmp),wp)) < 0.1 / rday )   ztmp = REAL(NINT(ztmp),wp)   ! avoid truncation error
+      CALL event__set_time_parameters( nit000 - 1, ztmp, rdt )
 
       ! horizontal grid definition
       CALL set_scalar
-      CALL set_grid( "T", glamt, gphit ) 
-      CALL set_grid( "U", glamu, gphiu )
-      CALL set_grid( "V", glamv, gphiv )
-      CALL set_grid( "W", glamt, gphit )
+#if defined key_adam
+!     CALL set_grid( "grid_A", zlon, zlat )
+      WRITE(*,*) 'A0'
+      CALL set_adam_mooring
+      WRITE(*,*) 'A1'
+#endif
+      CALL set_grid( "grid_T", glamt, gphit )
+      CALL set_grid( "grid_U", glamu, gphiu )
+      CALL set_grid( "grid_V", glamv, gphiv )
+      CALL set_grid( "grid_W", glamt, gphit )
 
       ! vertical grid definition
-      CALL iom_set_axis_attr( "deptht", gdept_0 )
-      CALL iom_set_axis_attr( "depthu", gdept_0 )
-      CALL iom_set_axis_attr( "depthv", gdept_0 )
-      CALL iom_set_axis_attr( "depthw", gdepw_0 )
+      CALL event__set_vert_axis( "deptht", gdept_0 )
+      CALL event__set_vert_axis( "depthu", gdept_0 )
+      CALL event__set_vert_axis( "depthv", gdept_0 )
+      CALL event__set_vert_axis( "depthw", gdepw_0 )
 # if defined key_floats
-      CALL iom_set_axis_attr( "nfloat", (ji, ji=1,nfloat) )
+      CALL event__set_vert_axis( "nfloat", REAL(nfloat,wp)  )
 # endif
       
@@ -130,9 +138,5 @@
 
       ! end file definition
-       dtime%second=rdt
-       CALL xios_set_timestep(dtime)
-       CALL xios_close_context_definition()
-
-       CALL xios_update_calendar(0)
+      CALL event__close_io_definition
 #endif
 
@@ -147,12 +151,10 @@
       !!---------------------------------------------------------------------
 #if defined key_iomput
-      TYPE(xios_context) :: nemo_hdl
 
      IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-        CALL xios_get_handle("nemo",nemo_hdl)
+        CALL event__swap_context("nemo")
      ELSE
-        CALL xios_get_handle(TRIM(Agrif_CFixed())//"_nemo",nemo_hdl)
+        CALL event__swap_context(TRIM(Agrif_CFixed())//"_nemo")
      ENDIF
-     CALL xios_set_current_context(nemo_hdl)
 
 #endif
@@ -360,4 +362,7 @@
          i_s = 1
          i_e = jpmax_files
+#if defined key_iomput
+         CALL event__stop_ioserver
+#endif
       ENDIF
 
@@ -855,8 +860,9 @@
    !!                   INTERFACE iom_getatt
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_g0d_intatt( kiomid, cdatt, pvar )
+   SUBROUTINE iom_g0d_intatt( kiomid, cdatt, pvar, cdvar )
       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      INTEGER         , INTENT(  out)                 ::   pvar      ! read field
+      INTEGER         , INTENT(  out)                 ::   pvar      ! written field
+      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
@@ -864,5 +870,5 @@
             SELECT CASE (iom_file(kiomid)%iolib)
             CASE (jpioipsl )   ;   CALL ctl_stop('iom_getatt: only nf90 available')
-            CASE (jpnf90   )   ;   CALL iom_nf90_getatt( kiomid, cdatt, pvar )
+            CASE (jpnf90   )   ;   CALL iom_nf90_getatt( kiomid, cdatt, pv_i0d=pvar )
             CASE (jprstdimg)   ;   CALL ctl_stop('iom_getatt: only nf90 available')
             CASE DEFAULT    
@@ -873,4 +879,26 @@
    END SUBROUTINE iom_g0d_intatt
 
+   SUBROUTINE iom_g0d_ratt( kiomid, cdatt, pvar, cdvar )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
+      REAL(wp)        , INTENT(  out)                 ::   pvar      ! written field
+      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpioipsl )   ;   CALL ctl_stop('iom_getatt: only nf90 available')
+            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
+                                      CALL iom_nf90_getatt( kiomid, cdatt, pv_r0d=pvar, cdvar=cdvar )
+                                   ELSE
+                                      CALL iom_nf90_getatt( kiomid, cdatt, pv_r0d=pvar )
+                                   ENDIF
+            CASE (jprstdimg)   ;   CALL ctl_stop('iom_getatt: only nf90 available')
+            CASE DEFAULT    
+               CALL ctl_stop( 'iom_g0d_att: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_g0d_ratt
 
    !!----------------------------------------------------------------------
@@ -973,5 +1001,5 @@
       REAL(wp)        , INTENT(in) ::   pfield0d
 #if defined key_iomput
-      CALL xios_send_field(cdname, (/pfield0d/))
+      CALL event__write_field2D( cdname, RESHAPE( (/pfield0d/), (/1,1/) ) )
 #else
       IF( .FALSE. )   WRITE(numout,*) cdname, pfield0d   ! useless test to avoid compilation warnings
@@ -982,6 +1010,8 @@
       CHARACTER(LEN=*)          , INTENT(in) ::   cdname
       REAL(wp),     DIMENSION(:), INTENT(in) ::   pfield1d
+      INTEGER :: jpz
 #if defined key_iomput
-      CALL xios_send_field( cdname, RESHAPE( (/pfield1d/), (/1,1,SIZE(pfield1d)/) ) )
+      jpz=SIZE(pfield1d)
+      CALL event__write_field3D( cdname, RESHAPE( (/pfield1d/), (/1,1,jpz/) ) )
 #else
       IF( .FALSE. )   WRITE(numout,*) cdname, pfield1d   ! useless test to avoid compilation warnings
@@ -993,5 +1023,5 @@
       REAL(wp),     DIMENSION(:,:), INTENT(in) ::   pfield2d
 #if defined key_iomput
-      CALL xios_send_field(cdname, pfield2d)
+      CALL event__write_field2D( cdname, pfield2d(nldi:nlei, nldj:nlej) )
 #else
       IF( .FALSE. )   WRITE(numout,*) cdname, pfield2d   ! useless test to avoid compilation warnings
@@ -1003,5 +1033,5 @@
       REAL(wp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d
 #if defined key_iomput
-      CALL xios_send_field(cdname, pfield3d)
+      CALL event__write_field3D( cdname, pfield3d(nldi:nlei, nldj:nlej, :) )
 #else
       IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings
@@ -1013,63 +1043,5 @@
 #if defined key_iomput
 
-   SUBROUTINE iom_set_domain_attr( cdname, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj,   &
-      &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask )
-      CHARACTER(LEN=*)                 , INTENT(in) ::   cdname
-      INTEGER                , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj
-      INTEGER                , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj
-      INTEGER                , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj
-      REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) ::   lonvalue, latvalue
-      LOGICAL, DIMENSION(:,:), OPTIONAL, INTENT(in) ::   mask
-
-      IF ( xios_is_valid_domain     (cdname) ) THEN
-         CALL xios_set_domain_attr     ( cdname, 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   ,   &
-            &    zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,                         &
-            &    lonvalue=lonvalue, latvalue=latvalue,mask=mask )
-      ENDIF
-
-      IF ( xios_is_valid_domaingroup(cdname) ) THEN
-         CALL xios_set_domaingroup_attr( cdname, 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   ,   &
-            &    zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,                         &
-            &    lonvalue=lonvalue, latvalue=latvalue,mask=mask )
-      ENDIF
-
-   END SUBROUTINE iom_set_domain_attr
-
-
-   SUBROUTINE iom_set_axis_attr( cdname, paxis )
-      CHARACTER(LEN=*)      , INTENT(in) ::   cdname
-      REAL(wp), DIMENSION(:), INTENT(in) ::   paxis
-      IF ( xios_is_valid_axis     (cdname) )   CALL xios_set_axis_attr     ( cdname, size=size(paxis),value=paxis )
-      IF ( xios_is_valid_axisgroup(cdname) )   CALL xios_set_axisgroup_attr( cdname, size=size(paxis),value=paxis )
-   END SUBROUTINE iom_set_axis_attr
-
-
-   SUBROUTINE iom_set_field_attr( cdname, freq_op)
-      CHARACTER(LEN=*)          , INTENT(in) ::   cdname
-      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   freq_op
-      IF ( xios_is_valid_field     (cdname) )   CALL xios_set_field_attr     ( cdname, freq_op=freq_op )
-      IF ( xios_is_valid_fieldgroup(cdname) )   CALL xios_set_fieldgroup_attr( cdname, freq_op=freq_op )
-   END SUBROUTINE iom_set_field_attr
-
-
-   SUBROUTINE iom_set_file_attr( cdname, name, name_suffix )
-      CHARACTER(LEN=*)          , INTENT(in) ::   cdname
-      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   name, name_suffix
-      IF ( xios_is_valid_file     (cdname) )   CALL xios_set_file_attr     ( cdname, name=name, name_suffix=name_suffix )
-      IF ( xios_is_valid_filegroup(cdname) )   CALL xios_set_filegroup_attr( cdname, name=name, name_suffix=name_suffix )
-   END SUBROUTINE iom_set_file_attr
-
-
-   SUBROUTINE iom_set_grid_attr( cdname, mask )
-      CHARACTER(LEN=*)                   , INTENT(in) ::   cdname
-      LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) ::   mask
-      IF ( xios_is_valid_grid     (cdname) )   CALL xios_set_grid_attr     ( cdname, mask=mask )
-      IF ( xios_is_valid_gridgroup(cdname) )   CALL xios_set_gridgroup_attr( cdname, mask=mask )
-   END SUBROUTINE iom_set_grid_attr
-
-
-   SUBROUTINE set_grid( cdgrd, plon, plat )
+   SUBROUTINE set_grid( cdname, plon, plat )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -1078,31 +1050,13 @@
       !!
       !!----------------------------------------------------------------------
-      CHARACTER(LEN=1)            , INTENT(in) ::   cdgrd
+      CHARACTER(LEN=*)            , INTENT(in) ::   cdname
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plon
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
-      !
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
-      INTEGER  :: ni,nj
-      
-      ni=nlei-nldi+1 ; nj=nlej-nldj+1
-
-      CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-1, jbegin=njmpp+nldj-1, ni=ni, nj=nj)
-      CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
-      CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   &
-         &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
-
-      IF ( ln_mskland ) THEN
-         ! mask land points, keep values on coast line -> specific mask for U, V and W points
-         SELECT CASE ( cdgrd )
-         CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:)
-         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. )
-         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpi,:)   ;   CALL lbc_lnk( zmask, 'V', 1. )
-         CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1)
-         END SELECT
-         !
-         CALL iom_set_domain_attr( "grid_"//cdgrd       , mask = zmask(:,:,1) /= 0. )
-         CALL iom_set_grid_attr  ( "grid_"//cdgrd//"_3D", mask = zmask(:,:,:) /= 0. )
-      ENDIF
-      
+
+      CALL event__set_grid_dimension( cdname, jpiglo, jpjglo)
+      CALL event__set_grid_domain( cdname, nlei-nldi+1, nlej-nldj+1, nimpp+nldi-1, njmpp+nldj-1, &
+         &                         plon(nldi:nlei, nldj:nlej), plat(nldi:nlei, nldj:nlej) )
+      CALL event__set_grid_type_nemo( cdname )
+
    END SUBROUTINE set_grid
 
@@ -1117,10 +1071,47 @@
       REAL(wp), DIMENSION(1,1) ::   zz = 1.
       !!----------------------------------------------------------------------
-      CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea, jbegin=1, ni=1, nj=1)
-      CALL iom_set_domain_attr('scalarpoint', data_dim=1)
-      CALL iom_set_domain_attr('scalarpoint', lonvalue=(/ zz /), latvalue=(/ zz /))
+      CALL event__set_grid_dimension( 'scalarpoint', jpnij, 1)
+      CALL event__set_grid_domain   ( 'scalarpoint', 1, 1, narea, 1, zz, zz )
+      CALL event__set_grid_type_nemo( 'scalarpoint' )
 
    END SUBROUTINE set_scalar
 
+#if defined key_adam
+
+   SUBROUTINE set_adam_mooring
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   define fake grids for adam's mooring data
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp)        ,DIMENSION( 2833,1) ::   zlon
+      REAL(wp)        ,DIMENSION( 2833,1) ::   zlat
+      INTEGER         ,DIMENSION( 2833,1) ::   ix
+      INTEGER         ,DIMENSION( 2833,1) ::   iy
+      INTEGER                           ::   ji
+      !!----------------------------------------------------------------------
+#  include "NA_lons.h90"      
+#  include "NA_lats.h90"      
+      DO ji = 1, 2833
+         CALL dom_ngb( zlon(ji), zlat(ji), ix(ji), iy(ji), 'T' )
+      ENDDO
+!     WRITE(*,*) 'CLOSEST', narea, ix(1), iy(1), zlon(1), zlat(1)
+      WRITE(*,*) 'a0'
+!     CALL event__set_grid_dimension( 'grid_A', 1, 1)
+      CALL event__set_grid_dimension( 'grid_A', 2833, 1)
+!     CALL event__set_grid_dimension( 'scalarpointX', jpnij, 1)
+      WRITE(*,*) 'a1'
+!     CALL event__set_grid_domain   ( 'grid_A', 1, 1, ix(1), iy(1), zlon(1), zlat(1) )
+      CALL event__set_grid_domain   ( 'grid_A', 2833, 1, 1, 1, zlon, zlat )
+!     CALL event__set_grid_domain   ( 'scalarpointX', 1, 1, narea, 1, 1, 1 )
+      WRITE(*,*) 'a2'
+      CALL event__set_grid_type_nemo( 'grid_A' )
+!     CALL event__set_grid_type_nemo( 'scalarpointX' )
+      WRITE(*,*) 'a3'
+             
+   END SUBROUTINE set_adam_mooring
+
+#endif
 
    SUBROUTINE set_xmlatt
@@ -1131,10 +1122,13 @@
       !!
       !!----------------------------------------------------------------------
+#if defined key_adam
+      CHARACTER(len=6),DIMENSION( 9) ::   clsuff                   ! suffix name
+#else
       CHARACTER(len=6),DIMENSION( 8) ::   clsuff                   ! suffix name
+#endif
       CHARACTER(len=1),DIMENSION( 3) ::   clgrd                    ! suffix name
       CHARACTER(len=50)              ::   clname                   ! file name
       CHARACTER(len=1)               ::   cl1                      ! 1 character
       CHARACTER(len=2)               ::   cl2                      ! 1 character
-      CHARACTER(len=255)             ::   tfo
       INTEGER                        ::   idt                      ! time-step in seconds
       INTEGER                        ::   iddss, ihhss             ! number of seconds in 1 day, 1 hour and 1 year
@@ -1156,32 +1150,40 @@
 
       ! frequency of the call of iom_put (attribut: freq_op)
-      tfo = TRIM(i2str(idt))//'s'
-      CALL iom_set_field_attr('field_definition', freq_op=tfo)
-      CALL iom_set_field_attr('SBC'   , freq_op=TRIM(i2str(idt* nn_fsbc ))//'s')
-      CALL iom_set_field_attr('ptrc_T', freq_op=TRIM(i2str(idt* nn_dttrc))//'s')
-      CALL iom_set_field_attr('diad_T', freq_op=TRIM(i2str(idt* nn_dttrc))//'s')
-       
+      CALL event__set_attribut( 'field_definition', attr( field__freq_op, idt           ) )    ! model time-step
+      CALL event__set_attribut( 'SBC'             , attr( field__freq_op, idt * nn_fsbc ) )    ! SBC time-step
+      
       ! output file names (attribut: name)
+#if defined key_adam
+      clsuff(:) = (/ 'grid_A', 'grid_T', 'grid_U', 'grid_V', 'grid_W', 'icemod', 'ptrc_T', 'diad_T', 'scalar' /)      
+#else
       clsuff(:) = (/ 'grid_T', 'grid_U', 'grid_V', 'grid_W', 'icemod', 'ptrc_T', 'diad_T', 'scalar' /)      
+#endif
+      WRITE(*,*) 'set adam2'
       DO jg = 1, SIZE(clsuff)                                                                  ! grid type
-         DO jh = 1, 24                                                                         ! 1-24 hours
-            WRITE(cl2,'(i2)') jh 
-            CALL dia_nam( clname, jh * ihhss, clsuff(jg), ldfsec = .TRUE. )
-            CALL iom_set_file_attr(TRIM(ADJUSTL(cl2))//'h_'//clsuff(jg), name=TRIM(clname))
+         DO jh = 1, 12                                                                         ! 1, 2, 3, 4, 6, 12 hours
+            IF( MOD(12,jh) == 0 ) THEN 
+               WRITE(cl2,'(i2)') jh 
+               CALL dia_nam( clname, jh * ihhss, clsuff(jg), ldfsec = .TRUE. )
+               CALL event__set_attribut( TRIM(ADJUSTL(cl2))//'h_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
          END DO
-         DO jd = 1, 30                                                                         ! 1-30 days
+         DO jd = 1, 5, 2                                                                       ! 1, 3, 5 days
             WRITE(cl1,'(i1)') jd 
             CALL dia_nam( clname, jd * iddss, clsuff(jg), ldfsec = .TRUE. )
-            CALL iom_set_file_attr(cl1//'d_'//clsuff(jg), name=TRIM(clname))
+            CALL event__set_attribut( cl1//'d_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
          END DO
-         DO jm = 1, 11                                                                         ! 1-11 months
-            WRITE(cl1,'(i1)') jm 
-            CALL dia_nam( clname, -jm, clsuff(jg) )
-            CALL iom_set_file_attr(cl1//'m_'//clsuff(jg), name=TRIM(clname))
+         DO jm = 1, 6                                                                          ! 1, 2, 3, 4, 6 months
+            IF( MOD(6,jm) == 0 ) THEN 
+               WRITE(cl1,'(i1)') jm 
+               CALL dia_nam( clname, -jm, clsuff(jg) )
+               CALL event__set_attribut( cl1//'m_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
          END DO
-         DO jy = 1, 50                                                                         ! 1-50 years  
-            WRITE(cl2,'(i2)') jy 
-            CALL dia_nam( clname, -jy * iyymo, clsuff(jg) )
-            CALL iom_set_file_attr(TRIM(ADJUSTL(cl2))//'y_'//clsuff(jg), name=TRIM(clname))
+         DO jy = 1, 10                                                                         ! 1, 2, 5, 10 years  
+            IF( MOD(10,jy) == 0 ) THEN 
+               WRITE(cl2,'(i2)') jy 
+               CALL dia_nam( clname, -jy * iyymo, clsuff(jg) )
+               CALL event__set_attribut( TRIM(ADJUSTL(cl2))//'y_'//clsuff(jg), attr( file__name, TRIM(clname) ) )
+            ENDIF
          END DO
       END DO
@@ -1193,6 +1195,7 @@
          ! Equatorial section (attributs: jbegin, ni, name_suffix)
          CALL dom_ngb( 0., 0., ix, iy, cl1 )
-         CALL iom_set_domain_attr('Eq'//cl1, zoom_jbegin=iy, zoom_ni=jpiglo)
-         CALL iom_set_file_attr('Eq'//cl1, name_suffix= '_Eq')
+         CALL event__set_attribut( 'Eq'//cl1, attr( zoom__jbegin     , iy     ) )
+         CALL event__set_attribut( 'Eq'//cl1, attr( zoom__ni         , jpiglo ) )
+         CALL event__set_attribut( 'Eq'//cl1, attr( file__name_suffix, '_Eq'  ) )
       END DO
       ! TAO moorings (attributs: ibegin, jbegin, name_suffix)
@@ -1209,4 +1212,5 @@
       CALL set_mooring( zlonpira, zlatpira )
       
+      WRITE(*,*) 'set adam3'
    END SUBROUTINE set_xmlatt
 
@@ -1269,6 +1273,7 @@
                ENDIF
                clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon))
-               CALL iom_set_domain_attr(TRIM(clname)//cl1, zoom_ibegin= ix, zoom_jbegin= iy)
-               CALL iom_set_file_attr(TRIM(clname)//cl1, name_suffix= '_'//TRIM(clname))
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( zoom__ibegin     , ix                ) )
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( zoom__jbegin     , iy                ) )
+               CALL event__set_attribut( TRIM(clname)//cl1, attr( file__name_suffix, '_'//TRIM(clname) ) )      
             END DO
          END DO
@@ -1286,13 +1291,5 @@
 #endif
 
-   FUNCTION i2str(int)
-   IMPLICIT NONE
-      INTEGER, INTENT(IN) :: int
-      CHARACTER(LEN=255) :: i2str
-
-      WRITE(i2str,*) int
-      
-   END FUNCTION i2str  
-   
+
    !!======================================================================
 END MODULE iom
