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 @ 7508

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

changes on code duplication and workshare construct

  • Property svn:keywords set to Id
File size: 53.7 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      ! ----------------------------------------------------------------------------- !
285      !      0   Wind components and module at T-point relative to the moving ocean   !
286      ! ----------------------------------------------------------------------------- !
287
288      ! ... components ( U10m - U_oce ) at T-point (unmasked)
289              zwnd_i(ji,jj) = 0.e0 
290              zwnd_j(ji,jj) = 0.e0
291            END DO
292         END DO
293#if defined key_cyclone
294      CALL wnd_cyc( kt, zwnd_i, zwnd_j )    ! add analytical tropical cyclone (Vincent et al. JGR 2012)
295!$OMP PARALLEL DO schedule(static) private(jj, ji)
296      DO jj = 2, jpjm1
297         DO ji = fs_2, fs_jpim1   ! vect. opt.
298            sf(jp_wndi)%fnow(ji,jj,1) = sf(jp_wndi)%fnow(ji,jj,1) + zwnd_i(ji,jj)
299            sf(jp_wndj)%fnow(ji,jj,1) = sf(jp_wndj)%fnow(ji,jj,1) + zwnd_j(ji,jj)
300         END DO
301      END DO
302#endif
303!$OMP PARALLEL DO schedule(static) private(jj, ji)
304      DO jj = 2, jpjm1
305         DO ji = fs_2, fs_jpim1   ! vect. opt.
306            zwnd_i(ji,jj) = (  sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pu(ji-1,jj  ) + pu(ji,jj) )  )
307            zwnd_j(ji,jj) = (  sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( pv(ji  ,jj-1) + pv(ji,jj) )  )
308         END DO
309      END DO
310      CALL lbc_lnk( zwnd_i(:,:) , 'T', -1. )
311      CALL lbc_lnk( zwnd_j(:,:) , 'T', -1. )
312      ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
313!$OMP PARALLEL DO schedule(static) private(jj, ji)
314      DO jj = 1, jpj
315         DO ji = 1, jpi
316            wndm(ji,jj) = SQRT(  zwnd_i(ji,jj) * zwnd_i(ji,jj)   &
317         &             + zwnd_j(ji,jj) * zwnd_j(ji,jj)  ) * tmask(ji,jj,1)
318
319         END DO
320      END DO
321      ! ----------------------------------------------------------------------------- !
322      !      I   Radiative FLUXES                                                     !
323      ! ----------------------------------------------------------------------------- !
324
325      ! ocean albedo assumed to be constant + modify now Qsr to include the diurnal cycle                    ! Short Wave
326      zztmp = 1. - albo
327      IF( ln_dm2dc ) THEN
328         qsr(:,:) = zztmp * sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) * tmask(:,:,1)
329      ELSE
330         qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:,1)   * tmask(:,:,1)
331      ENDIF
332
333!$OMP PARALLEL 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            ! ----------------------------------------------------------------------------- !
338            !     II    Turbulent FLUXES                                                    !
339            ! ----------------------------------------------------------------------------- !
340
341            ! ... specific humidity at SST and IST
342            zqsatw(ji,jj) = zcoef_qsatw * EXP( -5107.4 / zst(ji,jj) )
343
344         END DO
345      END DO
346      ! ... NCAR Bulk formulae, computation of Cd, Ch, Ce at T-point :
347      CALL turb_core_2z( rn_zqt, rn_zu, zst, sf(jp_tair)%fnow, zqsatw, sf(jp_humi)%fnow, wndm,   &
348         &               Cd, Ch, Ce, zt_zu, zq_zu )
349   
350      ! ... tau module, i and j component
351!$OMP PARALLEL DO schedule(static) private(jj, ji,zztmp)
352      DO jj = 1, jpj
353         DO ji = 1, jpi
354            zztmp = rhoa * wndm(ji,jj) * Cd(ji,jj)
355            taum  (ji,jj) = zztmp * wndm  (ji,jj)
356            zwnd_i(ji,jj) = zztmp * zwnd_i(ji,jj)
357            zwnd_j(ji,jj) = zztmp * zwnd_j(ji,jj)
358         END DO
359      END DO
360
361      ! ... add the HF tau contribution to the wind stress module?
362      IF( lhftau ) THEN
363!$OMP PARALLEL DO schedule(static) private(jj, ji)
364         DO jj = 1, jpj
365            DO ji = 1, jpi
366               taum(ji,jj) = taum(ji,jj) + sf(jp_tdif)%fnow(ji,jj,1)
367            END DO
368         END DO
369      ENDIF
370      CALL iom_put( "taum_oce", taum )   ! output wind stress module
371
372      ! ... utau, vtau at U- and V_points, resp.
373      !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines
374      !     Note the use of MAX(tmask(i,j),tmask(i+1,j) is to mask tau over ice shelves
375!$OMP PARALLEL DO schedule(static) private(jj, ji)
376      DO jj = 1, jpjm1
377         DO ji = 1, fs_jpim1
378            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) ) &
379               &          * MAX(tmask(ji,jj,1),tmask(ji+1,jj,1))
380            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) ) &
381               &          * MAX(tmask(ji,jj,1),tmask(ji,jj+1,1))
382         END DO
383      END DO
384      CALL lbc_lnk( utau(:,:), 'U', -1. )
385      CALL lbc_lnk( vtau(:,:), 'V', -1. )
386
387   
388      !  Turbulent fluxes over ocean
389      ! -----------------------------
390!$OMP PARALLEL DO schedule(static) private(jj, ji)
391      DO jj = 1, jpj
392         DO ji = 1, jpi
393            IF( ABS( rn_zu - rn_zqt) < 0.01_wp ) THEN
394            !! q_air and t_air are (or "are almost") given at 10m (wind reference height)
395               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
396               zqsb (ji,jj) =                     cpa*rhoa*Ch(ji,jj)*( zst   (ji,jj) - sf(jp_tair)%fnow(ji,jj,1) )*wndm(ji,jj)   ! Sensible Heat
397            ELSE
398            !! q_air and t_air are not given at 10m (wind reference height)
399            ! Values of temp. and hum. adjusted to height of wind during bulk algorithm iteration must be used!!!
400               zevap(ji,jj) = rn_efac*MAX( 0._wp,     rhoa*Ce(ji,jj)*( zqsatw(ji,jj) - zq_zu(ji,jj) )*wndm(ji,jj) )   ! Evaporation
401               zqsb (ji,jj) =                     cpa*rhoa*Ch(ji,jj)*( zst   (ji,jj) - zt_zu(ji,jj) )*wndm(ji,jj)     ! Sensible Heat
402            ENDIF
403            zqla (ji,jj) = Lv * zevap(ji,jj)                                                              ! Latent Heat
404         END DO
405      END DO
406      IF(ln_ctl) THEN
407         CALL prt_ctl( tab2d_1=zqla  , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=Ce , clinfo2=' Ce  : ' )
408         CALL prt_ctl( tab2d_1=zqsb  , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=Ch , clinfo2=' Ch  : ' )
409         CALL prt_ctl( tab2d_1=zqlw  , clinfo1=' blk_oce_core: zqlw   : ', tab2d_2=qsr, clinfo2=' qsr : ' )
410         CALL prt_ctl( tab2d_1=zqsatw, clinfo1=' blk_oce_core: zqsatw : ', tab2d_2=zst, clinfo2=' zst : ' )
411         CALL prt_ctl( tab2d_1=utau  , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
412            &          tab2d_2=vtau  , clinfo2=              ' vtau : '  , mask2=vmask )
413         CALL prt_ctl( tab2d_1=wndm  , clinfo1=' blk_oce_core: wndm   : ')
414         CALL prt_ctl( tab2d_1=zst   , clinfo1=' blk_oce_core: zst    : ')
415      ENDIF
416       
417      ! ----------------------------------------------------------------------------- !
418      !     III    Total FLUXES                                                       !
419      ! ----------------------------------------------------------------------------- !
420      !
421!$OMP PARALLEL DO schedule(static) private(jj, ji)
422      DO jj = 1, jpj
423         DO ji = 1, jpi
424      emp (ji,jj) = (  zevap(ji,jj)                                          &   ! mass flux (evap. - precip.)
425         &         - sf(jp_prec)%fnow(ji,jj,1) * rn_pfac  ) * tmask(ji,jj,1)
426      !
427      qns(ji,jj) = zqlw(ji,jj) - zqsb(ji,jj) - zqla(ji,jj)                                &   ! Downward Non Solar
428         &     - sf(jp_snow)%fnow(ji,jj,1) * rn_pfac * lfus                         &   ! remove latent melting heat for solid precip
429         &     - zevap(ji,jj) * pst(ji,jj) * rcp                                      &   ! remove evap heat content at SST
430         &     + ( sf(jp_prec)%fnow(ji,jj,1) - sf(jp_snow)%fnow(ji,jj,1) ) * rn_pfac  &   ! add liquid precip heat content at Tair
431         &     * ( sf(jp_tair)%fnow(ji,jj,1) - rt0 ) * rcp                          &
432         &     + sf(jp_snow)%fnow(ji,jj,1) * rn_pfac                                &   ! add solid  precip heat content at min(Tair,Tsnow)
433         &     * ( MIN( sf(jp_tair)%fnow(ji,jj,1), rt0_snow ) - rt0 ) * cpic * tmask(ji,jj,1)
434         END DO
435      END DO
436      !
437#if defined key_lim3
438!$OMP PARALLEL DO schedule(static) private(jj, ji)
439      DO jj = 1, jpj
440         DO ji = 1, jpi
441            qns_oce(ji,jj) = zqlw(ji,jj) - zqsb(ji,jj) - zqla(ji,jj)   ! non solar without emp (only needed by LIM3)
442            qsr_oce(ji,jj) = qsr(ji,jj)
443         END DO
444      END DO
445#endif
446      !
447      IF ( nn_ice == 0 ) THEN
448         CALL iom_put( "qlw_oce" ,   zqlw )                 ! output downward longwave heat over the ocean
449         CALL iom_put( "qsb_oce" , - zqsb )                 ! output downward sensible heat over the ocean
450         CALL iom_put( "qla_oce" , - zqla )                 ! output downward latent   heat over the ocean
451         CALL iom_put( "qemp_oce",   qns-zqlw+zqsb+zqla )   ! output downward heat content of E-P over the ocean
452         CALL iom_put( "qns_oce" ,   qns  )                 ! output downward non solar heat over the ocean
453         CALL iom_put( "qsr_oce" ,   qsr  )                 ! output downward solar heat over the ocean
454         CALL iom_put( "qt_oce"  ,   qns+qsr )              ! output total downward heat over the ocean
455!$OMP PARALLEL DO schedule(static) private(jj, ji)
456      DO jj = 1, jpj
457         DO ji = 1, jpi
458            tprecip(ji,jj) = sf(jp_prec)%fnow(ji,jj,1) * rn_pfac   ! output total precipitation [kg/m2/s]
459            sprecip(ji,jj) = sf(jp_snow)%fnow(ji,jj,1) * rn_pfac   ! output solid precipitation [kg/m2/s]
460         END DO
461      END DO
462         CALL iom_put( 'snowpre', sprecip * 86400. )        ! Snow
463         CALL iom_put( 'precip' , tprecip * 86400. )        ! Total precipitation
464      ENDIF
465      !
466      IF(ln_ctl) THEN
467         CALL prt_ctl(tab2d_1=zqsb , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=zqlw , clinfo2=' zqlw  : ')
468         CALL prt_ctl(tab2d_1=zqla , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=qsr  , clinfo2=' qsr   : ')
469         CALL prt_ctl(tab2d_1=pst  , clinfo1=' blk_oce_core: pst    : ', tab2d_2=emp  , clinfo2=' emp   : ')
470         CALL prt_ctl(tab2d_1=utau , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
471            &         tab2d_2=vtau , clinfo2=              ' vtau  : ' , mask2=vmask )
472      ENDIF
473      !
474      CALL wrk_dealloc( jpi,jpj, zwnd_i, zwnd_j, zqsatw, zqlw, zqsb, zqla, zevap )
475      CALL wrk_dealloc( jpi,jpj, Cd, Ch, Ce, zst, zt_zu, zq_zu )
476      !
477      IF( nn_timing == 1 )  CALL timing_stop('blk_oce_core')
478      !
479   END SUBROUTINE blk_oce_core
480 
481   
482#if defined key_lim2 || defined key_lim3
483   SUBROUTINE blk_ice_core_tau
484      !!---------------------------------------------------------------------
485      !!                     ***  ROUTINE blk_ice_core_tau  ***
486      !!
487      !! ** Purpose :   provide the surface boundary condition over sea-ice
488      !!
489      !! ** Method  :   compute momentum using CORE bulk
490      !!                formulea, ice variables and read atmospheric fields.
491      !!                NB: ice drag coefficient is assumed to be a constant
492      !!---------------------------------------------------------------------
493      INTEGER  ::   ji, jj    ! dummy loop indices
494      REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2
495      REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f               ! relative wind module and components at F-point
496      REAL(wp) ::             zwndi_t , zwndj_t               ! relative wind components at T-point
497      !!---------------------------------------------------------------------
498      !
499      IF( nn_timing == 1 )  CALL timing_start('blk_ice_core_tau')
500      !
501      ! local scalars ( place there for vector optimisation purposes)
502      zcoef_wnorm  = rhoa * Cice
503      zcoef_wnorm2 = rhoa * Cice * 0.5
504
505!!gm brutal....
506!$OMP PARALLEL DO schedule(static) private(jj, ji)
507      DO jj = 1, jpj
508         DO ji = 1, jpi
509            utau_ice  (ji,jj) = 0._wp
510            vtau_ice  (ji,jj) = 0._wp
511            wndm_ice  (ji,jj) = 0._wp
512         END DO
513      END DO
514!!gm end
515
516      ! ----------------------------------------------------------------------------- !
517      !    Wind components and module relative to the moving ocean ( U10m - U_ice )   !
518      ! ----------------------------------------------------------------------------- !
519      SELECT CASE( cp_ice_msh )
520      CASE( 'I' )                  ! B-grid ice dynamics :   I-point (i.e. F-point with sea-ice indexation)
521         !                           and scalar wind at T-point ( = | U10m - U_ice | ) (masked)
522!$OMP PARALLEL DO schedule(static) private(jj,ji,zwndi_f,zwndj_f,zwnorm_f,zwndi_t,zwndj_t)
523         DO jj = 2, jpjm1
524            DO ji = 2, jpim1   ! B grid : NO vector opt
525               ! ... scalar wind at I-point (fld being at T-point)
526               zwndi_f = 0.25 * (  sf(jp_wndi)%fnow(ji-1,jj  ,1) + sf(jp_wndi)%fnow(ji  ,jj  ,1)   &
527                  &              + sf(jp_wndi)%fnow(ji-1,jj-1,1) + sf(jp_wndi)%fnow(ji  ,jj-1,1)  ) - rn_vfac * u_ice(ji,jj)
528               zwndj_f = 0.25 * (  sf(jp_wndj)%fnow(ji-1,jj  ,1) + sf(jp_wndj)%fnow(ji  ,jj  ,1)   &
529                  &              + sf(jp_wndj)%fnow(ji-1,jj-1,1) + sf(jp_wndj)%fnow(ji  ,jj-1,1)  ) - rn_vfac * v_ice(ji,jj)
530               zwnorm_f = zcoef_wnorm * SQRT( zwndi_f * zwndi_f + zwndj_f * zwndj_f )
531               ! ... ice stress at I-point
532               utau_ice(ji,jj) = zwnorm_f * zwndi_f
533               vtau_ice(ji,jj) = zwnorm_f * zwndj_f
534               ! ... scalar wind at T-point (fld being at T-point)
535               zwndi_t = sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  u_ice(ji,jj+1) + u_ice(ji+1,jj+1)   &
536                  &                                                    + u_ice(ji,jj  ) + u_ice(ji+1,jj  )  )
537               zwndj_t = sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.25 * (  v_ice(ji,jj+1) + v_ice(ji+1,jj+1)   &
538                  &                                                    + v_ice(ji,jj  ) + v_ice(ji+1,jj  )  )
539               wndm_ice(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
540            END DO
541         END DO
542         CALL lbc_lnk( utau_ice, 'I', -1. )
543         CALL lbc_lnk( vtau_ice, 'I', -1. )
544         CALL lbc_lnk( wndm_ice, 'T',  1. )
545         !
546      CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean)
547!$OMP PARALLEL
548!$OMP DO schedule(static) private(jj,ji,zwndi_t,zwndj_t)
549         DO jj = 2, jpj
550            DO ji = fs_2, jpi   ! vect. opt.
551               zwndi_t = (  sf(jp_wndi)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( u_ice(ji-1,jj  ) + u_ice(ji,jj) )  )
552               zwndj_t = (  sf(jp_wndj)%fnow(ji,jj,1) - rn_vfac * 0.5 * ( v_ice(ji  ,jj-1) + v_ice(ji,jj) )  )
553               wndm_ice(ji,jj) = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
554            END DO
555         END DO
556!$OMP DO schedule(static) private(jj,ji)
557         DO jj = 2, jpjm1
558            DO ji = fs_2, fs_jpim1   ! vect. opt.
559               utau_ice(ji,jj) = zcoef_wnorm2 * ( wndm_ice(ji+1,jj  ) + wndm_ice(ji,jj) )                          &
560                  &          * ( 0.5 * (sf(jp_wndi)%fnow(ji+1,jj,1) + sf(jp_wndi)%fnow(ji,jj,1) ) - rn_vfac * u_ice(ji,jj) )
561               vtau_ice(ji,jj) = zcoef_wnorm2 * ( wndm_ice(ji,jj+1  ) + wndm_ice(ji,jj) )                          &
562                  &          * ( 0.5 * (sf(jp_wndj)%fnow(ji,jj+1,1) + sf(jp_wndj)%fnow(ji,jj,1) ) - rn_vfac * v_ice(ji,jj) )
563            END DO
564         END DO
565!$OMP END PARALLEL
566         CALL lbc_lnk( utau_ice, 'U', -1. )
567         CALL lbc_lnk( vtau_ice, 'V', -1. )
568         CALL lbc_lnk( wndm_ice, 'T',  1. )
569         !
570      END SELECT
571
572      IF(ln_ctl) THEN
573         CALL prt_ctl(tab2d_1=utau_ice  , clinfo1=' blk_ice_core: utau_ice : ', tab2d_2=vtau_ice  , clinfo2=' vtau_ice : ')
574         CALL prt_ctl(tab2d_1=wndm_ice  , clinfo1=' blk_ice_core: wndm_ice : ')
575      ENDIF
576
577      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_core_tau')
578     
579   END SUBROUTINE blk_ice_core_tau
580
581
582   SUBROUTINE blk_ice_core_flx( ptsu, palb )
583      !!---------------------------------------------------------------------
584      !!                     ***  ROUTINE blk_ice_core_flx  ***
585      !!
586      !! ** Purpose :   provide the surface boundary condition over sea-ice
587      !!
588      !! ** Method  :   compute heat and freshwater exchanged
589      !!                between atmosphere and sea-ice using CORE bulk
590      !!                formulea, ice variables and read atmmospheric fields.
591      !!
592      !! caution : the net upward water flux has with mm/day unit
593      !!---------------------------------------------------------------------
594      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   ptsu          ! sea ice surface temperature
595      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   palb          ! ice albedo (all skies)
596      !!
597      INTEGER  ::   ji, jj, jl    ! dummy loop indices
598      REAL(wp) ::   zst2, zst3
599      REAL(wp) ::   zcoef_dqlw, zcoef_dqla, zcoef_dqsb
600      REAL(wp) ::   zztmp, z1_lsub                               ! temporary variable
601      !!
602      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qlw             ! long wave heat flux over ice
603      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qsb             ! sensible  heat flux over ice
604      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqlw            ! long wave heat sensitivity over ice
605      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqsb            ! sensible  heat sensitivity over ice
606      REAL(wp), DIMENSION(:,:)  , POINTER ::   zevap, zsnw       ! evaporation and snw distribution after wind blowing (LIM3)
607      !!---------------------------------------------------------------------
608      !
609      IF( nn_timing == 1 )  CALL timing_start('blk_ice_core_flx')
610      !
611      CALL wrk_alloc( jpi,jpj,jpl, z_qlw, z_qsb, z_dqlw, z_dqsb ) 
612
613      ! local scalars ( place there for vector optimisation purposes)
614      zcoef_dqlw   = 4.0 * 0.95 * Stef
615      zcoef_dqla   = -Ls * Cice * 11637800. * (-5897.8)
616      zcoef_dqsb   = rhoa * cpa * Cice
617
618      zztmp = 1. / ( 1. - albo )
619      !                                     ! ========================== !
620!$OMP PARALLEL
621!$OMP DO schedule(static) private(jl,jj,ji,zst2,zst3)
622      DO jl = 1, jpl                        !  Loop over ice categories  !
623         !                                  ! ========================== !
624         DO jj = 1 , jpj
625            DO ji = 1, jpi
626               ! ----------------------------!
627               !      I   Radiative FLUXES   !
628               ! ----------------------------!
629               zst2 = ptsu(ji,jj,jl) * ptsu(ji,jj,jl)
630               zst3 = ptsu(ji,jj,jl) * zst2
631               ! Short Wave (sw)
632               qsr_ice(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr(ji,jj)
633               ! Long  Wave (lw)
634               z_qlw(ji,jj,jl) = 0.95 * ( sf(jp_qlw)%fnow(ji,jj,1) - Stef * ptsu(ji,jj,jl) * zst3 ) * tmask(ji,jj,1)
635               ! lw sensitivity
636               z_dqlw(ji,jj,jl) = zcoef_dqlw * zst3                                               
637
638               ! ----------------------------!
639               !     II    Turbulent FLUXES  !
640               ! ----------------------------!
641
642               ! ... turbulent heat fluxes
643               ! Sensible Heat
644               z_qsb(ji,jj,jl) = rhoa * cpa * Cice * wndm_ice(ji,jj) * ( ptsu(ji,jj,jl) - sf(jp_tair)%fnow(ji,jj,1) )
645               ! Latent Heat
646               qla_ice(ji,jj,jl) = rn_efac * MAX( 0.e0, rhoa * Ls  * Cice * wndm_ice(ji,jj)   &                           
647                  &                         * (  11637800. * EXP( -5897.8 / ptsu(ji,jj,jl) ) / rhoa - sf(jp_humi)%fnow(ji,jj,1)  ) )
648              ! Latent heat sensitivity for ice (Dqla/Dt)
649               IF( qla_ice(ji,jj,jl) > 0._wp ) THEN
650                  dqla_ice(ji,jj,jl) = rn_efac * zcoef_dqla * wndm_ice(ji,jj) / ( zst2 ) * EXP( -5897.8 / ptsu(ji,jj,jl) )
651               ELSE
652                  dqla_ice(ji,jj,jl) = 0._wp
653               ENDIF
654
655               ! Sensible heat sensitivity (Dqsb_ice/Dtn_ice)
656               z_dqsb(ji,jj,jl) = zcoef_dqsb * wndm_ice(ji,jj)
657
658               ! ----------------------------!
659               !     III    Total FLUXES     !
660               ! ----------------------------!
661               ! Downward Non Solar flux
662               qns_ice (ji,jj,jl) =     z_qlw (ji,jj,jl) - z_qsb (ji,jj,jl) - qla_ice (ji,jj,jl)
663               ! Total non solar heat flux sensitivity for ice
664               dqns_ice(ji,jj,jl) = - ( z_dqlw(ji,jj,jl) + z_dqsb(ji,jj,jl) + dqla_ice(ji,jj,jl) )
665            END DO
666            !
667         END DO
668         !
669      END DO
670      !
671!$OMP DO schedule(static) private(jj, ji)
672      DO jj = 1, jpj
673         DO ji = 1, jpi
674            tprecip(ji,jj) = sf(jp_prec)%fnow(ji,jj,1) * rn_pfac      ! total precipitation [kg/m2/s]
675            sprecip(ji,jj) = sf(jp_snow)%fnow(ji,jj,1) * rn_pfac      ! solid precipitation [kg/m2/s]
676         END DO
677      END DO
678!$OMP END PARALLEL     
679      CALL iom_put( 'snowpre', sprecip * 86400. )                  ! Snow precipitation
680      CALL iom_put( 'precip' , tprecip * 86400. )                  ! Total precipitation
681
682#if defined  key_lim3
683      CALL wrk_alloc( jpi,jpj, zevap, zsnw ) 
684
685      ! --- evaporation --- !
686      z1_lsub = 1._wp / Lsub
687
688!$OMP PARALLEL     
689!$OMP DO schedule(static) private(jl, jj, ji)
690      DO jl = 1, jpl 
691         DO jj = 1, jpj
692            DO ji = 1, jpi
693               evap_ice (ji,jj,jl) = rn_efac * qla_ice (ji,jj,jl) * z1_lsub    ! sublimation
694               devap_ice(ji,jj,jl) = rn_efac * dqla_ice(ji,jj,jl) * z1_lsub    ! d(sublimation)/dT
695            END DO
696         END DO
697      END DO
698!$OMP DO schedule(static) private(jj, ji)
699      DO jj = 1, jpj
700         DO ji = 1, jpi
701            zevap    (ji,jj)   = rn_efac * ( emp(ji,jj) + tprecip(ji,jj) )  ! evaporation over ocean
702            ! --- evaporation minus precipitation --- !
703            zsnw(ji,jj) = 0._wp
704         END DO
705      END DO
706!$OMP END PARALLEL
707      CALL lim_thd_snwblow( pfrld, zsnw )  ! snow distribution over ice after wind blowing
708   
709      emp_oce(:,:) = pfrld(:,:) * zevap(:,:) - ( tprecip(:,:) - sprecip(:,:) ) - sprecip(:,:) * (1._wp - zsnw )
710      emp_ice(:,:) = SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) - sprecip(:,:) * zsnw
711      emp_tot(:,:) = emp_oce(:,:) + emp_ice(:,:)
712
713      ! --- heat flux associated with emp --- !
714      qemp_oce(:,:) = - pfrld(:,:) * zevap(:,:) * sst_m(:,:) * rcp                            & ! evap at sst
715      &          + ( tprecip(:,:) - sprecip(:,:) ) * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp  & ! liquid precip at Tair
716      &          +   sprecip(:,:) * ( 1._wp - zsnw ) *                                    & ! solid precip at min(Tair,Tsnow)
717      &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
718      qemp_ice(:,:) =   sprecip(:,:) * zsnw *                                                   & ! solid precip (only)
719      &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
720
721      ! --- total solar and non solar fluxes --- !
722      qns_tot(:,:) = pfrld(:,:) * qns_oce(:,:) + SUM( a_i_b(:,:,:) * qns_ice(:,:,:), dim=3 ) + qemp_ice(:,:) + qemp_oce(:,:)
723      qsr_tot(:,:) = pfrld(:,:) * qsr_oce(:,:) + SUM( a_i_b(:,:,:) * qsr_ice(:,:,:), dim=3 )
724
725      ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo)
726      ! --- !
727      qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
728
729      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
730!$OMP PARALLEL DO schedule(static) private(jl)
731      DO jl = 1, jpl
732         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * cpic * tmask(:,:,1) )
733                                   ! But we do not have Tice => consider it at 0°C => evap=0
734      END DO
735      CALL wrk_dealloc( jpi,jpj, zevap, zsnw ) 
736#endif
737
738      !--------------------------------------------------------------------
739      ! FRACTIONs of net shortwave radiation which is not absorbed in the
740      ! thin surface layer and penetrates inside the ice cover
741      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 )
742      !
743!$OMP PARALLEL DO schedule(static) private(jj, ji)
744      DO jj = 1, jpj
745         DO ji = 1, jpi
746            fr1_i0(ji,jj) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
747            fr2_i0(ji,jj) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
748         END DO
749      END DO
750      !
751      !
752      IF(ln_ctl) THEN
753         CALL prt_ctl(tab3d_1=qla_ice , clinfo1=' blk_ice_core: qla_ice  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb    : ', kdim=jpl)
754         CALL prt_ctl(tab3d_1=z_qlw   , clinfo1=' blk_ice_core: z_qlw    : ', tab3d_2=dqla_ice, clinfo2=' dqla_ice : ', kdim=jpl)
755         CALL prt_ctl(tab3d_1=z_dqsb  , clinfo1=' blk_ice_core: z_dqsb   : ', tab3d_2=z_dqlw  , clinfo2=' z_dqlw   : ', kdim=jpl)
756         CALL prt_ctl(tab3d_1=dqns_ice, clinfo1=' blk_ice_core: dqns_ice : ', tab3d_2=qsr_ice , clinfo2=' qsr_ice  : ', kdim=jpl)
757         CALL prt_ctl(tab3d_1=ptsu    , clinfo1=' blk_ice_core: ptsu     : ', tab3d_2=qns_ice , clinfo2=' qns_ice  : ', kdim=jpl)
758         CALL prt_ctl(tab2d_1=tprecip , clinfo1=' blk_ice_core: tprecip  : ', tab2d_2=sprecip , clinfo2=' sprecip  : ')
759      ENDIF
760
761      CALL wrk_dealloc( jpi,jpj,jpl, z_qlw, z_qsb, z_dqlw, z_dqsb )
762      !
763      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_core_flx')
764     
765   END SUBROUTINE blk_ice_core_flx
766#endif
767
768   SUBROUTINE turb_core_2z( zt, zu, sst, T_zt, q_sat, q_zt, dU,    &
769      &                      Cd, Ch, Ce , T_zu, q_zu )
770      !!----------------------------------------------------------------------
771      !!                      ***  ROUTINE  turb_core  ***
772      !!
773      !! ** Purpose :   Computes turbulent transfert coefficients of surface
774      !!                fluxes according to Large & Yeager (2004) and Large & Yeager (2008)
775      !!                If relevant (zt /= zu), adjust temperature and humidity from height zt to zu
776      !!
777      !! ** Method : Monin Obukhov Similarity Theory
778      !!             + Large & Yeager (2004,2008) closure: CD_n10 = f(U_n10)
779      !!
780      !! ** References :   Large & Yeager, 2004 / Large & Yeager, 2008
781      !!
782      !! ** Last update: Laurent Brodeau, June 2014:
783      !!    - handles both cases zt=zu and zt/=zu
784      !!    - optimized: less 2D arrays allocated and less operations
785      !!    - better first guess of stability by checking air-sea difference of virtual temperature
786      !!       rather than temperature difference only...
787      !!    - added function "cd_neutral_10m" that uses the improved parametrization of
788      !!      Large & Yeager 2008. Drag-coefficient reduction for Cyclone conditions!
789      !!    - using code-wide physical constants defined into "phycst.mod" rather than redifining them
790      !!      => 'vkarmn' and 'grav'
791      !!----------------------------------------------------------------------
792      REAL(wp), INTENT(in   )                     ::   zt       ! height for T_zt and q_zt                   [m]
793      REAL(wp), INTENT(in   )                     ::   zu       ! height for dU                              [m]
794      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   sst      ! sea surface temperature              [Kelvin]
795      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   T_zt     ! potential air temperature            [Kelvin]
796      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   q_sat    ! sea surface specific humidity         [kg/kg]
797      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   q_zt     ! specific air humidity                 [kg/kg]
798      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj) ::   dU       ! relative wind module at zu            [m/s]
799      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Cd       ! transfer coefficient for momentum         (tau)
800      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Ch       ! transfer coefficient for sensible heat (Q_sens)
801      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   Ce       ! transfert coefficient for evaporation   (Q_lat)
802      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   T_zu     ! air temp. shifted at zu                     [K]
803      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   q_zu     ! spec. hum.  shifted at zu               [kg/kg]
804      !
805      INTEGER ::   j_itt
806      INTEGER ::   ji, jj    ! dummy loop indices
807      INTEGER , PARAMETER ::   nb_itt = 5       ! number of itterations
808      LOGICAL ::   l_zt_equal_zu = .FALSE.      ! if q and t are given at different height than U
809      !
810      REAL(wp), DIMENSION(:,:), POINTER ::   U_zu          ! relative wind at zu                            [m/s]
811      REAL(wp), DIMENSION(:,:), POINTER ::   Ce_n10        ! 10m neutral latent coefficient
812      REAL(wp), DIMENSION(:,:), POINTER ::   Ch_n10        ! 10m neutral sensible coefficient
813      REAL(wp), DIMENSION(:,:), POINTER ::   sqrt_Cd_n10   ! root square of Cd_n10
814      REAL(wp), DIMENSION(:,:), POINTER ::   sqrt_Cd       ! root square of Cd
815      REAL(wp), DIMENSION(:,:), POINTER ::   zeta_u        ! stability parameter at height zu
816      REAL(wp), DIMENSION(:,:), POINTER ::   zeta_t        ! stability parameter at height zt
817      REAL(wp), DIMENSION(:,:), POINTER ::   zpsi_h_u, zpsi_m_u
818      REAL(wp), DIMENSION(:,:), POINTER ::   ztmp0, ztmp1, ztmp2
819      REAL(wp), DIMENSION(:,:), POINTER ::   stab          ! 1st stability test integer
820      !!----------------------------------------------------------------------
821
822      IF( nn_timing == 1 )  CALL timing_start('turb_core_2z')
823   
824      CALL wrk_alloc( jpi,jpj, U_zu, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd )
825      CALL wrk_alloc( jpi,jpj, zeta_u, stab )
826      CALL wrk_alloc( jpi,jpj, zpsi_h_u, zpsi_m_u, ztmp0, ztmp1, ztmp2 )
827
828      l_zt_equal_zu = .FALSE.
829      IF( ABS(zu - zt) < 0.01 ) l_zt_equal_zu = .TRUE.    ! testing "zu == zt" is risky with double precision
830
831      IF( .NOT. l_zt_equal_zu )   CALL wrk_alloc( jpi,jpj, zeta_t )
832
833      U_zu = MAX( 0.5 , dU )   !  relative wind speed at zu (normally 10m), we don't want to fall under 0.5 m/s
834
835      !! First guess of stability:
836      ztmp0 = T_zt*(1. + 0.608*q_zt) - sst*(1. + 0.608*q_sat) ! air-sea difference of virtual pot. temp. at zt
837      stab  = 0.5 + sign(0.5,ztmp0)                           ! stab = 1 if dTv > 0  => STABLE, 0 if unstable
838
839      !! Neutral coefficients at 10m:
840      IF( ln_cdgw ) THEN      ! wave drag case
841!$OMP PARALLEL DO schedule(static) private(jj, ji)
842         DO jj = 1, jpj
843            DO ji = 1, jpi
844               cdn_wave(ji,jj) = cdn_wave(ji,jj) + rsmall * ( 1._wp - tmask(ji,jj,1) )
845               ztmp0   (ji,jj) = cdn_wave(ji,jj)
846            END DO
847         END DO
848      ELSE
849         ztmp0 = cd_neutral_10m( U_zu )
850      ENDIF
851      sqrt_Cd_n10 = SQRT( ztmp0 )
852      Ce_n10  = 1.e-3*( 34.6 * sqrt_Cd_n10 )
853      Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab))
854   
855      !! Initializing transf. coeff. with their first guess neutral equivalents :
856      Cd = ztmp0   ;   Ce = Ce_n10   ;   Ch = Ch_n10   ;   sqrt_Cd = sqrt_Cd_n10
857
858      !! Initializing values at z_u with z_t values:
859      T_zu = T_zt   ;   q_zu = q_zt
860
861      !!  * Now starting iteration loop
862      DO j_itt=1, nb_itt
863         !
864         ztmp1 = T_zu - sst   ! Updating air/sea differences
865         ztmp2 = q_zu - q_sat 
866
867         ! Updating turbulent scales :   (L&Y 2004 eq. (7))
868         ztmp1  = Ch/sqrt_Cd*ztmp1    ! theta*
869         ztmp2  = Ce/sqrt_Cd*ztmp2    ! q*
870       
871         ztmp0 = T_zu*(1. + 0.608*q_zu) ! virtual potential temperature at zu
872
873         ! Estimate the inverse of Monin-Obukov length (1/L) at height zu:
874         ztmp0 =  (vkarmn*grav/ztmp0*(ztmp1*(1.+0.608*q_zu) + 0.608*T_zu*ztmp2)) / (Cd*U_zu*U_zu) 
875         !                                                                     ( Cd*U_zu*U_zu is U*^2 at zu)
876
877         !! Stability parameters :
878         zeta_u   = zu*ztmp0   ;  zeta_u = sign( min(abs(zeta_u),10.0), zeta_u )
879         zpsi_h_u = psi_h( zeta_u )
880         zpsi_m_u = psi_m( zeta_u )
881       
882         !! Shifting temperature and humidity at zu (L&Y 2004 eq. (9b-9c))
883         IF ( .NOT. l_zt_equal_zu ) THEN
884            zeta_t = zt*ztmp0 ;  zeta_t = sign( min(abs(zeta_t),10.0), zeta_t )
885            stab = LOG(zu/zt) - zpsi_h_u + psi_h(zeta_t)  ! stab just used as temp array!!!
886            T_zu = T_zt + ztmp1/vkarmn*stab    ! ztmp1 is still theta*
887            q_zu = q_zt + ztmp2/vkarmn*stab    ! ztmp2 is still q*
888            q_zu = max(0., q_zu)
889         END IF
890       
891         IF( ln_cdgw ) THEN      ! surface wave case
892            sqrt_Cd = vkarmn / ( vkarmn / sqrt_Cd_n10 - zpsi_m_u ) 
893            Cd      = sqrt_Cd * sqrt_Cd
894         ELSE
895           ! Update neutral wind speed at 10m and neutral Cd at 10m (L&Y 2004 eq. 9a)...
896           !   In very rare low-wind conditions, the old way of estimating the
897           !   neutral wind speed at 10m leads to a negative value that causes the code
898           !   to crash. To prevent this a threshold of 0.25m/s is imposed.
899           ztmp0 = MAX( 0.25 , U_zu/(1. + sqrt_Cd_n10/vkarmn*(LOG(zu/10.) - zpsi_m_u)) ) !  U_n10
900           ztmp0 = cd_neutral_10m(ztmp0)                                                 ! Cd_n10
901           sqrt_Cd_n10 = sqrt(ztmp0)
902       
903           Ce_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)                     ! L&Y 2004 eq. (6b)
904           stab    = 0.5 + sign(0.5,zeta_u)                           ! update stability
905           Ch_n10  = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab))  ! L&Y 2004 eq. (6c-6d)
906
907           !! Update of transfer coefficients:
908           ztmp1 = 1. + sqrt_Cd_n10/vkarmn*(LOG(zu/10.) - zpsi_m_u)   ! L&Y 2004 eq. (10a)
909           Cd      = ztmp0 / ( ztmp1*ztmp1 )   
910           sqrt_Cd = SQRT( Cd )
911         ENDIF
912         !
913         ztmp0 = (LOG(zu/10.) - zpsi_h_u) / vkarmn / sqrt_Cd_n10
914         ztmp2 = sqrt_Cd / sqrt_Cd_n10
915         ztmp1 = 1. + Ch_n10*ztmp0               
916         Ch  = Ch_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10b)
917         !
918         ztmp1 = 1. + Ce_n10*ztmp0               
919         Ce  = Ce_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10c)
920         !
921      END DO
922
923      CALL wrk_dealloc( jpi,jpj, U_zu, Ce_n10, Ch_n10, sqrt_Cd_n10, sqrt_Cd )
924      CALL wrk_dealloc( jpi,jpj, zeta_u, stab )
925      CALL wrk_dealloc( jpi,jpj, zpsi_h_u, zpsi_m_u, ztmp0, ztmp1, ztmp2 )
926
927      IF( .NOT. l_zt_equal_zu ) CALL wrk_dealloc( jpi,jpj, zeta_t )
928
929      IF( nn_timing == 1 )  CALL timing_stop('turb_core_2z')
930      !
931   END SUBROUTINE turb_core_2z
932
933
934   FUNCTION cd_neutral_10m( zw10 )
935      !!----------------------------------------------------------------------
936      !! Estimate of the neutral drag coefficient at 10m as a function
937      !! of neutral wind  speed at 10m
938      !!
939      !! Origin: Large & Yeager 2008 eq.(11a) and eq.(11b)
940      !!
941      !! Author: L. Brodeau, june 2014
942      !!----------------------------------------------------------------------   
943      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   zw10           ! scalar wind speed at 10m (m/s)
944      REAL(wp), DIMENSION(jpi,jpj)             ::   cd_neutral_10m
945      !
946      REAL(wp), DIMENSION(:,:), POINTER ::   rgt33
947      !!----------------------------------------------------------------------   
948      !
949      CALL wrk_alloc( jpi,jpj, rgt33 )
950      !
951      !! When wind speed > 33 m/s => Cyclone conditions => special treatment
952      rgt33 = 0.5_wp + SIGN( 0.5_wp, (zw10 - 33._wp) )   ! If zw10 < 33. => 0, else => 1 
953      cd_neutral_10m = 1.e-3 * ( &
954         &       (1._wp - rgt33)*( 2.7_wp/zw10 + 0.142_wp + zw10/13.09_wp - 3.14807E-10*zw10**6) & ! zw10< 33.
955         &      + rgt33         *      2.34   )                                                    ! zw10 >= 33.
956      !
957      CALL wrk_dealloc( jpi,jpj, rgt33)
958      !
959   END FUNCTION cd_neutral_10m
960
961
962   FUNCTION psi_m(pta)   !! Psis, L&Y 2004 eq. (8c), (8d), (8e)
963      !-------------------------------------------------------------------------------
964      ! universal profile stability function for momentum
965      !-------------------------------------------------------------------------------
966      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pta
967      !
968      REAL(wp), DIMENSION(jpi,jpj)             :: psi_m
969      REAL(wp), DIMENSION(:,:), POINTER        :: X2, X, stabit
970      !-------------------------------------------------------------------------------
971      !
972      CALL wrk_alloc( jpi,jpj, X2, X, stabit )
973      !
974      X2 = SQRT( ABS( 1. - 16.*pta ) )  ;  X2 = MAX( X2 , 1. )   ;   X = SQRT( X2 )
975      stabit = 0.5 + SIGN( 0.5 , pta )
976      psi_m = -5.*pta*stabit  &                                                          ! Stable
977         &    + (1. - stabit)*(2.*LOG((1. + X)*0.5) + LOG((1. + X2)*0.5) - 2.*ATAN(X) + rpi*0.5)  ! Unstable
978      !
979      CALL wrk_dealloc( jpi,jpj, X2, X, stabit )
980      !
981   END FUNCTION psi_m
982
983
984   FUNCTION psi_h( pta )    !! Psis, L&Y 2004 eq. (8c), (8d), (8e)
985      !-------------------------------------------------------------------------------
986      ! universal profile stability function for temperature and humidity
987      !-------------------------------------------------------------------------------
988      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pta
989      !
990      REAL(wp), DIMENSION(jpi,jpj)             ::   psi_h
991      REAL(wp), DIMENSION(:,:), POINTER        ::   X2, X, stabit
992      !-------------------------------------------------------------------------------
993      !
994      CALL wrk_alloc( jpi,jpj, X2, X, stabit )
995      !
996      X2 = SQRT( ABS( 1. - 16.*pta ) )   ;   X2 = MAX( X2 , 1. )   ;   X = SQRT( X2 )
997      stabit = 0.5 + SIGN( 0.5 , pta )
998      psi_h = -5.*pta*stabit   &                                       ! Stable
999         &    + (1. - stabit)*(2.*LOG( (1. + X2)*0.5 ))                ! Unstable
1000      !
1001      CALL wrk_dealloc( jpi,jpj, X2, X, stabit )
1002      !
1003   END FUNCTION psi_h
1004
1005   !!======================================================================
1006END MODULE sbcblk_core
Note: See TracBrowser for help on using the repository browser.