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.
sbcblk_core.F90 in branches/2014/dev_CNRS0_blk_core/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2014/dev_CNRS0_blk_core/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90 @ 4675

Last change on this file since 4675 was 4675, checked in by gm, 10 years ago

#1348 CORE bulk simplification and optimization: changes in sbcblk_core and namelist_ref

  • Property svn:keywords set to Id
File size: 51.2 KB
Line 
1MODULE sbcblk_core
2   !!======================================================================
3   !!                       ***  MODULE  sbcblk_core  ***
4   !! Ocean forcing:  momentum, heat and freshwater flux formulation
5   !!=====================================================================
6   !! History :  1.0  !  2004-08  (U. Schweckendiek)  Original code
7   !!            2.0  !  2005-04  (L. Brodeau, A.M. Treguier) additions:
8   !!                           -  new bulk routine for efficiency
9   !!                           -  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
14   !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put
15   !!            3.3  !  2010-10  (S. Masson)  add diurnal cycle
16   !!            3.4  !  2011-11  (C. Harris) Fill arrays required by CICE
17   !!            3.7  !  2014-06  (L. Brodeau) simplification and optimization of CORE bulk
18   !!----------------------------------------------------------------------
19
20   !!----------------------------------------------------------------------
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   !!   blk_bio_meanqsr : compute daily mean short wave radiation over the ocean
25   !!   blk_ice_meanqsr : compute daily mean short wave radiation over the ice
26   !!   turb_core_2z    : Computes turbulent transfert coefficients
27   !!   cd_neutral_10m  : Estimate of the neutral drag coefficient at 10m
28   !!   psi_m           : universal profile stability function for momentum
29   !!   psi_h           : universal profile stability function for temperature and humidity
30   !!----------------------------------------------------------------------
31   USE oce             ! ocean dynamics and tracers
32   USE dom_oce         ! ocean space and time domain
33   USE phycst          ! physical constants
34   USE fldread         ! read input fields
35   USE sbc_oce         ! Surface boundary condition: ocean fields
36   USE cyclone         ! Cyclone 10m wind form trac of cyclone centres
37   USE sbcdcy          ! surface boundary condition: diurnal cycle
38   USE iom             ! I/O manager library
39   USE in_out_manager  ! I/O manager
40   USE lib_mpp         ! distribued memory computing library
41   USE wrk_nemo        ! work arrays
42   USE timing          ! Timing
43   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
44   USE prtctl          ! Print control
45   USE sbcwave, ONLY   :  cdn_wave ! wave module
46#if defined key_lim3 || defined key_cice
47   USE sbc_ice         ! Surface boundary condition: ice fields
48#endif
49   USE lib_fortran     ! to use key_nosignedzero
50
51   IMPLICIT NONE
52   PRIVATE
53
54   PUBLIC   sbc_blk_core         ! routine called in sbcmod module
55   PUBLIC   blk_ice_core         ! routine called in sbc_ice_lim module
56   PUBLIC   blk_ice_meanqsr      ! routine called in sbc_ice_lim module
57   PUBLIC   turb_core_2z         ! routine calles in sbcblk_mfs module
58
59   INTEGER , PARAMETER ::   jpfld   = 9           ! maximum number of files to read
60   INTEGER , PARAMETER ::   jp_wndi = 1           ! index of 10m wind velocity (i-component) (m/s)    at T-point
61   INTEGER , PARAMETER ::   jp_wndj = 2           ! index of 10m wind velocity (j-component) (m/s)    at T-point
62   INTEGER , PARAMETER ::   jp_humi = 3           ! index of specific humidity               ( % )
63   INTEGER , PARAMETER ::   jp_qsr  = 4           ! index of solar heat                      (W/m2)
64   INTEGER , PARAMETER ::   jp_qlw  = 5           ! index of Long wave                       (W/m2)
65   INTEGER , PARAMETER ::   jp_tair = 6           ! index of 10m air temperature             (Kelvin)
66   INTEGER , PARAMETER ::   jp_prec = 7           ! index of total precipitation (rain+snow) (Kg/m2/s)
67   INTEGER , PARAMETER ::   jp_snow = 8           ! index of snow (solid prcipitation)       (kg/m2/s)
68   INTEGER , PARAMETER ::   jp_tdif = 9           ! index of tau diff associated to HF tau   (N/m2)   at T-point
69
70   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf   ! structure of input fields (file informations, fields read)
71
72   !                                             !!! CORE bulk parameters
73   REAL(wp), PARAMETER ::   rhoa =    1.22        ! air density
74   REAL(wp), PARAMETER ::   cpa  = 1000.5         ! specific heat of air
75   REAL(wp), PARAMETER ::   Lv   =    2.5e6       ! latent heat of vaporization
76   REAL(wp), PARAMETER ::   Ls   =    2.839e6     ! latent heat of sublimation
77   REAL(wp), PARAMETER ::   Stef =    5.67e-8     ! Stefan Boltzmann constant
78   REAL(wp), PARAMETER ::   Cice =    1.4e-3      ! iovi 1.63e-3     ! transfer coefficient over ice
79   REAL(wp), PARAMETER ::   albo =    0.066       ! ocean albedo assumed to be constant
80
81   !                                  !!* Namelist namsbc_core : CORE bulk parameters
82   LOGICAL  ::   ln_taudif   ! logical flag to use the "mean of stress module - module of mean stress" data
83   REAL(wp) ::   rn_pfac     ! multiplication factor for precipitation
84   REAL(wp) ::   rn_efac     ! multiplication factor for evaporation (clem)
85   REAL(wp) ::   rn_vfac     ! multiplication factor for ice/ocean velocity in the calculation of wind stress (clem)
86   REAL(wp) ::   rn_zqt      ! z(q,t) : height of humidity and temperature measurements
87   REAL(wp) ::   rn_zu       ! z(u)   : height of wind measurements
88
89   !! * Substitutions
90#  include "domzgr_substitute.h90"
91#  include "vectopt_loop_substitute.h90"
92   !!----------------------------------------------------------------------
93   !! NEMO/OPA 3.7 , NEMO-consortium (2014)
94   !! $Id$
95   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
96   !!----------------------------------------------------------------------
97CONTAINS
98
99   SUBROUTINE sbc_blk_core( kt )
100      !!---------------------------------------------------------------------
101      !!                    ***  ROUTINE sbc_blk_core  ***
102      !!
103      !! ** Purpose :   provide at each time step the surface ocean fluxes
104      !!      (momentum, heat, freshwater and runoff)
105      !!
106      !! ** Method  : (1) READ each fluxes in NetCDF files:
107      !!      the 10m wind velocity (i-component) (m/s)    at T-point
108      !!      the 10m wind velocity (j-component) (m/s)    at T-point
109      !!      the 10m or 2m specific humidity     ( % )
110      !!      the solar heat                      (W/m2)
111      !!      the Long wave                       (W/m2)
112      !!      the 10m or 2m air temperature       (Kelvin)
113      !!      the total precipitation (rain+snow) (Kg/m2/s)
114      !!      the snow (solid prcipitation)       (kg/m2/s)
115      !!      the tau diff associated to HF tau   (N/m2)   at T-point   (ln_taudif=T)
116      !!              (2) CALL blk_oce_core
117      !!
118      !!      C A U T I O N : never mask the surface stress fields
119      !!                      the stress is assumed to be in the (i,j) mesh referential
120      !!
121      !! ** Action  :   defined at each time-step at the air-sea interface
122      !!              - utau, vtau  i- and j-component of the wind stress
123      !!              - taum, wndm  wind stress and 10m wind modules at T-point
124      !!              - qns, qsr    non-solar and solar heat fluxes
125      !!              - emp         upward mass flux (evapo. - precip.)
126      !!              - sfx         salt flux due to freezing/melting (non-zero only if ice is present)
127      !!                            (set in limsbc(_2).F90)
128      !!
129      !! ** References :   Large & Yeager, 2004 / Large & Yeager, 2008
130      !!                   Brodeau et al. Ocean Modelling 2010
131      !!----------------------------------------------------------------------
132      INTEGER, INTENT(in) ::   kt   ! ocean time step
133      !
134      INTEGER  ::   ierror   ! return error code
135      INTEGER  ::   ifpr     ! dummy loop indice
136      INTEGER  ::   jfld     ! dummy loop arguments
137      INTEGER  ::   ios      ! Local integer output status for namelist read
138      !
139      CHARACTER(len=100) ::  cn_dir   !   Root directory for location of core files
140      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i     ! array of namelist informations on the fields to read
141      TYPE(FLD_N) ::   sn_wndi, sn_wndj, sn_humi, sn_qsr       ! informations about the fields to be read
142      TYPE(FLD_N) ::   sn_qlw , sn_tair, sn_prec, sn_snow      !   "                                 "
143      TYPE(FLD_N) ::   sn_tdif                                 !   "                                 "
144      NAMELIST/namsbc_core/ cn_dir , ln_taudif, rn_pfac, rn_efac, rn_vfac,  &
145         &                  sn_wndi, sn_wndj, sn_humi  , sn_qsr ,           &
146         &                  sn_qlw , sn_tair, sn_prec  , sn_snow,           &
147         &                  sn_tdif, rn_zqt,  rn_zu
148      !!---------------------------------------------------------------------
149      !
150      !                                         ! ====================== !
151      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
152         !                                      ! ====================== !
153         !
154         REWIND( numnam_ref )              ! Namelist namsbc_core in reference namelist : CORE bulk parameters
155         READ  ( numnam_ref, namsbc_core, IOSTAT = ios, ERR = 901)
156901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_core in reference namelist', lwp )
157         !
158         REWIND( numnam_cfg )              ! Namelist namsbc_core in configuration namelist : CORE bulk parameters
159         READ  ( numnam_cfg, namsbc_core, IOSTAT = ios, ERR = 902 )
160902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_core in configuration namelist', lwp )
161
162         WRITE ( numond, namsbc_core )
163         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
164         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &
165            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' )
166         IF( ln_dm2dc .AND. sn_qsr%ln_tint ) THEN
167            CALL ctl_warn( 'sbc_blk_core: ln_dm2dc is taking care of the temporal interpolation of daily qsr',   &
168               &         '              ==> We force time interpolation = .false. for qsr' )
169            sn_qsr%ln_tint = .false.
170         ENDIF
171         !                                         ! store namelist information in an array
172         slf_i(jp_wndi) = sn_wndi   ;   slf_i(jp_wndj) = sn_wndj
173         slf_i(jp_qsr ) = sn_qsr    ;   slf_i(jp_qlw ) = sn_qlw
174         slf_i(jp_tair) = sn_tair   ;   slf_i(jp_humi) = sn_humi
175         slf_i(jp_prec) = sn_prec   ;   slf_i(jp_snow) = sn_snow
176         slf_i(jp_tdif) = sn_tdif
177         !
178         lhftau = ln_taudif                        ! do we use HF tau information?
179         jfld = jpfld - COUNT( (/.NOT. lhftau/) )
180         !
181         ALLOCATE( sf(jfld), STAT=ierror )         ! set sf structure
182         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_core: unable to allocate sf structure' )
183         DO ifpr= 1, jfld
184            ALLOCATE( sf(ifpr)%fnow(jpi,jpj,1) )
185            IF( slf_i(ifpr)%ln_tint )   ALLOCATE( sf(ifpr)%fdta(jpi,jpj,1,2) )
186         END DO
187         !                                         ! fill sf with slf_i and control print
188         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_core', 'flux formulation for ocean surface boundary condition', 'namsbc_core' )
189         !
190         sfx(:,:) = 0._wp                          ! salt flux; zero unless ice is present (computed in limsbc(_2).F90)
191         !
192      ENDIF
193
194      CALL fld_read( kt, nn_fsbc, sf )             ! input fields provided at the current time-step
195
196      !                                            ! compute the surface ocean fluxes using CORE bulk formulea
197      IF( MOD( kt - 1, nn_fsbc ) == 0 )   CALL blk_oce_core( kt, sf, sst_m, ssu_m, ssv_m )
198
199      ! If diurnal cycle is activated, compute a daily mean short waves flux for biogeochemistery
200      IF( ltrcdm2dc )   CALL blk_bio_meanqsr
201
202#if defined key_cice
203      IF( MOD( kt - 1, nn_fsbc ) == 0 )   THEN
204         qlw_ice(:,:,1)   = sf(jp_qlw)%fnow(:,:,1) 
205         qsr_ice(:,:,1)   = sf(jp_qsr)%fnow(:,:,1)
206         tatm_ice(:,:)    = sf(jp_tair)%fnow(:,:,1)         
207         qatm_ice(:,:)    = sf(jp_humi)%fnow(:,:,1)
208         tprecip(:,:)     = sf(jp_prec)%fnow(:,:,1) * rn_pfac
209         sprecip(:,:)     = sf(jp_snow)%fnow(:,:,1) * rn_pfac
210         wndi_ice(:,:)    = sf(jp_wndi)%fnow(:,:,1)
211         wndj_ice(:,:)    = sf(jp_wndj)%fnow(:,:,1)
212      ENDIF
213#endif
214      !
215   END SUBROUTINE sbc_blk_core
216   
217   
218   SUBROUTINE blk_oce_core( kt, sf, pst, pu, pv )
219      !!---------------------------------------------------------------------
220      !!                     ***  ROUTINE blk_core  ***
221      !!
222      !! ** Purpose :   provide the momentum, heat and freshwater fluxes at
223      !!      the ocean surface at each time step
224      !!
225      !! ** Method  :   CORE bulk formulea for the ocean using atmospheric
226      !!      fields read in sbc_read
227      !!
228      !! ** Outputs : - utau    : i-component of the stress at U-point  (N/m2)
229      !!              - vtau    : j-component of the stress at V-point  (N/m2)
230      !!              - taum    : Wind stress module at T-point         (N/m2)
231      !!              - wndm    : Wind speed module at T-point          (m/s)
232      !!              - qsr     : Solar heat flux over the ocean        (W/m2)
233      !!              - qns     : Non Solar heat flux over the ocean    (W/m2)
234      !!              - evap    : Evaporation over the ocean            (kg/m2/s)
235      !!              - emp     : evaporation minus precipitation       (kg/m2/s)
236      !!
237      !!  ** Nota  :   sf has to be a dummy argument for AGRIF on NEC
238      !!---------------------------------------------------------------------
239      INTEGER  , INTENT(in   )                 ::   kt    ! time step index
240      TYPE(fld), INTENT(inout), DIMENSION(:)   ::   sf    ! input data
241      REAL(wp) , INTENT(in)   , DIMENSION(:,:) ::   pst   ! surface temperature                      [Celcius]
242      REAL(wp) , INTENT(in)   , DIMENSION(:,:) ::   pu    ! surface current at U-point (i-component) [m/s]
243      REAL(wp) , INTENT(in)   , DIMENSION(:,:) ::   pv    ! surface current at V-point (j-component) [m/s]
244      !
245      INTEGER  ::   ji, jj               ! dummy loop indices
246      REAL(wp) ::   zcoef_qsatw, zztmp   ! local variable
247      REAL(wp), DIMENSION(:,:), POINTER ::   zwnd_i, zwnd_j    ! wind speed components at T-point
248      REAL(wp), DIMENSION(:,:), POINTER ::   zqsatw            ! specific humidity at pst
249      REAL(wp), DIMENSION(:,:), POINTER ::   zqlw, zqsb        ! long wave and sensible heat fluxes
250      REAL(wp), DIMENSION(:,:), POINTER ::   zqla, zevap       ! latent heat fluxes and evaporation
251      REAL(wp), DIMENSION(:,:), POINTER ::   Cd                ! transfer coefficient for momentum      (tau)
252      REAL(wp), DIMENSION(:,:), POINTER ::   Ch                ! transfer coefficient for sensible heat (Q_sens)
253      REAL(wp), DIMENSION(:,:), POINTER ::   Ce                ! tansfert coefficient for evaporation   (Q_lat)
254      REAL(wp), DIMENSION(:,:), POINTER ::   zst               ! surface temperature in Kelvin
255      REAL(wp), DIMENSION(:,:), POINTER ::   zt_zu             ! air temperature at wind speed height
256      REAL(wp), DIMENSION(:,:), POINTER ::   zq_zu             ! air spec. hum.  at wind speed height
257      !!---------------------------------------------------------------------
258      !
259      IF( nn_timing == 1 )  CALL timing_start('blk_oce_core')
260      !
261      CALL wrk_alloc( jpi,jpj, zwnd_i, zwnd_j, zqsatw, zqlw, zqsb, zqla, zevap )
262      CALL wrk_alloc( jpi,jpj, Cd, Ch, Ce, zst, zt_zu, zq_zu )
263      !
264      ! local scalars ( place there for vector optimisation purposes)
265      zcoef_qsatw = 0.98 * 640380. / rhoa
266     
267      zst(:,:) = pst(:,:) + rt0      ! convert SST from Celcius to Kelvin (and set minimum value far above 0 K)
268
269      ! ----------------------------------------------------------------------------- !
270      !      0   Wind components and module at T-point relative to the moving ocean   !
271      ! ----------------------------------------------------------------------------- !
272
273      ! ... components ( U10m - U_oce ) at T-point (unmasked)
274      zwnd_i(:,:) = 0.e0 
275      zwnd_j(:,:) = 0.e0
276#if defined key_cyclone
277      CALL wnd_cyc( kt, zwnd_i, zwnd_j )    ! add analytical tropical cyclone (Vincent et al. JGR 2012)
278      DO jj = 2, jpjm1
279         DO ji = fs_2, fs_jpim1   ! vect. opt.
280            sf(jp_wndi)%fnow(ji,jj,1) = sf(jp_wndi)%fnow(ji,jj,1) + zwnd_i(ji,jj)
281            sf(jp_wndj)%fnow(ji,jj,1) = sf(jp_wndj)%fnow(ji,jj,1) + zwnd_j(ji,jj)
282         END DO
283      END DO
284#endif
285      DO jj = 2, jpjm1
286         DO ji = fs_2, fs_jpim1   ! vect. opt.
287            zwnd_i(ji,jj) = (  sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pu(ji-1,jj  ) + pu(ji,jj) )  )
288            zwnd_j(ji,jj) = (  sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pv(ji  ,jj-1) + pv(ji,jj) )  )
289         END DO
290      END DO
291      CALL lbc_lnk( zwnd_i(:,:) , 'T', -1. )
292      CALL lbc_lnk( zwnd_j(:,:) , 'T', -1. )
293      ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
294      wndm(:,:) = SQRT(  zwnd_i(:,:) * zwnd_i(:,:)   &
295         &             + zwnd_j(:,:) * zwnd_j(:,:)  ) * tmask(:,:,1)
296
297      ! ----------------------------------------------------------------------------- !
298      !      I   Radiative FLUXES                                                     !
299      ! ----------------------------------------------------------------------------- !
300
301      ! ocean albedo assumed to be constant + modify now Qsr to include the diurnal cycle                    ! Short Wave
302      zztmp = 1. - albo
303      IF( ln_dm2dc ) THEN   ;   qsr(:,:) = zztmp * sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) * tmask(:,:,1)
304      ELSE                  ;   qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:,1)   * tmask(:,:,1)
305      ENDIF
306      zqlw(:,:) = (  sf(jp_qlw)%fnow(:,:,1) - Stef * zst(:,:)*zst(:,:)*zst(:,:)*zst(:,:)  ) * tmask(:,:,1)   ! Long  Wave
307      ! ----------------------------------------------------------------------------- !
308      !     II    Turbulent FLUXES                                                    !
309      ! ----------------------------------------------------------------------------- !
310
311      ! ... specific humidity at SST and IST
312      zqsatw(:,:) = zcoef_qsatw * EXP( -5107.4 / zst(:,:) )
313
314      ! ... NCAR Bulk formulae, computation of Cd, Ch, Ce at T-point :
315      CALL turb_core_2z( rn_zqt, rn_zu, zst, sf(jp_tair)%fnow, zqsatw, sf(jp_humi)%fnow, wndm,   &
316         &               Cd, Ch, Ce, zt_zu, zq_zu )
317   
318      ! ... tau module, i and j component
319      DO jj = 1, jpj
320         DO ji = 1, jpi
321            zztmp = rhoa * wndm(ji,jj) * Cd(ji,jj)
322            taum  (ji,jj) = zztmp * wndm  (ji,jj)
323            zwnd_i(ji,jj) = zztmp * zwnd_i(ji,jj)
324            zwnd_j(ji,jj) = zztmp * zwnd_j(ji,jj)
325         END DO
326      END DO
327
328      ! ... add the HF tau contribution to the wind stress module?
329      IF( lhftau ) THEN
330         taum(:,:) = taum(:,:) + sf(jp_tdif)%fnow(:,:,1)
331      ENDIF
332      CALL iom_put( "taum_oce", taum )   ! output wind stress module
333
334      ! ... utau, vtau at U- and V_points, resp.
335      !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines
336      DO jj = 1, jpjm1
337         DO ji = 1, fs_jpim1
338            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) )
339            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) )
340         END DO
341      END DO
342      CALL lbc_lnk( utau(:,:), 'U', -1. )
343      CALL lbc_lnk( vtau(:,:), 'V', -1. )
344
345   
346      !  Turbulent fluxes over ocean
347      ! -----------------------------
348      IF( ABS( rn_zu - rn_zqt) < 0.01_wp ) THEN
349         !! q_air and t_air are (or "are almost") given at 10m (wind reference height)
350         zevap(:,:) = rn_efac*MAX( 0._wp,     rhoa*Ce(:,:)*( zqsatw(:,:) - sf(jp_humi)%fnow(:,:,1) )*wndm(:,:) ) ! Evaporation
351         zqsb (:,:) =                     cpa*rhoa*Ch(:,:)*( zst   (:,:) - sf(jp_tair)%fnow(:,:,1) )*wndm(:,:)   ! Sensible Heat
352      ELSE
353         !! q_air and t_air are not given at 10m (wind reference height)
354         ! Values of temp. and hum. adjusted to height of wind during bulk algorithm iteration must be used!!!
355         zevap(:,:) = rn_efac*MAX( 0.e0,     rhoa*Ce(:,:)*( zqsatw(:,:) - zq_zu(:,:) )*wndm(:,:) )   ! Evaporation
356         zqsb (:,:) =                    cpa*rhoa*Ch(:,:)*( zst   (:,:) - zt_zu(:,:) )*wndm(:,:)     ! Sensible Heat
357      ENDIF
358      zqla (:,:) = Lv * zevap(:,:)                                                              ! Latent Heat
359
360      IF(ln_ctl) THEN
361         CALL prt_ctl( tab2d_1=zqla  , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=Ce , clinfo2=' Ce  : ' )
362         CALL prt_ctl( tab2d_1=zqsb  , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=Ch , clinfo2=' Ch  : ' )
363         CALL prt_ctl( tab2d_1=zqlw  , clinfo1=' blk_oce_core: zqlw   : ', tab2d_2=qsr, clinfo2=' qsr : ' )
364         CALL prt_ctl( tab2d_1=zqsatw, clinfo1=' blk_oce_core: zqsatw : ', tab2d_2=zst, clinfo2=' zst : ' )
365         CALL prt_ctl( tab2d_1=utau  , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
366            &          tab2d_2=vtau  , clinfo2=              ' vtau : '  , mask2=vmask )
367         CALL prt_ctl( tab2d_1=wndm  , clinfo1=' blk_oce_core: wndm   : ')
368         CALL prt_ctl( tab2d_1=zst   , clinfo1=' blk_oce_core: zst    : ')
369      ENDIF
370       
371      ! ----------------------------------------------------------------------------- !
372      !     III    Total FLUXES                                                       !
373      ! ----------------------------------------------------------------------------- !
374      !
375      emp (:,:) = (  zevap(:,:)                                          &   ! mass flux (evap. - precip.)
376         &         - sf(jp_prec)%fnow(:,:,1) * rn_pfac  ) * tmask(:,:,1)
377      qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                                &   ! Downward Non Solar flux
378         &     - sf(jp_snow)%fnow(:,:,1) * rn_pfac * lfus                         &   ! remove latent melting heat for solid precip
379         &     - zevap(:,:) * pst(:,:) * rcp                                      &   ! remove evap heat content at SST
380         &     + ( sf(jp_prec)%fnow(:,:,1) - sf(jp_snow)%fnow(:,:,1) ) * rn_pfac  &   ! add liquid precip heat content at Tair
381         &     * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp                          &
382         &     + sf(jp_snow)%fnow(:,:,1) * rn_pfac                                &   ! add solid  precip heat content at min(Tair,Tsnow)
383         &     * ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic 
384      !
385      CALL iom_put( "qlw_oce",   zqlw )                 ! output downward longwave heat over the ocean
386      CALL iom_put( "qsb_oce", - zqsb )                 ! output downward sensible heat over the ocean
387      CALL iom_put( "qla_oce", - zqla )                 ! output downward latent   heat over the ocean
388      CALL iom_put( "qhc_oce",   qns-zqlw+zqsb+zqla )   ! output downward heat content of E-P over the ocean
389      CALL iom_put( "qns_oce",   qns  )                 ! output downward non solar heat over the ocean
390      !
391      IF(ln_ctl) THEN
392         CALL prt_ctl(tab2d_1=zqsb , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=zqlw , clinfo2=' zqlw  : ')
393         CALL prt_ctl(tab2d_1=zqla , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=qsr  , clinfo2=' qsr   : ')
394         CALL prt_ctl(tab2d_1=pst  , clinfo1=' blk_oce_core: pst    : ', tab2d_2=emp  , clinfo2=' emp   : ')
395         CALL prt_ctl(tab2d_1=utau , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
396            &         tab2d_2=vtau , clinfo2=              ' vtau  : ' , mask2=vmask )
397      ENDIF
398      !
399      CALL wrk_dealloc( jpi,jpj, zwnd_i, zwnd_j, zqsatw, zqlw, zqsb, zqla, zevap )
400      CALL wrk_dealloc( jpi,jpj, Cd, Ch, Ce, zst, zt_zu, zq_zu )
401      !
402      IF( nn_timing == 1 )  CALL timing_stop('blk_oce_core')
403      !
404   END SUBROUTINE blk_oce_core
405 
406   
407   SUBROUTINE blk_ice_core(  pst   , pui   , pvi   , palb ,   &
408      &                      p_taui, p_tauj, p_qns , p_qsr,   &
409      &                      p_qla , p_dqns, p_dqla,          &
410      &                      p_tpr , p_spr ,                  &
411      &                      p_fr1 , p_fr2 , cd_grid, pdim  ) 
412      !!---------------------------------------------------------------------
413      !!                     ***  ROUTINE blk_ice_core  ***
414      !!
415      !! ** Purpose :   provide the surface boundary condition over sea-ice
416      !!
417      !! ** Method  :   compute momentum, heat and freshwater exchanged
418      !!                between atmosphere and sea-ice using CORE bulk
419      !!                formulea, ice variables and read atmmospheric fields.
420      !!                NB: ice drag coefficient is assumed to be a constant
421      !!
422      !! caution : the net upward water flux has with mm/day unit
423      !!---------------------------------------------------------------------
424      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pst      ! ice surface temperature (>0, =rt0 over land) [Kelvin]
425      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pui      ! ice surface velocity (i- and i- components      [m/s]
426      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pvi      !    at I-point (B-grid) or U & V-point (C-grid)
427      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   palb     ! ice albedo (clear sky) (alb_ice_cs)               [%]
428      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_taui   ! i- & j-components of surface ice stress        [N/m2]
429      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tauj   !   at I-point (B-grid) or U & V-point (C-grid)
430      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qns    ! non solar heat flux over ice (T-point)         [W/m2]
431      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qsr    !     solar heat flux over ice (T-point)         [W/m2]
432      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qla    ! latent    heat flux over ice (T-point)         [W/m2]
433      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqns   ! non solar heat sensistivity  (T-point)         [W/m2]
434      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqla   ! latent    heat sensistivity  (T-point)         [W/m2]
435      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tpr    ! total precipitation          (T-point)      [Kg/m2/s]
436      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_spr    ! solid precipitation          (T-point)      [Kg/m2/s]
437      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr1    ! 1sr fraction of qsr penetration in ice (T-point)  [%]
438      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr2    ! 2nd fraction of qsr penetration in ice (T-point)  [%]
439      CHARACTER(len=1)          , INTENT(in   ) ::   cd_grid  ! ice grid ( C or B-grid)
440      INTEGER                   , INTENT(in   ) ::   pdim     ! number of ice categories
441      !!
442      INTEGER  ::   ji, jj, jl    ! dummy loop indices
443      INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays)
444      REAL(wp) ::   zst2, zst3
445      REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2, zcoef_dqlw, zcoef_dqla, zcoef_dqsb
446      REAL(wp) ::   zztmp                                        ! temporary variable
447      REAL(wp) ::   zcoef_frca                                   ! fractional cloud amount
448      REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f                  ! relative wind module and components at F-point
449      REAL(wp) ::             zwndi_t , zwndj_t                  ! relative wind components at T-point
450      !!
451      REAL(wp), DIMENSION(:,:)  , POINTER ::   z_wnds_t          ! wind speed ( = | U10m - U_ice | ) at T-point
452      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qlw             ! long wave heat flux over ice
453      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qsb             ! sensible  heat flux over ice
454      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqlw            ! long wave heat sensitivity over ice
455      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqsb            ! sensible  heat sensitivity over ice
456      !!---------------------------------------------------------------------
457      !
458      IF( nn_timing == 1 )  CALL timing_start('blk_ice_core')
459      !
460      CALL wrk_alloc( jpi,jpj, z_wnds_t )
461      CALL wrk_alloc( jpi,jpj,pdim, z_qlw, z_qsb, z_dqlw, z_dqsb ) 
462
463      ijpl  = pdim                            ! number of ice categories
464
465      ! local scalars ( place there for vector optimisation purposes)
466      zcoef_wnorm  = rhoa * Cice
467      zcoef_wnorm2 = rhoa * Cice * 0.5
468      zcoef_dqlw   = 4.0 * 0.95 * Stef
469      zcoef_dqla   = -Ls * Cice * 11637800. * (-5897.8)
470      zcoef_dqsb   = rhoa * cpa * Cice
471      zcoef_frca   = 1.0  - 0.3
472
473!!gm brutal....
474      z_wnds_t(:,:) = 0.e0
475      p_taui  (:,:) = 0.e0
476      p_tauj  (:,:) = 0.e0
477!!gm end
478
479#if defined key_lim3
480      tatm_ice(:,:) = sf(jp_tair)%fnow(:,:,1)   ! LIM3: make Tair available in sea-ice. WARNING allocated after call to ice_init
481#endif
482      ! ----------------------------------------------------------------------------- !
483      !    Wind components and module relative to the moving ocean ( U10m - U_ice )   !
484      ! ----------------------------------------------------------------------------- !
485      SELECT CASE( cd_grid )
486      CASE( 'I' )                  ! B-grid ice dynamics :   I-point (i.e. F-point with sea-ice indexation)
487         !                           and scalar wind at T-point ( = | U10m - U_ice | ) (masked)
488         DO jj = 2, jpjm1
489            DO ji = 2, jpim1   ! B grid : NO vector opt
490               ! ... scalar wind at I-point (fld being at T-point)
491               zwndi_f = 0.25 * (  sf(jp_wndi)%fnow(ji-1,jj  ,1) + sf(jp_wndi)%fnow(ji  ,jj  ,1)   &
492                  &              + sf(jp_wndi)%fnow(ji-1,jj-1,1) + sf(jp_wndi)%fnow(ji  ,jj-1,1)  ) - rn_vfac * pui(ji,jj)
493               zwndj_f = 0.25 * (  sf(jp_wndj)%fnow(ji-1,jj  ,1) + sf(jp_wndj)%fnow(ji  ,jj  ,1)   &
494                  &              + sf(jp_wndj)%fnow(ji-1,jj-1,1) + sf(jp_wndj)%fnow(ji  ,jj-1,1)  ) - rn_vfac * pvi(ji,jj)
495               zwnorm_f = zcoef_wnorm * SQRT( zwndi_f * zwndi_f + zwndj_f * zwndj_f )
496               ! ... ice stress at I-point
497               p_taui(ji,jj) = zwnorm_f * zwndi_f
498               p_tauj(ji,jj) = zwnorm_f * zwndj_f
499               ! ... scalar wind at T-point (fld being at T-point)
500               zwndi_t = sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  pui(ji,jj+1) + pui(ji+1,jj+1)   &
501                  &                                                    + pui(ji,jj  ) + pui(ji+1,jj  )  )
502               zwndj_t = sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  pvi(ji,jj+1) + pvi(ji+1,jj+1)   &
503                  &                                                    + pvi(ji,jj  ) + pvi(ji+1,jj  )  )
504               z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
505            END DO
506         END DO
507         CALL lbc_lnk( p_taui  , 'I', -1. )
508         CALL lbc_lnk( p_tauj  , 'I', -1. )
509         CALL lbc_lnk( z_wnds_t, 'T',  1. )
510         !
511      CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean)
512         DO jj = 2, jpj
513            DO ji = fs_2, jpi   ! vect. opt.
514               zwndi_t = (  sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pui(ji-1,jj  ) + pui(ji,jj) )  )
515               zwndj_t = (  sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pvi(ji  ,jj-1) + pvi(ji,jj) )  )
516               z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
517            END DO
518         END DO
519         DO jj = 2, jpjm1
520            DO ji = fs_2, fs_jpim1   ! vect. opt.
521               p_taui(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji+1,jj  ) + z_wnds_t(ji,jj) )                          &
522                  &          * ( 0.5 * (sf(jp_wndi)%fnow(ji+1,jj,1) + sf(jp_wndi)%fnow(ji,jj,1) ) - rn_vfac * pui(ji,jj) )
523               p_tauj(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji,jj+1  ) + z_wnds_t(ji,jj) )                          &
524                  &          * ( 0.5 * (sf(jp_wndj)%fnow(ji,jj+1,1) + sf(jp_wndj)%fnow(ji,jj,1) ) - rn_vfac * pvi(ji,jj) )
525            END DO
526         END DO
527         CALL lbc_lnk( p_taui  , 'U', -1. )
528         CALL lbc_lnk( p_tauj  , 'V', -1. )
529         CALL lbc_lnk( z_wnds_t, 'T',  1. )
530         !
531      END SELECT
532
533      zztmp = 1. / ( 1. - albo )
534      !                                     ! ========================== !
535      DO jl = 1, ijpl                       !  Loop over ice categories  !
536         !                                  ! ========================== !
537         DO jj = 1 , jpj
538            DO ji = 1, jpi
539               ! ----------------------------!
540               !      I   Radiative FLUXES   !
541               ! ----------------------------!
542               zst2 = pst(ji,jj,jl) * pst(ji,jj,jl)
543               zst3 = pst(ji,jj,jl) * zst2
544               ! Short Wave (sw)
545               p_qsr(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr(ji,jj)
546               ! Long  Wave (lw)
547               ! iovino
548               IF( ff(ji,jj) .GT. 0._wp ) THEN
549                  z_qlw(ji,jj,jl) = ( 0.95 * sf(jp_qlw)%fnow(ji,jj,1) - Stef * pst(ji,jj,jl) * zst3 ) * tmask(ji,jj,1)
550               ELSE
551                  z_qlw(ji,jj,jl) = 0.95 * ( sf(jp_qlw)%fnow(ji,jj,1) - Stef * pst(ji,jj,jl) * zst3 ) * tmask(ji,jj,1)
552               ENDIF
553               ! lw sensitivity
554               z_dqlw(ji,jj,jl) = zcoef_dqlw * zst3                                               
555
556               ! ----------------------------!
557               !     II    Turbulent FLUXES  !
558               ! ----------------------------!
559
560               ! ... turbulent heat fluxes
561               ! Sensible Heat
562               z_qsb(ji,jj,jl) = rhoa * cpa * Cice * z_wnds_t(ji,jj) * ( pst(ji,jj,jl) - sf(jp_tair)%fnow(ji,jj,1) )
563               ! Latent Heat
564               p_qla(ji,jj,jl) = rn_efac * MAX( 0.e0, rhoa * Ls  * Cice * z_wnds_t(ji,jj)   &                           
565                  &                         * (  11637800. * EXP( -5897.8 / pst(ji,jj,jl) ) / rhoa - sf(jp_humi)%fnow(ji,jj,1)  ) )
566               ! Latent heat sensitivity for ice (Dqla/Dt)
567               p_dqla(ji,jj,jl) = rn_efac * zcoef_dqla * z_wnds_t(ji,jj) / ( zst2 ) * EXP( -5897.8 / pst(ji,jj,jl) )
568               ! Sensible heat sensitivity (Dqsb_ice/Dtn_ice)
569               z_dqsb(ji,jj,jl) = zcoef_dqsb * z_wnds_t(ji,jj)
570
571               ! ----------------------------!
572               !     III    Total FLUXES     !
573               ! ----------------------------!
574               ! Downward Non Solar flux
575               p_qns (ji,jj,jl) =     z_qlw (ji,jj,jl) - z_qsb (ji,jj,jl) - p_qla (ji,jj,jl)
576               ! Total non solar heat flux sensitivity for ice
577               p_dqns(ji,jj,jl) = - ( z_dqlw(ji,jj,jl) + z_dqsb(ji,jj,jl) + p_dqla(ji,jj,jl) )
578            END DO
579            !
580         END DO
581         !
582      END DO
583      !
584      !--------------------------------------------------------------------
585      ! FRACTIONs of net shortwave radiation which is not absorbed in the
586      ! thin surface layer and penetrates inside the ice cover
587      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 )
588
589      p_fr1(:,:) = ( 0.18 * ( 1.0 - zcoef_frca ) + 0.35 * zcoef_frca )
590      p_fr2(:,:) = ( 0.82 * ( 1.0 - zcoef_frca ) + 0.65 * zcoef_frca )
591
592      p_tpr(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac      ! total precipitation [kg/m2/s]
593      p_spr(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac      ! solid precipitation [kg/m2/s]
594      CALL iom_put( 'snowpre', p_spr * 86400. )                  ! Snow precipitation
595      CALL iom_put( 'precip' , p_tpr * 86400. )                  ! Total precipitation
596      !
597      IF(ln_ctl) THEN
598         CALL prt_ctl(tab3d_1=p_qla   , clinfo1=' blk_ice_core: p_qla  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb  : ', kdim=ijpl)
599         CALL prt_ctl(tab3d_1=z_qlw   , clinfo1=' blk_ice_core: z_qlw  : ', tab3d_2=p_dqla  , clinfo2=' p_dqla : ', kdim=ijpl)
600         CALL prt_ctl(tab3d_1=z_dqsb  , clinfo1=' blk_ice_core: z_dqsb : ', tab3d_2=z_dqlw  , clinfo2=' z_dqlw : ', kdim=ijpl)
601         CALL prt_ctl(tab3d_1=p_dqns  , clinfo1=' blk_ice_core: p_dqns : ', tab3d_2=p_qsr   , clinfo2=' p_qsr  : ', kdim=ijpl)
602         CALL prt_ctl(tab3d_1=pst     , clinfo1=' blk_ice_core: pst    : ', tab3d_2=p_qns   , clinfo2=' p_qns  : ', kdim=ijpl)
603         CALL prt_ctl(tab2d_1=p_tpr   , clinfo1=' blk_ice_core: p_tpr  : ', tab2d_2=p_spr   , clinfo2=' p_spr  : ')
604         CALL prt_ctl(tab2d_1=p_taui  , clinfo1=' blk_ice_core: p_taui : ', tab2d_2=p_tauj  , clinfo2=' p_tauj : ')
605         CALL prt_ctl(tab2d_1=z_wnds_t, clinfo1=' blk_ice_core: z_wnds_t : ')
606      ENDIF
607
608      CALL wrk_dealloc( jpi,jpj, z_wnds_t )
609      CALL wrk_dealloc( jpi,jpj,pdim, z_qlw, z_qsb, z_dqlw, z_dqsb )
610      !
611      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_core')
612      !
613   END SUBROUTINE blk_ice_core
614
615
616   SUBROUTINE blk_bio_meanqsr
617      !!---------------------------------------------------------------------
618      !!                     ***  ROUTINE blk_bio_meanqsr
619      !!                     
620      !! ** Purpose :   provide daily qsr_mean for PISCES when
621      !!                analytic diurnal cycle is applied in physic
622      !!               
623      !! ** Method  :   add part where there is no ice
624      !!
625      !!---------------------------------------------------------------------
626      IF( nn_timing == 1 )  CALL timing_start('blk_bio_meanqsr')
627      !
628      qsr_mean(:,:) = (1. - albo ) *  sf(jp_qsr)%fnow(:,:,1)
629      !
630      IF( nn_timing == 1 )  CALL timing_stop('blk_bio_meanqsr')
631      !
632   END SUBROUTINE blk_bio_meanqsr
633 
634 
635   SUBROUTINE blk_ice_meanqsr( palb, p_qsr_mean, pdim )
636      !!---------------------------------------------------------------------
637      !!
638      !! ** Purpose :   provide the daily qsr_mean over sea_ice for PISCES when
639      !!                analytic diurnal cycle is applied in physic
640      !!
641      !! ** Method  :   compute qsr
642      !!
643      !!---------------------------------------------------------------------
644      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   palb       ! ice albedo (clear sky) (alb_ice_cs)               [%]
645      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qsr_mean !     solar heat flux over ice (T-point)         [W/m2]
646      INTEGER                   , INTENT(in   ) ::   pdim       ! number of ice categories
647      !
648      INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays)
649      INTEGER  ::   ji, jj, jl    ! dummy loop indices
650      REAL(wp) ::   zztmp         ! temporary variable
651      !!---------------------------------------------------------------------
652      IF( nn_timing == 1 )  CALL timing_start('blk_ice_meanqsr')
653      !
654      ijpl  = pdim                            ! number of ice categories
655      zztmp = 1. / ( 1. - albo )
656      !                                     ! ========================== !
657      DO jl = 1, ijpl                       !  Loop over ice categories  !
658         !                                  ! ========================== !
659         DO jj = 1 , jpj
660            DO ji = 1, jpi
661                  p_qsr_mean(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr_mean(ji,jj)
662            END DO
663         END DO
664      END DO
665      !
666      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_meanqsr')
667      !
668   END SUBROUTINE blk_ice_meanqsr 
669
670
671   SUBROUTINE turb_core_2z( zt, zu, sst, T_zt, q_sat, q_zt, dU,    &
672      &                      Cd, Ch, Ce , T_zu, q_zu )
673      !!----------------------------------------------------------------------
674      !!                      ***  ROUTINE  turb_core  ***
675      !!
676      !! ** Purpose :   Computes turbulent transfert coefficients of surface
677      !!                fluxes according to Large & Yeager (2004) and Large & Yeager (2008)
678      !!                If relevant (zt /= zu), adjust temperature and humidity from height zt to zu
679      !!
680      !! ** Method : Monin Obukhov Similarity Theory
681      !!             + Large & Yeager (2004,2008) closure: CD_n10 = f(U_n10)
682      !!
683      !! ** References :   Large & Yeager, 2004 / Large & Yeager, 2008
684      !!
685      !! ** Last update: Laurent Brodeau, June 2014:
686      !!    - handles both cases zt=zu and zt/=zu
687      !!    - optimized: less 2D arrays allocated and less operations
688      !!    - better first guess of stability by checking air-sea difference of virtual temperature
689      !!       rather than temperature difference only...
690      !!    - added function "cd_neutral_10m" that uses the improved parametrization of
691      !!      Large & Yeager 2008. Drag-coefficient reduction for Cyclone conditions!
692      !!    - using code-wide physical constants defined into "phycst.mod" rather than redifining them
693      !!      => 'vkarmn' and 'grav'
694      !!----------------------------------------------------------------------
695      REAL(wp), INTENT(in   )                     ::   zt       ! height for T_zt and q_zt                   [m]
696      REAL(wp), INTENT(in   )                     ::   zu       ! height for dU                              [m]
697      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   sst      ! sea surface temperature              [Kelvin]
698      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   T_zt     ! potential air temperature            [Kelvin]
699      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   q_sat    ! sea surface specific humidity         [kg/kg]
700      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   q_zt     ! specific air humidity                 [kg/kg]
701      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   dU       ! relative wind module at zu            [m/s]
702      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Cd       ! transfer coefficient for momentum         (tau)
703      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Ch       ! transfer coefficient for sensible heat (Q_sens)
704      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Ce       ! transfert coefficient for evaporation   (Q_lat)
705      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   T_zu     ! air temp. shifted at zu                     [K]
706      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   q_zu     ! spec. hum.  shifted at zu               [kg/kg]
707      !
708      INTEGER ::   j_itt
709      INTEGER , PARAMETER ::   nb_itt = 5       ! number of itterations
710      LOGICAL ::   l_zt_equal_zu = .FALSE.      ! if q and t are given at different height than U
711      !
712      REAL(wp), DIMENSION(:,:), POINTER ::   U_zu          ! relative wind at zu                            [m/s]
713      REAL(wp), DIMENSION(:,:), POINTER ::   Ce_n10        ! 10m neutral latent coefficient
714      REAL(wp), DIMENSION(:,:), POINTER ::   Ch_n10        ! 10m neutral sensible coefficient
715      REAL(wp), DIMENSION(:,:), POINTER ::   sqrt_Cd_n10   ! root square of Cd_n10
716      REAL(wp), DIMENSION(:,:), POINTER ::   sqrt_Cd       ! root square of Cd
717      REAL(wp), DIMENSION(:,:), POINTER ::   zeta_u        ! stability parameter at height zu
718      REAL(wp), DIMENSION(:,:), POINTER ::   zeta_t        ! stability parameter at height zt
719      REAL(wp), DIMENSION(:,:), POINTER ::   zpsi_h_u, zpsi_m_u
720      REAL(wp), DIMENSION(:,:), POINTER ::   ztmp0, ztmp1, ztmp2
721      REAL(wp), DIMENSION(:,:), POINTER ::   stab          ! 1st stability test integer
722      !!----------------------------------------------------------------------
723
724      IF( nn_timing == 1 )  CALL timing_start('turb_core_2z')
725   
726      CALL wrk_alloc( jpi,jpj, U_zu, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd )
727      CALL wrk_alloc( jpi,jpj, zeta_u, stab )
728      CALL wrk_alloc( jpi,jpj, zpsi_h_u, zpsi_m_u, ztmp0, ztmp1, ztmp2 )
729
730      l_zt_equal_zu = .FALSE.
731      IF( ABS(zu - zt) < 0.01 ) l_zt_equal_zu = .TRUE.    ! testing "zu == zt" is risky with double precision
732
733      IF( .NOT. l_zt_equal_zu )   CALL wrk_alloc( jpi,jpj, zeta_t )
734
735      U_zu = MAX( 0.5 , dU )   !  relative wind speed at zu (normally 10m), we don't want to fall under 0.5 m/s
736
737      !! First guess of stability:
738      ztmp0 = T_zt*(1. + 0.608*q_zt) - sst*(1. + 0.608*q_sat) ! air-sea difference of virtual pot. temp. at zt
739      stab  = 0.5 + sign(0.5,ztmp0)                           ! stab = 1 if dTv > 0  => STABLE, 0 if unstable
740
741      !! Neutral coefficients at 10m:
742      IF( ln_cdgw ) THEN      ! wave drag case
743         cdn_wave(:,:) = cdn_wave(:,:) + rsmall * ( 1._wp - tmask(:,:,1) )
744         ztmp0   (:,:) = cdn_wave(:,:)
745      ELSE
746         ztmp0 = cd_neutral_10m( U_zu )
747      ENDIF
748      sqrt_Cd_n10 = SQRT( ztmp0 )
749      Ce_n10  = 1.e-3*( 34.6 * sqrt_Cd_n10 )
750      Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab))
751   
752      !! Initializing transf. coeff. with their first guess neutral equivalents :
753      Cd = ztmp0   ;   Ce = Ce_n10   ;   Ch = Ch_n10   ;   sqrt_Cd = sqrt_Cd_n10
754
755      !! Initializing values at z_u with z_t values:
756      T_zu = T_zt   ;   q_zu = q_zt
757
758      !!  * Now starting iteration loop
759      DO j_itt=1, nb_itt
760         !
761         ztmp1 = T_zu - sst   ! Updating air/sea differences
762         ztmp2 = q_zu - q_sat 
763
764         ! Updating turbulent scales :   (L&Y 2004 eq. (7))
765         ztmp1  = Ch/sqrt_Cd*ztmp1    ! theta*
766         ztmp2  = Ce/sqrt_Cd*ztmp2    ! q*
767       
768         ztmp0 = T_zu*(1. + 0.608*q_zu) ! virtual potential temperature at zu
769
770         ! Estimate the inverse of Monin-Obukov length (1/L) at height zu:
771         ztmp0 =  (vkarmn*grav/ztmp0*(ztmp1*(1.+0.608*q_zu) + 0.608*T_zu*ztmp2)) / (Cd*U_zu*U_zu) 
772         !                                                                     ( Cd*U_zu*U_zu is U*^2 at zu)
773
774         !! Stability parameters :
775         zeta_u   = zu*ztmp0   ;  zeta_u = sign( min(abs(zeta_u),10.0), zeta_u )
776         zpsi_h_u = psi_h( zeta_u )
777         zpsi_m_u = psi_m( zeta_u )
778       
779         !! Shifting temperature and humidity at zu (L&Y 2004 eq. (9b-9c))
780         IF ( .NOT. l_zt_equal_zu ) THEN
781            zeta_t = zt*ztmp0 ;  zeta_t = sign( min(abs(zeta_t),10.0), zeta_t )
782            stab = LOG(zu/zt) - zpsi_h_u + psi_h(zeta_t)  ! stab just used as temp array!!!
783            T_zu = T_zt + ztmp1/vkarmn*stab    ! ztmp1 is still theta*
784            q_zu = q_zt + ztmp2/vkarmn*stab    ! ztmp2 is still q*
785            q_zu = max(0., q_zu)
786         END IF
787       
788         IF( ln_cdgw ) THEN      ! surface wave case
789            sqrt_Cd = vkarmn / ( vkarmn / sqrt_Cd_n10 - zpsi_m_u ) 
790            Cd      = sqrt_Cd * sqrt_Cd
791         ELSE
792           ! Update neutral wind speed at 10m and neutral Cd at 10m (L&Y 2004 eq. 9a)...
793           !   In very rare low-wind conditions, the old way of estimating the
794           !   neutral wind speed at 10m leads to a negative value that causes the code
795           !   to crash. To prevent this a threshold of 0.25m/s is imposed.
796           ztmp0 = MAX( 0.25 , U_zu/(1. + sqrt_Cd_n10/vkarmn*(LOG(zu/10.) - zpsi_m_u)) ) !  U_n10
797           ztmp0 = cd_neutral_10m(ztmp0)                                                 ! Cd_n10
798           sqrt_Cd_n10 = sqrt(ztmp0)
799       
800           Ce_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)                     ! L&Y 2004 eq. (6b)
801           stab    = 0.5 + sign(0.5,zeta_u)                           ! update stability
802           Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab))  ! L&Y 2004 eq. (6c-6d)
803
804           !! Update of transfer coefficients:
805           ztmp1 = 1. + sqrt_Cd_n10/vkarmn*(LOG(zu/10.) - zpsi_m_u)   ! L&Y 2004 eq. (10a)
806           Cd      = ztmp0 / ( ztmp1*ztmp1 )   
807           sqrt_Cd = SQRT( Cd )
808         ENDIF
809         !
810         ztmp0 = (LOG(zu/10.) - zpsi_h_u) / vkarmn / sqrt_Cd_n10
811         ztmp2 = sqrt_Cd / sqrt_Cd_n10
812         ztmp1 = 1. + Ch_n10*ztmp0               
813         Ch  = Ch_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10b)
814         !
815         ztmp1 = 1. + Ce_n10*ztmp0               
816         Ce  = Ce_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10c)
817         !
818      END DO
819
820      CALL wrk_dealloc( jpi,jpj, U_zu, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd )
821      CALL wrk_dealloc( jpi,jpj, zeta_u, stab )
822      CALL wrk_dealloc( jpi,jpj, zpsi_h_u, zpsi_m_u, ztmp0, ztmp1, ztmp2 )
823
824      IF( .NOT. l_zt_equal_zu ) CALL wrk_dealloc( jpi,jpj, zeta_t )
825
826      IF( nn_timing == 1 )  CALL timing_stop('turb_core_2z')
827      !
828   END SUBROUTINE turb_core_2z
829
830
831   FUNCTION cd_neutral_10m( zw10 )
832      !!----------------------------------------------------------------------
833      !! Estimate of the neutral drag coefficient at 10m as a function
834      !! of neutral wind  speed at 10m
835      !!
836      !! Origin: Large & Yeager 2008 eq.(11a) and eq.(11b)
837      !!
838      !! Author: L. Brodeau, june 2014
839      !!----------------------------------------------------------------------   
840      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   zw10           ! scalar wind speed at 10m (m/s)
841      REAL(wp), DIMENSION(jpi,jpj)             ::   cd_neutral_10m
842      !
843      REAL(wp), DIMENSION(:,:), POINTER ::   rgt33
844      !!----------------------------------------------------------------------   
845      !
846      CALL wrk_alloc( jpi,jpj, rgt33 )
847      !
848      !! When wind speed > 33 m/s => Cyclone conditions => special treatment
849      rgt33 = 0.5_wp + SIGN( 0.5_wp, (zw10 - 33._wp) )   ! If zw10 < 33. => 0, else => 1 
850      cd_neutral_10m = 1.e-3 * ( &
851         &       (rgt33 + 1._wp)*( 2.7_wp/zw10 + 0.142_wp + zw10/13.09_wp - 3.14807E-10*zw10**6) & ! zw10< 33.
852         &      + rgt33         *      2.34   )                                                    ! zw10 >= 33.
853      !
854      CALL wrk_dealloc( jpi,jpj, rgt33)
855      !
856   END FUNCTION cd_neutral_10m
857
858
859   FUNCTION psi_m(pta)   !! Psis, L&Y 2004 eq. (8c), (8d), (8e)
860      !-------------------------------------------------------------------------------
861      ! universal profile stability function for momentum
862      !-------------------------------------------------------------------------------
863      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pta
864      !
865      REAL(wp), DIMENSION(jpi,jpj)             :: psi_m
866      REAL(wp), DIMENSION(:,:), POINTER        :: X2, X, stabit
867      !-------------------------------------------------------------------------------
868      !
869      CALL wrk_alloc( jpi,jpj, X2, X, stabit )
870      !
871      X2 = SQRT( ABS( 1. - 16.*pta ) )  ;  X2 = MAX( X2 , 1. )   ;   X = SQRT( X2 )
872      stabit = 0.5 + SIGN( 0.5 , pta )
873      psi_m = -5.*pta*stabit  &                                                          ! Stable
874         &    + (1. - stabit)*(2.*LOG((1. + X)*0.5) + LOG((1. + X2)*0.5) - 2.*ATAN(X) + rpi*0.5)  ! Unstable
875      !
876      CALL wrk_dealloc( jpi,jpj, X2, X, stabit )
877      !
878   END FUNCTION psi_m
879
880
881   FUNCTION psi_h( pta )    !! Psis, L&Y 2004 eq. (8c), (8d), (8e)
882      !-------------------------------------------------------------------------------
883      ! universal profile stability function for temperature and humidity
884      !-------------------------------------------------------------------------------
885      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pta
886      !
887      REAL(wp), DIMENSION(jpi,jpj)             ::   psi_h
888      REAL(wp), DIMENSION(:,:), POINTER        ::   X2, X, stabit
889      !-------------------------------------------------------------------------------
890      !
891      CALL wrk_alloc( jpi,jpj, X2, X, stabit )
892      !
893      X2 = SQRT( ABS( 1. - 16.*pta ) )   ;   X2 = MAX( X2 , 1. )   ;   X = SQRT( X2 )
894      stabit = 0.5 + SIGN( 0.5 , pta )
895      psi_h = -5.*pta*stabit   &                                       ! Stable
896         &    + (1. - stabit)*(2.*LOG( (1. + X2)*0.5 ))                ! Unstable
897      !
898      CALL wrk_dealloc( jpi,jpj, X2, X, stabit )
899      !
900   END FUNCTION psi_h
901
902   !!======================================================================
903END MODULE sbcblk_core
Note: See TracBrowser for help on using the repository browser.