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/2011/dev_r2784_CMCC1_topbfm/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2011/dev_r2784_CMCC1_topbfm/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90 @ 2799

Last change on this file since 2799 was 2799, checked in by vichi, 13 years ago

Updated sbcblk_core.F90 so it can be used for both ORCA2 and ORCA025

  • Property svn:keywords set to Id
File size: 64.5 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   !!----------------------------------------------------------------------
17
18   !!----------------------------------------------------------------------
19   !!   sbc_blk_core  : bulk formulation as ocean surface boundary condition
20   !!                   (forced mode, CORE bulk formulea)
21   !!   blk_oce_core  : ocean: computes momentum, heat and freshwater fluxes
22   !!   blk_ice_core  : ice  : computes momentum, heat and freshwater fluxes
23   !!   turb_core     : computes the CORE turbulent transfer coefficients
24   !!----------------------------------------------------------------------
25   USE oce             ! ocean dynamics and tracers
26   USE dom_oce         ! ocean space and time domain
27   USE phycst          ! physical constants
28   USE fldread         ! read input fields
29   USE sbc_oce         ! Surface boundary condition: ocean fields
30   USE sbcdcy          ! surface boundary condition: diurnal cycle
31   USE iom             ! I/O manager library
32   USE in_out_manager  ! I/O manager
33   USE lib_mpp         ! distribued memory computing library
34   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
35   USE prtctl          ! Print control
36#if defined key_lim3
37   USE sbc_ice         ! Surface boundary condition: ice fields
38#endif
39
40   IMPLICIT NONE
41   PRIVATE
42
43   PUBLIC   sbc_blk_core         ! routine called in sbcmod module
44   PUBLIC   blk_ice_core         ! routine called in sbc_ice_lim module
45
46   INTEGER , PARAMETER ::   jp_wndi = 1           ! index of 10m wind velocity (i-component) (m/s)    at T-point
47   INTEGER , PARAMETER ::   jp_wndj = 2           ! index of 10m wind velocity (j-component) (m/s)    at T-point
48   INTEGER , PARAMETER ::   jp_humi = 3           ! index of specific humidity               ( - )
49   INTEGER , PARAMETER ::   jp_qsr  = 4           ! index of solar heat                      (W/m2)
50   INTEGER , PARAMETER ::   jp_qlw  = 5           ! index of Long wave                       (W/m2)
51   INTEGER , PARAMETER ::   jp_tair = 6           ! index of 10m air temperature             (Kelvin)
52   INTEGER , PARAMETER ::   jp_prec = 7           ! index of total precipitation (rain+snow) (Kg/m2/s)
53   INTEGER , PARAMETER ::   jp_snow = 8           ! index of snow (solid prcipitation)       (kg/m2/s)
54   INTEGER , PARAMETER ::   jp_tdif = 9           ! index of tau diff associated to HF tau   (N/m2)   at T-point
55#if defined key_orca_r025
56   INTEGER , PARAMETER ::   jp_swc  = 10          ! index of GEWEX correction for SW radiation  at T-point
57   INTEGER , PARAMETER ::   jp_lwc  = 11          ! index of GEWEX correction for LW radiation  at T-point
58   INTEGER , PARAMETER ::   jp_prc  = 12          ! index of PMWC correction forat T-point
59   INTEGER , PARAMETER ::   jpfld   = 12          ! maximum number of files to read
60#else
61   INTEGER , PARAMETER ::   jpfld   = 9           ! maximum number of files to read
62#endif
63   
64   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf   ! structure of input fields (file informations, fields read)
65         
66   !                                             !!! CORE bulk parameters
67   REAL(wp), PARAMETER ::   rhoa =    1.22        ! air density
68   REAL(wp), PARAMETER ::   cpa  = 1000.5         ! specific heat of air
69   REAL(wp), PARAMETER ::   Lv   =    2.5e6       ! latent heat of vaporization
70   REAL(wp), PARAMETER ::   Ls   =    2.839e6     ! latent heat of sublimation
71   REAL(wp), PARAMETER ::   Stef =    5.67e-8     ! Stefan Boltzmann constant
72   REAL(wp), PARAMETER ::   Cice =    1.63e-3     ! transfer coefficient over ice
73   REAL(wp), PARAMETER ::   albo =    0.066       ! ocean albedo assumed to be contant
74
75   !                                  !!* Namelist namsbc_core : CORE bulk parameters
76   LOGICAL  ::   ln_2m     = .FALSE.   ! logical flag for height of air temp. and hum
77   LOGICAL  ::   ln_taudif = .FALSE.   ! logical flag to use the "mean of stress module - module of mean stress" data
78   REAL(wp) ::   rn_pfac   = 1.        ! multiplication factor for precipitation
79
80#if defined key_orca_r025
81   LOGICAL  ::   ln_printdia= .TRUE.     ! logical flag for height of air temp. and hum
82   LOGICAL  ::   ln_netsw   = .TRUE.     ! logical flag for height of air temp. and hum
83   LOGICAL  ::   ln_core_graceopt=.FALSE., ln_core_spinup=.FALSE.
84   LOGICAL  ::   ln_gwxc = .TRUE.
85   LOGICAL  ::   ln_corad_antar =.FALSE., ln_corad_arc =.FALSE. , ln_cotair_arc = .FALSE.
86   LOGICAL  ::   ln_coprecip =.FALSE.
87   REAL(wp) ::   rn_qns_bias = 0._wp     ! heat flux bias
88
89   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  area 
90   REAL(wp) :: araux
91
92   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  zqlw, zqsb  ! long wave and sensible heat fluxes
93   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  zqla, zevap ! latent heat fluxes and evaporation
94
95   REAL(wp), PARAMETER :: zalph = 2.408724e-06_wp, &
96   & zbet = -0.006936579_wp, zgam = 449.9094_wp ! GRACE regression coefficients
97#endif
98
99   !! * Substitutions
100#  include "domzgr_substitute.h90"
101#  include "vectopt_loop_substitute.h90"
102   !!----------------------------------------------------------------------
103   !! NEMO/OPA 3.3 , NEMO-consortium (2010)
104   !! $Id$
105   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
106   !!----------------------------------------------------------------------
107CONTAINS
108   
109   SUBROUTINE sbc_blk_core( kt )
110      !!---------------------------------------------------------------------
111      !!                    ***  ROUTINE sbc_blk_core  ***
112      !!                   
113      !! ** Purpose :   provide at each time step the surface ocean fluxes
114      !!      (momentum, heat, freshwater and runoff)
115      !!
116      !! ** Method  : (1) READ each fluxes in NetCDF files:
117      !!      the 10m wind velocity (i-component) (m/s)    at T-point
118      !!      the 10m wind velocity (j-component) (m/s)    at T-point
119      !!      the specific humidity               ( - )
120      !!      the solar heat                      (W/m2)
121      !!      the Long wave                       (W/m2)
122      !!      the 10m air temperature             (Kelvin)
123      !!      the total precipitation (rain+snow) (Kg/m2/s)
124      !!      the snow (solid prcipitation)       (kg/m2/s)
125      !!   OPTIONAL parameter (see ln_taudif namelist flag):
126      !!      the tau diff associated to HF tau   (N/m2)   at T-point
127      !!              (2) CALL blk_oce_core
128      !!
129      !!      C A U T I O N : never mask the surface stress fields
130      !!                      the stress is assumed to be in the mesh referential
131      !!                      i.e. the (i,j) referential
132      !!
133      !! ** Action  :   defined at each time-step at the air-sea interface
134      !!              - utau, vtau  i- and j-component of the wind stress
135      !!              - taum        wind stress module at T-point
136      !!              - wndm        10m wind module at T-point
137      !!              - qns, qsr    non-slor and solar heat flux
138      !!              - emp, emps   evaporation minus precipitation
139      !!----------------------------------------------------------------------
140#if defined key_orca_r025
141      USE ice_2
142#endif
143      INTEGER, INTENT(in) ::   kt   ! ocean time step
144      !!
145      INTEGER  ::   ierror   ! return error code
146      INTEGER  ::   ifpr     ! dummy loop indice
147      INTEGER  ::   jfld     ! dummy loop arguments
148      INTEGER  ::   ji, jj
149      !!
150      CHARACTER(len=100) ::  cn_dir   !   Root directory for location of core files
151      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i     ! array of namelist informations on the fields to read
152      TYPE(FLD_N) ::   sn_wndi, sn_wndj, sn_humi, sn_qsr       ! informations about the fields to be read
153      TYPE(FLD_N) ::   sn_qlw , sn_tair, sn_prec, sn_snow      !   "                                 "
154      TYPE(FLD_N) ::   sn_tdif                                 !   "                                 "
155      TYPE(FLD_N) ::   sn_swc, sn_lwc                          !   "                                 "
156      TYPE(FLD_N) ::   sn_prc
157      INTEGER  ::   iter_shapiro = 250
158      REAL :: zzlat, zzlat1, zzlat2, zfm, zfrld, ztmp
159      REAL(wp), DIMENSION(jpi,jpj):: xyt,z_qsr,z_qlw,z_qsr1,z_qlw1, z_hum, z_tair
160      REAL(wp), DIMENSION(jpi,jpj):: zqsr_lr, zqsr_hr, zqlw_lr, zqlw_hr, zprec_hr, zprec_lr
161      CHARACTER(len=20)  ::  c_kind='ORCA_GLOB'
162#if defined key_orca_r025
163      NAMELIST/namsbc_core/ cn_dir , ln_2m  , ln_taudif, rn_pfac,           &
164         &                  sn_wndi, sn_wndj, sn_humi  , sn_qsr ,           &
165         &                  sn_qlw , sn_tair, sn_prec  , sn_snow, sn_tdif   &
166         &                  sn_swc , sn_lwc , sn_prc   , ln_gwxc  ,         &
167         &                  ln_corad_antar, ln_corad_arc, ln_cotair_arc, ln_coprecip ,  &
168         &                  rn_qns_bias, ln_printdia, ln_netsw, ln_core_graceopt,ln_core_spinup
169      !!---------------------------------------------------------------------
170#else
171      NAMELIST/namsbc_core/ cn_dir , ln_2m  , ln_taudif, rn_pfac,           &
172         &                  sn_wndi, sn_wndj, sn_humi  , sn_qsr ,           &
173         &                  sn_qlw , sn_tair, sn_prec  , sn_snow, sn_tdif
174      !!---------------------------------------------------------------------
175#endif
176
177      !                                         ! ====================== !
178      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
179         !                                      ! ====================== !
180#if defined key_orca_r025
181         !                                      !==  allocate sbc arrays
182            IF( sbc_blk_core_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_core_alloc : unable to allocate arrays' )
183#endif
184
185         ! set file information (default values)
186         cn_dir = './'       ! directory in which the model is executed
187         !
188         ! (NB: frequency positive => hours, negative => months)
189         !            !    file    ! frequency ! variable ! time intep !  clim   ! 'yearly' or ! weights  ! rotation !
190         !            !    name    !  (hours)  !  name    !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs    !
191         sn_wndi = FLD_N( 'uwnd10m',    24     , 'u_10'   ,  .false.   , .false. ,   'yearly'  , ''       , ''       )
192         sn_wndj = FLD_N( 'vwnd10m',    24     , 'v_10'   ,  .false.   , .false. ,   'yearly'  , ''       , ''       )
193         sn_qsr  = FLD_N( 'qsw'    ,    24     , 'qsw'    ,  .false.   , .false. ,   'yearly'  , ''       , ''       )
194         sn_qlw  = FLD_N( 'qlw'    ,    24     , 'qlw'    ,  .false.   , .false. ,   'yearly'  , ''       , ''       )
195         sn_tair = FLD_N( 'tair10m',    24     , 't_10'   ,  .false.   , .false. ,   'yearly'  , ''       , ''       )
196         sn_humi = FLD_N( 'humi10m',    24     , 'q_10'   ,  .false.   , .false. ,   'yearly'  , ''       , ''       )
197         sn_prec = FLD_N( 'precip' ,    -1     , 'precip' ,  .true.    , .false. ,   'yearly'  , ''       , ''       )
198         sn_snow = FLD_N( 'snow'   ,    -1     , 'snow'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       )
199         sn_tdif = FLD_N( 'taudif' ,    24     , 'taudif' ,  .true.    , .false. ,   'yearly'  , ''       , ''       )
200#if defined key_orca_r025
201         sn_swc  = FLD_N( 'swc'    ,    24     ,  'swc'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       )
202         sn_lwc  = FLD_N( 'lwc'    ,    24     ,  'lwc'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       )
203         sn_prc  = FLD_N( 'prc'    ,    24     ,  'prc'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       )
204#endif
205         !
206         REWIND( numnam )                          ! read in namlist namsbc_core
207         READ  ( numnam, namsbc_core )
208         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
209         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   & 
210            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
211         IF( ln_dm2dc .AND. sn_qsr%ln_tint ) THEN
212            CALL ctl_warn( 'sbc_blk_core: ln_dm2dc is taking care of the temporal interpolation of daily qsr',   &
213                 &         '              ==> We force time interpolation = .false. for qsr' )
214            sn_qsr%ln_tint = .false.
215         ENDIF
216         !                                         ! store namelist information in an array
217         slf_i(jp_wndi) = sn_wndi   ;   slf_i(jp_wndj) = sn_wndj
218         slf_i(jp_qsr ) = sn_qsr    ;   slf_i(jp_qlw ) = sn_qlw
219         slf_i(jp_tair) = sn_tair   ;   slf_i(jp_humi) = sn_humi
220         slf_i(jp_prec) = sn_prec   ;   slf_i(jp_snow) = sn_snow
221         slf_i(jp_tdif) = sn_tdif
222#if defined key_orca_r025
223            slf_i(jp_swc ) = sn_swc
224            slf_i(jp_lwc ) = sn_lwc
225            slf_i(jp_prc ) = sn_prc
226#endif
227         !                 
228         lhftau = ln_taudif                        ! do we use HF tau information?
229         jfld = jpfld - COUNT( (/.NOT. lhftau/) )
230#if defined key_orca_r025
231         IF( .NOT. ln_gwxc )     jfld = jfld - 2
232         IF( .NOT. ln_coprecip ) jfld = jfld - 1
233#endif
234         !
235         ALLOCATE( sf(jfld), STAT=ierror )         ! set sf structure
236         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_core: unable to allocate sf structure' )
237         DO ifpr= 1, jfld
238            ALLOCATE( sf(ifpr)%fnow(jpi,jpj,1) )
239            IF( slf_i(ifpr)%ln_tint )   ALLOCATE( sf(ifpr)%fdta(jpi,jpj,1,2) )
240         END DO
241         !                                         ! fill sf with slf_i and control print
242         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_core', 'flux formulation for ocean surface boundary condition', 'namsbc_core' )
243         !
244#if defined key_orca_r025
245         IF( ln_printdia .OR. ln_core_graceopt ) THEN
246           area = (e1t * e2t)
247           araux = sum ( area * tmask(:,:,1) )
248           IF(lk_mpp) CALL mpp_sum ( araux )
249         ENDIF
250#endif
251      ENDIF
252
253      CALL fld_read( kt, nn_fsbc, sf )        ! input fields provided at the current time-step
254
255      IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
256
257#if defined key_orca_r025
258      ! Introduce ERA-Interim filtering and correction
259
260         IF( ln_gwxc ) THEN
261
262           call Shapiro_1D(sf(jp_qsr)%fnow(:,:,1),iter_shapiro, c_kind, zqsr_lr)
263           zqsr_hr(:,:)=sf(jp_qsr)%fnow(:,:,1)-zqsr_lr(:,:)          ! We get large scale and small scale
264
265           call Shapiro_1D(sf(jp_qlw)%fnow(:,:,1),iter_shapiro, c_kind, zqlw_lr)
266           zqlw_hr(:,:)=sf(jp_qlw)%fnow(:,:,1)-zqlw_lr(:,:)          ! We get large scale and small scale
267
268           z_qsr1(:,:)=zqsr_lr(:,:)*sf(jp_swc)%fnow(:,:,1) + zqsr_hr(:,:)
269           z_qlw1(:,:)=zqlw_lr(:,:)*sf(jp_lwc)%fnow(:,:,1) + zqlw_hr(:,:)
270
271           DO jj=1,jpj
272             DO ji=1,jpi
273               z_qsr1(ji,jj)=max(z_qsr1(ji,jj),0.0)
274               z_qlw1(ji,jj)=max(z_qlw1(ji,jj),0.0)
275             END DO
276           END DO
277
278         ENDIF
279
280         IF( ln_coprecip ) THEN
281
282           call Shapiro_1D(sf(jp_prec)%fnow(:,:,1),iter_shapiro,c_kind,zprec_lr)
283           zprec_hr(:,:)=sf(jp_prec)%fnow(:,:,1)-zprec_lr(:,:)       ! We get large scale and small scale
284
285           DO jj=1,jpj
286             DO ji=1,jpi
287               IF( zprec_lr(ji,jj) .GT. 0._wp ) THEN
288                  ztmp = LOG( ( 1000._wp + sf(jp_prc)%fnow(ji,jj,1) ) * EXP( zprec_lr(ji,jj) ) / 1000._wp )
289                  sf(jp_prec)%fnow(ji,jj,1) = max(ztmp+zprec_hr(ji,jj),0.0)
290               ENDIF
291             END DO
292           END DO
293
294         ENDIF
295
296         IF ( ln_corad_antar ) THEN           ! correction of SW and LW in the Southern Ocean
297 
298           z_qsr(:,:)=0.8*z_qsr1(:,:)
299           z_qlw(:,:)=1.1*z_qlw1(:,:)
300           xyt(:,:) = 0.e0
301           zzlat1 = -65.
302           zzlat2 = -60.
303           DO jj = 1, jpj
304             DO ji = 1, jpi
305               zzlat = gphit(ji,jj)
306               IF ( zzlat >= zzlat1 .AND. zzlat <= zzlat2 ) THEN
307                  xyt(ji,jj) = (zzlat2-zzlat)/(zzlat2-zzlat1)
308               ELSE IF ( zzlat < zzlat1 ) THEN
309                  xyt(ji,jj) = 1
310               ENDIF
311             END DO
312           END DO
313           z_qsr1(:,:)=z_qsr(:,:)*xyt(:,:)+(1.0-xyt(:,:))*z_qsr1(:,:)
314           z_qlw1(:,:)=z_qlw(:,:)*xyt(:,:)+(1.0-xyt(:,:))*z_qlw1(:,:)
315
316         ENDIF
317
318         IF ( ln_corad_arc ) THEN         ! correction of SW in the Arctic Ocean
319
320           z_qsr(:,:)=0.7*z_qsr1(:,:)
321           xyt(:,:) = 0.e0
322           zzlat1 = 78.
323           zzlat2 = 82.
324           DO jj = 1, jpj
325             DO ji = 1, jpi
326               zzlat = gphit(ji,jj)
327               IF ( zzlat >= zzlat1 .AND. zzlat <= zzlat2 ) THEN
328                  xyt(ji,jj) = (zzlat-zzlat1)/(zzlat2-zzlat1)
329               ELSE IF ( zzlat > zzlat2 ) THEN
330                  xyt(ji,jj) = 1
331               ENDIF
332             END DO
333           END DO
334           z_qsr1(:,:)=z_qsr(:,:)*xyt(:,:)+(1.0-xyt(:,:))*z_qsr1(:,:)
335
336         ENDIF
337
338         sf(jp_qsr)%fnow(:,:,1)=z_qsr1(:,:)
339         sf(jp_qlw)%fnow(:,:,1)=z_qlw1(:,:)
340
341         IF ( ln_cotair_arc ) THEN           ! correction of Air Temperature in the Arctic Ocean
342
343           z_tair(:,:)=sf(jp_tair)%fnow(:,:,1) - 2.0
344           xyt(:,:) = 0.e0 ; zzlat1 = 78. ; zzlat2 = 82.
345           DO jj = 1, jpj
346             DO ji = 1, jpi
347               zzlat = gphit(ji,jj) ; zfrld=frld(ji,jj)
348               IF ( zzlat >= zzlat1 .AND. zzlat <= zzlat2 .AND. zfrld < 0.85 ) THEN
349                  xyt(ji,jj) = (zzlat-zzlat1)/(zzlat2-zzlat1)
350               ELSE IF ( zzlat > zzlat2 .AND. zfrld < 0.85 ) THEN
351                  xyt(ji,jj) = 1
352               ENDIF
353             END DO
354           END DO
355           sf(jp_tair)%fnow(:,:,1)=z_tair(:,:)*xyt(:,:)+(1.0-xyt(:,:))*sf(jp_tair)%fnow(:,:,1)
356
357         ENDIF
358
359#endif
360
361         CALL blk_oce_core( sf, sst_m, ssu_m, ssv_m )   ! compute the surface ocean fluxes using CLIO bulk formulea
362
363      ENDIF
364      !                                                  ! using CORE bulk formulea
365   END SUBROUTINE sbc_blk_core
366   
367   
368   SUBROUTINE blk_oce_core( sf, pst, pu, pv )
369      !!---------------------------------------------------------------------
370      !!                     ***  ROUTINE blk_core  ***
371      !!
372      !! ** Purpose :   provide the momentum, heat and freshwater fluxes at
373      !!      the ocean surface at each time step
374      !!
375      !! ** Method  :   CORE bulk formulea for the ocean using atmospheric
376      !!      fields read in sbc_read
377      !!
378      !! ** Outputs : - utau    : i-component of the stress at U-point  (N/m2)
379      !!              - vtau    : j-component of the stress at V-point  (N/m2)
380      !!              - taum    : Wind stress module at T-point         (N/m2)
381      !!              - wndm    : Wind speed module at T-point          (m/s)
382      !!              - qsr     : Solar heat flux over the ocean        (W/m2)
383      !!              - qns     : Non Solar heat flux over the ocean    (W/m2)
384      !!              - evap    : Evaporation over the ocean            (kg/m2/s)
385      !!              - emp(s)  : evaporation minus precipitation       (kg/m2/s)
386      !!
387      !!  ** Nota  :   sf has to be a dummy argument for AGRIF on NEC
388      !!---------------------------------------------------------------------
389      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
390      USE wrk_nemo, ONLY:   zwnd_i => wrk_2d_1  , zwnd_j => wrk_2d_2      ! wind speed components at T-point
391      USE wrk_nemo, ONLY:   zqsatw => wrk_2d_3           ! specific humidity at pst
392      USE wrk_nemo, ONLY:   zqlw   => wrk_2d_4  , zqsb   => wrk_2d_5      ! long wave and sensible heat fluxes
393      USE wrk_nemo, ONLY:   zqla   => wrk_2d_6  , zevap  => wrk_2d_7      ! latent heat fluxes and evaporation
394      USE wrk_nemo, ONLY:   Cd     => wrk_2d_8           ! transfer coefficient for momentum      (tau)
395      USE wrk_nemo, ONLY:   Ch     => wrk_2d_9           ! transfer coefficient for sensible heat (Q_sens)
396      USE wrk_nemo, ONLY:   Ce     => wrk_2d_10          ! transfer coefficient for evaporation   (Q_lat)
397      USE wrk_nemo, ONLY:   zst    => wrk_2d_11          ! surface temperature in Kelvin
398      USE wrk_nemo, ONLY:   zt_zu  => wrk_2d_12          ! air temperature at wind speed height
399      USE wrk_nemo, ONLY:   zq_zu  => wrk_2d_13          ! air spec. hum.  at wind speed height
400      !
401      TYPE(fld), INTENT(in), DIMENSION(:)   ::   sf    ! input data
402      REAL(wp) , INTENT(in), DIMENSION(:,:) ::   pst   ! surface temperature                      [Celcius]
403      REAL(wp) , INTENT(in), DIMENSION(:,:) ::   pu    ! surface current at U-point (i-component) [m/s]
404      REAL(wp) , INTENT(in), DIMENSION(:,:) ::   pv    ! surface current at V-point (j-component) [m/s]
405      !
406      INTEGER  ::   ji, jj               ! dummy loop indices
407      REAL(wp) ::   zcoef_qsatw, zztmp   ! local variable
408      !!---------------------------------------------------------------------
409
410      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10,11,12,13) ) THEN
411         CALL ctl_stop('blk_oce_core: requested workspace arrays unavailable')   ;   RETURN
412      ENDIF
413      !
414      ! local scalars ( place there for vector optimisation purposes)
415      zcoef_qsatw = 0.98 * 640380. / rhoa
416     
417      zst(:,:) = pst(:,:) + rt0      ! converte Celcius to Kelvin (and set minimum value far above 0 K)
418
419      ! ----------------------------------------------------------------------------- !
420      !      0   Wind components and module at T-point relative to the moving ocean   !
421      ! ----------------------------------------------------------------------------- !
422
423      ! ... components ( U10m - U_oce ) at T-point (unmasked)
424      zwnd_i(:,:) = 0.e0 
425      zwnd_j(:,:) = 0.e0
426#if defined key_vectopt_loop
427!CDIR COLLAPSE
428#endif
429      DO jj = 2, jpjm1
430         DO ji = fs_2, fs_jpim1   ! vect. opt.
431            zwnd_i(ji,jj) = (  sf(jp_wndi)%fnow(ji,jj,1) - 0.5 * ( pu(ji-1,jj  ) + pu(ji,jj) )  )
432            zwnd_j(ji,jj) = (  sf(jp_wndj)%fnow(ji,jj,1) - 0.5 * ( pv(ji  ,jj-1) + pv(ji,jj) )  )
433         END DO
434      END DO
435      CALL lbc_lnk( zwnd_i(:,:) , 'T', -1. )
436      CALL lbc_lnk( zwnd_j(:,:) , 'T', -1. )
437      ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
438!CDIR NOVERRCHK
439!CDIR COLLAPSE
440      wndm(:,:) = SQRT(  zwnd_i(:,:) * zwnd_i(:,:)   &
441         &             + zwnd_j(:,:) * zwnd_j(:,:)  ) * tmask(:,:,1)
442
443      ! ----------------------------------------------------------------------------- !
444      !      I   Radiative FLUXES                                                     !
445      ! ----------------------------------------------------------------------------- !
446   
447      ! ocean albedo assumed to be constant + modify now Qsr to include the diurnal cycle                    ! Short Wave
448      zztmp = 1. - albo
449      IF( ln_dm2dc ) THEN   ;   qsr(:,:) = zztmp * sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) * tmask(:,:,1)
450      ELSE                  ;   qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:,1)   * tmask(:,:,1)
451      ENDIF
452!CDIR COLLAPSE
453      zqlw(:,:) = (  sf(jp_qlw)%fnow(:,:,1) - Stef * zst(:,:)*zst(:,:)*zst(:,:)*zst(:,:)  ) * tmask(:,:,1)   ! Long  Wave
454      ! ----------------------------------------------------------------------------- !
455      !     II    Turbulent FLUXES                                                    !
456      ! ----------------------------------------------------------------------------- !
457
458      ! ... specific humidity at SST and IST
459!CDIR NOVERRCHK
460!CDIR COLLAPSE
461      zqsatw(:,:) = zcoef_qsatw * EXP( -5107.4 / zst(:,:) ) 
462
463      ! ... NCAR Bulk formulae, computation of Cd, Ch, Ce at T-point :
464      IF( ln_2m ) THEN
465         !! If air temp. and spec. hum. are given at different height (2m) than wind (10m) :
466         CALL TURB_CORE_2Z(2.,10., zst   , sf(jp_tair)%fnow,         &
467            &                      zqsatw, sf(jp_humi)%fnow, wndm,   &
468            &                      Cd    , Ch              , Ce  ,   &
469            &                      zt_zu , zq_zu                   )
470      ELSE
471         !! If air temp. and spec. hum. are given at same height than wind (10m) :
472!gm bug?  at the compiling phase, add a copy in temporary arrays...  ==> check perf
473!         CALL TURB_CORE_1Z( 10., zst   (:,:), sf(jp_tair)%fnow(:,:),              &
474!            &                    zqsatw(:,:), sf(jp_humi)%fnow(:,:), wndm(:,:),   &
475!            &                    Cd    (:,:),             Ch  (:,:), Ce  (:,:)  )
476!gm bug
477! ARPDBG - this won't compile with gfortran. Fix but check performance
478! as per comment above.
479         CALL TURB_CORE_1Z( 10., zst   , sf(jp_tair)%fnow(:,:,1),       &
480            &                    zqsatw, sf(jp_humi)%fnow(:,:,1), wndm, &
481            &                    Cd    , Ch              , Ce    )
482      ENDIF
483
484      ! ... tau module, i and j component
485      DO jj = 1, jpj
486         DO ji = 1, jpi
487            zztmp = rhoa * wndm(ji,jj) * Cd(ji,jj)
488            taum  (ji,jj) = zztmp * wndm  (ji,jj)
489            zwnd_i(ji,jj) = zztmp * zwnd_i(ji,jj)
490            zwnd_j(ji,jj) = zztmp * zwnd_j(ji,jj)
491         END DO
492      END DO
493
494      ! ... add the HF tau contribution to the wind stress module?
495      IF( lhftau ) THEN 
496!CDIR COLLAPSE
497#if defined key_orca_r025
498         ! Changed!!! Multiply by QSCAT correction
499           zwnd_i(:,:) = zwnd_i(:,:) * sf(jp_tdif)%fnow(:,:,1)
500           zwnd_j(:,:) = zwnd_j(:,:) * sf(jp_tdif)%fnow(:,:,1)
501#endif
502         taum(:,:) = taum(:,:) + sf(jp_tdif)%fnow(:,:,1)
503      ENDIF
504      CALL iom_put( "taum_oce", taum )   ! output wind stress module
505
506      ! ... utau, vtau at U- and V_points, resp.
507      !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines
508      DO jj = 1, jpjm1
509         DO ji = 1, fs_jpim1
510            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) )
511            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) )
512         END DO
513      END DO
514      CALL lbc_lnk( utau(:,:), 'U', -1. )
515      CALL lbc_lnk( vtau(:,:), 'V', -1. )
516
517      !  Turbulent fluxes over ocean
518      ! -----------------------------
519      IF( ln_2m ) THEN
520         ! Values of temp. and hum. adjusted to 10m must be used instead of 2m values
521         zevap(:,:) = MAX( 0.e0, rhoa    *Ce(:,:)*( zqsatw(:,:) - zq_zu(:,:) ) * wndm(:,:) )   ! Evaporation
522         zqsb (:,:) =            rhoa*cpa*Ch(:,:)*( zst   (:,:) - zt_zu(:,:) ) * wndm(:,:)     ! Sensible Heat
523      ELSE
524!CDIR COLLAPSE
525         zevap(:,:) = MAX( 0.e0, rhoa    *Ce(:,:)*( zqsatw(:,:) - sf(jp_humi)%fnow(:,:,1) ) * wndm(:,:) )   ! Evaporation
526!CDIR COLLAPSE
527         zqsb (:,:) =            rhoa*cpa*Ch(:,:)*( zst   (:,:) - sf(jp_tair)%fnow(:,:,1) ) * wndm(:,:)     ! Sensible Heat
528      ENDIF
529!CDIR COLLAPSE
530      zqla (:,:) = Lv * zevap(:,:)                                                              ! Latent Heat
531
532      IF(ln_ctl) THEN
533         CALL prt_ctl( tab2d_1=zqla  , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=Ce , clinfo2=' Ce  : ' )
534         CALL prt_ctl( tab2d_1=zqsb  , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=Ch , clinfo2=' Ch  : ' )
535         CALL prt_ctl( tab2d_1=zqlw  , clinfo1=' blk_oce_core: zqlw   : ', tab2d_2=qsr, clinfo2=' qsr : ' )
536         CALL prt_ctl( tab2d_1=zqsatw, clinfo1=' blk_oce_core: zqsatw : ', tab2d_2=zst, clinfo2=' zst : ' )
537         CALL prt_ctl( tab2d_1=utau  , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
538            &          tab2d_2=vtau  , clinfo2=              ' vtau : '  , mask2=vmask )
539         CALL prt_ctl( tab2d_1=wndm  , clinfo1=' blk_oce_core: wndm   : ')
540         CALL prt_ctl( tab2d_1=zst   , clinfo1=' blk_oce_core: zst    : ')
541      ENDIF
542       
543      ! ----------------------------------------------------------------------------- !
544      !     III    Total FLUXES                                                       !
545      ! ----------------------------------------------------------------------------- !
546     
547!CDIR COLLAPSE
548      qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)      ! Downward Non Solar flux
549!CDIR COLLAPSE
550      emp(:,:) = zevap(:,:) - sf(jp_prec)%fnow(:,:,1) * rn_pfac * tmask(:,:,1)
551!CDIR COLLAPSE
552      emps(:,:) = emp(:,:)
553      !
554      CALL iom_put( "qlw_oce",   zqlw )                 ! output downward longwave heat over the ocean
555      CALL iom_put( "qsb_oce", - zqsb )                 ! output downward sensible heat over the ocean
556      CALL iom_put( "qla_oce", - zqla )                 ! output downward latent   heat over the ocean
557      CALL iom_put( "qns_oce",   qns  )                 ! output downward non solar heat over the ocean
558      !
559      IF(ln_ctl) THEN
560         CALL prt_ctl(tab2d_1=zqsb , clinfo1=' blk_oce_core: zqsb   : ', tab2d_2=zqlw , clinfo2=' zqlw  : ')
561         CALL prt_ctl(tab2d_1=zqla , clinfo1=' blk_oce_core: zqla   : ', tab2d_2=qsr  , clinfo2=' qsr   : ')
562         CALL prt_ctl(tab2d_1=pst  , clinfo1=' blk_oce_core: pst    : ', tab2d_2=emp  , clinfo2=' emp   : ')
563         CALL prt_ctl(tab2d_1=utau , clinfo1=' blk_oce_core: utau   : ', mask1=umask,   &
564            &         tab2d_2=vtau , clinfo2=              ' vtau  : ' , mask2=vmask )
565      ENDIF
566      !
567      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10,11,12,13) )   &
568          CALL ctl_stop('blk_oce_core: failed to release workspace arrays')
569      !
570   END SUBROUTINE blk_oce_core
571   
572   
573   SUBROUTINE blk_ice_core(  pst   , pui   , pvi   , palb ,   &
574      &                      p_taui, p_tauj, p_qns , p_qsr,   &
575      &                      p_qla , p_dqns, p_dqla,          &
576      &                      p_tpr , p_spr ,                  &
577      &                      p_fr1 , p_fr2 , cd_grid, pdim  ) 
578      !!---------------------------------------------------------------------
579      !!                     ***  ROUTINE blk_ice_core  ***
580      !!
581      !! ** Purpose :   provide the surface boundary condition over sea-ice
582      !!
583      !! ** Method  :   compute momentum, heat and freshwater exchanged
584      !!                between atmosphere and sea-ice using CORE bulk
585      !!                formulea, ice variables and read atmmospheric fields.
586      !!                NB: ice drag coefficient is assumed to be a constant
587      !!
588      !! caution : the net upward water flux has with mm/day unit
589      !!---------------------------------------------------------------------
590      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
591      USE wrk_nemo, ONLY:   z_wnds_t => wrk_2d_1                ! wind speed ( = | U10m - U_ice | ) at T-point
592      USE wrk_nemo, ONLY:   wrk_3d_4 , wrk_3d_5 , wrk_3d_6 , wrk_3d_7
593      !!
594      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pst      ! ice surface temperature (>0, =rt0 over land) [Kelvin]
595      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pui      ! ice surface velocity (i- and i- components      [m/s]
596      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pvi      !    at I-point (B-grid) or U & V-point (C-grid)
597      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   palb     ! ice albedo (clear sky) (alb_ice_cs)               [%]
598      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_taui   ! i- & j-components of surface ice stress        [N/m2]
599      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tauj   !   at I-point (B-grid) or U & V-point (C-grid)
600      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qns    ! non solar heat flux over ice (T-point)         [W/m2]
601      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qsr    !     solar heat flux over ice (T-point)         [W/m2]
602      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qla    ! latent    heat flux over ice (T-point)         [W/m2]
603      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqns   ! non solar heat sensistivity  (T-point)         [W/m2]
604      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqla   ! latent    heat sensistivity  (T-point)         [W/m2]
605      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tpr    ! total precipitation          (T-point)      [Kg/m2/s]
606      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_spr    ! solid precipitation          (T-point)      [Kg/m2/s]
607      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr1    ! 1sr fraction of qsr penetration in ice (T-point)  [%]
608      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr2    ! 2nd fraction of qsr penetration in ice (T-point)  [%]
609      CHARACTER(len=1)          , INTENT(in   ) ::   cd_grid  ! ice grid ( C or B-grid)
610      INTEGER                   , INTENT(in   ) ::   pdim     ! number of ice categories
611      !!
612      INTEGER  ::   ji, jj, jl    ! dummy loop indices
613      INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays)
614      REAL(wp) ::   zst2, zst3
615      REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2, zcoef_dqlw, zcoef_dqla, zcoef_dqsb
616      REAL(wp) ::   zztmp                                        ! temporary variable
617      REAL(wp) ::   zcoef_frca                                   ! fractional cloud amount
618      REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f                  ! relative wind module and components at F-point
619      REAL(wp) ::             zwndi_t , zwndj_t                  ! relative wind components at T-point
620      !!
621      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qlw             ! long wave heat flux over ice
622      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qsb             ! sensible  heat flux over ice
623      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqlw            ! long wave heat sensitivity over ice
624      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_dqsb            ! sensible  heat sensitivity over ice
625      !!---------------------------------------------------------------------
626
627      ijpl  = pdim                            ! number of ice categories
628
629      ! Set-up access to workspace arrays
630      IF( wrk_in_use(2, 1) .OR. wrk_in_use(3, 4,5,6,7) ) THEN
631         CALL ctl_stop('blk_ice_core: requested workspace arrays unavailable')   ;   RETURN
632      ELSE IF(ijpl > jpk) THEN
633         CALL ctl_stop('blk_ice_core: no. of ice categories > jpk so wrk_nemo 3D workspaces cannot be used.')
634         RETURN
635      END IF
636      ! Set-up pointers to sub-arrays of workspaces
637      z_qlw  => wrk_3d_4(:,:,1:ijpl)
638      z_qsb  => wrk_3d_5(:,:,1:ijpl)
639      z_dqlw => wrk_3d_6(:,:,1:ijpl)
640      z_dqsb => wrk_3d_7(:,:,1:ijpl)
641
642      ! local scalars ( place there for vector optimisation purposes)
643      zcoef_wnorm  = rhoa * Cice
644      zcoef_wnorm2 = rhoa * Cice * 0.5
645      zcoef_dqlw   = 4.0 * 0.95 * Stef
646      zcoef_dqla   = -Ls * Cice * 11637800. * (-5897.8)
647      zcoef_dqsb   = rhoa * cpa * Cice
648      zcoef_frca   = 1.0  - 0.3
649
650!!gm brutal....
651      z_wnds_t(:,:) = 0.e0
652      p_taui  (:,:) = 0.e0
653      p_tauj  (:,:) = 0.e0
654!!gm end
655
656#if defined key_lim3
657      tatm_ice(:,:) = sf(jp_tair)%fnow(:,:,1)   ! LIM3: make Tair available in sea-ice. WARNING allocated after call to ice_init
658#endif
659      ! ----------------------------------------------------------------------------- !
660      !    Wind components and module relative to the moving ocean ( U10m - U_ice )   !
661      ! ----------------------------------------------------------------------------- !
662      SELECT CASE( cd_grid )
663      CASE( 'I' )                  ! B-grid ice dynamics :   I-point (i.e. F-point with sea-ice indexation)
664         !                           and scalar wind at T-point ( = | U10m - U_ice | ) (masked)
665!CDIR NOVERRCHK
666         DO jj = 2, jpjm1
667            DO ji = 2, jpim1   ! B grid : NO vector opt
668               ! ... scalar wind at I-point (fld being at T-point)
669               zwndi_f = 0.25 * (  sf(jp_wndi)%fnow(ji-1,jj  ,1) + sf(jp_wndi)%fnow(ji  ,jj  ,1)   &
670                  &              + sf(jp_wndi)%fnow(ji-1,jj-1,1) + sf(jp_wndi)%fnow(ji  ,jj-1,1)  ) - pui(ji,jj)
671               zwndj_f = 0.25 * (  sf(jp_wndj)%fnow(ji-1,jj  ,1) + sf(jp_wndj)%fnow(ji  ,jj  ,1)   &
672                  &              + sf(jp_wndj)%fnow(ji-1,jj-1,1) + sf(jp_wndj)%fnow(ji  ,jj-1,1)  ) - pvi(ji,jj)
673               zwnorm_f = zcoef_wnorm * SQRT( zwndi_f * zwndi_f + zwndj_f * zwndj_f )
674               ! ... ice stress at I-point
675               p_taui(ji,jj) = zwnorm_f * zwndi_f
676               p_tauj(ji,jj) = zwnorm_f * zwndj_f
677               ! ... scalar wind at T-point (fld being at T-point)
678               zwndi_t = sf(jp_wndi)%fnow(ji,jj,1) - 0.25 * (  pui(ji,jj+1) + pui(ji+1,jj+1)   &
679                  &                                          + pui(ji,jj  ) + pui(ji+1,jj  )  )
680               zwndj_t = sf(jp_wndj)%fnow(ji,jj,1) - 0.25 * (  pvi(ji,jj+1) + pvi(ji+1,jj+1)   &
681                  &                                          + pvi(ji,jj  ) + pvi(ji+1,jj  )  )
682               z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
683            END DO
684         END DO
685         CALL lbc_lnk( p_taui  , 'I', -1. )
686         CALL lbc_lnk( p_tauj  , 'I', -1. )
687         CALL lbc_lnk( z_wnds_t, 'T',  1. )
688         !
689      CASE( 'C' )                  ! C-grid ice dynamics :   U & V-points (same as ocean)
690#if defined key_vectopt_loop
691!CDIR COLLAPSE
692#endif
693         DO jj = 2, jpj
694            DO ji = fs_2, jpi   ! vect. opt.
695               zwndi_t = (  sf(jp_wndi)%fnow(ji,jj,1) - 0.5 * ( pui(ji-1,jj  ) + pui(ji,jj) )  )
696               zwndj_t = (  sf(jp_wndj)%fnow(ji,jj,1) - 0.5 * ( pvi(ji  ,jj-1) + pvi(ji,jj) )  )
697               z_wnds_t(ji,jj)  = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
698            END DO
699         END DO
700#if defined key_vectopt_loop
701!CDIR COLLAPSE
702#endif
703         DO jj = 2, jpjm1
704            DO ji = fs_2, fs_jpim1   ! vect. opt.
705               p_taui(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji+1,jj  ) + z_wnds_t(ji,jj) )                          &
706                  &          * ( 0.5 * (sf(jp_wndi)%fnow(ji+1,jj,1) + sf(jp_wndi)%fnow(ji,jj,1) ) - pui(ji,jj) )
707               p_tauj(ji,jj) = zcoef_wnorm2 * ( z_wnds_t(ji,jj+1  ) + z_wnds_t(ji,jj) )                          &
708                  &          * ( 0.5 * (sf(jp_wndj)%fnow(ji,jj+1,1) + sf(jp_wndj)%fnow(ji,jj,1) ) - pvi(ji,jj) )
709            END DO
710         END DO
711         CALL lbc_lnk( p_taui  , 'U', -1. )
712         CALL lbc_lnk( p_tauj  , 'V', -1. )
713         CALL lbc_lnk( z_wnds_t, 'T',  1. )
714         !
715      END SELECT
716
717      zztmp = 1. / ( 1. - albo )
718      !                                     ! ========================== !
719      DO jl = 1, ijpl                       !  Loop over ice categories  !
720         !                                  ! ========================== !
721!CDIR NOVERRCHK
722!CDIR COLLAPSE
723         DO jj = 1 , jpj
724!CDIR NOVERRCHK
725            DO ji = 1, jpi
726               ! ----------------------------!
727               !      I   Radiative FLUXES   !
728               ! ----------------------------!
729               zst2 = pst(ji,jj,jl) * pst(ji,jj,jl)
730               zst3 = pst(ji,jj,jl) * zst2
731               ! Short Wave (sw)
732               p_qsr(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr(ji,jj)
733               ! Long  Wave (lw)
734               z_qlw(ji,jj,jl) = 0.95 * (  sf(jp_qlw)%fnow(ji,jj,1) - Stef * pst(ji,jj,jl) * zst3  ) * tmask(ji,jj,1)
735               ! lw sensitivity
736               z_dqlw(ji,jj,jl) = zcoef_dqlw * zst3                                               
737
738               ! ----------------------------!
739               !     II    Turbulent FLUXES  !
740               ! ----------------------------!
741
742               ! ... turbulent heat fluxes
743               ! Sensible Heat
744               z_qsb(ji,jj,jl) = rhoa * cpa * Cice * z_wnds_t(ji,jj) * ( pst(ji,jj,jl) - sf(jp_tair)%fnow(ji,jj,1) )
745               ! Latent Heat
746               p_qla(ji,jj,jl) = MAX( 0.e0, rhoa * Ls  * Cice * z_wnds_t(ji,jj)   &                           
747                  &                    * (  11637800. * EXP( -5897.8 / pst(ji,jj,jl) ) / rhoa - sf(jp_humi)%fnow(ji,jj,1)  ) )
748               ! Latent heat sensitivity for ice (Dqla/Dt)
749               p_dqla(ji,jj,jl) = zcoef_dqla * z_wnds_t(ji,jj) / ( zst2 ) * EXP( -5897.8 / pst(ji,jj,jl) )
750               ! Sensible heat sensitivity (Dqsb_ice/Dtn_ice)
751               z_dqsb(ji,jj,jl) = zcoef_dqsb * z_wnds_t(ji,jj)
752
753               ! ----------------------------!
754               !     III    Total FLUXES     !
755               ! ----------------------------!
756               ! Downward Non Solar flux
757               p_qns (ji,jj,jl) =     z_qlw (ji,jj,jl) - z_qsb (ji,jj,jl) - p_qla (ji,jj,jl)     
758               ! Total non solar heat flux sensitivity for ice
759               p_dqns(ji,jj,jl) = - ( z_dqlw(ji,jj,jl) + z_dqsb(ji,jj,jl) + p_dqla(ji,jj,jl) )   
760            END DO
761            !
762         END DO
763         !
764      END DO
765      !
766      !--------------------------------------------------------------------
767      ! FRACTIONs of net shortwave radiation which is not absorbed in the
768      ! thin surface layer and penetrates inside the ice cover
769      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 )
770   
771!CDIR COLLAPSE
772      p_fr1(:,:) = ( 0.18 * ( 1.0 - zcoef_frca ) + 0.35 * zcoef_frca )
773!CDIR COLLAPSE
774      p_fr2(:,:) = ( 0.82 * ( 1.0 - zcoef_frca ) + 0.65 * zcoef_frca )
775       
776!CDIR COLLAPSE
777      p_tpr(:,:) = sf(jp_prec)%fnow(:,:,1) * rn_pfac      ! total precipitation [kg/m2/s]
778!CDIR COLLAPSE
779      p_spr(:,:) = sf(jp_snow)%fnow(:,:,1) * rn_pfac      ! solid precipitation [kg/m2/s]
780      CALL iom_put( 'snowpre', p_spr )                  ! Snow precipitation
781      !
782      IF(ln_ctl) THEN
783         CALL prt_ctl(tab3d_1=p_qla   , clinfo1=' blk_ice_core: p_qla  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb  : ', kdim=ijpl)
784         CALL prt_ctl(tab3d_1=z_qlw   , clinfo1=' blk_ice_core: z_qlw  : ', tab3d_2=p_dqla  , clinfo2=' p_dqla : ', kdim=ijpl)
785         CALL prt_ctl(tab3d_1=z_dqsb  , clinfo1=' blk_ice_core: z_dqsb : ', tab3d_2=z_dqlw  , clinfo2=' z_dqlw : ', kdim=ijpl)
786         CALL prt_ctl(tab3d_1=p_dqns  , clinfo1=' blk_ice_core: p_dqns : ', tab3d_2=p_qsr   , clinfo2=' p_qsr  : ', kdim=ijpl)
787         CALL prt_ctl(tab3d_1=pst     , clinfo1=' blk_ice_core: pst    : ', tab3d_2=p_qns   , clinfo2=' p_qns  : ', kdim=ijpl)
788         CALL prt_ctl(tab2d_1=p_tpr   , clinfo1=' blk_ice_core: p_tpr  : ', tab2d_2=p_spr   , clinfo2=' p_spr  : ')
789         CALL prt_ctl(tab2d_1=p_taui  , clinfo1=' blk_ice_core: p_taui : ', tab2d_2=p_tauj  , clinfo2=' p_tauj : ')
790         CALL prt_ctl(tab2d_1=z_wnds_t, clinfo1=' blk_ice_core: z_wnds_t : ')
791      ENDIF
792
793      IF( wrk_not_released(2, 1)       .OR.   &
794          wrk_not_released(3, 4,5,6,7) )   CALL ctl_stop('blk_ice_core: failed to release workspace arrays')
795      !
796   END SUBROUTINE blk_ice_core
797 
798
799   SUBROUTINE TURB_CORE_1Z(zu, sst, T_a, q_sat, q_a,   &
800      &                        dU , Cd , Ch   , Ce   )
801      !!----------------------------------------------------------------------
802      !!                      ***  ROUTINE  turb_core  ***
803      !!
804      !! ** Purpose :   Computes turbulent transfert coefficients of surface
805      !!                fluxes according to Large & Yeager (2004)
806      !!
807      !! ** Method  :   I N E R T I A L   D I S S I P A T I O N   M E T H O D
808      !!      Momentum, Latent and sensible heat exchange coefficients
809      !!      Caution: this procedure should only be used in cases when air
810      !!      temperature (T_air), air specific humidity (q_air) and wind (dU)
811      !!      are provided at the same height 'zzu'!
812      !!
813      !! References :   Large & Yeager, 2004 : ???
814      !!----------------------------------------------------------------------
815      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
816      USE wrk_nemo, ONLY: dU10 => wrk_2d_14        ! dU                             [m/s]
817      USE wrk_nemo, ONLY: dT => wrk_2d_15          ! air/sea temperature difference   [K]
818      USE wrk_nemo, ONLY: dq => wrk_2d_16          ! air/sea humidity difference      [K]
819      USE wrk_nemo, ONLY: Cd_n10 => wrk_2d_17      ! 10m neutral drag coefficient
820      USE wrk_nemo, ONLY: Ce_n10 => wrk_2d_18      ! 10m neutral latent coefficient
821      USE wrk_nemo, ONLY: Ch_n10 => wrk_2d_19      ! 10m neutral sensible coefficient
822      USE wrk_nemo, ONLY: sqrt_Cd_n10 => wrk_2d_20 ! root square of Cd_n10
823      USE wrk_nemo, ONLY: sqrt_Cd => wrk_2d_21     ! root square of Cd
824      USE wrk_nemo, ONLY: T_vpot => wrk_2d_22      ! virtual potential temperature    [K]
825      USE wrk_nemo, ONLY: T_star => wrk_2d_23      ! turbulent scale of tem. fluct.
826      USE wrk_nemo, ONLY: q_star => wrk_2d_24      ! turbulent humidity of temp. fluct.
827      USE wrk_nemo, ONLY: U_star => wrk_2d_25      ! turb. scale of velocity fluct.
828      USE wrk_nemo, ONLY: L => wrk_2d_26           ! Monin-Obukov length              [m]
829      USE wrk_nemo, ONLY: zeta => wrk_2d_27        ! stability parameter at height zu
830      USE wrk_nemo, ONLY: U_n10 => wrk_2d_28       ! neutral wind velocity at 10m     [m]
831      USE wrk_nemo, ONLY: xlogt  => wrk_2d_29,    xct => wrk_2d_30,   &
832                          zpsi_h => wrk_2d_31, zpsi_m => wrk_2d_32
833      USE wrk_nemo, ONLY: stab => iwrk_2d_1      ! 1st guess stability test integer
834      !
835      REAL(wp)                , INTENT(in   ) ::   zu      ! altitude of wind measurement       [m]
836      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   sst     ! sea surface temperature         [Kelvin]
837      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   T_a     ! potential air temperature       [Kelvin]
838      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   q_sat   ! sea surface specific humidity   [kg/kg]
839      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   q_a     ! specific air humidity           [kg/kg]
840      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   dU      ! wind module |U(zu)-U(0)|        [m/s]
841      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Cd      ! transfert coefficient for momentum       (tau)
842      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Ch      ! transfert coefficient for temperature (Q_sens)
843      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Ce      ! transfert coefficient for evaporation  (Q_lat)
844      !!
845      INTEGER :: j_itt
846      INTEGER , PARAMETER ::   nb_itt = 3
847      REAL(wp), PARAMETER ::   grav   = 9.8   ! gravity                       
848      REAL(wp), PARAMETER ::   kappa  = 0.4   ! von Karman s constant
849      !!----------------------------------------------------------------------
850
851      IF(  wrk_in_use(2,             14,15,16,17,18,19,        &
852                         20,21,22,23,24,25,26,27,28,29,        &
853                         30,31,32)                      .OR.   &
854          iwrk_in_use(2, 1)                               ) THEN
855         CALL ctl_stop('TURB_CORE_1Z: requested workspace arrays unavailable')   ;   RETURN
856      ENDIF
857
858      !! * Start
859      !! Air/sea differences
860      dU10 = max(0.5, dU)     ! we don't want to fall under 0.5 m/s
861      dT = T_a - sst          ! assuming that T_a is allready the potential temp. at zzu
862      dq = q_a - q_sat
863      !!   
864      !! Virtual potential temperature
865      T_vpot = T_a*(1. + 0.608*q_a)
866      !!
867      !! Neutral Drag Coefficient
868      stab    = 0.5 + sign(0.5,dT)    ! stable : stab = 1 ; unstable : stab = 0
869      Cd_n10  = 1E-3 * ( 2.7/dU10 + 0.142 + dU10/13.09 )    !   L & Y eq. (6a)
870      sqrt_Cd_n10 = sqrt(Cd_n10)
871      Ce_n10  = 1E-3 * ( 34.6 * sqrt_Cd_n10 )               !   L & Y eq. (6b)
872      Ch_n10  = 1E-3*sqrt_Cd_n10*(18*stab + 32.7*(1-stab)) !   L & Y eq. (6c), (6d)
873      !!
874      !! Initializing transfert coefficients with their first guess neutral equivalents :
875      Cd = Cd_n10 ;  Ce = Ce_n10 ;  Ch = Ch_n10 ;  sqrt_Cd = sqrt(Cd)
876
877      !! * Now starting iteration loop
878      DO j_itt=1, nb_itt
879         !! Turbulent scales :
880         U_star  = sqrt_Cd*dU10                !   L & Y eq. (7a)
881         T_star  = Ch/sqrt_Cd*dT               !   L & Y eq. (7b)
882         q_star  = Ce/sqrt_Cd*dq               !   L & Y eq. (7c)
883
884         !! Estimate the Monin-Obukov length :
885         L  = (U_star**2)/( kappa*grav*(T_star/T_vpot + q_star/(q_a + 1./0.608)) )
886
887         !! Stability parameters :
888         zeta  = zu/L ;  zeta   = sign( min(abs(zeta),10.0), zeta )
889         zpsi_h  = psi_h(zeta)
890         zpsi_m  = psi_m(zeta)
891
892         !! Shifting the wind speed to 10m and neutral stability :
893         U_n10 = dU10*1./(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)) !  L & Y eq. (9a)
894
895         !! Updating the neutral 10m transfer coefficients :
896         Cd_n10  = 1E-3 * (2.7/U_n10 + 0.142 + U_n10/13.09)              !  L & Y eq. (6a)
897         sqrt_Cd_n10 = sqrt(Cd_n10)
898         Ce_n10  = 1E-3 * (34.6 * sqrt_Cd_n10)                           !  L & Y eq. (6b)
899         stab    = 0.5 + sign(0.5,zeta)
900         Ch_n10  = 1E-3*sqrt_Cd_n10*(18.*stab + 32.7*(1-stab))           !  L & Y eq. (6c), (6d)
901
902         !! Shifting the neutral  10m transfer coefficients to ( zu , zeta ) :
903         !!
904         xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10) - zpsi_m)
905         Cd  = Cd_n10/(xct*xct) ;  sqrt_Cd = sqrt(Cd)
906         !!
907         xlogt = log(zu/10.) - zpsi_h
908         !!
909         xct = 1. + Ch_n10*xlogt/kappa/sqrt_Cd_n10
910         Ch  = Ch_n10*sqrt_Cd/sqrt_Cd_n10/xct
911         !!
912         xct = 1. + Ce_n10*xlogt/kappa/sqrt_Cd_n10
913         Ce  = Ce_n10*sqrt_Cd/sqrt_Cd_n10/xct
914         !!
915      END DO
916      !!
917      IF( wrk_not_released(2,             14,15,16,17,18,19,          &
918         &                    20,21,22,23,24,25,26,27,28,29,          &
919         &                    30,31,32                      )   .OR.  &     
920         iwrk_not_released(2, 1)                                  )   &
921         CALL ctl_stop('TURB_CORE_1Z: failed to release workspace arrays')
922      !
923    END SUBROUTINE TURB_CORE_1Z
924
925
926    SUBROUTINE TURB_CORE_2Z(zt, zu, sst, T_zt, q_sat, q_zt, dU, Cd, Ch, Ce, T_zu, q_zu)
927      !!----------------------------------------------------------------------
928      !!                      ***  ROUTINE  turb_core  ***
929      !!
930      !! ** Purpose :   Computes turbulent transfert coefficients of surface
931      !!                fluxes according to Large & Yeager (2004).
932      !!
933      !! ** Method  :   I N E R T I A L   D I S S I P A T I O N   M E T H O D
934      !!      Momentum, Latent and sensible heat exchange coefficients
935      !!      Caution: this procedure should only be used in cases when air
936      !!      temperature (T_air) and air specific humidity (q_air) are at 2m
937      !!      whereas wind (dU) is at 10m.
938      !!
939      !! References :   Large & Yeager, 2004 : ???
940      !!----------------------------------------------------------------------
941      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
942      USE wrk_nemo, ONLY: dU10 => wrk_2d_14        ! dU                             [m/s]
943      USE wrk_nemo, ONLY: dT => wrk_2d_15          ! air/sea temperature difference   [K]
944      USE wrk_nemo, ONLY: dq => wrk_2d_16          ! air/sea humidity difference      [K]
945      USE wrk_nemo, ONLY: Cd_n10 => wrk_2d_17      ! 10m neutral drag coefficient
946      USE wrk_nemo, ONLY: Ce_n10 => wrk_2d_18      ! 10m neutral latent coefficient
947      USE wrk_nemo, ONLY: Ch_n10 => wrk_2d_19      ! 10m neutral sensible coefficient
948      USE wrk_nemo, ONLY: sqrt_Cd_n10 => wrk_2d_20 ! root square of Cd_n10
949      USE wrk_nemo, ONLY: sqrt_Cd => wrk_2d_21     ! root square of Cd
950      USE wrk_nemo, ONLY: T_vpot => wrk_2d_22      ! virtual potential temperature    [K]
951      USE wrk_nemo, ONLY: T_star => wrk_2d_23     ! turbulent scale of tem. fluct.
952      USE wrk_nemo, ONLY: q_star => wrk_2d_24     ! turbulent humidity of temp. fluct.
953      USE wrk_nemo, ONLY: U_star => wrk_2d_25     ! turb. scale of velocity fluct.
954      USE wrk_nemo, ONLY: L => wrk_2d_26          ! Monin-Obukov length              [m]
955      USE wrk_nemo, ONLY: zeta_u => wrk_2d_27     ! stability parameter at height zu
956      USE wrk_nemo, ONLY: zeta_t => wrk_2d_28     ! stability parameter at height zt
957      USE wrk_nemo, ONLY: U_n10 => wrk_2d_29      ! neutral wind velocity at 10m     [m]
958      USE wrk_nemo, ONLY: xlogt => wrk_2d_30, xct => wrk_2d_31, zpsi_hu => wrk_2d_32, zpsi_ht => wrk_2d_33, zpsi_m => wrk_2d_34
959      USE wrk_nemo, ONLY: stab => iwrk_2d_1      ! 1st guess stability test integer
960      !!
961      REAL(wp), INTENT(in)   :: &
962         zt,      &     ! height for T_zt and q_zt                   [m]
963         zu             ! height for dU                              [m]
964      REAL(wp), INTENT(in), DIMENSION(jpi,jpj) ::  &
965         sst,      &     ! sea surface temperature              [Kelvin]
966         T_zt,     &     ! potential air temperature            [Kelvin]
967         q_sat,    &     ! sea surface specific humidity         [kg/kg]
968         q_zt,     &     ! specific air humidity                 [kg/kg]
969         dU              ! relative wind module |U(zu)-U(0)|       [m/s]
970      REAL(wp), INTENT(out), DIMENSION(jpi,jpj)  ::  &
971         Cd,       &     ! transfer coefficient for momentum         (tau)
972         Ch,       &     ! transfer coefficient for sensible heat (Q_sens)
973         Ce,       &     ! transfert coefficient for evaporation   (Q_lat)
974         T_zu,     &     ! air temp. shifted at zu                     [K]
975         q_zu            ! spec. hum.  shifted at zu               [kg/kg]
976
977      INTEGER :: j_itt
978      INTEGER, PARAMETER :: nb_itt = 3   ! number of itterations
979      REAL(wp), PARAMETER ::                        &
980         grav   = 9.8,      &  ! gravity                       
981         kappa  = 0.4          ! von Karman's constant
982      !!----------------------------------------------------------------------
983      !!  * Start
984
985      IF(  wrk_in_use(2,             14,15,16,17,18,19,        &
986                         20,21,22,23,24,25,26,27,28,29,        &         
987                         30,31,32,33,34)                .OR.   &
988          iwrk_in_use(2, 1)                               ) THEN
989         CALL ctl_stop('TURB_CORE_2Z: requested workspace arrays unavailable')   ;   RETURN
990      ENDIF
991
992      !! Initial air/sea differences
993      dU10 = max(0.5, dU)      !  we don't want to fall under 0.5 m/s
994      dT = T_zt - sst 
995      dq = q_zt - q_sat
996
997      !! Neutral Drag Coefficient :
998      stab = 0.5 + sign(0.5,dT)                 ! stab = 1  if dT > 0  -> STABLE
999      Cd_n10  = 1E-3*( 2.7/dU10 + 0.142 + dU10/13.09 ) 
1000      sqrt_Cd_n10 = sqrt(Cd_n10)
1001      Ce_n10  = 1E-3*( 34.6 * sqrt_Cd_n10 )
1002      Ch_n10  = 1E-3*sqrt_Cd_n10*(18*stab + 32.7*(1 - stab))
1003
1004      !! Initializing transf. coeff. with their first guess neutral equivalents :
1005      Cd = Cd_n10 ;  Ce = Ce_n10 ;  Ch = Ch_n10 ;  sqrt_Cd = sqrt(Cd)
1006
1007      !! Initializing z_u values with z_t values :
1008      T_zu = T_zt ;  q_zu = q_zt
1009
1010      !!  * Now starting iteration loop
1011      DO j_itt=1, nb_itt
1012         dT = T_zu - sst ;  dq = q_zu - q_sat ! Updating air/sea differences
1013         T_vpot = T_zu*(1. + 0.608*q_zu)    ! Updating virtual potential temperature at zu
1014         U_star = sqrt_Cd*dU10                ! Updating turbulent scales :   (L & Y eq. (7))
1015         T_star  = Ch/sqrt_Cd*dT              !
1016         q_star  = Ce/sqrt_Cd*dq              !
1017         !!
1018         L = (U_star*U_star) &                ! Estimate the Monin-Obukov length at height zu
1019              & / (kappa*grav/T_vpot*(T_star*(1.+0.608*q_zu) + 0.608*T_zu*q_star))
1020         !! Stability parameters :
1021         zeta_u  = zu/L  ;  zeta_u = sign( min(abs(zeta_u),10.0), zeta_u )
1022         zeta_t  = zt/L  ;  zeta_t = sign( min(abs(zeta_t),10.0), zeta_t )
1023         zpsi_hu = psi_h(zeta_u)
1024         zpsi_ht = psi_h(zeta_t)
1025         zpsi_m  = psi_m(zeta_u)
1026         !!
1027         !! Shifting the wind speed to 10m and neutral stability : (L & Y eq.(9a))
1028!        U_n10 = dU10/(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - psi_m(zeta_u)))
1029         U_n10 = dU10/(1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m))
1030         !!
1031         !! Shifting temperature and humidity at zu :          (L & Y eq. (9b-9c))
1032!        T_zu = T_zt - T_star/kappa*(log(zt/zu) + psi_h(zeta_u) - psi_h(zeta_t))
1033         T_zu = T_zt - T_star/kappa*(log(zt/zu) + zpsi_hu - zpsi_ht)
1034!        q_zu = q_zt - q_star/kappa*(log(zt/zu) + psi_h(zeta_u) - psi_h(zeta_t))
1035         q_zu = q_zt - q_star/kappa*(log(zt/zu) + zpsi_hu - zpsi_ht)
1036         !!
1037         !! q_zu cannot have a negative value : forcing 0
1038         stab = 0.5 + sign(0.5,q_zu) ;  q_zu = stab*q_zu
1039         !!
1040         !! Updating the neutral 10m transfer coefficients :
1041         Cd_n10  = 1E-3 * (2.7/U_n10 + 0.142 + U_n10/13.09)    ! L & Y eq. (6a)
1042         sqrt_Cd_n10 = sqrt(Cd_n10)
1043         Ce_n10  = 1E-3 * (34.6 * sqrt_Cd_n10)                 ! L & Y eq. (6b)
1044         stab    = 0.5 + sign(0.5,zeta_u)
1045         Ch_n10  = 1E-3*sqrt_Cd_n10*(18.*stab + 32.7*(1-stab)) ! L & Y eq. (6c-6d)
1046         !!
1047         !!
1048         !! Shifting the neutral 10m transfer coefficients to (zu,zeta_u) :
1049!        xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10.) - psi_m(zeta_u))
1050         xct = 1. + sqrt_Cd_n10/kappa*(log(zu/10.) - zpsi_m)
1051         Cd = Cd_n10/(xct*xct) ; sqrt_Cd = sqrt(Cd)
1052         !!
1053!        xlogt = log(zu/10.) - psi_h(zeta_u)
1054         xlogt = log(zu/10.) - zpsi_hu
1055         !!
1056         xct = 1. + Ch_n10*xlogt/kappa/sqrt_Cd_n10
1057         Ch  = Ch_n10*sqrt_Cd/sqrt_Cd_n10/xct
1058         !!
1059         xct = 1. + Ce_n10*xlogt/kappa/sqrt_Cd_n10
1060         Ce  = Ce_n10*sqrt_Cd/sqrt_Cd_n10/xct
1061         !!
1062         !!
1063      END DO
1064      !!
1065     IF( wrk_not_released(2,              14,15,16,17,18,19,          &
1066         &                    20,21,22,23,24,25,26,27,28,29,          &
1067         &                    30,31,32,33,34                )   .OR.  & 
1068         iwrk_not_released(2, 1)                                  )   &
1069         CALL ctl_stop('TURB_CORE_2Z: failed to release workspace arrays')
1070      !
1071    END SUBROUTINE TURB_CORE_2Z
1072
1073
1074    FUNCTION psi_m(zta)   !! Psis, L & Y eq. (8c), (8d), (8e)
1075      !-------------------------------------------------------------------------------
1076      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
1077      USE wrk_nemo, ONLY:     X2 => wrk_2d_35
1078      USE wrk_nemo, ONLY:     X  => wrk_2d_36
1079      USE wrk_nemo, ONLY: stabit => wrk_2d_37
1080      !!
1081      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: zta
1082
1083      REAL(wp), PARAMETER :: pi = 3.141592653589793_wp
1084      REAL(wp), DIMENSION(jpi,jpj)             :: psi_m
1085      !-------------------------------------------------------------------------------
1086
1087      IF( wrk_in_use(2, 35,36,37) ) THEN
1088         CALL ctl_stop('psi_m: requested workspace arrays unavailable')   ;   RETURN
1089      ENDIF
1090
1091      X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.0) ;  X  = sqrt(X2)
1092      stabit    = 0.5 + sign(0.5,zta)
1093      psi_m = -5.*zta*stabit  &                                                          ! Stable
1094         &    + (1. - stabit)*(2*log((1. + X)/2) + log((1. + X2)/2) - 2*atan(X) + pi/2)  ! Unstable
1095
1096      IF( wrk_not_released(2, 35,36,37) )   CALL ctl_stop('psi_m: failed to release workspace arrays')
1097      !
1098    END FUNCTION psi_m
1099
1100
1101    FUNCTION psi_h( zta )    !! Psis, L & Y eq. (8c), (8d), (8e)
1102      !-------------------------------------------------------------------------------
1103      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
1104      USE wrk_nemo, ONLY:     X2 => wrk_2d_35
1105      USE wrk_nemo, ONLY:     X  => wrk_2d_36
1106      USE wrk_nemo, ONLY: stabit => wrk_2d_37
1107      !
1108      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   zta
1109      !
1110      REAL(wp), DIMENSION(jpi,jpj)             ::   psi_h
1111      !-------------------------------------------------------------------------------
1112
1113      IF( wrk_in_use(2, 35,36,37) ) THEN
1114         CALL ctl_stop('psi_h: requested workspace arrays unavailable')   ;   RETURN
1115      ENDIF
1116
1117      X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.) ;  X  = sqrt(X2)
1118      stabit    = 0.5 + sign(0.5,zta)
1119      psi_h = -5.*zta*stabit  &                                       ! Stable
1120         &    + (1. - stabit)*(2.*log( (1. + X2)/2. ))                 ! Unstable
1121
1122      IF( wrk_not_released(2, 35,36,37) )   CALL ctl_stop('psi_h: failed to release workspace arrays')
1123      !
1124    END FUNCTION psi_h
1125
1126#if defined key_orca_r025
1127    INTEGER FUNCTION sbc_blk_core_alloc()
1128      !!----------------------------------------------------------------------
1129      !!                ***  ROUTINE sbc_blk_core_alloc  ***
1130      !!----------------------------------------------------------------------
1131      ALLOCATE( area(jpi,jpj)         , zqlw(jpi,jpj)      ,     &
1132         &      zqsb(jpi,jpj)         , zqla(jpi,jpj)      ,     &
1133         &      zevap(jpi,jpj)        , STAT=sbc_blk_core_alloc )
1134      zqlw=0._wp
1135      zqsb=0._wp
1136   !
1137      IF( lk_mpp            )   CALL mpp_sum ( sbc_blk_core_alloc )
1138      IF( sbc_blk_core_alloc > 0 )   CALL ctl_warn('sbc_blk_core_alloc: allocation of arrays failed')
1139    END FUNCTION sbc_blk_core_alloc
1140#endif
1141
1142    SUBROUTINE Shapiro_1D(rla_varin,id_np, cd_overlap, rlpa_varout) !GIG
1143      !!=====================================================================
1144      !!
1145      !! Description: This function applies a 1D Shapiro filter
1146      !!              (3 points filter) horizontally to a 2D field
1147      !!              in regular grid
1148      !! Arguments :
1149      !!            rla_varin   : Input variable to filter
1150      !!            zla_mask    : Input mask variable
1151      !!            id_np       : Number of Shapiro filter iterations
1152      !!            cd_overlap  : Logical argument for periodical condition
1153      !!                          (global ocean case)
1154      !!            rlpa_varout : Output filtered variable
1155      !!
1156      !! History : 08/2009  S. CAILLEAU : from 1st version of N. FERRY
1157      !!           09/2009  C. REGNIER  : Corrections
1158      !!
1159      !!=====================================================================
1160      IMPLICIT NONE
1161      INTEGER, INTENT(IN)                       :: id_np
1162      REAL(wp), DIMENSION(jpi,jpj), INTENT(IN)  :: rla_varin !GIG
1163      CHARACTER(len=20), INTENT(IN)             :: cd_overlap !GIG
1164      REAL(wp), DIMENSION(jpi,jpj), INTENT(OUT) :: rlpa_varout !GIG
1165
1166      REAL(wp), DIMENSION(jpi,jpj)              :: rlpa_varout_tmp
1167      REAL, PARAMETER                           :: rl_alpha = 1./2.    ! fixed stability coefficient (isotrope case)
1168      REAL, parameter                           :: rap_aniso_diff_XY=2.25 ! anisotrope case
1169      REAL                                      :: alphax,alphay, znum, zden,test
1170      INTEGER                                   :: ji, jj, jn, nn
1171!
1172!! rap_aniso_diff_XY=2.25 : valeur trouvée empiriquement pour 140 itération pour le filtre de Shapiro et
1173!! pour un rapport d'anisotopie de 1.5 : on filtre de plus rapidement en x qu'eny.
1174!------------------------------------------------------------------------------
1175!
1176! Loop on several filter iterations
1177
1178!     Global ocean case
1179      IF (( cd_overlap == 'MERCA_GLOB' )   .OR.   &
1180          ( cd_overlap == 'REGULAR_GLOB' ) .OR.   &
1181          ( cd_overlap == 'ORCA_GLOB' )) THEN
1182             rlpa_varout(:,:) = rla_varin(:,:)
1183             rlpa_varout_tmp(:,:) = rlpa_varout(:,:)
1184!
1185
1186       alphax=1./2.
1187       alphay=1./2.
1188!  Dx/Dy=rap_aniso_diff_XY  , D_ = vitesse de diffusion
1189!  140 passes du fitre, Lx/Ly=1.5, le rap_aniso_diff_XY correspondant est:
1190       IF ( rap_aniso_diff_XY .GE. 1. ) alphay=alphay/rap_aniso_diff_XY
1191       IF ( rap_aniso_diff_XY .LT. 1. ) alphax=alphax*rap_aniso_diff_XY
1192
1193        DO jn = 1,id_np   ! number of passes of the filter
1194            DO ji = 2,jpim1
1195               DO jj = 2,jpjm1
1196                  ! We crop on the coast
1197                   znum = rlpa_varout_tmp(ji,jj)   &
1198                          + 0.25*alphax*(rlpa_varout_tmp(ji-1,jj  )-rlpa_varout_tmp(ji,jj))*tmask(ji-1,jj  ,1)  &
1199                          + 0.25*alphax*(rlpa_varout_tmp(ji+1,jj  )-rlpa_varout_tmp(ji,jj))*tmask(ji+1,jj  ,1)  &
1200                          + 0.25*alphay*(rlpa_varout_tmp(ji  ,jj-1)-rlpa_varout_tmp(ji,jj))*tmask(ji  ,jj-1,1)  &
1201                          + 0.25*alphay*(rlpa_varout_tmp(ji  ,jj+1)-rlpa_varout_tmp(ji,jj))*tmask(ji  ,jj+1,1)
1202                   rlpa_varout(ji,jj)=znum*tmask(ji,jj,1)+rla_varin(ji,jj)*(1.-tmask(ji,jj,1))
1203                ENDDO  ! end loop ji
1204            ENDDO  ! end loop jj
1205!
1206!
1207!           Periodical condition in case of cd_overlap (global ocean)
1208!           - on a mercator projection grid we consider that singular point at poles
1209!             are a mean of the values at points of the previous latitude
1210!           - on ORCA and regular grid we copy the values at points of the previous latitude
1211            IF ( cd_overlap == 'MERCAT_GLOB' ) THEN
1212!GIG case unchecked
1213               rlpa_varout(1,1) = SUM(rlpa_varout(:,2)) / jpi
1214               rlpa_varout(jpi,jpj) = SUM(rlpa_varout(:,jpj-1)) / jpi
1215            ELSE
1216               call lbc_lnk(rlpa_varout, 'T', 1.) ! Boundary condition
1217            ENDIF
1218            rlpa_varout_tmp(:,:) = rlpa_varout(:,:)
1219         ENDDO  ! end loop jn
1220      ENDIF
1221
1222!
1223    END SUBROUTINE Shapiro_1D
1224
1225 
1226   !!======================================================================
1227END MODULE sbcblk_core
Note: See TracBrowser for help on using the repository browser.