Index: branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/icewri.F90
===================================================================
--- branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/icewri.F90	(revision 8534)
+++ branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/icewri.F90	(revision 8562)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE ice_wri( kindic )
+   SUBROUTINE ice_wri( kt )
       !!-------------------------------------------------------------------
       !!  This routine computes the average of some variables and write it
@@ -50,8 +50,8 @@
       !!  modif : 03/06/98
       !!-------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kindic   ! if kindic < 0 there has been an error somewhere
+      INTEGER, INTENT(in) ::   kt   ! time-step
       !
       INTEGER  ::  ji, jj, jk, jl  ! dummy loop indices
-      REAL(wp) ::  z2da, z2db, ztmp, zrho1, zrho2, zmiss_val
+      REAL(wp) ::  z2da, z2db, zrho1, zrho2, zmiss_val
       REAL(wp), DIMENSION(jpi,jpj)     ::  z2d, zswi, zmiss !  2D workspace
       REAL(wp), DIMENSION(jpi,jpj)     ::  zfb              ! ice freeboard
@@ -95,19 +95,4 @@
       ! Standard outputs
       !----------------------------------------
-      ! fluxes 
-      IF( iom_use('qsr_oce') )   CALL iom_put( "qsr_oce" , qsr_oce(:,:) * ( 1._wp - at_i_b(:,:) ) )                      !     solar flux at ocean surface
-      IF( iom_use('qns_oce') )   CALL iom_put( "qns_oce" , qns_oce(:,:) * ( 1._wp - at_i_b(:,:) ) + qemp_oce(:,:) )      ! non-solar flux at ocean surface
-      IF( iom_use('qsr_ice') )   CALL iom_put( "qsr_ice" , SUM( qsr_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) )                 !     solar flux at ice surface
-      IF( iom_use('qns_ice') )   CALL iom_put( "qns_ice" , SUM( qns_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) + qemp_ice(:,:) ) ! non-solar flux at ice surface
-      IF( iom_use('qtr_ice') )   CALL iom_put( "qtr_ice" , SUM( ftr_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) )                 !     solar flux transmitted thru ice
-      IF( iom_use('qt_oce' ) )   CALL iom_put( "qt_oce"  , ( qsr_oce(:,:) + qns_oce(:,:) ) * ( 1._wp - at_i_b(:,:) ) + qemp_oce(:,:) )
-      IF( iom_use('qt_ice' ) )   CALL iom_put( "qt_ice"  , SUM( ( qns_ice(:,:,:) + qsr_ice(:,:,:) )   &
-         &                                                      * a_i_b(:,:,:), dim=3 ) + qemp_ice(:,:) )
-!!gm I don't understand the variable below.... why not multiplied by a_i_b or (1-a_i_b) ??? 
-      IF( iom_use('qemp_oce') )  CALL iom_put( "qemp_oce" , qemp_oce(:,:) )  
-      IF( iom_use('qemp_ice') )  CALL iom_put( "qemp_ice" , qemp_ice(:,:) )  
-      IF( iom_use('emp_oce' ) )  CALL iom_put( "emp_oce"  , emp_oce (:,:) )   ! emp over ocean (taking into account the snow blown away from the ice)
-      IF( iom_use('emp_ice' ) )  CALL iom_put( "emp_ice"  , emp_ice (:,:) )   ! emp over ice   (taking into account the snow blown away from the ice)
-
       ! velocity
       IF( iom_use('uice_ipa') )  CALL iom_put( "uice_ipa" , u_ice         )   ! ice velocity u component
@@ -126,11 +111,9 @@
          IF( iom_use('icevel_mv') )   CALL iom_put( "icevel_mv"    , z2d(:,:) * zswi(:,:) + zmiss(:,:) )   ! ice velocity module (missing value)
       ENDIF
-
-      IF( iom_use('tau_icebfr') )     CALL iom_put( "tau_icebfr"  , tau_icebfr             )  ! ice friction with ocean bottom (landfast ice)  
       !
       IF( iom_use('miceage')  )       CALL iom_put( "miceage"     , om_i * zswi * zamask15 )  ! mean ice age
       IF( iom_use('micet')    )       CALL iom_put( "micet"       , ( tm_i  - rt0 ) * zswi )  ! ice mean    temperature
       IF( iom_use('icest')    )       CALL iom_put( "icest"       , ( tm_su - rt0 ) * zswi )  ! ice surface temperature
-      IF( iom_use('icecolf')  )       CALL iom_put( "icecolf"     , hicol                  )  ! frazil ice collection thickness
+      IF( iom_use('icecolf')  )       CALL iom_put( "icecolf"     , ht_i_new               )  ! new ice thickness formed in the leads
       !
       CALL iom_put( "isst"        , sst_m               )        ! sea surface temperature
@@ -142,74 +125,11 @@
       CALL iom_put( "isnowhc"     , et_s  * zswi        )        ! snow total heat content
       CALL iom_put( "ibrinv"      , bvm_i * zswi * 100. )        ! brine volume
-      CALL iom_put( "snowpre"     , sprecip * 86400.    )        ! snow precipitation [m/day]
       CALL iom_put( "micesalt"    , smt_i   * zswi      )        ! mean ice salinity
       CALL iom_put( "snowvol"     , vt_s    * zswi      )        ! snow volume
       
-      CALL iom_put( "sfxbog"      , sfx_bog * rday      )        ! salt flux from bottom growth
-      CALL iom_put( "sfxbom"      , sfx_bom * rday      )        ! salt flux from bottom melting
-      CALL iom_put( "sfxsum"      , sfx_sum * rday      )        ! salt flux from surface melting
-      CALL iom_put( "sfxlam"      , sfx_lam * rday      )        ! salt flux from lateral melting
-      CALL iom_put( "sfxsni"      , sfx_sni * rday      )        ! salt flux from snow ice formation
-      CALL iom_put( "sfxopw"      , sfx_opw * rday      )        ! salt flux from open water formation
-      CALL iom_put( "sfxdyn"      , sfx_dyn * rday      )        ! salt flux from ridging rafting
-      CALL iom_put( "sfxres"      , sfx_res * rday      )        ! salt flux from corrections (resultant)
-      CALL iom_put( "sfxbri"      , sfx_bri * rday      )        ! salt flux from brines
-      CALL iom_put( "sfxsub"      , sfx_sub * rday      )        ! salt flux from sublimation
-      CALL iom_put( "sfx"         , sfx     * rday      )        ! total salt flux
-
-      ztmp = rday / rhoic
-      CALL iom_put( "vfxres"     , wfx_res * ztmp       )        ! daily prod./melting due to corrections 
-      CALL iom_put( "vfxopw"     , wfx_opw * ztmp       )        ! daily lateral thermodynamic ice production
-      CALL iom_put( "vfxsni"     , wfx_sni * ztmp       )        ! daily snowice ice production
-      CALL iom_put( "vfxbog"     , wfx_bog * ztmp       )        ! daily bottom thermodynamic ice production
-      CALL iom_put( "vfxdyn"     , wfx_dyn * ztmp       )        ! daily dynamic ice production (rid/raft)
-      CALL iom_put( "vfxsum"     , wfx_sum * ztmp       )        ! surface melt 
-      CALL iom_put( "vfxbom"     , wfx_bom * ztmp       )        ! bottom melt 
-      CALL iom_put( "vfxlam"     , wfx_lam * ztmp       )        ! lateral melt 
-      CALL iom_put( "vfxice"     , wfx_ice * ztmp       )        ! total ice growth/melt 
-
-      IF ( ln_pnd ) &
-         CALL iom_put( "vfxpnd"  , wfx_pnd * ztmp       )        ! melt pond water flux
-
-      IF ( iom_use( "vfxthin" ) ) THEN   ! ice production for open water + thin ice (<20cm) => comparable to observations  
-         WHERE( htm_i(:,:) < 0.2 .AND. htm_i(:,:) > 0. ) ; z2d = wfx_bog
-         ELSEWHERE                                       ; z2d = 0._wp
-         END WHERE
-         CALL iom_put( "vfxthin", ( wfx_opw + z2d ) * ztmp )
-      ENDIF
-
-      ztmp = rday * r1_rhosn
-      CALL iom_put( "vfxspr"     , wfx_spr * ztmp       )        ! precip (snow)
-      CALL iom_put( "vfxsnw"     , wfx_snw * ztmp       )        ! total snw growth/melt 
-      CALL iom_put( "vfxsub"     , wfx_sub * ztmp       )        ! sublimation (snow/ice) 
-      CALL iom_put( "vfxsub_err" , wfx_err_sub * ztmp   )        ! "excess" of sublimation sent to ocean      
- 
-      CALL iom_put ('hfxthd'     , hfx_thd(:,:)         )   !  
-      CALL iom_put ('hfxdyn'     , hfx_dyn(:,:)         )   !  
-      CALL iom_put ('hfxres'     , hfx_res(:,:)         )   !  
-      CALL iom_put ('hfxout'     , hfx_out(:,:)         )   !  
-      CALL iom_put ('hfxin'      , hfx_in(:,:)          )   !  
-      CALL iom_put ('hfxsnw'     , hfx_snw(:,:)         )   !  
-      CALL iom_put ('hfxsub'     , hfx_sub(:,:)         )   !  
-      CALL iom_put ('hfxerr'     , hfx_err_dif(:,:)     )   !  
-      CALL iom_put ('hfxerr_rem' , hfx_err_rem(:,:)     )   !  
-      
-      CALL iom_put ('hfxsum'     , hfx_sum(:,:)         )   !  
-      CALL iom_put ('hfxbom'     , hfx_bom(:,:)         )   !  
-      CALL iom_put ('hfxbog'     , hfx_bog(:,:)         )   !  
-      CALL iom_put ('hfxdif'     , hfx_dif(:,:)         )   !  
-      CALL iom_put ('hfxopw'     , hfx_opw(:,:)         )   !  
-      CALL iom_put ('hfxtur'     , fhtur(:,:) * at_i_b(:,:) ) ! turbulent heat flux at ice base 
-      CALL iom_put ('hfxdhc'     , diag_heat(:,:)       )   ! Heat content variation in snow and ice 
-      CALL iom_put ('hfxspr'     , hfx_spr(:,:)         )   ! Heat content of snow precip 
-
-!!gm ====>>>>>  THIS should be moved where at_ip, vt_ip are computed fro the last time in the time-step  (limmpd)
-      ! MV MP 2016
       IF ( ln_pnd ) THEN
          CALL iom_put( "iceamp"  , at_ip  * zswi        )   ! melt pond total fraction
          CALL iom_put( "icevmp"  , vt_ip  * zswi        )   ! melt pond total volume per unit area
       ENDIF
-      ! END MV MP 2016
-!!gm  <<<<<<======= end
 
       !----------------------------------
@@ -225,5 +145,4 @@
       IF ( iom_use('brinevol_cat') )  CALL iom_put( "brinevol_cat", bv_i * 100. * zswi2 )          ! brine volume
 
-      ! MV MP 2016
       IF ( ln_pnd ) THEN
          IF ( iom_use('iceamp_cat') )  CALL iom_put( "iceamp_cat"     , a_ip       * zswi2   )       ! melt pond frac for categories
@@ -232,5 +151,4 @@
          IF ( iom_use('iceafp_cat') )  CALL iom_put( "iceafp_cat"     , a_ip_frac  * zswi2   )       ! melt pond frac for categories
       ENDIF
-      ! END MV MP 2016
 
       !--------------------------------
@@ -360,5 +278,5 @@
       !! History :   4.0  !  2013-06  (C. Rousset)
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in )   ::   kt               ! ocean time-step index)
+      INTEGER, INTENT( in )   ::   kt               ! ocean time-step index
       INTEGER, INTENT( in )   ::   kid , kh_i
       INTEGER                 ::   nz_i, jl
@@ -476,8 +394,6 @@
       CALL histwrite( kid, "sntemcat", kt, tm_su - rt0 , jpi*jpj*jpl, (/1/) )    
 
-      ! Close the file
-      ! -----------------
-!!gm I don't understand why the file is not closed !
-      !CALL histclo( kid )
+      !! The file is closed in dia_wri_state (ocean routine)
+      !! CALL histclo( kid )
       !
     END SUBROUTINE ice_wri_state
