Index: trunk/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- trunk/NEMO/OPA_SRC/DIA/diawri.F90	(revision 631)
+++ trunk/NEMO/OPA_SRC/DIA/diawri.F90	(revision 632)
@@ -120,8 +120,8 @@
       CHARACTER (len=80) :: clname
       !!----------------------------------------------------------------------
-      
+
       ! 0. Initialisation
       ! -----------------
-      
+
       ! local variable for debugging
       ll_print = .FALSE.
@@ -160,5 +160,5 @@
 
          ! Define the NETCDF files (one per grid)
-         
+
          ! Compute julian date from starting date of the run
          CALL ymds2ju( nyear, nmonth, nday, 0.e0, zjulian )
@@ -175,7 +175,7 @@
          WRITE(inum,*) clhstnam
          CLOSE(inum)
-         
+
          ! Define the T grid FILE ( nid_T )
-         
+
          CALL dia_nam( clhstnam, nwrite, 'grid_T' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
@@ -224,5 +224,5 @@
          CALL histvert( nid_W, "depthw", "Vertical W levels",      &  ! Vertical grid: gdepw
             &          "m", ipk, gdepw_0, nz_W )
- 
+
 
          ! Declare all the output fields as NETCDF variables
@@ -280,4 +280,14 @@
             &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
 #endif
+
+#if defined key_flx_core
+         CALL histdef( nid_T, "solhflup", "Latent Heat Flux Upward"         , "W/m2"   ,   &  ! qla
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "solwfldo", "Longwave Radiation downward"     , "W/m2"   ,   &  ! qlw
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+         CALL histdef( nid_T, "sosbhfup", "Sensible Heat Flux upward"       , "W/m2"   ,   &  ! qsb
+            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+#endif
+
 
 #if ( defined key_coupled && ! defined key_ice_lim ) 
@@ -432,4 +442,9 @@
       zw2d(:,:) = erp(:,:) * sn(:,:,1) * tmask(:,:,1)
       CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
+#endif
+#if defined key_flx_core
+      CALL histwrite( nid_T, "solhflup", it, qla           , ndim_hT, ndex_hT )   ! latent heat flux
+      CALL histwrite( nid_T, "solwfldo", it, qlw           , ndim_hT, ndex_hT )   ! longwave heat flux
+      CALL histwrite( nid_T, "sosbhfup", it, qsb           , ndim_hT, ndex_hT )   ! sensible heat flux
 #endif
 #if ( defined key_coupled && ! defined key_ice_lim ) 
@@ -556,8 +571,8 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
       IF(lwp) WRITE(numout,*) '                and named :', cdfile_name, '.nc'
-      
+
       ! 0. Initialisation
       ! -----------------
-      
+
       ! Define frequency of output and means
       zdt  = rdt
@@ -617,5 +632,5 @@
       ! donne le nombre d'elements, et idex la liste des indices a sortir
       idex(1) = 1   ! init to avoid compil warning
-      
+
       ! Write all fields on T grid
       CALL histwrite( id_i, "votemper", 1, tn    , jpi*jpj*jpk, idex )    ! now temperature
@@ -641,5 +656,5 @@
 
    END SUBROUTINE dia_wri_state
- 
+
 #endif
    !!======================================================================
Index: trunk/NEMO/OPA_SRC/DIA/diawri_dimg.h90
===================================================================
--- trunk/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 631)
+++ trunk/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 632)
@@ -82,5 +82,5 @@
 
     !! * local declarations
-    INTEGER :: inbsel
+    INTEGER :: inbsel, jk
 !!  INTEGER :: iwrite
     INTEGER :: iyear,imon,iday
@@ -113,4 +113,7 @@
     inbsel = 17
 #endif
+#if defined key_flx_core
+    inbsel = 23
+#endif
 
     IF( inbsel >  jpk) THEN
@@ -131,5 +134,4 @@
     !
     IF( .NOT. ll_dia_inst ) THEN
-       !#if ! defined key_diainstant
        !
        !! * Mean output section
@@ -191,4 +193,9 @@
        fsel(:,:,18) = fsel(:,:,18) + gps(:,:)/g 
 #endif
+#if defined key_flx_core
+       fsel(:,:,21) = fsel(:,:,21) + qla(:,:)
+       fsel(:,:,22) = fsel(:,:,22) + qlw(:,:)
+       fsel(:,:,23) = fsel(:,:,23) + qsb(:,:)
+#endif
        !
        ! Output of dynamics and tracer fields and selected fields (numwri)
@@ -224,8 +231,11 @@
           fsel(:,:,20)= spgv(:,:)
 #endif
+          ! mask mean field with tmask except taux tauy (1,2)
+          DO jk=3,inbsel
+            fsel(:,:,jk)=fsel(:,:,jk)*tmask(:,:,1)
+          END DO
        ENDIF
        !
     ELSE   ! ll_dia_inst true
-       !#  else
        !
        !! * Instantaneous output section
@@ -248,6 +258,6 @@
           fsel(:,:,1 ) = taux(:,:) * umask(:,:,1)
           fsel(:,:,2 ) = tauy(:,:) * vmask(:,:,1)
-          fsel(:,:,3 ) = qt  (:,:) 
-          fsel(:,:,4 ) = emp (:,:)
+          fsel(:,:,3 ) = qt  (:,:) * tmask(:,:,1)
+          fsel(:,:,4 ) = emp (:,:) * tmask(:,:,1)
           fsel(:,:,5 ) = (tb  (:,:,1) -sst(:,:)) *tmask(:,:,1)
 
@@ -257,16 +267,16 @@
           fsel(:,:,6 ) = bsfn(:,:)
 #endif
-          fsel(:,:,7 ) = qsr (:,:)
-          fsel(:,:,8 ) = qrp (:,:)
-          fsel(:,:,9 ) = erp (:,:)*tmask(:,:,1)
-          fsel(:,:,10) = hmld(:,:) 
-          fsel(:,:,11) = hmlp(:,:)
-          fsel(:,:,12) = freeze(:,:)
+          fsel(:,:,7 ) = qsr (:,:) * tmask(:,:,1)
+          fsel(:,:,8 ) = qrp (:,:) * tmask(:,:,1)
+          fsel(:,:,9 ) = erp (:,:) * tmask(:,:,1)
+          fsel(:,:,10) = hmld(:,:) * tmask(:,:,1)
+          fsel(:,:,11) = hmlp(:,:) * tmask(:,:,1)
+          fsel(:,:,12) = freeze(:,:) * tmask(:,:,1)
           fsel(:,:,13) =  sst(:,:)  
           !         fsel(:,:,14) =  qct(:,:)
           !         fsel(:,:,15) =  fbt(:,:)
-          fsel(:,:,16) =  emps(:,:)
+          fsel(:,:,16) =  emps(:,:) * tmask(:,:,1)
 #if defined key_ice_lim
-          fsel(:,:,17) =  fsalt(:,:)
+          fsel(:,:,17) =  fsalt(:,:) * tmask(:,:,1)
 #endif
 #ifdef key_diaspr           
@@ -275,8 +285,12 @@
           fsel(:,:,20) =      spgv(:,:)
 #endif
+#if defined key_flx_core
+          fsel(:,:,21) =  qla(:,:)* tmask(:,:,1)
+          fsel(:,:,22) =  qlw(:,:)* tmask(:,:,1)
+          fsel(:,:,23) =  qsb(:,:)* tmask(:,:,1)
+#endif
           !
           !         qct(:,:) = 0._wp
        ENDIF
-       !#endif
     ENDIF
     !
Index: trunk/NEMO/OPA_SRC/SBC/flx_oce.F90
===================================================================
--- trunk/NEMO/OPA_SRC/SBC/flx_oce.F90	(revision 631)
+++ trunk/NEMO/OPA_SRC/SBC/flx_oce.F90	(revision 632)
@@ -16,5 +16,5 @@
    IMPLICIT NONE
    PRIVATE
-   
+
 
    !!----------------------------------------------------------------------
@@ -30,5 +30,5 @@
       p_emp             !: evaporation minus precipitation            
 
-#elif defined key_ice_lim || defined key_flx_bulk_monthly || defined key_flx_bulk_daily
+#elif defined key_ice_lim || defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_core
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj)    ::   &  !:
       qsr_ice  ,      &  !: solar flux over ice
@@ -56,5 +56,5 @@
    !!   Default option                                         Empty module
    !!----------------------------------------------------------------------
-   
+
 #endif
 
Index: trunk/NEMO/OPA_SRC/SBC/ocesbc.F90
===================================================================
--- trunk/NEMO/OPA_SRC/SBC/ocesbc.F90	(revision 631)
+++ trunk/NEMO/OPA_SRC/SBC/ocesbc.F90	(revision 632)
@@ -42,4 +42,7 @@
       qt  ,         &  !: total surface heat flux (w/m2)
       qsr ,         &  !: solar radiation (w/m2)
+      qla ,         &  !: Latent heat flux (W/m2)
+      qlw ,         &  !: Long Wave Heat Flux (W/m2)
+      qsb ,         &  !: Sensible Heat Flux (W/m2)
       emp ,         &  !: evaporation minus precipitation (kg/m2/s = mm/s)
       emps,         &  !: evaporation - precipitation (free surface)
@@ -90,8 +93,8 @@
       REAL(wp) ::   ztdta, ztgel, zqrp
       !!----------------------------------------------------------------------
- 
+
       ! 1. initialization to zero at kt = nit000
       ! ---------------------------------------
-      
+
       IF( kt == nit000 ) THEN     
          qsr   (:,:) = 0.e0
@@ -202,8 +205,11 @@
       ! 1. initialization to zero at kt = nit000
       ! ---------------------------------------
-      
+
       IF( kt == nit000 ) THEN     
          qsr    (:,:) = 0.e0
          qt     (:,:) = 0.e0
+         qla    (:,:) = 0.e0
+         qlw    (:,:) = 0.e0
+         qsb    (:,:) = 0.e0
          qrp    (:,:) = 0.e0
          emp    (:,:) = 0.e0
@@ -214,5 +220,9 @@
 #endif
       ENDIF
-
+#if defined key_flx_core
+      qla(:,:) = (1 - freeze(:,:))*qla_oce + freeze(:,:)*qla_ice(:,:)
+      qsb(:,:) = (1 - freeze(:,:))*qsb_oce + freeze(:,:)*qsb_ice(:,:)
+      qlw(:,:) = (1 - freeze(:,:))*qlw_oce + freeze(:,:)*qlw_ice(:,:)
+#endif
       IF( MOD( kt-1, nfice ) == 0 ) THEN
 
@@ -325,7 +335,7 @@
 
             ! hemisphere indicator (=1 north, =-1 south)
-            
+
             zhemis = float(isign(1, mjg(jj)-(jpjglo/2+1)))
-            
+
             ! a) net downward radiative flux qsr()
             ! - AGCM qsrc if no ice
@@ -350,10 +360,10 @@
             zqi = -3. + zhemis
             qt(ji,jj) = ( (1.-zice) * zq + zice * zqi ) * tmask(ji,jj,1) + qrp(ji,jj)
-            
+
             ! d) water flux damping term erp()
             ! - no damping
             zerp = 0.
             erp(ji,jj) = zerp
-            
+
             ! e) net upward water flux e() = eo + runoff() + erp()
             ! for e0
@@ -364,5 +374,5 @@
             zro = runoff(ji,jj)
             emp(ji,jj) = ( ( 1. - zice ) *  ze + zice * zei + zro ) * tmask(ji,jj,1) + erp(ji,jj)
-            
+
             ! f) net upward water flux for the salinity surface 
             !    boundary condition
@@ -375,5 +385,5 @@
 # elif defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_forced_daily || defined key_flx_core
       !!-------------------------------------------------------------------------
-      !!   'key_flx_bulk_monthly' or 'key_flx_bulk_daily' or        bulk formulea
+      !!   'key_flx_bulk_monthly' or 'key_flx_bulk_daily' or  core   bulk formulea
       !!   'key_flx_forced_daily'                                or no bulk case 
       !!-------------------------------------------------------------------------
@@ -397,5 +407,5 @@
       USE dtasst, ONLY : rclice  ! sea surface temperature data
 #endif
-#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_core
       USE blk_oce                ! bulk variables
 #endif
@@ -424,9 +434,12 @@
       ! 1. initialization to zero at kt = nit000
       ! ---------------------------------------
-      
+
       IF( kt == nit000 ) THEN     
          qsr    (:,:) = 0.e0
          freeze (:,:) = 0.e0
          qt     (:,:) = 0.e0
+         qla    (:,:) = 0.e0
+         qlw    (:,:) = 0.e0
+         qsb    (:,:) = 0.e0
          qrp    (:,:) = 0.e0
          emp    (:,:) = 0.e0
@@ -438,5 +451,5 @@
       ENDIF
 
-#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_core
       ifreq      = nfbulk
       zqt (:,:)  = qsr_oce(:,:) + qnsr_oce(:,:)
@@ -451,5 +464,9 @@
       zemp(:,:)  = p_emp(:,:)
 #endif 
-
+#if defined key_flx_core
+      qla(:,:) = (1 - freeze(:,:))*qla_oce + freeze(:,:)*qla_ice(:,:)
+      qsb(:,:) = (1 - freeze(:,:))*qsb_oce + freeze(:,:)*qsb_ice(:,:)
+      qlw(:,:) = (1 - freeze(:,:))*qlw_oce + freeze(:,:)*qlw_ice(:,:)
+#endif 
       IF( MOD( kt-1, ifreq) == 0 ) THEN
          ! Computation of internal and evaporation damping terms       
@@ -491,5 +508,5 @@
                  &                                  + freeze(ji,jj)  * zqrj ) ) * tmask(ji,jj,1)
 
-#if ! defined key_flx_bulk_monthly && ! defined key_flx_bulk_daily
+#if ! defined key_flx_bulk_monthly && ! defined key_flx_bulk_daily && ! defined key_flx_core
                zqrp = dqdt0 * ( tb(ji,jj,1) - ztdta )
                qrp(ji,jj) = qrp(ji,jj) + (1. - ziclim(ji,jj)) * zqrp
@@ -549,5 +566,5 @@
          ! -------------------------------------------------
          CALL lbc_lnk( emp, 'T', 1. )
-      
+
       ENDIF
 
@@ -757,5 +774,5 @@
             qrp   (:,:) = 0.e0
             erp   (:,:) = 0.e0
-   
+
             runoff(:,:) = 0.e0
          ENDIF
@@ -856,7 +873,7 @@
       aplus  = 0.e0
       aminus = 0.e0
-      
+
       IF( nbit_cmp == 1) THEN
-         
+
          IF(ln_ctl)   THEN
             WRITE(charout,FMT="('oce_sbc_dmp : a+ = ',D23.16, ' a- = ',D23.16)") aplus, aminus
@@ -892,5 +909,5 @@
 #else
       ! Rigid-lid (emp=emps=E-P-R+Erp)
-      
+
       erp(:,:) = ( 1. - zfreeze(:,:) ) * zsrp    &   ! surface restoring term
          &     * ( zsss(:,:) - s_dta(:,:,1) )     &
Index: trunk/NEMO/OPA_SRC/restart.F90
===================================================================
--- trunk/NEMO/OPA_SRC/restart.F90	(revision 631)
+++ trunk/NEMO/OPA_SRC/restart.F90	(revision 632)
@@ -69,8 +69,8 @@
          lrst_oce = .FALSE.
       ENDIF
-      
+
       IF    ( kt == nitrst-1 .AND. lrst_oce         ) THEN
          CALL ctl_stop( 'rst_opn: we cannot create an ocean restart at every time step',    &
-            &           'if the run ahs more than one tie step!!!' )
+            &           'if the run has more than one time step!!!' )
          numrow = 0
       ELSEIF( kt == nitrst-1 .OR.  nitend == nit000 ) THEN   ! beware if model runs only one time step
@@ -85,5 +85,10 @@
          IF(lwp) THEN
             WRITE(numout,*)
-            WRITE(numout,*) '             open ocean restart.output NetCDF file: '//clname
+            SELECT CASE ( jprstlib )
+            CASE ( jpnf90 )
+               WRITE(numout,*) '             open ocean restart.output NetCDF file: '//clname
+            CASE ( jprstdimg )
+               WRITE(numout,*) '             open ocean restart.output binary file: '//clname
+            END SELECT
             IF( kt == nitrst-1 ) THEN
                WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp
@@ -104,5 +109,5 @@
       !!                   ***  ROUTINE rstwrite  ***
       !!                     
-      !! ** Purpose :   Write restart fields in NetCDF format
+      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
       !!
       !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
@@ -134,5 +139,5 @@
       CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn    )
       CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn   )
-      
+
 #if defined key_ice_lim        
       CALL iom_rstput( kt, nitrst, numrow, 'nfice'  , REAL( nfice, wp) )   !  ice computation frequency
@@ -145,5 +150,5 @@
 # endif
 #endif
-#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_core 
       CALL iom_rstput( kt, nitrst, numrow, 'nfbulk' , REAL( nfbulk, wp) )   !  bulk computation frequency
       CALL iom_rstput( kt, nitrst, numrow, 'gsst'   , gsst    )
@@ -175,7 +180,7 @@
       !!                   ***  ROUTINE rst_read  ***
       !! 
-      !! ** Purpose :   Read files for restart
+      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
       !! 
-      !! ** Method  :   Read the previous fields on the NetCDF file 
+      !! ** Method  :   Read the previous fields on the NetCDF/binary file 
       !!      the first record indicates previous characterics
       !!      after control with the present run, we read :
@@ -208,7 +213,12 @@
       IF(lwp) THEN                                             ! Contol prints
          WRITE(numout,*)
-         WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
+         SELECT CASE ( jprstlib )
+         CASE ( jpnf90 )
+            WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
+         CASE ( jprstdimg )
+            WRITE(numout,*) 'rst_read : read oce binary restart file'
+         END SELECT
          WRITE(numout,*) '~~~~~~~~'
-         
+
          WRITE(numout,*) ' *** Info on the present job : '
          WRITE(numout,*) '   time-step           : ', nit000
@@ -329,5 +339,5 @@
       ENDIF
 #endif
-#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_core 
       ! Louvain La Neuve Sea Ice Model
       IF( iom_varid( numror, 'nfbulk' ) > 0 ) THEN 
@@ -345,5 +355,5 @@
       ENDIF
 #endif
-      
+
       !!sm: end of TO BE MOVED IN NEW SURFACE MODULE...
 
