Index: branches/2015/dev_r5918_nemo_v3_6_STABLE_XIOS2/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2015/dev_r5918_nemo_v3_6_STABLE_XIOS2/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 5923)
+++ branches/2015/dev_r5918_nemo_v3_6_STABLE_XIOS2/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 5928)
@@ -94,17 +94,17 @@
       CHARACTER(len=*), INTENT(in)  :: cdname
 #if defined key_iomput
-#if defined XIOS1
-      TYPE(xios_time)   :: dtime    = xios_time(0, 0, 0, 0, 0, 0)
-      CHARACTER(len=19) :: cldate 
-#else
-      TYPE(xios_duration)   :: dtime    = xios_duration(0, 0, 0, 0, 0, 0)
-      TYPE(xios_date) :: start_date
-#endif
-      CHARACTER(len=10) :: clname
-      INTEGER           ::   ji
+#if ! defined key_xios2
+      TYPE(xios_time)     :: dtime    = xios_time(0, 0, 0, 0, 0, 0)
+      CHARACTER(len=19)   :: cldate 
+#else
+      TYPE(xios_duration) :: dtime    = xios_duration(0, 0, 0, 0, 0, 0)
+      TYPE(xios_date)     :: start_date
+#endif
+      CHARACTER(len=10)   :: clname
+      INTEGER             :: ji
       !
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_bnds
       !!----------------------------------------------------------------------
-#if defined XIOS1
+#if ! defined key_xios2
       ALLOCATE( z_bnds(jpk,2) )
 #else
@@ -118,5 +118,5 @@
 
       ! calendar parameters
-#if defined XIOS1
+#if ! defined key_xios2
       SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
       CASE ( 1)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "Gregorian")
@@ -129,12 +129,15 @@
       ! Calendar type is now defined in xml file 
       SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
-      CASE ( 1)   ; CALL xios_define_calendar(TYPE="Gregorian", time_origin=xios_date(1900,01,01,00,00,00),start_date = xios_date(nyear,nmonth,nday,0,0,0))
-      CASE ( 0)   ; CALL xios_define_calendar(TYPE="NoLeap", time_origin=xios_date(1900,01,01,00,00,00),start_date = xios_date(nyear,nmonth,nday,0,0,0))
-      CASE (30)   ; CALL xios_define_calendar(TYPE="D360", time_origin=xios_date(1900,01,01,00,00,00),start_date = xios_date(nyear,nmonth,nday,0,0,0))
+      CASE ( 1)   ; CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(1900,01,01,00,00,00), &
+          &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
+      CASE ( 0)   ; CALL xios_define_calendar( TYPE = "NoLeap"   , time_origin = xios_date(1900,01,01,00,00,00), &
+          &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
+      CASE (30)   ; CALL xios_define_calendar( TYPE = "D360"     , time_origin = xios_date(1900,01,01,00,00,00), &
+          &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
       END SELECT
 #endif
       ! horizontal grid definition
 
-#if defined XIOS1
+#if ! defined key_xios2
       CALL set_scalar
 #endif
@@ -189,5 +192,5 @@
 
       ! Add vertical grid bounds
-#if defined XIOS1
+#if ! defined key_xios2
       z_bnds(:      ,1) = gdepw_1d(:)
       z_bnds(1:jpkm1,2) = gdepw_1d(2:jpk)
@@ -196,5 +199,5 @@
       z_bnds(1      ,:) = gdepw_1d(:)
       z_bnds(2,1:jpkm1) = gdepw_1d(2:jpk)
-      z_bnds(2,jpk:) = gdepw_1d(jpk) + e3t_1d(jpk)
+      z_bnds(2,jpk:   ) = gdepw_1d(jpk) + e3t_1d(jpk)
 #endif
 
@@ -202,14 +205,16 @@
       CALL iom_set_axis_attr( "depthu", bounds=z_bnds )
       CALL iom_set_axis_attr( "depthv", bounds=z_bnds )
-#if defined XIOS1
-      z_bnds(:    ,2) = gdept_1d(:)
-      z_bnds(2:jpk,1) = gdept_1d(1:jpkm1)
-      z_bnds(1    ,1) = gdept_1d(1) - e3w_1d(1)
-#else
-      z_bnds(2,:) = gdept_1d(:)
-      z_bnds(1,2:jpk) = gdept_1d(1:jpkm1)
-      z_bnds(1,1) = gdept_1d(1) - e3w_1d(1)
+
+#if ! defined key_xios2
+      z_bnds(:    ,2)  = gdept_1d(:)
+      z_bnds(2:jpk,1)  = gdept_1d(1:jpkm1)
+      z_bnds(1    ,1)  = gdept_1d(1) - e3w_1d(1)
+#else
+      z_bnds(2,:    )  = gdept_1d(:)
+      z_bnds(1,2:jpk)  = gdept_1d(1:jpkm1)
+      z_bnds(1,1    )  = gdept_1d(1) - e3w_1d(1)
 #endif
       CALL iom_set_axis_attr( "depthw", bounds=z_bnds )
+
 
 # if defined key_floats
@@ -1190,5 +1195,5 @@
       LOGICAL,  DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   mask
 
-#if defined XIOS1
+#if ! defined key_xios2
       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,   &
@@ -1224,5 +1229,5 @@
    END SUBROUTINE iom_set_domain_attr
 
-#if ! defined XIOS1
+#if defined key_xios2
   SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj)
      CHARACTER(LEN=*)                   , INTENT(in) ::   cdid
@@ -1242,5 +1247,5 @@
       REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds
       IF ( PRESENT(paxis) ) THEN
-#if defined XIOS1 
+#if ! defined key_xios2
          IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, size=SIZE(paxis), value=paxis )
          IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, size=SIZE(paxis), value=paxis )
@@ -1257,10 +1262,10 @@
    SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset )
       CHARACTER(LEN=*)          , INTENT(in) ::   cdid
-#if defined XIOS1 
-      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   freq_op
-      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   freq_offset
-#else
-      TYPE(xios_duration)   ,OPTIONAL , INTENT(in) ::   freq_op
-      TYPE(xios_duration)   ,OPTIONAL , INTENT(in) ::   freq_offset
+#if ! defined key_xios2
+      CHARACTER(LEN=*)   ,OPTIONAL , INTENT(in) ::   freq_op
+      CHARACTER(LEN=*)   ,OPTIONAL , INTENT(in) ::   freq_offset
+#else
+      TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_op
+      TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_offset
 #endif
       IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr     ( cdid, freq_op=freq_op, freq_offset=freq_offset )
@@ -1281,5 +1286,5 @@
       CHARACTER(LEN=*)          , INTENT(in ) ::   cdid
       CHARACTER(LEN=*),OPTIONAL , INTENT(out) ::   name, name_suffix
-#if defined XIOS1 
+#if ! defined key_xios2
       CHARACTER(LEN=*),OPTIONAL , INTENT(out) ::    output_freq
 #else
@@ -1290,5 +1295,5 @@
       IF( PRESENT( name        ) )   name = ''          ! default values
       IF( PRESENT( name_suffix ) )   name_suffix = ''
-#if defined XIOS1 
+#if ! defined key_xios2
       IF( PRESENT( output_freq ) )   output_freq = ''
 #else
@@ -1315,5 +1320,5 @@
       CHARACTER(LEN=*)                   , INTENT(in) ::   cdid
       LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) ::   mask
-#if defined XIOS1 
+#if ! defined key_xios2
       IF ( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask=mask )
       IF ( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask=mask )
@@ -1363,5 +1368,5 @@
       ni=nlei-nldi+1 ; nj=nlej-nldj+1
 
-#if defined XIOS1
+#if ! defined key_xios2
      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)
 #else
@@ -1516,5 +1521,5 @@
 
       CALL dom_ngb( 180., 90., ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots)
-#if defined XIOS1
+#if ! defined key_xios2
       CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-1, jbegin=njmpp+nldj-1, ni=ni, nj=nj)
       CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
@@ -1574,5 +1579,5 @@
       REAL(wp)        ,DIMENSION( 3) ::   zlonpira                 ! longitudes of pirata moorings
       REAL(wp)        ,DIMENSION( 9) ::   zlatpira                 ! latitudes  of pirata moorings
-#if ! defined XIOS1
+#if  defined key_xios2
       TYPE(xios_duration)   ::   freq_op, freq_offset
 #endif
@@ -1581,5 +1586,5 @@
       ! 
       ! frequency of the call of iom_put (attribut: freq_op)
-#if defined XIOS1
+#if ! defined key_xios2
       WRITE(cl1,'(i1)')        1   ;   CALL iom_set_field_attr('field_definition', freq_op = cl1//'ts', freq_offset='0ts')
       WRITE(cl1,'(i1)')  nn_fsbc   ;   CALL iom_set_field_attr('SBC'             , freq_op = cl1//'ts', freq_offset='0ts')
@@ -1589,8 +1594,8 @@
 #else
       freq_op%timestep=1         ; freq_offset%timestep=0 ; CALL iom_set_field_attr('field_definition', freq_op = freq_op, freq_offset=freq_offset)
-      freq_op%timestep=nn_fsbc   ; freq_offset%timestep=0 ; CALL iom_set_field_attr('SBC', freq_op = freq_op, freq_offset=freq_offset)
-      freq_op%timestep=nn_fsbc   ; freq_offset%timestep=0 ; CALL iom_set_field_attr('SBC_scalar', freq_op = freq_op, freq_offset=freq_offset)
-      freq_op%timestep=nn_dttrc  ; freq_offset%timestep=0 ; CALL iom_set_field_attr('ptrc_T', freq_op = freq_op, freq_offset=freq_offset)
-      freq_op%timestep=nn_dttrc  ; freq_offset%timestep=0 ; CALL iom_set_field_attr('diad_T', freq_op = freq_op, freq_offset=freq_offset)
+      freq_op%timestep=nn_fsbc   ; freq_offset%timestep=0 ; CALL iom_set_field_attr('SBC'             , freq_op = freq_op, freq_offset=freq_offset)
+      freq_op%timestep=nn_fsbc   ; freq_offset%timestep=0 ; CALL iom_set_field_attr('SBC_scalar'      , freq_op = freq_op, freq_offset=freq_offset)
+      freq_op%timestep=nn_dttrc  ; freq_offset%timestep=0 ; CALL iom_set_field_attr('ptrc_T'          , freq_op = freq_op, freq_offset=freq_offset)
+      freq_op%timestep=nn_dttrc  ; freq_offset%timestep=0 ; CALL iom_set_field_attr('diad_T'          , freq_op = freq_op, freq_offset=freq_offset)
 #endif
        
@@ -1615,5 +1620,5 @@
          ! Equatorial section (attributs: jbegin, ni, name_suffix)
          CALL dom_ngb( 0., 0., ix, iy, cl1 )
-#if defined XIOS1         
+#if ! defined key_xios2
          CALL iom_set_domain_attr ('Eq'//cl1, zoom_jbegin=iy, zoom_ni=jpiglo)
 #else
@@ -1699,5 +1704,5 @@
                ENDIF
                clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon))
-#if defined XIOS1
+#if ! defined key_xios2
                CALL iom_set_domain_attr (TRIM(clname)//cl1, zoom_ibegin= ix, zoom_jbegin= iy)
 #else
@@ -1732,5 +1737,5 @@
       REAL(wp)           ::   zsec
       LOGICAL            ::   llexist
-#if ! defined XIOS1
+#if  defined key_xios2
       TYPE(xios_duration)   ::   output_freq 
 #endif      
@@ -1739,5 +1744,5 @@
 
       DO jn = 1,2
-#if defined XIOS1
+#if ! defined key_xios2
          IF( jn == 1 )   CALL iom_get_file_attr( cdid, name        = clname, output_freq = clfreq )
 #else
@@ -1755,5 +1760,5 @@
             END DO
 
-#if defined XIOS1
+#if ! defined key_xios2
             idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@')
             DO WHILE ( idx /= 0 ) 
