Index: trunk/NEMO/LIM_SRC_2/limsbc_2.F90
===================================================================
--- trunk/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 1479)
+++ trunk/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 1482)
@@ -25,4 +25,5 @@
    USE lbclnk           ! ocean lateral boundary condition
    USE in_out_manager   ! I/O manager
+   USE iom              ! 
    USE albedo           ! albedo parameters
    USE prtctl           ! Print control
@@ -92,4 +93,5 @@
       REAL(wp) ::   zsang, zmod, zfm
       REAL(wp), DIMENSION(jpi,jpj) ::   ztio_u, ztio_v   ! ocean stress below sea-ice
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqnsoce          ! save qns before its modification by ice model
 
       !!---------------------------------------------------------------------
@@ -121,4 +123,5 @@
 !!gm re-verifies the non solar expression, especially over open ocen
 !!gm
+      zqnsoce(:,:) = qns(:,:)
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -185,5 +188,8 @@
          END DO
       END DO
-  
+
+      CALL iom_put( 'qns_io_cea', qns(:,:) - zqnsoce(:,:) * pfrld(:,:) )      
+      CALL iom_put( 'qsr_io_cea', fstric(:,:) * (1. - pfrld(:,:)) )
+
       !------------------------------------------!
       !      mass flux at the ocean surface      !
@@ -275,8 +281,6 @@
 
       !-----------------------------------------------!
-      !   Storing the transmitted variables           !
+      !   Coupling variables                          !
       !-----------------------------------------------!
-
-      fr_i(:,:) = 1.0 - frld(:,:)       ! sea-ice fraction
 
       IF ( lk_cpl ) THEN           
@@ -286,4 +290,5 @@
          CALL albedo_ice( tn_ice, reshape( hicif, (/jpi,jpj,1/) ), reshape( hsnif, (/jpi,jpj,1/) ), zalbp, zalb )
          alb_ice(:,:,1) =  0.5 * ( zalbp(:,:,1) + zalb (:,:,1) )   ! Ice albedo (mean clear and overcast skys)
+         CALL iom_put( "icealb_cea", alb_ice(:,:,1) * fr_i(:,:) )  ! ice albedo
       ENDIF
 
Index: trunk/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- trunk/NEMO/LIM_SRC_2/limthd_2.F90	(revision 1479)
+++ trunk/NEMO/LIM_SRC_2/limthd_2.F90	(revision 1482)
@@ -20,4 +20,5 @@
    USE lbclnk
    USE in_out_manager  ! I/O manager
+   USE iom             ! IOM library
    USE ice_2           ! LIM sea-ice variables
    USE sbc_oce         ! 
@@ -87,5 +88,5 @@
       REAL(wp) ::   zfntlat, zpareff     ! test. the val. of lead heat budget
       REAL(wp) ::   zfi                  ! temporary scalar
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zhicifp   ! ice thickness for outputs
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztmp      ! working array
       REAL(wp), DIMENSION(jpi,jpj)     ::   zqlbsbq   ! link with lead energy budget qldif
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmsk      ! working array
@@ -109,5 +110,4 @@
       rdmsnif(:,:) = 0.e0   ! variation of snow mass per unit area
       rdmicif(:,:) = 0.e0   ! variation of ice mass per unit area
-      hicifp (:,:) = 0.e0   ! daily thermodynamic ice production. 
       zmsk (:,:,:) = 0.e0
 
@@ -222,11 +222,11 @@
             fbif   (ji,jj) = zindb * (  fsbbq(ji,jj) / MAX( (1.0 - frld(ji,jj)) , epsi20 ) + fdtcn(ji,jj) )
             
-            ! computation of the daily thermodynamic ice production (only needed for output)
-            zhicifp(ji,jj) = hicif(ji,jj) * ( 1.0 - frld(ji,jj) )
+            ! computation of the thermodynamic ice production (only needed for output)
+            hicifp(ji,jj) = hicif(ji,jj) * ( 1.0 - frld(ji,jj) )
          END DO
       END DO
       
       sst_m(:,:) = sst_m(:,:) - rt0
-      
+               
       !         Select icy points and fulfill arrays for the vectorial grid.
       !----------------------------------------------------------------------
@@ -247,6 +247,6 @@
          CALL prt_ctl(tab2d_1=qcmif, clinfo1=' lim_thd: qcmif   : ', tab2d_2=fbif   , clinfo2='  fbif    : ')
          zmsk(:,:,1) = tms(:,:)
-         CALL prt_ctl(tab2d_1=qcmif  , clinfo1=' lim_thd: qcmif   : ', mask1=zmsk)
-         CALL prt_ctl(tab2d_1=zhicifp, clinfo1=' lim_thd: zhicifp : ')
+         CALL prt_ctl(tab2d_1=qcmif , clinfo1=' lim_thd: qcmif  : ', mask1=zmsk)
+         CALL prt_ctl(tab2d_1=hicifp, clinfo1=' lim_thd: hicifp : ')
          WRITE(charout, FMT="('lim_thd: nbpb = ',I4)") nbpb
          CALL prt_ctl_info(charout)
@@ -309,8 +309,10 @@
          CALL tab_1d_2d_2( nbpb, fdvolif    , npb, dvlbq_1d  (1:nbpb)     , jpi, jpj )
          CALL tab_1d_2d_2( nbpb, rdvonif    , npb, dvnbq_1d  (1:nbpb)     , jpi, jpj ) 
-         !
-      ENDIF
-
-      
+         CALL tab_1d_2d_2( nbpb, qsr_ice(:,:,1), npb, qsr_ice_1d(1:nbpb)  , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qns_ice(:,:,1), npb, qns_ice_1d(1:nbpb)  , jpi, jpj )
+         IF( .NOT. lk_cpl )   CALL tab_1d_2d_2( nbpb, qla_ice(:,:,1), npb, qla_ice_1d(1:nbpb)  , jpi, jpj )
+         !
+      ENDIF
+
       ! Up-date sea ice thickness
       !--------------------------
@@ -395,7 +397,26 @@
          DO ji = 1, jpi
             frld  (ji,jj) = MIN( frld(ji,jj), ABS( frld(ji,jj) - 2.0 ) )
-            hicifp(ji,jj) =  hicif(ji,jj) * ( 1.0 - frld(ji,jj) ) - zhicifp(ji,jj) + hicifp(ji,jj)
-         END DO
-      END DO
+            fr_i  (ji,jj) = 1.0 - frld(ji,jj)  
+            hicifp(ji,jj) = hicif(ji,jj) * fr_i(ji,jj) - hicifp(ji,jj)
+         END DO
+      END DO
+
+      ! Outputs
+      !--------------------------------------------------------------------------------
+      ztmp(:,:) = 1. - pfrld(:,:)                                   ! fraction of ice after the dynamic, before the thermodynamic
+      CALL iom_put( 'ioceflxb', fbif )                              ! Oceanic flux at the ice base           [W/m2 ???]
+      CALL iom_put( 'qsr_ai_cea', qsr_ice(:,:,1) * ztmp(:,:) )      ! Solar flux over the ice                [W/m2]
+      CALL iom_put( 'qns_ai_cea', qns_ice(:,:,1) * ztmp(:,:) )      ! Non-solar flux over the ice            [W/m2]
+      IF( .NOT. lk_cpl )   CALL iom_put( 'qla_ai_cea', qla_ice(:,:,1) * ztmp(:,:) )     ! Latent flux over the ice  [W/m2]
+      !
+      CALL iom_put( 'snowthic_cea', hsnif (:,:) * fr_i(:,:) )       ! Snow thickness                   [m]
+      CALL iom_put( 'icethic_cea' , hicif (:,:) * fr_i(:,:) )       ! Ice thickness                    [m]
+      CALL iom_put( 'iceprod_cea' , hicifp(:,:) / rdt_ice   )       ! Ice produced                     [m/s]
+      !
+      ztmp(:,:) = 1. - AINT( frld, wp )                             ! return 1 as soon as there is ice
+      CALL iom_put( 'ice_pres', ztmp )                              ! Ice presence                           [-]
+      CALL iom_put( 'ist_ipa' , ( sist(:,:) - rt0 ) * ztmp(:,:) )   ! Ice surface temperature            [Celius]
+      CALL iom_put( 'uice_ipa',  u_ice(:,:)         * ztmp(:,:) )   ! Ice velocity along i-axis at I-point
+      CALL iom_put( 'vice_ipa',  v_ice(:,:)         * ztmp(:,:) )   ! Ice velocity along j-axis at I-point
 
       IF(ln_ctl) THEN
Index: trunk/NEMO/LIM_SRC_2/limwri_2.F90
===================================================================
--- trunk/NEMO/LIM_SRC_2/limwri_2.F90	(revision 1479)
+++ trunk/NEMO/LIM_SRC_2/limwri_2.F90	(revision 1482)
@@ -4,6 +4,7 @@
    !!         Ice diagnostics :  write ice output files
    !!======================================================================
-   !! history :  2.0  ! 03-08  (C. Ethe) original code
-   !!            2.0  ! 04-10  (C. Ethe )  1D configuration
+   !! history :  2.0  ! 2003-08  (C. Ethe)      original code
+   !!            2.0  ! 2004-10  (C. Ethe )     1D configuration
+   !!             -   ! 2009-06  (B. Lemaire )  iom_put + lim_wri_state_2
    !!-------------------------------------------------------------------
 #if defined key_lim2
@@ -14,4 +15,7 @@
    !!   lim_wri_2      : write of the diagnostics variables in ouput file 
    !!   lim_wri_init_2 : initialization and namelist read
+   !!   lim_wri_state_2 : write for initial state or/and abandon:
+   !!                     > output.init.nc (if ninist = 1 in namelist)
+   !!                     > output.abort.nc
    !!----------------------------------------------------------------------
    USE phycst
@@ -32,5 +36,8 @@
    PRIVATE
 
-   PUBLIC   lim_wri_2      ! routine called by sbc_ice_lim_2
+#if ! defined key_iomput
+   PUBLIC   lim_wri_2         ! called by sbc_ice_lim_2
+#endif
+   PUBLIC   lim_wri_state_2   ! called by dia_wri_state 
 
    INTEGER, PARAMETER                       ::   jpnoumax = 40   ! maximum number of variable for ice output
@@ -61,14 +68,11 @@
 CONTAINS
 
-#if defined key_dimgout
+#if ! defined key_iomput
+# if defined key_dimgout
    !!----------------------------------------------------------------------
    !!   'key_dimgout'                                    Direct Access file
    !!----------------------------------------------------------------------
 # include "limwri_dimg_2.h90"
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                          NetCDF file
-   !!----------------------------------------------------------------------
-
+# else
    SUBROUTINE lim_wri_2( kt )
       !!-------------------------------------------------------------------
@@ -92,7 +96,5 @@
       REAL(wp), DIMENSION(jpi,jpj,jpnoumax) ::   zcmo
       !!-------------------------------------------------------------------
-
-      CALL iom_setkt( kt + nn_fsbc - 1 )
-      !                                          !--------------------!
+                                                 !--------------------!
       IF( kt == nit000 ) THEN                    !   Initialisation   !
          !                                       !--------------------!
@@ -180,16 +182,12 @@
          
          IF( nc(jf) == 1 )   CALL histwrite( nice, nam(jf), niter, zfield, ndim, ndex51 )
-         CALL iom_put( nam(jf), zfield )
          
       END DO
       
       IF( ( nn_fsbc * niter ) >= nitend )   CALL histclo( nice ) 
-      !
-      CALL iom_setkt( kt )
 
    END SUBROUTINE lim_wri_2
-   
-#endif
-   
+     
+
    SUBROUTINE lim_wri_init_2
       !!-------------------------------------------------------------------
@@ -273,4 +271,59 @@
    END SUBROUTINE lim_wri_init_2
 
+# endif
+#endif
+
+   SUBROUTINE lim_wri_state_2( kt, kid, kh_i )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE lim_wri_state_2  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!      the instantaneous ice state and forcing fields for ice model
+      !!        Used to find errors in the initial state or save the last
+      !!      ocean state in case of abnormal end of a simulation
+      !!
+      !! History :
+      !!   2.0  !  2009-06  (B. Lemaire)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt               ! ocean time-step index)
+      INTEGER, INTENT( in ) ::   kid , kh_i       
+      !!----------------------------------------------------------------------
+
+      CALL histdef( kid, "isnowthi", "Snow thickness"          , "m"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicethic", "Ice thickness"           , "m"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iiceprod", "Ice produced"            , "m/kt"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "ileadfra", "Ice concentration"       , "-"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicetemp", "Ice temperature"         , "K"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "ioceflxb", "flux at ice base"        , "w/m2"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicevelu", "i-Ice speed (I-point)"   , "m/s"    , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicevelv", "j-Ice speed (I-point)"   , "m/s"    , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "isstempe", "Sea surface temperature" , "C"      , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "isssalin", "Sea surface salinity"    , "PSU"    , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicestru", "i-Wind stress over ice (I-pt)", "Pa", jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "iicestrv", "j-Wind stress over ice (I-pt)", "Pa", jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicesflx", "Solar flux over ice"     , "w/m2"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "iicenflx", "Non-solar flux over ice" , "w/m2"   , jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "isnowpre", "Snow precipitation"      , "kg/m2/s", jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+
+      CALL histend( kid )   ! end of the file definition
+
+      CALL histwrite( kid, "isnowthi", kt, hsnif          , jpi*jpj, (/1/) )   
+      CALL histwrite( kid, "iicethic", kt, hicif          , jpi*jpj, (/1/) )    
+      CALL histwrite( kid, "iiceprod", kt, hicifp         , jpi*jpj, (/1/) )   
+      CALL histwrite( kid, "ileadfra", kt, 1. - frld(:,:) , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicetemp", kt, sist(:,:) - rt0, jpi*jpj, (/1/) )
+      CALL histwrite( kid, "ioceflxb", kt, fbif           , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicevelv", kt, u_ice          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicevelu", kt, v_ice          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "isstempe", kt, sst_m          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "isssalin", kt, sss_m          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicestru", kt, utau_ice       , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicestrv", kt, vtau_ice       , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicesflx", kt, qsr_ice(:,:,1) , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "iicenflx", kt, qns_ice(:,:,1) , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "isnowpre", kt, sprecip        , jpi*jpj, (/1/) )
+
+    END SUBROUTINE lim_wri_state_2
+
 #else
    !!----------------------------------------------------------------------
