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/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90 @ 5357

Last change on this file since 5357 was 5357, checked in by clem, 9 years ago

LIM3: change the interface between the ice and atm for both coupled and forced modes. Some work still needs to be done to deal with sublimation in coupled mode.

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