New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 5581 for branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90 – NEMO

Ignore:
Timestamp:
2015-07-10T13:28:53+02:00 (9 years ago)
Author:
timgraham
Message:

Merged head of trunk into branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90

    r4689 r5581  
    55   !!===================================================================== 
    66   !! History :  1.0  !  2004-08  (U. Schweckendiek)  Original code 
    7    !!            2.0  !  2005-04  (L. Brodeau, A.M. Treguier) additions:  
     7   !!            2.0  !  2005-04  (L. Brodeau, A.M. Treguier) additions: 
    88   !!                           -  new bulk routine for efficiency 
    99   !!                           -  WINDS ARE NOW ASSUMED TO BE AT T POINTS in input files !!!! 
    10    !!                           -  file names and file characteristics in namelist  
    11    !!                           -  Implement reading of 6-hourly fields    
    12    !!            3.0  !  2006-06  (G. Madec) sbc rewritting    
    13    !!             -   !  2006-12  (L. Brodeau) Original code for TURB_CORE_2Z 
     10   !!                           -  file names and file characteristics in namelist 
     11   !!                           -  Implement reading of 6-hourly fields 
     12   !!            3.0  !  2006-06  (G. Madec) sbc rewritting 
     13   !!             -   !  2006-12  (L. Brodeau) Original code for turb_core_2z 
    1414   !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put 
    1515   !!            3.3  !  2010-10  (S. Masson)  add diurnal cycle 
    1616   !!            3.4  !  2011-11  (C. Harris) Fill arrays required by CICE 
     17   !!            3.7  !  2014-06  (L. Brodeau) simplification and optimization of CORE bulk 
    1718   !!---------------------------------------------------------------------- 
    1819 
    1920   !!---------------------------------------------------------------------- 
    20    !!   sbc_blk_core  : bulk formulation as ocean surface boundary condition 
    21    !!                   (forced mode, CORE bulk formulea) 
    22    !!   blk_oce_core  : ocean: computes momentum, heat and freshwater fluxes 
    23    !!   blk_ice_core  : ice  : computes momentum, heat and freshwater fluxes 
    24    !!   turb_core     : computes the CORE turbulent transfer coefficients  
     21   !!   sbc_blk_core    : bulk formulation as ocean surface boundary condition (forced mode, CORE bulk formulea) 
     22   !!   blk_oce_core    : computes momentum, heat and freshwater fluxes over ocean 
     23   !!   blk_ice_core    : computes momentum, heat and freshwater fluxes over ice 
     24   !!   turb_core_2z    : Computes turbulent transfert coefficients 
     25   !!   cd_neutral_10m  : Estimate of the neutral drag coefficient at 10m 
     26   !!   psi_m           : universal profile stability function for momentum 
     27   !!   psi_h           : universal profile stability function for temperature and humidity 
    2528   !!---------------------------------------------------------------------- 
    2629   USE oce             ! ocean dynamics and tracers 
     
    3841   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    3942   USE prtctl          ! Print control 
    40    USE sbcwave,ONLY :  cdn_wave !wave module  
    41 #if defined key_lim3 || defined key_cice 
     43   USE sbcwave, ONLY   :  cdn_wave ! wave module 
    4244   USE sbc_ice         ! Surface boundary condition: ice fields 
     45   USE lib_fortran     ! to use key_nosignedzero 
     46#if defined key_lim3 
     47   USE ice, ONLY       : u_ice, v_ice, jpl, pfrld, a_i_b 
     48   USE limthd_dh       ! for CALL lim_thd_snwblow 
     49#elif defined key_lim2 
     50   USE ice_2, ONLY     : u_ice, v_ice 
     51   USE par_ice_2 
    4352#endif 
    44    USE lib_fortran     ! to use key_nosignedzero 
    4553 
    4654   IMPLICIT NONE 
     
    4856 
    4957   PUBLIC   sbc_blk_core         ! routine called in sbcmod module 
    50    PUBLIC   blk_ice_core         ! routine called in sbc_ice_lim module 
    51    PUBLIC   blk_ice_meanqsr      ! routine called in sbc_ice_lim module 
     58#if defined key_lim2 || defined key_lim3 
     59   PUBLIC   blk_ice_core_tau     ! routine called in sbc_ice_lim module 
     60   PUBLIC   blk_ice_core_flx     ! routine called in sbc_ice_lim module 
     61#endif 
    5262   PUBLIC   turb_core_2z         ! routine calles in sbcblk_mfs module 
    5363 
    54    INTEGER , PARAMETER ::   jpfld   = 9           ! maximum number of files to read  
     64   INTEGER , PARAMETER ::   jpfld   = 9           ! maximum number of files to read 
    5565   INTEGER , PARAMETER ::   jp_wndi = 1           ! index of 10m wind velocity (i-component) (m/s)    at T-point 
    5666   INTEGER , PARAMETER ::   jp_wndj = 2           ! index of 10m wind velocity (j-component) (m/s)    at T-point 
     
    6272   INTEGER , PARAMETER ::   jp_snow = 8           ! index of snow (solid prcipitation)       (kg/m2/s) 
    6373   INTEGER , PARAMETER ::   jp_tdif = 9           ! index of tau diff associated to HF tau   (N/m2)   at T-point 
    64     
     74 
    6575   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf   ! structure of input fields (file informations, fields read) 
    66           
     76 
    6777   !                                             !!! CORE bulk parameters 
    6878   REAL(wp), PARAMETER ::   rhoa =    1.22        ! air density 
     
    7585 
    7686   !                                  !!* Namelist namsbc_core : CORE bulk parameters 
    77    LOGICAL  ::   ln_2m       ! logical flag for height of air temp. and hum 
    7887   LOGICAL  ::   ln_taudif   ! logical flag to use the "mean of stress module - module of mean stress" data 
    7988   REAL(wp) ::   rn_pfac     ! multiplication factor for precipitation 
    8089   REAL(wp) ::   rn_efac     ! multiplication factor for evaporation (clem) 
    8190   REAL(wp) ::   rn_vfac     ! multiplication factor for ice/ocean velocity in the calculation of wind stress (clem) 
    82    LOGICAL  ::   ln_bulk2z   ! logical flag for case where z(q,t) and z(u) are specified in the namelist 
    8391   REAL(wp) ::   rn_zqt      ! z(q,t) : height of humidity and temperature measurements 
    8492   REAL(wp) ::   rn_zu       ! z(u)   : height of wind measurements 
     
    8896#  include "vectopt_loop_substitute.h90" 
    8997   !!---------------------------------------------------------------------- 
    90    !! NEMO/OPA 3.3 , NEMO-consortium (2010)  
     98   !! NEMO/OPA 3.7 , NEMO-consortium (2014) 
    9199   !! $Id$ 
    92100   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     
    97105      !!--------------------------------------------------------------------- 
    98106      !!                    ***  ROUTINE sbc_blk_core  *** 
    99       !!                    
     107      !! 
    100108      !! ** Purpose :   provide at each time step the surface ocean fluxes 
    101       !!      (momentum, heat, freshwater and runoff)  
     109      !!      (momentum, heat, freshwater and runoff) 
    102110      !! 
    103111      !! ** Method  : (1) READ each fluxes in NetCDF files: 
     
    118126      !! ** Action  :   defined at each time-step at the air-sea interface 
    119127      !!              - utau, vtau  i- and j-component of the wind stress 
    120       !!              - taum, wndm  wind stress and 10m wind modules at T-point 
     128      !!              - taum        wind stress module at T-point 
     129      !!              - wndm        wind speed  module at T-point over free ocean or leads in presence of sea-ice 
    121130      !!              - qns, qsr    non-solar and solar heat fluxes 
    122131      !!              - emp         upward mass flux (evapo. - precip.) 
    123132      !!              - sfx         salt flux due to freezing/melting (non-zero only if ice is present) 
    124133      !!                            (set in limsbc(_2).F90) 
     134      !! 
     135      !! ** References :   Large & Yeager, 2004 / Large & Yeager, 2008 
     136      !!                   Brodeau et al. Ocean Modelling 2010 
    125137      !!---------------------------------------------------------------------- 
    126138      INTEGER, INTENT(in) ::   kt   ! ocean time step 
    127       !! 
     139      ! 
    128140      INTEGER  ::   ierror   ! return error code 
    129141      INTEGER  ::   ifpr     ! dummy loop indice 
    130142      INTEGER  ::   jfld     ! dummy loop arguments 
    131143      INTEGER  ::   ios      ! Local integer output status for namelist read 
    132       !! 
     144      ! 
    133145      CHARACTER(len=100) ::  cn_dir   !   Root directory for location of core files 
    134146      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i     ! array of namelist informations on the fields to read 
     
    136148      TYPE(FLD_N) ::   sn_qlw , sn_tair, sn_prec, sn_snow      !   "                                 " 
    137149      TYPE(FLD_N) ::   sn_tdif                                 !   "                                 " 
    138       NAMELIST/namsbc_core/ cn_dir , ln_2m  , ln_taudif, rn_pfac, rn_efac, rn_vfac,  & 
     150      NAMELIST/namsbc_core/ cn_dir , ln_taudif, rn_pfac, rn_efac, rn_vfac,  & 
    139151         &                  sn_wndi, sn_wndj, sn_humi  , sn_qsr ,           & 
    140152         &                  sn_qlw , sn_tair, sn_prec  , sn_snow,           & 
    141          &                  sn_tdif, rn_zqt , ln_bulk2z, rn_zu 
    142       !!--------------------------------------------------------------------- 
    143  
     153         &                  sn_tdif, rn_zqt, rn_zu 
     154      !!--------------------------------------------------------------------- 
     155      ! 
    144156      !                                         ! ====================== ! 
    145157      IF( kt == nit000 ) THEN                   !  First call kt=nit000  ! 
     
    149161         READ  ( numnam_ref, namsbc_core, IOSTAT = ios, ERR = 901) 
    150162901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_core in reference namelist', lwp ) 
    151  
     163         ! 
    152164         REWIND( numnam_cfg )              ! Namelist namsbc_core in configuration namelist : CORE bulk parameters 
    153165         READ  ( numnam_cfg, namsbc_core, IOSTAT = ios, ERR = 902 ) 
    154166902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_core in configuration namelist', lwp ) 
    155167 
    156          IF(lwm) WRITE ( numond, namsbc_core ) 
     168         IF(lwm) WRITE( numond, namsbc_core ) 
    157169         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing? 
    158          IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &  
    159             &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' )  
     170         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   & 
     171            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
    160172         IF( ln_dm2dc .AND. sn_qsr%ln_tint ) THEN 
    161173            CALL ctl_warn( 'sbc_blk_core: ln_dm2dc is taking care of the temporal interpolation of daily qsr',   & 
    162                  &         '              ==> We force time interpolation = .false. for qsr' ) 
     174               &         '              ==> We force time interpolation = .false. for qsr' ) 
    163175            sn_qsr%ln_tint = .false. 
    164176         ENDIF 
     
    169181         slf_i(jp_prec) = sn_prec   ;   slf_i(jp_snow) = sn_snow 
    170182         slf_i(jp_tdif) = sn_tdif 
    171          !                  
     183         ! 
    172184         lhftau = ln_taudif                        ! do we use HF tau information? 
    173185         jfld = jpfld - COUNT( (/.NOT. lhftau/) ) 
     
    190202      !                                            ! compute the surface ocean fluxes using CORE bulk formulea 
    191203      IF( MOD( kt - 1, nn_fsbc ) == 0 )   CALL blk_oce_core( kt, sf, sst_m, ssu_m, ssv_m ) 
    192  
    193       ! If diurnal cycle is activated, compute a daily mean short waves flux for biogeochemistery  
    194       IF( ltrcdm2dc )   CALL blk_bio_meanqsr 
    195204 
    196205#if defined key_cice 
     
    226235      !!              - qsr     : Solar heat flux over the ocean        (W/m2) 
    227236      !!              - qns     : Non Solar heat flux over the ocean    (W/m2) 
    228       !!              - evap    : Evaporation over the ocean            (kg/m2/s) 
    229237      !!              - emp     : evaporation minus precipitation       (kg/m2/s) 
    230238      !! 
     
    269277      zwnd_j(:,:) = 0.e0 
    270278#if defined key_cyclone 
    271 # if defined key_vectopt_loop 
    272 !CDIR COLLAPSE 
    273 # endif 
    274       CALL wnd_cyc( kt, zwnd_i, zwnd_j )    ! add Manu ! 
     279      CALL wnd_cyc( kt, zwnd_i, zwnd_j )    ! add analytical tropical cyclone (Vincent et al. JGR 2012) 
    275280      DO jj = 2, jpjm1 
    276281         DO ji = fs_2, fs_jpim1   ! vect. opt. 
     
    279284         END DO 
    280285      END DO 
    281 #endif 
    282 #if defined key_vectopt_loop 
    283 !CDIR COLLAPSE 
    284286#endif 
    285287      DO jj = 2, jpjm1 
     
    292294      CALL lbc_lnk( zwnd_j(:,:) , 'T', -1. ) 
    293295      ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked) 
    294 !CDIR NOVERRCHK 
    295 !CDIR COLLAPSE 
    296296      wndm(:,:) = SQRT(  zwnd_i(:,:) * zwnd_i(:,:)   & 
    297297         &             + zwnd_j(:,:) * zwnd_j(:,:)  ) * tmask(:,:,1) 
     
    300300      !      I   Radiative FLUXES                                                     ! 
    301301      ! ----------------------------------------------------------------------------- ! 
    302      
     302 
    303303      ! ocean albedo assumed to be constant + modify now Qsr to include the diurnal cycle                    ! Short Wave 
    304304      zztmp = 1. - albo 
     
    306306      ELSE                  ;   qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:,1)   * tmask(:,:,1) 
    307307      ENDIF 
    308 !CDIR COLLAPSE 
     308 
    309309      zqlw(:,:) = (  sf(jp_qlw)%fnow(:,:,1) - Stef * zst(:,:)*zst(:,:)*zst(:,:)*zst(:,:)  ) * tmask(:,:,1)   ! Long  Wave 
    310310      ! ----------------------------------------------------------------------------- ! 
     
    313313 
    314314      ! ... specific humidity at SST and IST 
    315 !CDIR NOVERRCHK 
    316 !CDIR COLLAPSE 
    317       zqsatw(:,:) = zcoef_qsatw * EXP( -5107.4 / zst(:,:) )  
     315      zqsatw(:,:) = zcoef_qsatw * EXP( -5107.4 / zst(:,:) ) 
    318316 
    319317      ! ... NCAR Bulk formulae, computation of Cd, Ch, Ce at T-point : 
    320       IF( ln_2m ) THEN 
    321          !! If air temp. and spec. hum. are given at different height (2m) than wind (10m) : 
    322          CALL TURB_CORE_2Z(2.,10., zst   , sf(jp_tair)%fnow,         & 
    323             &                      zqsatw, sf(jp_humi)%fnow, wndm,   & 
    324             &                      Cd    , Ch              , Ce  ,   & 
    325             &                      zt_zu , zq_zu                   ) 
    326       ELSE IF( ln_bulk2z ) THEN 
    327          !! If the height of the air temp./spec. hum. and wind are to be specified by hand : 
    328          IF( rn_zqt == rn_zu ) THEN 
    329             !! If air temp. and spec. hum. are at the same height as wind : 
    330             CALL TURB_CORE_1Z( rn_zu, zst   , sf(jp_tair)%fnow(:,:,1),       & 
    331                &                      zqsatw, sf(jp_humi)%fnow(:,:,1), wndm, & 
    332                &                      Cd    , Ch                     , Ce  ) 
    333          ELSE 
    334             !! If air temp. and spec. hum. are at a different height to wind : 
    335             CALL TURB_CORE_2Z(rn_zqt, rn_zu , zst   , sf(jp_tair)%fnow,         & 
    336                &                              zqsatw, sf(jp_humi)%fnow, wndm,   & 
    337                &                              Cd    , Ch              , Ce  ,   & 
    338                &                              zt_zu , zq_zu                 ) 
    339          ENDIF 
    340       ELSE 
    341          !! If air temp. and spec. hum. are given at same height than wind (10m) : 
    342 !gm bug?  at the compiling phase, add a copy in temporary arrays...  ==> check perf 
    343 !         CALL TURB_CORE_1Z( 10., zst   (:,:), sf(jp_tair)%fnow(:,:),              & 
    344 !            &                    zqsatw(:,:), sf(jp_humi)%fnow(:,:), wndm(:,:),   & 
    345 !            &                    Cd    (:,:),             Ch  (:,:), Ce  (:,:)  ) 
    346 !gm bug 
    347 ! ARPDBG - this won't compile with gfortran. Fix but check performance 
    348 ! as per comment above. 
    349          CALL TURB_CORE_1Z( 10., zst   , sf(jp_tair)%fnow(:,:,1),       & 
    350             &                    zqsatw, sf(jp_humi)%fnow(:,:,1), wndm, & 
    351             &                    Cd    , Ch              , Ce    ) 
    352       ENDIF 
    353  
     318      CALL turb_core_2z( rn_zqt, rn_zu, zst, sf(jp_tair)%fnow, zqsatw, sf(jp_humi)%fnow, wndm,   & 
     319         &               Cd, Ch, Ce, zt_zu, zq_zu ) 
     320     
    354321      ! ... tau module, i and j component 
    355322      DO jj = 1, jpj 
     
    363330 
    364331      ! ... add the HF tau contribution to the wind stress module? 
    365       IF( lhftau ) THEN  
    366 !CDIR COLLAPSE 
     332      IF( lhftau ) THEN 
    367333         taum(:,:) = taum(:,:) + sf(jp_tdif)%fnow(:,:,1) 
    368334      ENDIF 
     
    371337      ! ... utau, vtau at U- and V_points, resp. 
    372338      !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines 
     339      !     Note the use of MAX(tmask(i,j),tmask(i+1,j) is to mask tau over ice shelves 
    373340      DO jj = 1, jpjm1 
    374341         DO ji = 1, fs_jpim1 
    375             utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) ) 
    376             vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) ) 
     342            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) ) & 
     343               &          * MAX(tmask(ji,jj,1),tmask(ji+1,jj,1)) 
     344            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) ) & 
     345               &          * MAX(tmask(ji,jj,1),tmask(ji,jj+1,1)) 
    377346         END DO 
    378347      END DO 
     
    380349      CALL lbc_lnk( vtau(:,:), 'V', -1. ) 
    381350 
     351     
    382352      !  Turbulent fluxes over ocean 
    383353      ! ----------------------------- 
    384       IF( ln_2m .OR. ( ln_bulk2z .AND. rn_zqt /= rn_zu ) ) THEN 
    385          ! Values of temp. and hum. adjusted to height of wind must be used 
    386          zevap(:,:) = rn_efac * MAX( 0.e0, rhoa    *Ce(:,:)*( zqsatw(:,:) - zq_zu(:,:) ) * wndm(:,:) )  ! Evaporation 
    387          zqsb (:,:) =                      rhoa*cpa*Ch(:,:)*( zst   (:,:) - zt_zu(:,:) ) * wndm(:,:)     ! Sensible Heat 
     354      IF( ABS( rn_zu - rn_zqt) < 0.01_wp ) THEN 
     355         !! q_air and t_air are (or "are almost") given at 10m (wind reference height) 
     356         zevap(:,:) = rn_efac*MAX( 0._wp,     rhoa*Ce(:,:)*( zqsatw(:,:) - sf(jp_humi)%fnow(:,:,1) )*wndm(:,:) ) ! Evaporation 
     357         zqsb (:,:) =                     cpa*rhoa*Ch(:,:)*( zst   (:,:) - sf(jp_tair)%fnow(:,:,1) )*wndm(:,:)   ! Sensible Heat 
    388358      ELSE 
    389 !CDIR COLLAPSE 
    390          zevap(:,:) = rn_efac * MAX( 0.e0, rhoa    *Ce(:,:)*( zqsatw(:,:) - sf(jp_humi)%fnow(:,:,1) ) * wndm(:,:) )   ! Evaporation 
    391 !CDIR COLLAPSE 
    392          zqsb (:,:) =            rhoa*cpa*Ch(:,:)*( zst   (:,:) - sf(jp_tair)%fnow(:,:,1) ) * wndm(:,:)     ! Sensible Heat 
    393       ENDIF 
    394 !CDIR COLLAPSE 
     359         !! q_air and t_air are not given at 10m (wind reference height) 
     360         ! Values of temp. and hum. adjusted to height of wind during bulk algorithm iteration must be used!!! 
     361         zevap(:,:) = rn_efac*MAX( 0._wp,     rhoa*Ce(:,:)*( zqsatw(:,:) - zq_zu(:,:) )*wndm(:,:) )   ! Evaporation 
     362         zqsb (:,:) =                     cpa*rhoa*Ch(:,:)*( zst   (:,:) - zt_zu(:,:) )*wndm(:,:)     ! Sensible Heat 
     363      ENDIF 
    395364      zqla (:,:) = Lv * zevap(:,:)                                                              ! Latent Heat 
    396365 
     
    409378      !     III    Total FLUXES                                                       ! 
    410379      ! ----------------------------------------------------------------------------- ! 
    411       
    412 !CDIR COLLAPSE 
     380      ! 
    413381      emp (:,:) = (  zevap(:,:)                                          &   ! mass flux (evap. - precip.) 
    414382         &         - sf(jp_prec)%fnow(:,:,1) * rn_pfac  ) * tmask(:,:,1) 
    415 !CDIR COLLAPSE 
    416       qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                                &   ! Downward Non Solar flux 
     383      ! 
     384      qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                                &   ! Downward Non Solar  
    417385         &     - sf(jp_snow)%fnow(:,:,1) * rn_pfac * lfus                         &   ! remove latent melting heat for solid precip 
    418386         &     - zevap(:,:) * pst(:,:) * rcp                                      &   ! remove evap heat content at SST 
    419387         &     + ( sf(jp_prec)%fnow(:,:,1) - sf(jp_snow)%fnow(:,:,1) ) * rn_pfac  &   ! add liquid precip heat content at Tair 
    420          &     * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp                          &    
     388         &     * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp                          & 
    421389         &     + sf(jp_snow)%fnow(:,:,1) * rn_pfac                                &   ! add solid  precip heat content at min(Tair,Tsnow) 
    422          &     * ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic  
    423       ! 
    424       CALL iom_put( "qlw_oce",   zqlw )                 ! output downward longwave heat over the ocean 
    425       CALL iom_put( "qsb_oce", - zqsb )                 ! output downward sensible heat over the ocean 
    426       CALL iom_put( "qla_oce", - zqla )                 ! output downward latent   heat over the ocean 
    427       CALL iom_put( "qhc_oce",   qns-zqlw+zqsb+zqla )   ! output downward heat content of E-P over the ocean 
    428       CALL iom_put( "qns_oce",   qns  )                 ! output downward non solar heat over the ocean 
     390         &     * ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) 
     391      ! 
     392#if defined key_lim3 
     393      qns_oce(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                                ! non solar without emp (only needed by LIM3) 
     394      qsr_oce(:,:) = qsr(:,:) 
     395#endif 
     396      ! 
     397      IF ( nn_ice == 0 ) THEN 
     398         CALL iom_put( "qlw_oce" ,   zqlw )                 ! output downward longwave heat over the ocean 
     399         CALL iom_put( "qsb_oce" , - zqsb )                 ! output downward sensible heat over the ocean 
     400         CALL iom_put( "qla_oce" , - zqla )                 ! output downward latent   heat over the ocean 
     401         CALL iom_put( "qemp_oce",   qns-zqlw+zqsb+zqla )   ! output downward heat content of E-P over the ocean 
     402         CALL iom_put( "qns_oce" ,   qns  )                 ! output downward non solar heat over the ocean 
     403         CALL iom_put( "qsr_oce" ,   qsr  )                 ! output downward solar heat over the ocean 
     404         CALL iom_put( "qt_oce"  ,   qns+qsr )              ! output total downward heat over the ocean 
     405      ENDIF 
    429406      ! 
    430407      IF(ln_ctl) THEN 
     
    442419      ! 
    443420   END SUBROUTINE blk_oce_core 
    444    
    445    SUBROUTINE blk_bio_meanqsr 
    446       !!--------------------------------------------------------------------- 
    447       !!                     ***  ROUTINE blk_bio_meanqsr 
    448       !!                      
    449       !! ** Purpose :   provide daily qsr_mean for PISCES when 
    450       !!                analytic diurnal cycle is applied in physic 
    451       !!                 
    452       !! ** Method  :   add part where there is no ice 
    453       !!  
    454       !!--------------------------------------------------------------------- 
    455       IF( nn_timing == 1 )  CALL timing_start('blk_bio_meanqsr') 
    456  
    457       qsr_mean(:,:) = (1. - albo ) *  sf(jp_qsr)%fnow(:,:,1) 
    458  
    459       IF( nn_timing == 1 )  CALL timing_stop('blk_bio_meanqsr') 
    460  
    461    END SUBROUTINE blk_bio_meanqsr 
    462421  
    463   
    464    SUBROUTINE blk_ice_meanqsr(palb,p_qsr_mean,pdim) 
    465       !!--------------------------------------------------------------------- 
    466       !! 
    467       !! ** Purpose :   provide the daily qsr_mean over sea_ice for PISCES when 
    468       !!                analytic diurnal cycle is applied in physic 
    469       !! 
    470       !! ** Method  :   compute qsr 
    471       !!  
    472       !!--------------------------------------------------------------------- 
    473       REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   palb       ! ice albedo (clear sky) (alb_ice_cs)               [%] 
    474       REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qsr_mean !     solar heat flux over ice (T-point)         [W/m2] 
    475       INTEGER                   , INTENT(in   ) ::   pdim       ! number of ice categories 
    476       !! 
    477       INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays) 
    478       INTEGER  ::   ji, jj, jl    ! dummy loop indices 
    479       REAL(wp) ::   zztmp         ! temporary variable 
    480       !!--------------------------------------------------------------------- 
    481       IF( nn_timing == 1 )  CALL timing_start('blk_ice_meanqsr') 
    482       ! 
    483       ijpl  = pdim                            ! number of ice categories 
    484       zztmp = 1. / ( 1. - albo ) 
    485       !                                     ! ========================== ! 
    486       DO jl = 1, ijpl                       !  Loop over ice categories  ! 
    487          !                                  ! ========================== ! 
    488          DO jj = 1 , jpj 
    489             DO ji = 1, jpi 
    490                   p_qsr_mean(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr_mean(ji,jj) 
     422    
     423#if defined key_lim2 || defined key_lim3 
     424   SUBROUTINE blk_ice_core_tau 
     425      !!--------------------------------------------------------------------- 
     426      !!                     ***  ROUTINE blk_ice_core_tau  *** 
     427      !! 
     428      !! ** Purpose :   provide the surface boundary condition over sea-ice 
     429      !! 
     430      !! ** Method  :   compute momentum using CORE bulk 
     431      !!                formulea, ice variables and read atmospheric fields. 
     432      !!                NB: ice drag coefficient is assumed to be a constant 
     433      !!--------------------------------------------------------------------- 
     434      INTEGER  ::   ji, jj    ! dummy loop indices 
     435      REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2 
     436      REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f               ! relative wind module and components at F-point 
     437      REAL(wp) ::             zwndi_t , zwndj_t               ! relative wind components at T-point 
     438      !!--------------------------------------------------------------------- 
     439      ! 
     440      IF( nn_timing == 1 )  CALL timing_start('blk_ice_core_tau') 
     441      ! 
     442      ! local scalars ( place there for vector optimisation purposes) 
     443      zcoef_wnorm  = rhoa * Cice 
     444      zcoef_wnorm2 = rhoa * Cice * 0.5 
     445 
     446!!gm brutal.... 
     447      utau_ice  (:,:) = 0._wp 
     448      vtau_ice  (:,:) = 0._wp 
     449      wndm_ice  (:,:) = 0._wp 
     450!!gm end 
     451 
     452      ! ----------------------------------------------------------------------------- ! 
     453      !    Wind components and module relative to the moving ocean ( U10m - U_ice )   ! 
     454      ! ----------------------------------------------------------------------------- ! 
     455      SELECT CASE( cp_ice_msh ) 
     456      CASE( 'I' )                  ! B-grid ice dynamics :   I-point (i.e. F-point with sea-ice indexation) 
     457         !                           and scalar wind at T-point ( = | U10m - U_ice | ) (masked) 
     458         DO jj = 2, jpjm1 
     459            DO ji = 2, jpim1   ! B grid : NO vector opt 
     460               ! ... scalar wind at I-point (fld being at T-point) 
     461               zwndi_f = 0.25 * (  sf(jp_wndi)%fnow(ji-1,jj  ,1) + sf(jp_wndi)%fnow(ji  ,jj  ,1)   & 
     462                  &              + sf(jp_wndi)%fnow(ji-1,jj-1,1) + sf(jp_wndi)%fnow(ji  ,jj-1,1)  ) - rn_vfac * u_ice(ji,jj) 
     463               zwndj_f = 0.25 * (  sf(jp_wndj)%fnow(ji-1,jj  ,1) + sf(jp_wndj)%fnow(ji  ,jj  ,1)   & 
     464                  &              + sf(jp_wndj)%fnow(ji-1,jj-1,1) + sf(jp_wndj)%fnow(ji  ,jj-1,1)  ) - rn_vfac * v_ice(ji,jj) 
     465               zwnorm_f = zcoef_wnorm * SQRT( zwndi_f * zwndi_f + zwndj_f * zwndj_f ) 
     466               ! ... ice stress at I-point 
     467               utau_ice(ji,jj) = zwnorm_f * zwndi_f 
     468               vtau_ice(ji,jj) = zwnorm_f * zwndj_f 
     469               ! ... scalar wind at T-point (fld being at T-point) 
     470               zwndi_t = sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  u_ice(ji,jj+1) + u_ice(ji+1,jj+1)   & 
     471                  &                                                    + u_ice(ji,jj  ) + u_ice(ji+1,jj  )  ) 
     472               zwndj_t = sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  v_ice(ji,jj+1) + v_ice(ji+1,jj+1)   & 
     473                  &                                                    + v_ice(ji,jj  ) + v_ice(ji+1,jj  )  ) 
     474               wndm_ice(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1) 
    491475            END DO 
    492476         END DO 
    493       END DO 
    494       ! 
    495       IF( nn_timing == 1 )  CALL timing_stop('blk_ice_meanqsr') 
    496       ! 
    497    END SUBROUTINE blk_ice_meanqsr   
    498   
    499     
    500    SUBROUTINE blk_ice_core(  pst   , pui   , pvi   , palb ,   & 
    501       &                      p_taui, p_tauj, p_qns , p_qsr,   & 
    502       &                      p_qla , p_dqns, p_dqla,          & 
    503       &                      p_tpr , p_spr ,                  & 
    504       &                      p_fr1 , p_fr2 , cd_grid, pdim  )  
    505       !!--------------------------------------------------------------------- 
    506       !!                     ***  ROUTINE blk_ice_core  *** 
     477         CALL lbc_lnk( utau_ice, 'I', -1. ) 
     478         CALL lbc_lnk( vtau_ice, 'I', -1. ) 
     479         CALL lbc_lnk( wndm_ice, 'T',  1. ) 
     480         ! 
     481      CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean) 
     482         DO jj = 2, jpj 
     483            DO ji = fs_2, jpi   ! vect. opt. 
     484               zwndi_t = (  sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( u_ice(ji-1,jj  ) + u_ice(ji,jj) )  ) 
     485               zwndj_t = (  sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( v_ice(ji  ,jj-1) + v_ice(ji,jj) )  ) 
     486               wndm_ice(ji,jj) = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1) 
     487            END DO 
     488         END DO 
     489         DO jj = 2, jpjm1 
     490            DO ji = fs_2, fs_jpim1   ! vect. opt. 
     491               utau_ice(ji,jj) = zcoef_wnorm2 * ( wndm_ice(ji+1,jj  ) + wndm_ice(ji,jj) )                          & 
     492                  &          * ( 0.5 * (sf(jp_wndi)%fnow(ji+1,jj,1) + sf(jp_wndi)%fnow(ji,jj,1) ) - rn_vfac * u_ice(ji,jj) ) 
     493               vtau_ice(ji,jj) = zcoef_wnorm2 * ( wndm_ice(ji,jj+1  ) + wndm_ice(ji,jj) )                          & 
     494                  &          * ( 0.5 * (sf(jp_wndj)%fnow(ji,jj+1,1) + sf(jp_wndj)%fnow(ji,jj,1) ) - rn_vfac * v_ice(ji,jj) ) 
     495            END DO 
     496         END DO 
     497         CALL lbc_lnk( utau_ice, 'U', -1. ) 
     498         CALL lbc_lnk( vtau_ice, 'V', -1. ) 
     499         CALL lbc_lnk( wndm_ice, 'T',  1. ) 
     500         ! 
     501      END SELECT 
     502 
     503      IF(ln_ctl) THEN 
     504         CALL prt_ctl(tab2d_1=utau_ice  , clinfo1=' blk_ice_core: utau_ice : ', tab2d_2=vtau_ice  , clinfo2=' vtau_ice : ') 
     505         CALL prt_ctl(tab2d_1=wndm_ice  , clinfo1=' blk_ice_core: wndm_ice : ') 
     506      ENDIF 
     507 
     508      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_core_tau') 
     509       
     510   END SUBROUTINE blk_ice_core_tau 
     511 
     512 
     513   SUBROUTINE blk_ice_core_flx( ptsu, palb ) 
     514      !!--------------------------------------------------------------------- 
     515      !!                     ***  ROUTINE blk_ice_core_flx  *** 
    507516      !! 
    508517      !! ** Purpose :   provide the surface boundary condition over sea-ice 
    509518      !! 
    510       !! ** Method  :   compute momentum, heat and freshwater exchanged 
     519      !! ** Method  :   compute heat and freshwater exchanged 
    511520      !!                between atmosphere and sea-ice using CORE bulk 
    512521      !!                formulea, ice variables and read atmmospheric fields. 
    513       !!                NB: ice drag coefficient is assumed to be a constant 
    514522      !!  
    515523      !! caution : the net upward water flux has with mm/day unit 
    516524      !!--------------------------------------------------------------------- 
    517       REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pst      ! ice surface temperature (>0, =rt0 over land) [Kelvin] 
    518       REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pui      ! ice surface velocity (i- and i- components      [m/s] 
    519       REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pvi      !    at I-point (B-grid) or U & V-point (C-grid) 
    520       REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   palb     ! ice albedo (clear sky) (alb_ice_cs)               [%] 
    521       REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_taui   ! i- & j-components of surface ice stress        [N/m2] 
    522       REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tauj   !   at I-point (B-grid) or U & V-point (C-grid) 
    523       REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qns    ! non solar heat flux over ice (T-point)         [W/m2] 
    524       REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qsr    !     solar heat flux over ice (T-point)         [W/m2] 
    525       REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qla    ! latent    heat flux over ice (T-point)         [W/m2] 
    526       REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqns   ! non solar heat sensistivity  (T-point)         [W/m2] 
    527       REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqla   ! latent    heat sensistivity  (T-point)         [W/m2] 
    528       REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tpr    ! total precipitation          (T-point)      [Kg/m2/s] 
    529       REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_spr    ! solid precipitation          (T-point)      [Kg/m2/s] 
    530       REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr1    ! 1sr fraction of qsr penetration in ice (T-point)  [%] 
    531       REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr2    ! 2nd fraction of qsr penetration in ice (T-point)  [%] 
    532       CHARACTER(len=1)          , INTENT(in   ) ::   cd_grid  ! ice grid ( C or B-grid) 
    533       INTEGER                   , INTENT(in   ) ::   pdim     ! number of ice categories 
     525      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   ptsu          ! sea ice surface temperature 
     526      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   palb          ! ice albedo (all skies) 
    534527      !! 
    535528      INTEGER  ::   ji, jj, jl    ! dummy loop indices 
    536       INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays) 
    537529      REAL(wp) ::   zst2, zst3 
    538       REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2, zcoef_dqlw, zcoef_dqla, zcoef_dqsb 
    539       REAL(wp) ::   zztmp                                        ! temporary variable 
    540       REAL(wp) ::   zcoef_frca                                   ! fractional cloud amount 
    541       REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f                  ! relative wind module and components at F-point 
    542       REAL(wp) ::             zwndi_t , zwndj_t                  ! relative wind components at T-point 
    543       !! 
    544       REAL(wp), DIMENSION(:,:)  , POINTER ::   z_wnds_t          ! wind speed ( = | U10m - U_ice | ) at T-point 
     530      REAL(wp) ::   zcoef_dqlw, zcoef_dqla, zcoef_dqsb 
     531      REAL(wp) ::   zztmp, z1_lsub                               ! temporary variable 
     532      !! 
    545533      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qlw             ! long wave heat flux over ice 
    546534      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qsb             ! sensible  heat flux over ice 
    547535      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqlw            ! long wave heat sensitivity over ice 
    548536      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqsb            ! sensible  heat sensitivity over ice 
    549       !!--------------------------------------------------------------------- 
    550       ! 
    551       IF( nn_timing == 1 )  CALL timing_start('blk_ice_core') 
    552       ! 
    553       CALL wrk_alloc( jpi,jpj, z_wnds_t ) 
    554       CALL wrk_alloc( jpi,jpj,pdim, z_qlw, z_qsb, z_dqlw, z_dqsb )  
    555  
    556       ijpl  = pdim                            ! number of ice categories 
     537      REAL(wp), DIMENSION(:,:)  , POINTER ::   zevap, zsnw       ! evaporation and snw distribution after wind blowing (LIM3) 
     538      !!--------------------------------------------------------------------- 
     539      ! 
     540      IF( nn_timing == 1 )  CALL timing_start('blk_ice_core_flx') 
     541      ! 
     542      CALL wrk_alloc( jpi,jpj,jpl, z_qlw, z_qsb, z_dqlw, z_dqsb )  
    557543 
    558544      ! local scalars ( place there for vector optimisation purposes) 
    559       zcoef_wnorm  = rhoa * Cice 
    560       zcoef_wnorm2 = rhoa * Cice * 0.5 
    561545      zcoef_dqlw   = 4.0 * 0.95 * Stef 
    562546      zcoef_dqla   = -Ls * Cice * 11637800. * (-5897.8) 
    563547      zcoef_dqsb   = rhoa * cpa * Cice 
    564       zcoef_frca   = 1.0  - 0.3 
    565       ! MV 2014 the proper cloud fraction (mean summer months from the CLIO climato, NH+SH) is 0.19 
    566       zcoef_frca   = 1.0  - 0.19 
    567  
    568 !!gm brutal.... 
    569       z_wnds_t(:,:) = 0.e0 
    570       p_taui  (:,:) = 0.e0 
    571       p_tauj  (:,:) = 0.e0 
    572 !!gm end 
    573  
    574 #if defined key_lim3 
    575       tatm_ice(:,:) = sf(jp_tair)%fnow(:,:,1)   ! LIM3: make Tair available in sea-ice. WARNING allocated after call to ice_init 
    576 #endif 
    577       ! ----------------------------------------------------------------------------- ! 
    578       !    Wind components and module relative to the moving ocean ( U10m - U_ice )   ! 
    579       ! ----------------------------------------------------------------------------- ! 
    580       SELECT CASE( cd_grid ) 
    581       CASE( 'I' )                  ! B-grid ice dynamics :   I-point (i.e. F-point with sea-ice indexation) 
    582          !                           and scalar wind at T-point ( = | U10m - U_ice | ) (masked) 
    583 !CDIR NOVERRCHK 
    584          DO jj = 2, jpjm1 
    585             DO ji = 2, jpim1   ! B grid : NO vector opt 
    586                ! ... scalar wind at I-point (fld being at T-point) 
    587                zwndi_f = 0.25 * (  sf(jp_wndi)%fnow(ji-1,jj  ,1) + sf(jp_wndi)%fnow(ji  ,jj  ,1)   & 
    588                   &              + sf(jp_wndi)%fnow(ji-1,jj-1,1) + sf(jp_wndi)%fnow(ji  ,jj-1,1)  ) - rn_vfac * pui(ji,jj) 
    589                zwndj_f = 0.25 * (  sf(jp_wndj)%fnow(ji-1,jj  ,1) + sf(jp_wndj)%fnow(ji  ,jj  ,1)   & 
    590                   &              + sf(jp_wndj)%fnow(ji-1,jj-1,1) + sf(jp_wndj)%fnow(ji  ,jj-1,1)  ) - rn_vfac * pvi(ji,jj) 
    591                zwnorm_f = zcoef_wnorm * SQRT( zwndi_f * zwndi_f + zwndj_f * zwndj_f ) 
    592                ! ... ice stress at I-point 
    593                p_taui(ji,jj) = zwnorm_f * zwndi_f 
    594                p_tauj(ji,jj) = zwnorm_f * zwndj_f 
    595                ! ... scalar wind at T-point (fld being at T-point) 
    596                zwndi_t = sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  pui(ji,jj+1) + pui(ji+1,jj+1)   & 
    597                   &                                                    + pui(ji,jj  ) + pui(ji+1,jj  )  ) 
    598                zwndj_t = sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  pvi(ji,jj+1) + pvi(ji+1,jj+1)   & 
    599                   &                                                    + pvi(ji,jj  ) + pvi(ji+1,jj  )  ) 
    600                z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1) 
    601             END DO 
    602          END DO 
    603          CALL lbc_lnk( p_taui  , 'I', -1. ) 
    604          CALL lbc_lnk( p_tauj  , 'I', -1. ) 
    605          CALL lbc_lnk( z_wnds_t, 'T',  1. ) 
    606          ! 
    607       CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean) 
    608 #if defined key_vectopt_loop 
    609 !CDIR COLLAPSE 
    610 #endif 
    611          DO jj = 2, jpj 
    612             DO ji = fs_2, jpi   ! vect. opt. 
    613                zwndi_t = (  sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pui(ji-1,jj  ) + pui(ji,jj) )  ) 
    614                zwndj_t = (  sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pvi(ji  ,jj-1) + pvi(ji,jj) )  ) 
    615                z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1) 
    616             END DO 
    617          END DO 
    618 #if defined key_vectopt_loop 
    619 !CDIR COLLAPSE 
    620 #endif 
    621          DO jj = 2, jpjm1 
    622             DO ji = fs_2, fs_jpim1   ! vect. opt. 
    623                p_taui(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji+1,jj  ) + z_wnds_t(ji,jj) )                          & 
    624                   &          * ( 0.5 * (sf(jp_wndi)%fnow(ji+1,jj,1) + sf(jp_wndi)%fnow(ji,jj,1) ) - rn_vfac * pui(ji,jj) ) 
    625                p_tauj(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji,jj+1  ) + z_wnds_t(ji,jj) )                          & 
    626                   &          * ( 0.5 * (sf(jp_wndj)%fnow(ji,jj+1,1) + sf(jp_wndj)%fnow(ji,jj,1) ) - rn_vfac * pvi(ji,jj) ) 
    627             END DO 
    628          END DO 
    629          CALL lbc_lnk( p_taui  , 'U', -1. ) 
    630          CALL lbc_lnk( p_tauj  , 'V', -1. ) 
    631          CALL lbc_lnk( z_wnds_t, 'T',  1. ) 
    632          ! 
    633       END SELECT 
    634548 
    635549      zztmp = 1. / ( 1. - albo ) 
    636550      !                                     ! ========================== ! 
    637       DO jl = 1, ijpl                       !  Loop over ice categories  ! 
     551      DO jl = 1, jpl                        !  Loop over ice categories  ! 
    638552         !                                  ! ========================== ! 
    639 !CDIR NOVERRCHK 
    640 !CDIR COLLAPSE 
    641553         DO jj = 1 , jpj 
    642 !CDIR NOVERRCHK 
    643554            DO ji = 1, jpi 
    644555               ! ----------------------------! 
    645556               !      I   Radiative FLUXES   ! 
    646557               ! ----------------------------! 
    647                zst2 = pst(ji,jj,jl) * pst(ji,jj,jl) 
    648                zst3 = pst(ji,jj,jl) * zst2 
     558               zst2 = ptsu(ji,jj,jl) * ptsu(ji,jj,jl) 
     559               zst3 = ptsu(ji,jj,jl) * zst2 
    649560               ! Short Wave (sw) 
    650                p_qsr(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr(ji,jj) 
     561               qsr_ice(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr(ji,jj) 
    651562               ! Long  Wave (lw) 
    652                z_qlw(ji,jj,jl) = 0.95 * ( sf(jp_qlw)%fnow(ji,jj,1) - Stef * pst(ji,jj,jl) * zst3 ) * tmask(ji,jj,1) 
     563               z_qlw(ji,jj,jl) = 0.95 * ( sf(jp_qlw)%fnow(ji,jj,1) - Stef * ptsu(ji,jj,jl) * zst3 ) * tmask(ji,jj,1) 
    653564               ! lw sensitivity 
    654565               z_dqlw(ji,jj,jl) = zcoef_dqlw * zst3                                                
     
    660571               ! ... turbulent heat fluxes 
    661572               ! Sensible Heat 
    662                z_qsb(ji,jj,jl) = rhoa * cpa * Cice * z_wnds_t(ji,jj) * ( pst(ji,jj,jl) - sf(jp_tair)%fnow(ji,jj,1) ) 
     573               z_qsb(ji,jj,jl) = rhoa * cpa * Cice * wndm_ice(ji,jj) * ( ptsu(ji,jj,jl) - sf(jp_tair)%fnow(ji,jj,1) ) 
    663574               ! Latent Heat 
    664                p_qla(ji,jj,jl) = rn_efac * MAX( 0.e0, rhoa * Ls  * Cice * z_wnds_t(ji,jj)   &                            
    665                   &                         * (  11637800. * EXP( -5897.8 / pst(ji,jj,jl) ) / rhoa - sf(jp_humi)%fnow(ji,jj,1)  ) ) 
    666                ! Latent heat sensitivity for ice (Dqla/Dt) 
    667                ! MV we also have to cap the sensitivity if the flux is zero 
    668                IF ( p_qla(ji,jj,jl) .GT. 0.0 ) THEN 
    669                   p_dqla(ji,jj,jl) = rn_efac * zcoef_dqla * z_wnds_t(ji,jj) / ( zst2 ) * EXP( -5897.8 / pst(ji,jj,jl) ) 
     575               qla_ice(ji,jj,jl) = rn_efac * MAX( 0.e0, rhoa * Ls  * Cice * wndm_ice(ji,jj)   &                            
     576                  &                         * (  11637800. * EXP( -5897.8 / ptsu(ji,jj,jl) ) / rhoa - sf(jp_humi)%fnow(ji,jj,1)  ) ) 
     577              ! Latent heat sensitivity for ice (Dqla/Dt) 
     578               IF( qla_ice(ji,jj,jl) > 0._wp ) THEN 
     579                  dqla_ice(ji,jj,jl) = rn_efac * zcoef_dqla * wndm_ice(ji,jj) / ( zst2 ) * EXP( -5897.8 / ptsu(ji,jj,jl) ) 
    670580               ELSE 
    671                   p_dqla(ji,jj,jl) = 0.0 
     581                  dqla_ice(ji,jj,jl) = 0._wp 
    672582               ENDIF 
    673                               
     583 
    674584               ! Sensible heat sensitivity (Dqsb_ice/Dtn_ice) 
    675                z_dqsb(ji,jj,jl) = zcoef_dqsb * z_wnds_t(ji,jj) 
     585               z_dqsb(ji,jj,jl) = zcoef_dqsb * wndm_ice(ji,jj) 
    676586 
    677587               ! ----------------------------! 
     
    679589               ! ----------------------------! 
    680590               ! Downward Non Solar flux 
    681                p_qns (ji,jj,jl) =     z_qlw (ji,jj,jl) - z_qsb (ji,jj,jl) - p_qla (ji,jj,jl)       
     591               qns_ice (ji,jj,jl) =     z_qlw (ji,jj,jl) - z_qsb (ji,jj,jl) - qla_ice (ji,jj,jl) 
    682592               ! Total non solar heat flux sensitivity for ice 
    683                p_dqns(ji,jj,jl) = - ( z_dqlw(ji,jj,jl) + z_dqsb(ji,jj,jl) + p_dqla(ji,jj,jl) )     
     593               dqns_ice(ji,jj,jl) = - ( z_dqlw(ji,jj,jl) + z_dqsb(ji,jj,jl) + dqla_ice(ji,jj,jl) ) 
    684594            END DO 
    685595            ! 
     
    688598      END DO 
    689599      ! 
     600      tprecip(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac      ! total precipitation [kg/m2/s] 
     601      sprecip(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac      ! solid precipitation [kg/m2/s] 
     602      CALL iom_put( 'snowpre', sprecip * 86400. )                  ! Snow precipitation 
     603      CALL iom_put( 'precip' , tprecip * 86400. )                  ! Total precipitation 
     604 
     605#if defined  key_lim3 
     606      CALL wrk_alloc( jpi,jpj, zevap, zsnw )  
     607 
     608      ! --- evaporation --- ! 
     609      z1_lsub = 1._wp / Lsub 
     610      evap_ice (:,:,:) = qla_ice (:,:,:) * z1_lsub ! sublimation 
     611      devap_ice(:,:,:) = dqla_ice(:,:,:) * z1_lsub 
     612      zevap    (:,:)   = emp(:,:) + tprecip(:,:)   ! evaporation over ocean 
     613 
     614      ! --- evaporation minus precipitation --- ! 
     615      zsnw(:,:) = 0._wp 
     616      CALL lim_thd_snwblow( pfrld, zsnw )  ! snow distribution over ice after wind blowing  
     617      emp_oce(:,:) = pfrld(:,:) * zevap(:,:) - ( tprecip(:,:) - sprecip(:,:) ) - sprecip(:,:) * (1._wp - zsnw ) 
     618      emp_ice(:,:) = SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) - sprecip(:,:) * zsnw 
     619      emp_tot(:,:) = emp_oce(:,:) + emp_ice(:,:) 
     620 
     621      ! --- heat flux associated with emp --- ! 
     622      qemp_oce(:,:) = - pfrld(:,:) * zevap(:,:) * sst_m(:,:) * rcp                               & ! evap at sst 
     623         &          + ( tprecip(:,:) - sprecip(:,:) ) * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp  & ! liquid precip at Tair 
     624         &          +   sprecip(:,:) * ( 1._wp - zsnw ) *                                        & ! solid precip at min(Tair,Tsnow) 
     625         &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     626      qemp_ice(:,:) =   sprecip(:,:) * zsnw *                                                    & ! solid precip (only) 
     627         &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     628 
     629      ! --- total solar and non solar fluxes --- ! 
     630      qns_tot(:,:) = pfrld(:,:) * qns_oce(:,:) + SUM( a_i_b(:,:,:) * qns_ice(:,:,:), dim=3 ) + qemp_ice(:,:) + qemp_oce(:,:) 
     631      qsr_tot(:,:) = pfrld(:,:) * qsr_oce(:,:) + SUM( a_i_b(:,:,:) * qsr_ice(:,:,:), dim=3 ) 
     632 
     633      ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- ! 
     634      qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus ) 
     635 
     636      CALL wrk_dealloc( jpi,jpj, zevap, zsnw )  
     637#endif 
     638 
    690639      !-------------------------------------------------------------------- 
    691640      ! FRACTIONs of net shortwave radiation which is not absorbed in the 
    692641      ! thin surface layer and penetrates inside the ice cover 
    693642      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 ) 
    694      
    695 !CDIR COLLAPSE 
    696       p_fr1(:,:) = ( 0.18 * ( 1.0 - zcoef_frca ) + 0.35 * zcoef_frca ) 
    697 !CDIR COLLAPSE 
    698       p_fr2(:,:) = ( 0.82 * ( 1.0 - zcoef_frca ) + 0.65 * zcoef_frca ) 
    699         
    700 !CDIR COLLAPSE 
    701       p_tpr(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac      ! total precipitation [kg/m2/s] 
    702 !CDIR COLLAPSE 
    703       p_spr(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac      ! solid precipitation [kg/m2/s] 
    704       CALL iom_put( 'snowpre', p_spr * 86400. )                  ! Snow precipitation  
    705       CALL iom_put( 'precip', p_tpr * 86400. )                   ! Total precipitation  
     643      ! 
     644      fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice ) 
     645      fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice ) 
     646      ! 
    706647      ! 
    707648      IF(ln_ctl) THEN 
    708          CALL prt_ctl(tab3d_1=p_qla   , clinfo1=' blk_ice_core: p_qla  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb  : ', kdim=ijpl) 
    709          CALL prt_ctl(tab3d_1=z_qlw   , clinfo1=' blk_ice_core: z_qlw  : ', tab3d_2=p_dqla  , clinfo2=' p_dqla : ', kdim=ijpl) 
    710          CALL prt_ctl(tab3d_1=z_dqsb  , clinfo1=' blk_ice_core: z_dqsb : ', tab3d_2=z_dqlw  , clinfo2=' z_dqlw : ', kdim=ijpl) 
    711          CALL prt_ctl(tab3d_1=p_dqns  , clinfo1=' blk_ice_core: p_dqns : ', tab3d_2=p_qsr   , clinfo2=' p_qsr  : ', kdim=ijpl) 
    712          CALL prt_ctl(tab3d_1=pst     , clinfo1=' blk_ice_core: pst    : ', tab3d_2=p_qns   , clinfo2=' p_qns  : ', kdim=ijpl) 
    713          CALL prt_ctl(tab2d_1=p_tpr   , clinfo1=' blk_ice_core: p_tpr  : ', tab2d_2=p_spr   , clinfo2=' p_spr  : ') 
    714          CALL prt_ctl(tab2d_1=p_taui  , clinfo1=' blk_ice_core: p_taui : ', tab2d_2=p_tauj  , clinfo2=' p_tauj : ') 
    715          CALL prt_ctl(tab2d_1=z_wnds_t, clinfo1=' blk_ice_core: z_wnds_t : ') 
    716       ENDIF 
    717  
    718       CALL wrk_dealloc( jpi,jpj, z_wnds_t ) 
    719       CALL wrk_dealloc( jpi,jpj,pdim, z_qlw, z_qsb, z_dqlw, z_dqsb )  
    720       ! 
    721       IF( nn_timing == 1 )  CALL timing_stop('blk_ice_core') 
    722       ! 
    723    END SUBROUTINE blk_ice_core 
    724    
    725  
    726    SUBROUTINE TURB_CORE_1Z(zu, sst, T_a, q_sat, q_a,   & 
    727       &                        dU , Cd , Ch   , Ce   ) 
     649         CALL prt_ctl(tab3d_1=qla_ice , clinfo1=' blk_ice_core: qla_ice  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb    : ', kdim=jpl) 
     650         CALL prt_ctl(tab3d_1=z_qlw   , clinfo1=' blk_ice_core: z_qlw    : ', tab3d_2=dqla_ice, clinfo2=' dqla_ice : ', kdim=jpl) 
     651         CALL prt_ctl(tab3d_1=z_dqsb  , clinfo1=' blk_ice_core: z_dqsb   : ', tab3d_2=z_dqlw  , clinfo2=' z_dqlw   : ', kdim=jpl) 
     652         CALL prt_ctl(tab3d_1=dqns_ice, clinfo1=' blk_ice_core: dqns_ice : ', tab3d_2=qsr_ice , clinfo2=' qsr_ice  : ', kdim=jpl) 
     653         CALL prt_ctl(tab3d_1=ptsu    , clinfo1=' blk_ice_core: ptsu     : ', tab3d_2=qns_ice , clinfo2=' qns_ice  : ', kdim=jpl) 
     654         CALL prt_ctl(tab2d_1=tprecip , clinfo1=' blk_ice_core: tprecip  : ', tab2d_2=sprecip , clinfo2=' sprecip  : ') 
     655      ENDIF 
     656 
     657      CALL wrk_dealloc( jpi,jpj,jpl, z_qlw, z_qsb, z_dqlw, z_dqsb ) 
     658      ! 
     659      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_core_flx') 
     660       
     661   END SUBROUTINE blk_ice_core_flx 
     662#endif 
     663 
     664   SUBROUTINE turb_core_2z( zt, zu, sst, T_zt, q_sat, q_zt, dU,    & 
     665      &                      Cd, Ch, Ce , T_zu, q_zu ) 
    728666      !!---------------------------------------------------------------------- 
    729667      !!                      ***  ROUTINE  turb_core  *** 
    730668      !! 
    731669      !! ** Purpose :   Computes turbulent transfert coefficients of surface 
    732       !!                fluxes according to Large & Yeager (2004) 
    733       !! 
    734       !! ** Method  :   I N E R T I A L   D I S S I P A T I O N   M E T H O D 
    735       !!      Momentum, Latent and sensible heat exchange coefficients 
    736       !!      Caution: this procedure should only be used in cases when air 
    737       !!      temperature (T_air), air specific humidity (q_air) and wind (dU) 
    738       !!      are provided at the same height 'zzu'! 
    739       !! 
    740       !! References :   Large & Yeager, 2004 : ??? 
    741       !!---------------------------------------------------------------------- 
    742       REAL(wp)                , INTENT(in   ) ::   zu      ! altitude of wind measurement       [m] 
    743       REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   sst     ! sea surface temperature         [Kelvin] 
    744       REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   T_a     ! potential air temperature       [Kelvin] 
    745       REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   q_sat   ! sea surface specific humidity   [kg/kg] 
    746       REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   q_a     ! specific air humidity           [kg/kg] 
    747       REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   dU      ! wind module |U(zu)-U(0)|        [m/s] 
    748       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Cd      ! transfert coefficient for momentum       (tau) 
    749       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Ch      ! transfert coefficient for temperature (Q_sens) 
    750       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Ce      ! transfert coefficient for evaporation  (Q_lat) 
    751       !! 
    752       INTEGER :: j_itt 
    753       INTEGER , PARAMETER ::   nb_itt = 3 
    754       REAL(wp), PARAMETER ::   grav   = 9.8   ! gravity                        
    755       REAL(wp), PARAMETER ::   kappa  = 0.4   ! von Karman s constant 
    756  
    757       REAL(wp), DIMENSION(:,:), POINTER  ::   dU10          ! dU                                   [m/s] 
    758       REAL(wp), DIMENSION(:,:), POINTER  ::   dT            ! air/sea temperature differeence      [K] 
    759       REAL(wp), DIMENSION(:,:), POINTER  ::   dq            ! air/sea humidity difference          [K] 
    760       REAL(wp), DIMENSION(:,:), POINTER  ::   Cd_n10        ! 10m neutral drag coefficient 
    761       REAL(wp), DIMENSION(:,:), POINTER  ::   Ce_n10        ! 10m neutral latent coefficient 
    762       REAL(wp), DIMENSION(:,:), POINTER  ::   Ch_n10        ! 10m neutral sensible coefficient 
    763       REAL(wp), DIMENSION(:,:), POINTER  ::   sqrt_Cd_n10   ! root square of Cd_n10 
    764       REAL(wp), DIMENSION(:,:), POINTER  ::   sqrt_Cd       ! root square of Cd 
    765       REAL(wp), DIMENSION(:,:), POINTER  ::   T_vpot        ! virtual potential temperature        [K] 
    766       REAL(wp), DIMENSION(:,:), POINTER  ::   T_star        ! turbulent scale of tem. fluct. 
    767       REAL(wp), DIMENSION(:,:), POINTER  ::   q_star        ! turbulent humidity of temp. fluct. 
    768       REAL(wp), DIMENSION(:,:), POINTER  ::   U_star        ! turb. scale of velocity fluct. 
    769       REAL(wp), DIMENSION(:,:), POINTER  ::   L             ! Monin-Obukov length                  [m] 
    770       REAL(wp), DIMENSION(:,:), POINTER  ::   zeta          ! stability parameter at height zu 
    771       REAL(wp), DIMENSION(:,:), POINTER  ::   U_n10         ! neutral wind velocity at 10m         [m]    
    772       REAL(wp), DIMENSION(:,:), POINTER  ::   xlogt, xct, zpsi_h, zpsi_m 
    773        
    774       INTEGER , DIMENSION(:,:), POINTER  ::   stab          ! 1st guess stability test integer 
    775       !!---------------------------------------------------------------------- 
    776       ! 
    777       IF( nn_timing == 1 )  CALL timing_start('TURB_CORE_1Z') 
    778       ! 
    779       CALL wrk_alloc( jpi,jpj, stab )   ! integer 
    780       CALL wrk_alloc( jpi,jpj, dU10, dT, dq, Cd_n10, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd, L ) 
    781       CALL wrk_alloc( jpi,jpj, T_vpot, T_star, q_star, U_star, zeta, U_n10, xlogt, xct, zpsi_h, zpsi_m ) 
    782  
    783       !! * Start 
    784       !! Air/sea differences 
    785       dU10 = max(0.5, dU)     ! we don't want to fall under 0.5 m/s 
    786       dT = T_a - sst          ! assuming that T_a is allready the potential temp. at zzu 
    787       dq = q_a - q_sat 
    788       !!     
    789       !! Virtual potential temperature 
    790       T_vpot = T_a*(1. + 0.608*q_a) 
    791       !! 
    792       !! Neutral Drag Coefficient 
    793       stab    = 0.5 + sign(0.5,dT)    ! stable : stab = 1 ; unstable : stab = 0  
    794       IF  ( ln_cdgw ) THEN 
    795         cdn_wave = cdn_wave - rsmall*(tmask(:,:,1)-1) 
    796         Cd_n10(:,:) =   cdn_wave 
    797       ELSE 
    798         Cd_n10  = 1.e-3 * ( 2.7/dU10 + 0.142 + dU10/13.09 )    !   L & Y eq. (6a) 
    799       ENDIF 
    800       sqrt_Cd_n10 = sqrt(Cd_n10) 
    801       Ce_n10  = 1.e-3 * ( 34.6 * sqrt_Cd_n10 )               !   L & Y eq. (6b) 
    802       Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1.-stab)) !   L & Y eq. (6c), (6d) 
    803       !! 
    804       !! Initializing transfert coefficients with their first guess neutral equivalents : 
    805       Cd = Cd_n10 ;  Ce = Ce_n10 ;  Ch = Ch_n10 ;  sqrt_Cd = sqrt(Cd) 
    806  
    807       !! * Now starting iteration loop 
    808       DO j_itt=1, nb_itt 
    809          !! Turbulent scales : 
    810          U_star  = sqrt_Cd*dU10                !   L & Y eq. (7a) 
    811          T_star  = Ch/sqrt_Cd*dT               !   L & Y eq. (7b) 
    812          q_star  = Ce/sqrt_Cd*dq               !   L & Y eq. (7c) 
    813  
    814          !! Estimate the Monin-Obukov length : 
    815          L  = (U_star**2)/( kappa*grav*(T_star/T_vpot + q_star/(q_a + 1./0.608)) ) 
    816  
    817          !! Stability parameters : 
    818          zeta  = zu/L ;  zeta   = sign( min(abs(zeta),10.0), zeta ) 
    819          zpsi_h  = psi_h(zeta) 
    820          zpsi_m  = psi_m(zeta) 
    821  
    822          IF  ( ln_cdgw ) THEN 
    823            sqrt_Cd=kappa/((kappa/sqrt_Cd_n10) - zpsi_m) ; Cd=sqrt_Cd*sqrt_Cd; 
    824          ELSE 
    825            !! Shifting the wind speed to 10m and neutral stability :  L & Y eq. (9a) 
    826            !   In very rare low-wind conditions, the old way of estimating the 
    827            !   neutral wind speed at 10m leads to a negative value that causes the code 
    828            !   to crash. To prevent this a threshold of 0.25m/s is now imposed. 
    829            U_n10 = MAX( 0.25 , dU10/(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)) ) 
    830  
    831            !! Updating the neutral 10m transfer coefficients : 
    832            Cd_n10  = 1.e-3 * (2.7/U_n10 + 0.142 + U_n10/13.09)              !  L & Y eq. (6a) 
    833            sqrt_Cd_n10 = sqrt(Cd_n10) 
    834            Ce_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)                           !  L & Y eq. (6b) 
    835            stab    = 0.5 + sign(0.5,zeta) 
    836            Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1.-stab))           !  L & Y eq. (6c), (6d) 
    837  
    838            !! Shifting the neutral  10m transfer coefficients to ( zu , zeta ) : 
    839            !! 
    840            xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10) - zpsi_m) 
    841            Cd  = Cd_n10/(xct*xct) ;  sqrt_Cd = sqrt(Cd) 
    842          ENDIF 
    843          !! 
    844          xlogt = log(zu/10.) - zpsi_h 
    845          !! 
    846          xct = 1. + Ch_n10*xlogt/kappa/sqrt_Cd_n10 
    847          Ch  = Ch_n10*sqrt_Cd/sqrt_Cd_n10/xct 
    848          !! 
    849          xct = 1. + Ce_n10*xlogt/kappa/sqrt_Cd_n10 
    850          Ce  = Ce_n10*sqrt_Cd/sqrt_Cd_n10/xct 
    851          !! 
    852       END DO 
    853       !! 
    854       CALL wrk_dealloc( jpi,jpj, stab )   ! integer 
    855       CALL wrk_dealloc( jpi,jpj, dU10, dT, dq, Cd_n10, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd, L ) 
    856       CALL wrk_dealloc( jpi,jpj, T_vpot, T_star, q_star, U_star, zeta, U_n10, xlogt, xct, zpsi_h, zpsi_m ) 
    857       ! 
    858       IF( nn_timing == 1 )  CALL timing_stop('TURB_CORE_1Z') 
    859       ! 
    860     END SUBROUTINE TURB_CORE_1Z 
    861  
    862  
    863     SUBROUTINE TURB_CORE_2Z(zt, zu, sst, T_zt, q_sat, q_zt, dU, Cd, Ch, Ce, T_zu, q_zu) 
    864       !!---------------------------------------------------------------------- 
    865       !!                      ***  ROUTINE  turb_core  *** 
    866       !! 
    867       !! ** Purpose :   Computes turbulent transfert coefficients of surface  
    868       !!                fluxes according to Large & Yeager (2004). 
    869       !! 
    870       !! ** Method  :   I N E R T I A L   D I S S I P A T I O N   M E T H O D 
    871       !!      Momentum, Latent and sensible heat exchange coefficients 
    872       !!      Caution: this procedure should only be used in cases when air 
    873       !!      temperature (T_air) and air specific humidity (q_air) are at a 
    874       !!      different height to wind (dU). 
    875       !! 
    876       !! References :   Large & Yeager, 2004 : ??? 
     670      !!                fluxes according to Large & Yeager (2004) and Large & Yeager (2008) 
     671      !!                If relevant (zt /= zu), adjust temperature and humidity from height zt to zu 
     672      !! 
     673      !! ** Method : Monin Obukhov Similarity Theory  
     674      !!             + Large & Yeager (2004,2008) closure: CD_n10 = f(U_n10) 
     675      !! 
     676      !! ** References :   Large & Yeager, 2004 / Large & Yeager, 2008 
     677      !! 
     678      !! ** Last update: Laurent Brodeau, June 2014: 
     679      !!    - handles both cases zt=zu and zt/=zu 
     680      !!    - optimized: less 2D arrays allocated and less operations 
     681      !!    - better first guess of stability by checking air-sea difference of virtual temperature 
     682      !!       rather than temperature difference only... 
     683      !!    - added function "cd_neutral_10m" that uses the improved parametrization of  
     684      !!      Large & Yeager 2008. Drag-coefficient reduction for Cyclone conditions! 
     685      !!    - using code-wide physical constants defined into "phycst.mod" rather than redifining them 
     686      !!      => 'vkarmn' and 'grav' 
    877687      !!---------------------------------------------------------------------- 
    878688      REAL(wp), INTENT(in   )                     ::   zt       ! height for T_zt and q_zt                   [m] 
     
    882692      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   q_sat    ! sea surface specific humidity         [kg/kg] 
    883693      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   q_zt     ! specific air humidity                 [kg/kg] 
    884       REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   dU       ! relative wind module |U(zu)-U(0)|       [m/s] 
     694      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   dU       ! relative wind module at zu            [m/s] 
    885695      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Cd       ! transfer coefficient for momentum         (tau) 
    886696      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Ch       ! transfer coefficient for sensible heat (Q_sens) 
     
    888698      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   T_zu     ! air temp. shifted at zu                     [K] 
    889699      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   q_zu     ! spec. hum.  shifted at zu               [kg/kg] 
    890  
    891       INTEGER :: j_itt 
    892       INTEGER , PARAMETER :: nb_itt = 5              ! number of itterations 
    893       REAL(wp), PARAMETER ::   grav   = 9.8          ! gravity                        
    894       REAL(wp), PARAMETER ::   kappa  = 0.4          ! von Karman's constant 
    895        
    896       REAL(wp), DIMENSION(:,:), POINTER ::   dU10          ! dU                                [m/s] 
    897       REAL(wp), DIMENSION(:,:), POINTER ::   dT            ! air/sea temperature differeence   [K] 
    898       REAL(wp), DIMENSION(:,:), POINTER ::   dq            ! air/sea humidity difference       [K] 
    899       REAL(wp), DIMENSION(:,:), POINTER ::   Cd_n10        ! 10m neutral drag coefficient 
     700      ! 
     701      INTEGER ::   j_itt 
     702      INTEGER , PARAMETER ::   nb_itt = 5       ! number of itterations 
     703      LOGICAL ::   l_zt_equal_zu = .FALSE.      ! if q and t are given at different height than U 
     704      ! 
     705      REAL(wp), DIMENSION(:,:), POINTER ::   U_zu          ! relative wind at zu                            [m/s] 
    900706      REAL(wp), DIMENSION(:,:), POINTER ::   Ce_n10        ! 10m neutral latent coefficient 
    901707      REAL(wp), DIMENSION(:,:), POINTER ::   Ch_n10        ! 10m neutral sensible coefficient 
    902708      REAL(wp), DIMENSION(:,:), POINTER ::   sqrt_Cd_n10   ! root square of Cd_n10 
    903709      REAL(wp), DIMENSION(:,:), POINTER ::   sqrt_Cd       ! root square of Cd 
    904       REAL(wp), DIMENSION(:,:), POINTER ::   T_vpot        ! virtual potential temperature        [K] 
    905       REAL(wp), DIMENSION(:,:), POINTER ::   T_star        ! turbulent scale of tem. fluct. 
    906       REAL(wp), DIMENSION(:,:), POINTER ::   q_star        ! turbulent humidity of temp. fluct. 
    907       REAL(wp), DIMENSION(:,:), POINTER ::   U_star        ! turb. scale of velocity fluct. 
    908       REAL(wp), DIMENSION(:,:), POINTER ::   L             ! Monin-Obukov length                  [m] 
    909710      REAL(wp), DIMENSION(:,:), POINTER ::   zeta_u        ! stability parameter at height zu 
    910711      REAL(wp), DIMENSION(:,:), POINTER ::   zeta_t        ! stability parameter at height zt 
    911       REAL(wp), DIMENSION(:,:), POINTER ::   U_n10         ! neutral wind velocity at 10m        [m] 
    912       REAL(wp), DIMENSION(:,:), POINTER ::   xlogt, xct, zpsi_hu, zpsi_ht, zpsi_m 
    913  
    914       INTEGER , DIMENSION(:,:), POINTER ::   stab          ! 1st stability test integer 
     712      REAL(wp), DIMENSION(:,:), POINTER ::   zpsi_h_u, zpsi_m_u 
     713      REAL(wp), DIMENSION(:,:), POINTER ::   ztmp0, ztmp1, ztmp2 
     714      REAL(wp), DIMENSION(:,:), POINTER ::   stab          ! 1st stability test integer 
    915715      !!---------------------------------------------------------------------- 
    916       ! 
    917       IF( nn_timing == 1 )  CALL timing_start('TURB_CORE_2Z') 
    918       ! 
    919       CALL wrk_alloc( jpi,jpj, dU10, dT, dq, Cd_n10, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd, L ) 
    920       CALL wrk_alloc( jpi,jpj, T_vpot, T_star, q_star, U_star, zeta_u, zeta_t, U_n10 ) 
    921       CALL wrk_alloc( jpi,jpj, xlogt, xct, zpsi_hu, zpsi_ht, zpsi_m ) 
    922       CALL wrk_alloc( jpi,jpj, stab )   ! interger 
    923  
    924       !! Initial air/sea differences 
    925       dU10 = max(0.5, dU)      !  we don't want to fall under 0.5 m/s 
    926       dT = T_zt - sst  
    927       dq = q_zt - q_sat 
    928  
    929       !! Neutral Drag Coefficient : 
    930       stab = 0.5 + sign(0.5,dT)                 ! stab = 1  if dT > 0  -> STABLE 
    931       IF( ln_cdgw ) THEN 
    932         cdn_wave = cdn_wave - rsmall*(tmask(:,:,1)-1) 
    933         Cd_n10(:,:) =   cdn_wave 
     716 
     717      IF( nn_timing == 1 )  CALL timing_start('turb_core_2z') 
     718     
     719      CALL wrk_alloc( jpi,jpj, U_zu, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd ) 
     720      CALL wrk_alloc( jpi,jpj, zeta_u, stab ) 
     721      CALL wrk_alloc( jpi,jpj, zpsi_h_u, zpsi_m_u, ztmp0, ztmp1, ztmp2 ) 
     722 
     723      l_zt_equal_zu = .FALSE. 
     724      IF( ABS(zu - zt) < 0.01 ) l_zt_equal_zu = .TRUE.    ! testing "zu == zt" is risky with double precision 
     725 
     726      IF( .NOT. l_zt_equal_zu )   CALL wrk_alloc( jpi,jpj, zeta_t ) 
     727 
     728      U_zu = MAX( 0.5 , dU )   !  relative wind speed at zu (normally 10m), we don't want to fall under 0.5 m/s 
     729 
     730      !! First guess of stability:  
     731      ztmp0 = T_zt*(1. + 0.608*q_zt) - sst*(1. + 0.608*q_sat) ! air-sea difference of virtual pot. temp. at zt 
     732      stab  = 0.5 + sign(0.5,ztmp0)                           ! stab = 1 if dTv > 0  => STABLE, 0 if unstable 
     733 
     734      !! Neutral coefficients at 10m: 
     735      IF( ln_cdgw ) THEN      ! wave drag case 
     736         cdn_wave(:,:) = cdn_wave(:,:) + rsmall * ( 1._wp - tmask(:,:,1) ) 
     737         ztmp0   (:,:) = cdn_wave(:,:) 
    934738      ELSE 
    935         Cd_n10  = 1.e-3*( 2.7/dU10 + 0.142 + dU10/13.09 )  
    936       ENDIF 
    937       sqrt_Cd_n10 = sqrt(Cd_n10) 
     739         ztmp0 = cd_neutral_10m( U_zu ) 
     740      ENDIF 
     741      sqrt_Cd_n10 = SQRT( ztmp0 ) 
    938742      Ce_n10  = 1.e-3*( 34.6 * sqrt_Cd_n10 ) 
    939743      Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab)) 
    940  
     744     
    941745      !! Initializing transf. coeff. with their first guess neutral equivalents : 
    942       Cd = Cd_n10 ;  Ce = Ce_n10 ;  Ch = Ch_n10 ;  sqrt_Cd = sqrt(Cd) 
    943  
    944       !! Initializing z_u values with z_t values : 
    945       T_zu = T_zt ;  q_zu = q_zt 
     746      Cd = ztmp0   ;   Ce = Ce_n10   ;   Ch = Ch_n10   ;   sqrt_Cd = sqrt_Cd_n10 
     747 
     748      !! Initializing values at z_u with z_t values: 
     749      T_zu = T_zt   ;   q_zu = q_zt 
    946750 
    947751      !!  * Now starting iteration loop 
    948752      DO j_itt=1, nb_itt 
    949          dT = T_zu - sst ;  dq = q_zu - q_sat ! Updating air/sea differences 
    950          T_vpot = T_zu*(1. + 0.608*q_zu)    ! Updating virtual potential temperature at zu 
    951          U_star = sqrt_Cd*dU10                ! Updating turbulent scales :   (L & Y eq. (7)) 
    952          T_star  = Ch/sqrt_Cd*dT              ! 
    953          q_star  = Ce/sqrt_Cd*dq              ! 
    954          !! 
    955          L = (U_star*U_star) &                ! Estimate the Monin-Obukov length at height zu 
    956               & / (kappa*grav/T_vpot*(T_star*(1.+0.608*q_zu) + 0.608*T_zu*q_star)) 
     753         ! 
     754         ztmp1 = T_zu - sst   ! Updating air/sea differences 
     755         ztmp2 = q_zu - q_sat  
     756 
     757         ! Updating turbulent scales :   (L&Y 2004 eq. (7)) 
     758         ztmp1  = Ch/sqrt_Cd*ztmp1    ! theta* 
     759         ztmp2  = Ce/sqrt_Cd*ztmp2    ! q* 
     760        
     761         ztmp0 = T_zu*(1. + 0.608*q_zu) ! virtual potential temperature at zu 
     762 
     763         ! Estimate the inverse of Monin-Obukov length (1/L) at height zu: 
     764         ztmp0 =  (vkarmn*grav/ztmp0*(ztmp1*(1.+0.608*q_zu) + 0.608*T_zu*ztmp2)) / (Cd*U_zu*U_zu)  
     765         !                                                                     ( Cd*U_zu*U_zu is U*^2 at zu) 
     766 
    957767         !! Stability parameters : 
    958          zeta_u  = zu/L  ;  zeta_u = sign( min(abs(zeta_u),10.0), zeta_u ) 
    959          zeta_t  = zt/L  ;  zeta_t = sign( min(abs(zeta_t),10.0), zeta_t ) 
    960          zpsi_hu = psi_h(zeta_u) 
    961          zpsi_ht = psi_h(zeta_t) 
    962          zpsi_m  = psi_m(zeta_u) 
    963          !! 
    964          !! Shifting the wind speed to 10m and neutral stability : L & Y eq.(9a) 
    965          !   In very rare low-wind conditions, the old way of estimating the 
    966          !   neutral wind speed at 10m leads to a negative value that causes the code 
    967          !   to crash. To prevent this a threshold of 0.25m/s is now imposed. 
    968          U_n10 = MAX( 0.25 , dU10/(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)) ) 
    969          !! 
    970          !! Shifting temperature and humidity at zu :          (L & Y eq. (9b-9c)) 
    971 !        T_zu = T_zt - T_star/kappa*(log(zt/zu) + psi_h(zeta_u) - psi_h(zeta_t)) 
    972          T_zu = T_zt - T_star/kappa*(log(zt/zu) + zpsi_hu - zpsi_ht) 
    973 !        q_zu = q_zt - q_star/kappa*(log(zt/zu) + psi_h(zeta_u) - psi_h(zeta_t)) 
    974          q_zu = q_zt - q_star/kappa*(log(zt/zu) + zpsi_hu - zpsi_ht) 
    975          !! 
    976          !! q_zu cannot have a negative value : forcing 0 
    977          stab = 0.5 + sign(0.5,q_zu) ;  q_zu = stab*q_zu 
    978          !! 
    979          IF( ln_cdgw ) THEN 
    980             sqrt_Cd=kappa/((kappa/sqrt_Cd_n10) - zpsi_m) ; Cd=sqrt_Cd*sqrt_Cd; 
     768         zeta_u   = zu*ztmp0   ;  zeta_u = sign( min(abs(zeta_u),10.0), zeta_u ) 
     769         zpsi_h_u = psi_h( zeta_u ) 
     770         zpsi_m_u = psi_m( zeta_u ) 
     771        
     772         !! Shifting temperature and humidity at zu (L&Y 2004 eq. (9b-9c)) 
     773         IF ( .NOT. l_zt_equal_zu ) THEN 
     774            zeta_t = zt*ztmp0 ;  zeta_t = sign( min(abs(zeta_t),10.0), zeta_t ) 
     775            stab = LOG(zu/zt) - zpsi_h_u + psi_h(zeta_t)  ! stab just used as temp array!!! 
     776            T_zu = T_zt + ztmp1/vkarmn*stab    ! ztmp1 is still theta* 
     777            q_zu = q_zt + ztmp2/vkarmn*stab    ! ztmp2 is still q* 
     778            q_zu = max(0., q_zu) 
     779         END IF 
     780        
     781         IF( ln_cdgw ) THEN      ! surface wave case 
     782            sqrt_Cd = vkarmn / ( vkarmn / sqrt_Cd_n10 - zpsi_m_u )  
     783            Cd      = sqrt_Cd * sqrt_Cd 
    981784         ELSE 
    982            !! Updating the neutral 10m transfer coefficients : 
    983            Cd_n10  = 1.e-3 * (2.7/U_n10 + 0.142 + U_n10/13.09)    ! L & Y eq. (6a) 
    984            sqrt_Cd_n10 = sqrt(Cd_n10) 
    985            Ce_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)                 ! L & Y eq. (6b) 
    986            stab    = 0.5 + sign(0.5,zeta_u) 
    987            Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1.-stab)) ! L & Y eq. (6c-6d) 
    988            !! 
    989            !! 
    990            !! Shifting the neutral 10m transfer coefficients to (zu,zeta_u) : 
    991            xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)   ! L & Y eq. (10a) 
    992            Cd = Cd_n10/(xct*xct) ; sqrt_Cd = sqrt(Cd) 
     785           ! Update neutral wind speed at 10m and neutral Cd at 10m (L&Y 2004 eq. 9a)... 
     786           !   In very rare low-wind conditions, the old way of estimating the 
     787           !   neutral wind speed at 10m leads to a negative value that causes the code 
     788           !   to crash. To prevent this a threshold of 0.25m/s is imposed. 
     789           ztmp0 = MAX( 0.25 , U_zu/(1. + sqrt_Cd_n10/vkarmn*(LOG(zu/10.) - zpsi_m_u)) ) !  U_n10 
     790           ztmp0 = cd_neutral_10m(ztmp0)                                                 ! Cd_n10 
     791           sqrt_Cd_n10 = sqrt(ztmp0) 
     792        
     793           Ce_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)                     ! L&Y 2004 eq. (6b) 
     794           stab    = 0.5 + sign(0.5,zeta_u)                           ! update stability 
     795           Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab))  ! L&Y 2004 eq. (6c-6d) 
     796 
     797           !! Update of transfer coefficients: 
     798           ztmp1 = 1. + sqrt_Cd_n10/vkarmn*(LOG(zu/10.) - zpsi_m_u)   ! L&Y 2004 eq. (10a) 
     799           Cd      = ztmp0 / ( ztmp1*ztmp1 )    
     800           sqrt_Cd = SQRT( Cd ) 
    993801         ENDIF 
    994          !! 
    995          xlogt = log(zu/10.) - zpsi_hu 
    996          !! 
    997          xct = 1. + Ch_n10*xlogt/kappa/sqrt_Cd_n10               ! L & Y eq. (10b) 
    998          Ch  = Ch_n10*sqrt_Cd/sqrt_Cd_n10/xct 
    999          !! 
    1000          xct = 1. + Ce_n10*xlogt/kappa/sqrt_Cd_n10               ! L & Y eq. (10c) 
    1001          Ce  = Ce_n10*sqrt_Cd/sqrt_Cd_n10/xct 
    1002          !! 
    1003          !! 
     802         ! 
     803         ztmp0 = (LOG(zu/10.) - zpsi_h_u) / vkarmn / sqrt_Cd_n10 
     804         ztmp2 = sqrt_Cd / sqrt_Cd_n10 
     805         ztmp1 = 1. + Ch_n10*ztmp0                
     806         Ch  = Ch_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10b) 
     807         ! 
     808         ztmp1 = 1. + Ce_n10*ztmp0                
     809         Ce  = Ce_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10c) 
     810         ! 
    1004811      END DO 
    1005       !! 
    1006       CALL wrk_dealloc( jpi,jpj, dU10, dT, dq, Cd_n10, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd, L ) 
    1007       CALL wrk_dealloc( jpi,jpj, T_vpot, T_star, q_star, U_star, zeta_u, zeta_t, U_n10 ) 
    1008       CALL wrk_dealloc( jpi,jpj, xlogt, xct, zpsi_hu, zpsi_ht, zpsi_m ) 
    1009       CALL wrk_dealloc( jpi,jpj, stab )   ! interger 
    1010       ! 
    1011       IF( nn_timing == 1 )  CALL timing_stop('TURB_CORE_2Z') 
    1012       ! 
    1013     END SUBROUTINE TURB_CORE_2Z 
    1014  
    1015  
    1016     FUNCTION psi_m(zta)   !! Psis, L & Y eq. (8c), (8d), (8e) 
     812 
     813      CALL wrk_dealloc( jpi,jpj, U_zu, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd ) 
     814      CALL wrk_dealloc( jpi,jpj, zeta_u, stab ) 
     815      CALL wrk_dealloc( jpi,jpj, zpsi_h_u, zpsi_m_u, ztmp0, ztmp1, ztmp2 ) 
     816 
     817      IF( .NOT. l_zt_equal_zu ) CALL wrk_dealloc( jpi,jpj, zeta_t ) 
     818 
     819      IF( nn_timing == 1 )  CALL timing_stop('turb_core_2z') 
     820      ! 
     821   END SUBROUTINE turb_core_2z 
     822 
     823 
     824   FUNCTION cd_neutral_10m( zw10 ) 
     825      !!---------------------------------------------------------------------- 
     826      !! Estimate of the neutral drag coefficient at 10m as a function  
     827      !! of neutral wind  speed at 10m 
     828      !! 
     829      !! Origin: Large & Yeager 2008 eq.(11a) and eq.(11b) 
     830      !! 
     831      !! Author: L. Brodeau, june 2014 
     832      !!----------------------------------------------------------------------     
     833      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   zw10           ! scalar wind speed at 10m (m/s) 
     834      REAL(wp), DIMENSION(jpi,jpj)             ::   cd_neutral_10m 
     835      ! 
     836      REAL(wp), DIMENSION(:,:), POINTER ::   rgt33 
     837      !!----------------------------------------------------------------------     
     838      ! 
     839      CALL wrk_alloc( jpi,jpj, rgt33 ) 
     840      ! 
     841      !! When wind speed > 33 m/s => Cyclone conditions => special treatment 
     842      rgt33 = 0.5_wp + SIGN( 0.5_wp, (zw10 - 33._wp) )   ! If zw10 < 33. => 0, else => 1   
     843      cd_neutral_10m = 1.e-3 * ( & 
     844         &       (1._wp - rgt33)*( 2.7_wp/zw10 + 0.142_wp + zw10/13.09_wp - 3.14807E-10*zw10**6) & ! zw10< 33. 
     845         &      + rgt33         *      2.34   )                                                    ! zw10 >= 33. 
     846      ! 
     847      CALL wrk_dealloc( jpi,jpj, rgt33) 
     848      ! 
     849   END FUNCTION cd_neutral_10m 
     850 
     851 
     852   FUNCTION psi_m(pta)   !! Psis, L&Y 2004 eq. (8c), (8d), (8e) 
    1017853      !------------------------------------------------------------------------------- 
    1018       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: zta 
    1019  
    1020       REAL(wp), PARAMETER :: pi = 3.141592653589793_wp 
     854      ! universal profile stability function for momentum 
     855      !------------------------------------------------------------------------------- 
     856      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pta 
     857      ! 
    1021858      REAL(wp), DIMENSION(jpi,jpj)             :: psi_m 
    1022859      REAL(wp), DIMENSION(:,:), POINTER        :: X2, X, stabit 
    1023860      !------------------------------------------------------------------------------- 
    1024  
     861      ! 
    1025862      CALL wrk_alloc( jpi,jpj, X2, X, stabit ) 
    1026  
    1027       X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.0) ;  X  = sqrt(X2) 
    1028       stabit    = 0.5 + sign(0.5,zta) 
    1029       psi_m = -5.*zta*stabit  &                                                          ! Stable 
    1030          &    + (1. - stabit)*(2*log((1. + X)/2) + log((1. + X2)/2) - 2*atan(X) + pi/2)  ! Unstable  
    1031  
     863      ! 
     864      X2 = SQRT( ABS( 1. - 16.*pta ) )  ;  X2 = MAX( X2 , 1. )   ;   X = SQRT( X2 ) 
     865      stabit = 0.5 + SIGN( 0.5 , pta ) 
     866      psi_m = -5.*pta*stabit  &                                                          ! Stable 
     867         &    + (1. - stabit)*(2.*LOG((1. + X)*0.5) + LOG((1. + X2)*0.5) - 2.*ATAN(X) + rpi*0.5)  ! Unstable 
     868      ! 
    1032869      CALL wrk_dealloc( jpi,jpj, X2, X, stabit ) 
    1033870      ! 
    1034     END FUNCTION psi_m 
    1035  
    1036  
    1037     FUNCTION psi_h( zta )    !! Psis, L & Y eq. (8c), (8d), (8e) 
     871   END FUNCTION psi_m 
     872 
     873 
     874   FUNCTION psi_h( pta )    !! Psis, L&Y 2004 eq. (8c), (8d), (8e) 
    1038875      !------------------------------------------------------------------------------- 
    1039       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   zta 
     876      ! universal profile stability function for temperature and humidity 
     877      !------------------------------------------------------------------------------- 
     878      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pta 
    1040879      ! 
    1041880      REAL(wp), DIMENSION(jpi,jpj)             ::   psi_h 
    1042       REAL(wp), DIMENSION(:,:), POINTER        :: X2, X, stabit 
     881      REAL(wp), DIMENSION(:,:), POINTER        ::   X2, X, stabit 
    1043882      !------------------------------------------------------------------------------- 
    1044  
     883      ! 
    1045884      CALL wrk_alloc( jpi,jpj, X2, X, stabit ) 
    1046  
    1047       X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.) ;  X  = sqrt(X2) 
    1048       stabit    = 0.5 + sign(0.5,zta) 
    1049       psi_h = -5.*zta*stabit  &                                       ! Stable 
    1050          &    + (1. - stabit)*(2.*log( (1. + X2)/2. ))                 ! Unstable 
    1051  
     885      ! 
     886      X2 = SQRT( ABS( 1. - 16.*pta ) )   ;   X2 = MAX( X2 , 1. )   ;   X = SQRT( X2 ) 
     887      stabit = 0.5 + SIGN( 0.5 , pta ) 
     888      psi_h = -5.*pta*stabit   &                                       ! Stable 
     889         &    + (1. - stabit)*(2.*LOG( (1. + X2)*0.5 ))                ! Unstable 
     890      ! 
    1052891      CALL wrk_dealloc( jpi,jpj, X2, X, stabit ) 
    1053892      ! 
    1054     END FUNCTION psi_h 
    1055    
     893   END FUNCTION psi_h 
     894 
    1056895   !!====================================================================== 
    1057896END MODULE sbcblk_core 
Note: See TracChangeset for help on using the changeset viewer.