Index: branches/2017/dev_r7881_ENHANCE09_RK3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2017/dev_r7881_ENHANCE09_RK3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8817)
+++ branches/2017/dev_r7881_ENHANCE09_RK3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8850)
@@ -205,8 +205,7 @@
       ! end file definition
       dtime%second = rdt
-      CALL xios_set_timestep(dtime)
+      CALL xios_set_timestep( dtime )
       CALL xios_close_context_definition()
-      
-      CALL xios_update_calendar(0)
+      CALL xios_update_calendar( 0 )
       !
       DEALLOCATE( zt_bnds, zw_bnds )
@@ -253,5 +252,5 @@
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
       INTEGER         , INTENT(in   ), OPTIONAL ::   kdlev    ! number of vertical levels
-
+      !
       CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
       CHARACTER(LEN=256)    ::   cltmpn    ! tempory name to store clname (in writting mode)
@@ -645,7 +644,7 @@
       INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
       LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrowattr   ! logical flag telling iom_get to
-                                                                           ! look for and use a file attribute
-                                                                           ! called open_ocean_jstart to set the start
-                                                                           ! value for the 2nd dimension (netcdf only)
+      !                                                                    ! look for and use a file attribute
+      !                                                                    ! called open_ocean_jstart to set the start
+      !                                                                    ! value for the 2nd dimension (netcdf only)
       !
       LOGICAL                        ::   llnoov      ! local definition to read overlap
@@ -780,5 +779,5 @@
          IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN 
             istart(1:idmspc) = kstart(1:idmspc) 
-            icnt(1:idmspc) = kcount(1:idmspc)
+            icnt  (1:idmspc) = kcount(1:idmspc)
          ELSE
             IF(idom == jpdom_unknown ) THEN
@@ -806,7 +805,7 @@
                   ENDIF
                   IF( PRESENT(pv_r3d) ) THEN
-                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = inlev
-                     ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3)
-                     ELSE                                                           ; icnt(3) = inlev
+                     IF( idom == jpdom_data ) THEN                        ;                               icnt(3) = inlev
+                     ELSEIF( ll_depth_spec .AND. PRESENT(kstart) ) THEN   ;   istart(3) = kstart(3)   ;   icnt(3) = kcount(3)
+                     ELSE                                                 ;                               icnt(3) = inlev
                      ENDIF
                   ENDIF
@@ -1251,5 +1250,4 @@
 
 #if defined key_iomput
-
    !!----------------------------------------------------------------------
    !!   'key_iomput'                                         IOM  interface
@@ -1413,9 +1411,10 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
       !
-      INTEGER  :: ni,nj
+      INTEGER  :: ni, nj
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
       !!----------------------------------------------------------------------
       !
-      ni=nlei-nldi+1 ; nj=nlej-nldj+1
+      ni = nlei-nldi+1
+      nj = nlej-nldj+1
       !
       CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj)
@@ -1468,5 +1467,6 @@
       END SELECT
       !
-      ni = nlei-nldi+1 ; nj = nlej-nldj+1  ! Dimensions of subdomain interior
+      ni = nlei-nldi+1   ! Dimensions of subdomain interior
+      nj = nlej-nldj+1
       !
       z_fld(:,:) = 1._wp
@@ -1553,10 +1553,11 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
       !
+      INTEGER  :: ni, nj, ix, iy
       REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon
-      INTEGER  :: ni,nj, ix, iy
-      !!----------------------------------------------------------------------
-      !
-      ni=nlei-nldi+1 ; nj=nlej-nldj+1            ! define zonal mean domain (jpj*jpk)
-      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0.
+      !!----------------------------------------------------------------------
+      !
+      ni=nlei-nldi+1       ! define zonal mean domain (jpj*jpk)
+      nj=nlej-nldj+1
+      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0._wp
       !
       CALL dom_ngb( -168.53, 65.03, ix, iy, 'T' ) !  i-line that passes through Bering Strait: Reference latitude (used in plots)
@@ -1616,9 +1617,11 @@
       ! 
       ! frequency of the call of iom_put (attribut: freq_op)
-      f_op%timestep = 1        ;  f_of%timestep = 0  ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of)
-      f_op%timestep = nn_fsbc  ;  f_of%timestep = 0  ; CALL iom_set_field_attr('SBC'             , freq_op=f_op, freq_offset=f_of)
-      f_op%timestep = nn_fsbc  ;  f_of%timestep = 0  ; CALL iom_set_field_attr('SBC_scalar'      , freq_op=f_op, freq_offset=f_of)
-      f_op%timestep = nn_dttrc ;  f_of%timestep = 0  ; CALL iom_set_field_attr('ptrc_T'          , freq_op=f_op, freq_offset=f_of)
-      f_op%timestep = nn_dttrc ;  f_of%timestep = 0  ; CALL iom_set_field_attr('diad_T'          , freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = 1        ;  f_of%timestep =  0  ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = 2        ;  f_of%timestep =  0  ; CALL iom_set_field_attr('trendT_even'     , freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = 2        ;  f_of%timestep = -1  ; CALL iom_set_field_attr('trendT_odd'      , freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = nn_fsbc  ;  f_of%timestep =  0  ; CALL iom_set_field_attr('SBC'             , freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = nn_fsbc  ;  f_of%timestep =  0  ; CALL iom_set_field_attr('SBC_scalar'      , freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = nn_dttrc ;  f_of%timestep =  0  ; CALL iom_set_field_attr('ptrc_T'          , freq_op=f_op, freq_offset=f_of)
+      f_op%timestep = nn_dttrc ;  f_of%timestep =  0  ; CALL iom_set_field_attr('diad_T'          , freq_op=f_op, freq_offset=f_of)
 
       ! output file names (attribut: name)
@@ -1753,13 +1756,13 @@
       TYPE(xios_duration)   ::   output_freq 
       !!----------------------------------------------------------------------
-
-      DO jn = 1,2
-
+      !
+      DO jn = 1, 2
+         !
          output_freq = xios_duration(0,0,0,0,0,0)
          IF( jn == 1 )   CALL iom_get_file_attr( cdid, name        = clname, output_freq = output_freq )
          IF( jn == 2 )   CALL iom_get_file_attr( cdid, name_suffix = clname )
-
+         !
          IF ( TRIM(clname) /= '' ) THEN 
-
+            !
             idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@')
             DO WHILE ( idx /= 0 ) 
@@ -1767,5 +1770,5 @@
                idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@')
             END DO
-
+            !
             idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@')
             DO WHILE ( idx /= 0 ) 
@@ -1798,5 +1801,5 @@
               idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@')
             END DO
-
+            !
             idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@')
             DO WHILE ( idx /= 0 ) 
@@ -1805,5 +1808,5 @@
                idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@')
             END DO
-
+            !
             idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@')
             DO WHILE ( idx /= 0 ) 
@@ -1812,5 +1815,5 @@
                idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@')
             END DO
-
+            !
             idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@')
             DO WHILE ( idx /= 0 ) 
@@ -1844,7 +1847,7 @@
       !! ** Purpose :   send back the date corresponding to the given julian day
       !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in   )           ::   pjday         ! julian day
-      LOGICAL , INTENT(in   ), OPTIONAL ::   ld24          ! true to force 24:00 instead of 00:00
-      LOGICAL , INTENT(in   ), OPTIONAL ::   ldfull        ! true to get the compleate date: yyyymmdd_hh:mm:ss
+      REAL(wp), INTENT(in   )           ::   pjday    ! julian day
+      LOGICAL , INTENT(in   ), OPTIONAL ::   ld24     ! true to force 24:00 instead of 00:00
+      LOGICAL , INTENT(in   ), OPTIONAL ::   ldfull   ! true to get the compleate date: yyyymmdd_hh:mm:ss
       !
       CHARACTER(LEN=20) ::   iom_sdate
@@ -1892,4 +1895,7 @@
 
 #else
+   !!----------------------------------------------------------------------
+   !!   NOT 'key_iomput'                               a few dummy routines
+   !!----------------------------------------------------------------------
 
    SUBROUTINE iom_setkt( kt, cdname )
@@ -1907,5 +1913,8 @@
 
    LOGICAL FUNCTION iom_use( cdname )
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
       CHARACTER(LEN=*), INTENT(in) ::   cdname
+      !!----------------------------------------------------------------------
 #if defined key_iomput
       iom_use = xios_field_is_active( cdname )
