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/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90 @ 7525

Last change on this file since 7525 was 7525, checked in by mocavero, 7 years ago

changes after review

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