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_clio.F90 in trunk/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: trunk/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90 @ 3558

Last change on this file since 3558 was 3558, checked in by rblod, 11 years ago

Fix issues when using key_nosignedzeo, see ticket #996

  • Property svn:keywords set to Id
File size: 53.3 KB
Line 
1MODULE sbcblk_clio
2   !!======================================================================
3   !!                   ***  MODULE  sbcblk_clio  ***
4   !! Ocean forcing:  bulk thermohaline forcing of the ocean (or ice)
5   !!=====================================================================
6   !! History :  OPA  !  1997-06 (Louvain-La-Neuve)  Original code
7   !!                 !  2001-04 (C. Ethe) add flx_blk_declin
8   !!   NEMO     2.0  !  2002-08 (C. Ethe, G. Madec) F90: Free form and module
9   !!            3.0  !  2008-03 (C. Talandier, G. Madec) surface module + LIM3
10   !!            3.2  !  2009-04 (B. Lemaire) Introduce iom_put
11   !!----------------------------------------------------------------------
12
13   !!----------------------------------------------------------------------
14   !!   sbc_blk_clio   : CLIO bulk formulation: read and update required input fields
15   !!   blk_clio_oce   : ocean CLIO bulk formulea: compute momentum, heat and freswater fluxes for the ocean
16   !!   blk_ice_clio   : ice   CLIO bulk formulea: compute momentum, heat and freswater fluxes for the sea-ice
17   !!   blk_clio_qsr_oce : shortwave radiation for ocean computed from the cloud cover
18   !!   blk_clio_qsr_ice : shortwave radiation for ice   computed from the cloud cover
19   !!   flx_blk_declin : solar declinaison
20   !!----------------------------------------------------------------------
21   USE oce             ! ocean dynamics and tracers
22   USE dom_oce         ! ocean space and time domain
23   USE phycst          ! physical constants
24   USE fldread         ! read input fields
25   USE sbc_oce         ! Surface boundary condition: ocean fields
26   USE iom             ! I/O manager library
27   USE in_out_manager  ! I/O manager
28   USE lib_mpp         ! distribued memory computing library
29   USE wrk_nemo        ! work arrays
30   USE timing          ! Timing
31   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
32
33   USE albedo
34   USE prtctl          ! Print control
35   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
36#if defined key_lim3
37   USE ice
38   USE sbc_ice         ! Surface boundary condition: ice fields
39#elif defined key_lim2
40   USE ice_2
41#endif
42
43   IMPLICIT NONE
44   PRIVATE
45
46   PUBLIC sbc_blk_clio        ! routine called by sbcmod.F90
47   PUBLIC blk_ice_clio        ! routine called by sbcice_lim.F90
48
49   INTEGER , PARAMETER ::   jpfld   = 7           ! maximum number of files to read
50   INTEGER , PARAMETER ::   jp_utau = 1           ! index of wind stress (i-component)      (N/m2)    at U-point
51   INTEGER , PARAMETER ::   jp_vtau = 2           ! index of wind stress (j-component)      (N/m2)    at V-point
52   INTEGER , PARAMETER ::   jp_wndm = 3           ! index of 10m wind module                 (m/s)    at T-point
53   INTEGER , PARAMETER ::   jp_humi = 4           ! index of specific humidity               ( - )
54   INTEGER , PARAMETER ::   jp_ccov = 5           ! index of cloud cover                     ( - )
55   INTEGER , PARAMETER ::   jp_tair = 6           ! index of 10m air temperature             (Kelvin)
56   INTEGER , PARAMETER ::   jp_prec = 7           ! index of total precipitation (rain+snow) (Kg/m2/s)
57
58   TYPE(FLD),ALLOCATABLE,DIMENSION(:) :: sf  ! structure of input fields (file informations, fields read)
59
60   INTEGER, PARAMETER  ::   jpintsr = 24          ! number of time step between sunrise and sunset
61   !                                              ! uses for heat flux computation
62   LOGICAL ::   lbulk_init = .TRUE.               ! flag, bulk initialization done or not)
63
64#if ! defined key_lim3                         
65   ! in namicerun with LIM3
66   REAL(wp) ::   cai = 1.40e-3 ! best estimate of atm drag in order to get correct FS export in ORCA2-LIM
67   REAL(wp) ::   cao = 1.00e-3 ! chosen by default  ==> should depends on many things...  !!gmto be updated
68#endif
69
70   REAL(wp) ::   rdtbs2      !:   
71   
72   REAL(wp), DIMENSION(19)  ::  budyko            ! BUDYKO's coefficient (cloudiness effect on LW radiation)
73   DATA budyko / 1.00, 0.98, 0.95, 0.92, 0.89, 0.86, 0.83, 0.80, 0.78, 0.75,   &
74      &          0.72, 0.69, 0.67, 0.64, 0.61, 0.58, 0.56, 0.53, 0.50 /
75   REAL(wp), DIMENSION(20)  :: tauco              ! cloud optical depth coefficient
76   DATA tauco / 6.6, 6.6, 7.0, 7.2, 7.1, 6.8, 6.5, 6.6, 7.1, 7.6,   &
77      &         6.6, 6.1, 5.6, 5.5, 5.8, 5.8, 5.6, 5.6, 5.6, 5.6 /
78   !!
79   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sbudyko      ! cloudiness effect on LW radiation
80   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   stauc        ! cloud optical depth
81   
82   REAL(wp) ::   eps20  = 1.e-20   ! constant values
83   
84   !! * Substitutions
85#  include "vectopt_loop_substitute.h90"
86   !!----------------------------------------------------------------------
87   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
88   !! $Id$
89   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
90   !!----------------------------------------------------------------------
91CONTAINS
92
93   SUBROUTINE sbc_blk_clio( kt )
94      !!---------------------------------------------------------------------
95      !!                    ***  ROUTINE sbc_blk_clio  ***
96      !!                   
97      !! ** Purpose :   provide at each time step the surface ocean fluxes
98      !!      (momentum, heat, freshwater and runoff)
99      !!
100      !! ** Method  : (1) READ each fluxes in NetCDF files:
101      !!      the i-component of the stress                (N/m2)
102      !!      the j-component of the stress                (N/m2)
103      !!      the 10m wind pseed module                    (m/s)
104      !!      the 10m air temperature                      (Kelvin)
105      !!      the 10m specific humidity                    (-)
106      !!      the cloud cover                              (-)
107      !!      the total precipitation (rain+snow)          (Kg/m2/s)
108      !!              (2) CALL blk_oce_clio
109      !!
110      !!      C A U T I O N : never mask the surface stress fields
111      !!                      the stress is assumed to be in the mesh referential
112      !!                      i.e. the (i,j) referential
113      !!
114      !! ** Action  :   defined at each time-step at the air-sea interface
115      !!              - utau, vtau  i- and j-component of the wind stress
116      !!              - taum        wind stress module at T-point
117      !!              - wndm        10m wind module at T-point
118      !!              - qns, qsr    non-slor and solar heat flux
119      !!              - emp, emps   evaporation minus precipitation
120      !!----------------------------------------------------------------------
121      INTEGER, INTENT(in) ::   kt   ! ocean time step
122      !!
123      INTEGER  ::   ifpr, jfpr   ! dummy indices
124      INTEGER  ::   ierr0, ierr1, ierr2, ierr3   ! return error code
125      !!
126      CHARACTER(len=100) ::  cn_dir                            !   Root directory for location of CLIO files
127      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                 ! array of namelist informations on the fields to read
128      TYPE(FLD_N) ::   sn_utau, sn_vtau, sn_wndm, sn_tair      ! informations about the fields to be read
129      TYPE(FLD_N) ::   sn_humi, sn_ccov, sn_prec               !   "                                 "
130      !!
131      NAMELIST/namsbc_clio/ cn_dir, sn_utau, sn_vtau, sn_wndm, sn_humi,   &
132         &                          sn_ccov, sn_tair, sn_prec
133      !!---------------------------------------------------------------------
134
135      !                                         ! ====================== !
136      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
137         !                                      ! ====================== !
138         ! set file information (default values)
139         cn_dir = './'       ! directory in which the model is executed
140
141         ! (NB: frequency positive => hours, negative => months)
142         !            !    file    ! frequency ! variable ! time intep !  clim   ! 'yearly' or ! weights  ! rotation !
143         !            !    name    !  (hours)  !  name    !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs    !
144         sn_utau = FLD_N( 'utau'   ,    24     , 'utau'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       ) 
145         sn_vtau = FLD_N( 'vtau'   ,    24     , 'vtau'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       ) 
146         sn_wndm = FLD_N( 'mwnd10m',    24     , 'm_10'   ,  .true.    , .false. ,   'yearly'  , ''       , ''       ) 
147         sn_tair = FLD_N( 'tair10m',    24     , 't_10'   ,  .false.   , .false. ,   'yearly'  , ''       , ''       ) 
148         sn_humi = FLD_N( 'humi10m',    24     , 'q_10'   ,  .false.   , .false. ,   'yearly'  , ''       , ''       ) 
149         sn_ccov = FLD_N( 'ccover' ,    -1     , 'cloud'  ,  .true.    , .false. ,   'yearly'  , ''       , ''       ) 
150         sn_prec = FLD_N( 'precip' ,    -1     , 'precip' ,  .true.    , .false. ,   'yearly'  , ''       , ''       ) 
151
152         REWIND( numnam )                    ! ... read in namlist namsbc_clio
153         READ  ( numnam, namsbc_clio )
154
155         ! store namelist information in an array
156         slf_i(jp_utau) = sn_utau   ;   slf_i(jp_vtau) = sn_vtau   ;   slf_i(jp_wndm) = sn_wndm
157         slf_i(jp_tair) = sn_tair   ;   slf_i(jp_humi) = sn_humi
158         slf_i(jp_ccov) = sn_ccov   ;   slf_i(jp_prec) = sn_prec
159         
160         ! set sf structure
161         ALLOCATE( sf(jpfld), STAT=ierr0 )
162         IF( ierr0 > 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_clio: unable to allocate sf structure' )
163         DO ifpr= 1, jpfld
164            ALLOCATE( sf(ifpr)%fnow(jpi,jpj,1) , STAT=ierr1)
165            IF( slf_i(ifpr)%ln_tint ) ALLOCATE( sf(ifpr)%fdta(jpi,jpj,1,2) , STAT=ierr2 )
166         END DO
167         IF( ierr1+ierr2 > 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_clio: unable to allocate sf array structure' )
168         ! fill sf with slf_i and control print
169         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_clio', 'flux formulation for ocean surface boundary condition', 'namsbc_clio' )
170         
171         ! allocate sbcblk clio arrays
172         ALLOCATE( sbudyko(jpi,jpj) , stauc(jpi,jpj), STAT=ierr3 )
173         IF( ierr3 > 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_clio: unable to allocate arrays' )
174         !
175      ENDIF
176      !                                         ! ====================== !
177      !                                         !    At each time-step   !
178      !                                         ! ====================== !
179      !
180      CALL fld_read( kt, nn_fsbc, sf )                ! input fields provided at the current time-step
181      !
182      IF( MOD( kt - 1, nn_fsbc ) == 0 )   CALL blk_oce_clio( sf, sst_m )
183      !
184   END SUBROUTINE sbc_blk_clio
185
186
187   SUBROUTINE blk_oce_clio( sf, pst )
188      !!---------------------------------------------------------------------------
189      !!                     ***  ROUTINE blk_oce_clio  ***
190      !!                 
191      !!  ** Purpose :   Compute momentum, heat and freshwater fluxes at ocean surface
192      !!               using CLIO bulk formulea
193      !!         
194      !!  ** Method  :   The flux of heat at the ocean surfaces are derived
195      !!       from semi-empirical ( or bulk ) formulae which relate the flux to
196      !!       the properties of the surface and of the lower atmosphere. Here, we
197      !!       follow the work of Oberhuber, 1988   
198      !!               - momentum flux (stresses) directly read in files at U- and V-points
199      !!               - compute ocean/ice albedos (call albedo_oce/albedo_ice) 
200      !!               - compute shortwave radiation for ocean (call blk_clio_qsr_oce)
201      !!               - compute long-wave radiation for the ocean
202      !!               - compute the turbulent heat fluxes over the ocean
203      !!               - deduce the evaporation over the ocean
204      !!  ** Action  :   Fluxes over the ocean:
205      !!               - utau, vtau  i- and j-component of the wind stress
206      !!               - taum        wind stress module at T-point
207      !!               - wndm        10m wind module at T-point
208      !!               - qns, qsr    non-slor and solar heat flux
209      !!               - emp, emps   evaporation minus precipitation
210      !!  ** Nota    :   sf has to be a dummy argument for AGRIF on NEC
211      !!----------------------------------------------------------------------
212      TYPE(fld), INTENT(in), DIMENSION(:)       ::   sf    ! input data
213      REAL(wp) , INTENT(in), DIMENSION(jpi,jpj) ::   pst   ! surface temperature                      [Celcius]
214      !!
215      INTEGER  ::   ji, jj   ! dummy loop indices
216      !!
217      REAL(wp) ::   zrhova, zcsho, zcleo, zcldeff               ! temporary scalars
218      REAL(wp) ::   zqsato, zdteta, zdeltaq, ztvmoy, zobouks    !    -         -
219      REAL(wp) ::   zpsims, zpsihs, zpsils, zobouku, zxins, zpsimu   !    -         -
220      REAL(wp) ::   zpsihu, zpsilu, zstab,zpsim, zpsih, zpsil   !    -         -
221      REAL(wp) ::   zvatmg, zcmn, zchn, zcln, zcmcmn, zdenum    !    -         -
222      REAL(wp) ::   zdtetar, ztvmoyr, zlxins, zchcm, zclcm      !    -         -
223      REAL(wp) ::   zmt1, zmt2, zmt3, ztatm3, ztamr, ztaevbk    !    -         -
224      REAL(wp) ::   zsst, ztatm, zcco1, zpatm, zcmax, zrmax     !    -         -
225      REAL(wp) ::   zrhoa, zev, zes, zeso, zqatm, zevsqr        !    -         -
226      REAL(wp) ::   ztx2, zty2                                  !    -         -
227      REAL(wp), POINTER, DIMENSION(:,:) ::   zqlw        ! long-wave heat flux over ocean
228      REAL(wp), POINTER, DIMENSION(:,:) ::   zqla        ! latent heat flux over ocean
229      REAL(wp), POINTER, DIMENSION(:,:) ::   zqsb        ! sensible heat flux over ocean
230      !!---------------------------------------------------------------------
231      !
232      IF( nn_timing == 1 )  CALL timing_start('blk_oce_clio')
233      !
234      CALL wrk_alloc( jpi,jpj, zqlw, zqla, zqsb )
235
236      zpatm = 101000._wp      ! atmospheric pressure  (assumed constant here)
237
238      !------------------------------------!
239      !   momentum fluxes  (utau, vtau )   !
240      !------------------------------------!
241!CDIR COLLAPSE
242      utau(:,:) = sf(jp_utau)%fnow(:,:,1)
243!CDIR COLLAPSE
244      vtau(:,:) = sf(jp_vtau)%fnow(:,:,1)
245
246      !------------------------------------!
247      !   wind stress module (taum )       !
248      !------------------------------------!
249!CDIR NOVERRCHK
250      DO jj = 2, jpjm1
251!CDIR NOVERRCHK
252         DO ji = fs_2, fs_jpim1   ! vector opt.
253            ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
254            zty2 = vtau(ji  ,jj-1) + vtau(ji,jj)
255            taum(ji,jj) = 0.5 * SQRT( ztx2 * ztx2 + zty2 * zty2 )
256         END DO
257      END DO
258      CALL lbc_lnk( taum, 'T', 1. )
259
260      !------------------------------------!
261      !   store the wind speed  (wndm )    !
262      !------------------------------------!
263!CDIR COLLAPSE
264      wndm(:,:) = sf(jp_wndm)%fnow(:,:,1)
265
266      !------------------------------------------------!
267      !   Shortwave radiation for ocean and snow/ice   !
268      !------------------------------------------------!
269     
270      CALL blk_clio_qsr_oce( qsr )
271
272      !------------------------!
273      !   Other ocean fluxes   !
274      !------------------------!
275!CDIR NOVERRCHK
276!CDIR COLLAPSE
277      DO jj = 1, jpj
278!CDIR NOVERRCHK
279         DO ji = 1, jpi
280            !
281            zsst  = pst(ji,jj)              + rt0           ! converte Celcius to Kelvin the SST
282            ztatm = sf(jp_tair)%fnow(ji,jj,1)               ! and set minimum value far above 0 K (=rt0 over land)
283            zcco1 = 1.0 - sf(jp_ccov)%fnow(ji,jj,1)         ! fraction of clear sky ( 1 - cloud cover)
284            zrhoa = zpatm / ( 287.04 * ztatm )              ! air density (equation of state for dry air)
285            ztamr = ztatm - rtt                             ! Saturation water vapour
286            zmt1  = SIGN( 17.269,  ztamr )                  !           ||
287            zmt2  = SIGN( 21.875,  ztamr )                  !          \  /
288            zmt3  = SIGN( 28.200, -ztamr )                  !           \/
289            zes   = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 ) / ( ztatm - 35.86  + MAX( 0.e0, zmt3 ) )  )
290            zev    = sf(jp_humi)%fnow(ji,jj,1) * zes        ! vapour pressure 
291            zevsqr = SQRT( zev * 0.01 )                     ! square-root of vapour pressure
292            zqatm = 0.622 * zev / ( zpatm - 0.378 * zev )   ! specific humidity
293
294            !--------------------------------------!
295            !  long-wave radiation over the ocean  !  ( Berliand 1952 ; all latitudes )
296            !--------------------------------------!
297            ztatm3  = ztatm * ztatm * ztatm
298            zcldeff = 1.0 - sbudyko(ji,jj) * sf(jp_ccov)%fnow(ji,jj,1) * sf(jp_ccov)%fnow(ji,jj,1)   
299            ztaevbk = ztatm * ztatm3 * zcldeff * ( 0.39 - 0.05 * zevsqr ) 
300            !
301            zqlw(ji,jj) = - emic * stefan * ( ztaevbk + 4. * ztatm3 * ( zsst - ztatm ) ) 
302
303            !--------------------------------------------------
304            !  Latent and sensible heat fluxes over the ocean
305            !--------------------------------------------------
306            !                                                          ! vapour pressure at saturation of ocean
307            zeso =  611.0 * EXP ( 17.2693884 * ( zsst - rtt ) * tmask(ji,jj,1) / ( zsst - 35.86 ) )
308
309            zqsato = ( 0.622 * zeso ) / ( zpatm - 0.378 * zeso )       ! humidity close to the ocean surface (at saturation)
310
311            ! Drag coefficients from Large and Pond (1981,1982)
312            !                                                          ! Stability parameters
313            zdteta  = zsst - ztatm
314            zdeltaq = zqatm - zqsato
315            ztvmoy  = ztatm * ( 1. + 2.2e-3 * ztatm * zqatm )
316            zdenum  = MAX( sf(jp_wndm)%fnow(ji,jj,1) * sf(jp_wndm)%fnow(ji,jj,1) * ztvmoy, eps20 )
317            zdtetar = zdteta / zdenum
318            ztvmoyr = ztvmoy * ztvmoy * zdeltaq / zdenum
319            !                                                          ! case of stable atmospheric conditions
320            zobouks = -70.0 * 10. * ( zdtetar + 3.2e-3 * ztvmoyr )
321            zobouks = MAX( 0.e0, zobouks )
322            zpsims = -7.0 * zobouks
323            zpsihs =  zpsims
324            zpsils =  zpsims
325            !                                                          ! case of unstable atmospheric conditions
326            zobouku = MIN(  0.e0, -100.0 * 10.0 * ( zdtetar + 2.2e-3 * ztvmoyr )  )
327            zxins   = ( 1. - 16. * zobouku )**0.25
328            zlxins  = LOG( ( 1. + zxins * zxins ) / 2. )
329            zpsimu  = 2. * LOG( ( 1 + zxins ) * 0.5 )  + zlxins - 2. * ATAN( zxins ) + rpi * 0.5
330            zpsihu  = 2. * zlxins
331            zpsilu  = zpsihu
332            !                                                          ! intermediate values
333            zstab   = MAX( 0.e0, SIGN( 1.e0, zdteta ) )
334            zpsim   = zstab * zpsimu + ( 1.0 - zstab ) * zpsims
335            zpsih   = zstab * zpsihu + ( 1.0 - zstab ) * zpsihs
336            zpsil   = zpsih
337           
338            zvatmg         = MAX( 0.032 * 1.5e-3 * sf(jp_wndm)%fnow(ji,jj,1) * sf(jp_wndm)%fnow(ji,jj,1) / grav, eps20 )
339            zcmn           = vkarmn / LOG ( 10. / zvatmg )
340            zchn           = 0.0327 * zcmn
341            zcln           = 0.0346 * zcmn
342            zcmcmn         = 1. / ( 1. - zcmn * zpsim / vkarmn )
343            ! sometimes the ratio zchn * zpsih / ( vkarmn * zcmn ) is too close to 1 and zchcm becomes very very big
344            zcmax = 0.1               ! choice for maximum value of the heat transfer coefficient, guided by my intuition
345            zrmax = 1 - 3.e-4 / zcmax ! maximum value of the ratio
346            zchcm = zcmcmn / ( 1. - MIN ( zchn * zpsih / ( vkarmn * zcmn ) , zrmax ) )
347            zclcm          = zchcm
348            !                                                          ! transfert coef. (Large and Pond 1981,1982)
349            zcsho          = zchn * zchcm                               
350            zcleo          = zcln * zclcm 
351
352            zrhova         = zrhoa * sf(jp_wndm)%fnow(ji,jj,1)
353
354            ! sensible heat flux
355            zqsb(ji,jj) = zrhova * zcsho * 1004.0  * ( zsst - ztatm ) 
356         
357            ! latent heat flux (bounded by zero)
358            zqla(ji,jj) = MAX(  0.e0, zrhova * zcleo * 2.5e+06 * ( zqsato - zqatm )  )
359            !               
360         END DO
361      END DO
362     
363      ! ----------------------------------------------------------------------------- !
364      !     III    Total FLUXES                                                       !
365      ! ----------------------------------------------------------------------------- !
366
367!CDIR COLLAPSE
368      emp (:,:) = zqla(:,:) / cevap - sf(jp_prec)%fnow(:,:,1) / rday * tmask(:,:,1)
369      qns (:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)         ! Downward Non Solar flux
370      emps(:,:) = emp(:,:)
371      !
372      CALL iom_put( "qlw_oce",   zqlw )   ! output downward longwave  heat over the ocean
373      CALL iom_put( "qsb_oce", - zqsb )   ! output downward sensible  heat over the ocean
374      CALL iom_put( "qla_oce", - zqla )   ! output downward latent    heat over the ocean
375      CALL iom_put( "qns_oce",   qns  )   ! output downward non solar heat over the ocean
376
377      IF(ln_ctl) THEN
378         CALL prt_ctl(tab2d_1=zqsb , clinfo1=' blk_oce_clio: zqsb   : ', tab2d_2=zqlw , clinfo2=' zqlw  : ')
379         CALL prt_ctl(tab2d_1=zqla , clinfo1=' blk_oce_clio: zqla   : ', tab2d_2=qsr  , clinfo2=' qsr   : ')
380         CALL prt_ctl(tab2d_1=pst  , clinfo1=' blk_oce_clio: pst    : ', tab2d_2=emp  , clinfo2=' emp   : ')
381         CALL prt_ctl(tab2d_1=utau , clinfo1=' blk_oce_clio: utau   : ', mask1=umask,   &
382            &         tab2d_2=vtau , clinfo2=' vtau : ', mask2=vmask )
383      ENDIF
384
385      CALL wrk_dealloc( jpi,jpj, zqlw, zqla, zqsb )
386      !
387      IF( nn_timing == 1 )  CALL timing_stop('blk_oce_clio')
388      !
389   END SUBROUTINE blk_oce_clio
390
391
392   SUBROUTINE blk_ice_clio(  pst   , palb_cs, palb_os ,       &
393      &                      p_taui, p_tauj, p_qns , p_qsr,   &
394      &                      p_qla , p_dqns, p_dqla,          &
395      &                      p_tpr , p_spr ,                  &
396      &                      p_fr1 , p_fr2 , cd_grid, pdim  )
397      !!---------------------------------------------------------------------------
398      !!                     ***  ROUTINE blk_ice_clio  ***
399      !!                 
400      !!  ** Purpose :   Computation of the heat fluxes at ocean and snow/ice
401      !!       surface the solar heat at ocean and snow/ice surfaces and the
402      !!       sensitivity of total heat fluxes to the SST variations
403      !!         
404      !!  ** Method  :   The flux of heat at the ice and ocean surfaces are derived
405      !!       from semi-empirical ( or bulk ) formulae which relate the flux to
406      !!       the properties of the surface and of the lower atmosphere. Here, we
407      !!       follow the work of Oberhuber, 1988   
408      !!
409      !!  ** Action  :   call albedo_oce/albedo_ice to compute ocean/ice albedo
410      !!          computation of snow precipitation
411      !!          computation of solar flux at the ocean and ice surfaces
412      !!          computation of the long-wave radiation for the ocean and sea/ice
413      !!          computation of turbulent heat fluxes over water and ice
414      !!          computation of evaporation over water
415      !!          computation of total heat fluxes sensitivity over ice (dQ/dT)
416      !!          computation of latent heat flux sensitivity over ice (dQla/dT)
417      !!
418      !!----------------------------------------------------------------------
419      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   pst      ! ice surface temperature                   [Kelvin]
420      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   palb_cs  ! ice albedo (clear    sky) (alb_ice_cs)         [%]
421      REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   palb_os  ! ice albedo (overcast sky) (alb_ice_os)         [%]
422      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_taui   ! surface ice stress at I-point (i-component) [N/m2]
423      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_tauj   ! surface ice stress at I-point (j-component) [N/m2]
424      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_qns    ! non solar heat flux over ice (T-point)      [W/m2]
425      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_qsr    !     solar heat flux over ice (T-point)      [W/m2]
426      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_qla    ! latent    heat flux over ice (T-point)      [W/m2]
427      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_dqns   ! non solar heat sensistivity  (T-point)      [W/m2]
428      REAL(wp), INTENT(  out), DIMENSION(:,:,:)   ::   p_dqla   ! latent    heat sensistivity  (T-point)      [W/m2]
429      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_tpr    ! total precipitation          (T-point)   [Kg/m2/s]
430      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_spr    ! solid precipitation          (T-point)   [Kg/m2/s]
431      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_fr1    ! 1sr fraction of qsr penetration in ice         [%]
432      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   p_fr2    ! 2nd fraction of qsr penetration in ice         [%]
433      CHARACTER(len=1), INTENT(in   )             ::   cd_grid  ! type of sea-ice grid ("C" or "B" grid)
434      INTEGER, INTENT(in   )                      ::   pdim     ! number of ice categories
435      !!
436      INTEGER  ::   ji, jj, jl    ! dummy loop indices
437      INTEGER  ::   ijpl          ! number of ice categories (size of 3rd dim of input arrays)
438      !!
439      REAL(wp) ::   zcoef, zmt1, zmt2, zmt3, ztatm3     ! temporary scalars
440      REAL(wp) ::   ztaevbk, zind1, zind2, zind3, ztamr         !    -         -
441      REAL(wp) ::   zesi, zqsati, zdesidt                       !    -         -
442      REAL(wp) ::   zdqla, zcldeff, zev, zes, zpatm, zrhova     !    -         -
443      REAL(wp) ::   zcshi, zclei, zrhovaclei, zrhovacshi        !    -         -
444      REAL(wp) ::   ztice3, zticemb, zticemb2, zdqlw, zdqsb     !    -         -
445      !!
446      REAL(wp), DIMENSION(:,:)  , POINTER ::   ztatm   ! Tair in Kelvin
447      REAL(wp), DIMENSION(:,:)  , POINTER ::   zqatm   ! specific humidity
448      REAL(wp), DIMENSION(:,:)  , POINTER ::   zevsqr  ! vapour pressure square-root
449      REAL(wp), DIMENSION(:,:)  , POINTER ::   zrhoa   ! air density
450      REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qlw, z_qsb
451      !!---------------------------------------------------------------------
452      !
453      IF( nn_timing == 1 )  CALL timing_start('blk_ice_clio')
454      !
455      CALL wrk_alloc( jpi,jpj, ztatm, zqatm, zevsqr, zrhoa )
456      CALL wrk_alloc( jpi,jpj,pdim, z_qlw, z_qsb )
457
458      ijpl  = pdim                           ! number of ice categories
459      zpatm = 101000.                        ! atmospheric pressure  (assumed constant  here)
460
461#if defined key_lim3     
462      tatm_ice(:,:) = sf(jp_tair)%fnow(:,:,1)   ! LIM3: make Tair available in sea-ice. WARNING allocated after call to ice_init
463#endif
464      !                                                        ! surface ocean fluxes computed with CLIO bulk formulea
465      !------------------------------------!
466      !   momentum fluxes  (utau, vtau )   !
467      !------------------------------------!
468
469      SELECT CASE( cd_grid )
470      CASE( 'C' )                          ! C-grid ice dynamics
471         zcoef  = cai / cao                         ! Change from air-sea stress to air-ice stress
472         p_taui(:,:) = zcoef * utau(:,:)
473         p_tauj(:,:) = zcoef * vtau(:,:)
474      CASE( 'I' )                          ! I-grid ice dynamics:  I-point (i.e. F-point lower-left corner)
475         zcoef  = 0.5_wp * cai / cao                ! Change from air-sea stress to air-ice stress
476         DO jj = 2, jpj         ! stress from ocean U- and V-points to ice U,V point
477            DO ji = 2, jpi   ! I-grid : no vector opt.
478               p_taui(ji,jj) = zcoef * ( utau(ji-1,jj  ) + utau(ji-1,jj-1) )
479               p_tauj(ji,jj) = zcoef * ( vtau(ji  ,jj-1) + vtau(ji-1,jj-1) )
480            END DO
481         END DO
482         CALL lbc_lnk( p_taui(:,:), 'I', -1. )   ;   CALL lbc_lnk( p_tauj(:,:), 'I', -1. )   ! I-point
483      END SELECT
484
485
486      !  Determine cloud optical depths as a function of latitude (Chou et al., 1981).
487      !  and the correction factor for taking into account  the effect of clouds
488      !------------------------------------------------------
489!CDIR NOVERRCHK
490!CDIR COLLAPSE
491      DO jj = 1, jpj
492!CDIR NOVERRCHK
493         DO ji = 1, jpi
494            ztatm (ji,jj) = sf(jp_tair)%fnow(ji,jj,1)                ! air temperature in Kelvins
495     
496            zrhoa(ji,jj) = zpatm / ( 287.04 * ztatm(ji,jj) )         ! air density (equation of state for dry air)
497     
498            ztamr = ztatm(ji,jj) - rtt                               ! Saturation water vapour
499            zmt1  = SIGN( 17.269,  ztamr )
500            zmt2  = SIGN( 21.875,  ztamr )
501            zmt3  = SIGN( 28.200, -ztamr )
502            zes   = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &
503               &                / ( ztatm(ji,jj) - 35.86  + MAX( 0.e0, zmt3 ) )  )
504
505            zev = sf(jp_humi)%fnow(ji,jj,1) * zes                    ! vapour pressure 
506            zevsqr(ji,jj) = SQRT( zev * 0.01 )                       ! square-root of vapour pressure
507            zqatm(ji,jj) = 0.622 * zev / ( zpatm - 0.378 * zev )     ! specific humidity
508
509            !----------------------------------------------------
510            !   Computation of snow precipitation (Ledley, 1985) |
511            !----------------------------------------------------
512            zmt1  =   253.0 - ztatm(ji,jj)            ;   zind1 = MAX( 0.e0, SIGN( 1.e0, zmt1 ) )
513            zmt2  = ( 272.0 - ztatm(ji,jj) ) / 38.0   ;   zind2 = MAX( 0.e0, SIGN( 1.e0, zmt2 ) )
514            zmt3  = ( 281.0 - ztatm(ji,jj) ) / 18.0   ;   zind3 = MAX( 0.e0, SIGN( 1.e0, zmt3 ) )
515            p_spr(ji,jj) = sf(jp_prec)%fnow(ji,jj,1) / rday   &      ! rday = converte mm/day to kg/m2/s
516               &         * (          zind1      &                   ! solid  (snow) precipitation [kg/m2/s]
517               &            + ( 1.0 - zind1 ) * (          zind2   * ( 0.5 + zmt2 )   &
518               &                                 + ( 1.0 - zind2 ) *  zind3 * zmt3  )   ) 
519
520            !----------------------------------------------------!
521            !  fraction of net penetrative shortwave radiation   !
522            !----------------------------------------------------!
523            ! fraction of qsr_ice which is NOT absorbed in the thin surface layer
524            ! and thus which penetrates inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
525            p_fr1(ji,jj) = 0.18  * ( 1.e0 - sf(jp_ccov)%fnow(ji,jj,1) ) + 0.35 * sf(jp_ccov)%fnow(ji,jj,1) 
526            p_fr2(ji,jj) = 0.82  * ( 1.e0 - sf(jp_ccov)%fnow(ji,jj,1) ) + 0.65 * sf(jp_ccov)%fnow(ji,jj,1)
527         END DO
528      END DO
529      CALL iom_put( 'snowpre', p_spr )   ! Snow precipitation
530     
531      !-----------------------------------------------------------!
532      !  snow/ice Shortwave radiation   (abedo already computed)  !
533      !-----------------------------------------------------------!
534      CALL blk_clio_qsr_ice( palb_cs, palb_os, p_qsr )
535
536      !                                     ! ========================== !
537      DO jl = 1, ijpl                       !  Loop over ice categories  !
538         !                                  ! ========================== !
539!CDIR NOVERRCHK
540!CDIR COLLAPSE
541         DO jj = 1 , jpj
542!CDIR NOVERRCHK
543            DO ji = 1, jpi
544               !-------------------------------------------!
545               !  long-wave radiation over ice categories  !  ( Berliand 1952 ; all latitudes )
546               !-------------------------------------------!
547               ztatm3  = ztatm(ji,jj) * ztatm(ji,jj) * ztatm(ji,jj)
548               zcldeff = 1.0 - sbudyko(ji,jj) * sf(jp_ccov)%fnow(ji,jj,1) * sf(jp_ccov)%fnow(ji,jj,1)   
549               ztaevbk = ztatm3 * ztatm(ji,jj) * zcldeff * ( 0.39 - 0.05 * zevsqr(ji,jj) ) 
550               !
551               z_qlw(ji,jj,jl) = - emic * stefan * ( ztaevbk + 4. * ztatm3 * ( pst(ji,jj,jl) - ztatm(ji,jj) ) ) 
552
553               !----------------------------------------
554               !  Turbulent heat fluxes over snow/ice     ( Latent and sensible )
555               !----------------------------------------       
556
557               ! vapour pressure at saturation of ice (tmask to avoid overflow in the exponential)
558               zesi =  611.0 * EXP( 21.8745587 * tmask(ji,jj,1) * ( pst(ji,jj,jl) - rtt )/ ( pst(ji,jj,jl) - 7.66 ) )
559               ! humidity close to the ice surface (at saturation)
560               zqsati   = ( 0.622 * zesi ) / ( zpatm - 0.378 * zesi )
561               
562               !  computation of intermediate values
563               zticemb  = pst(ji,jj,jl) - 7.66
564               zticemb2 = zticemb * zticemb 
565               ztice3   = pst(ji,jj,jl) * pst(ji,jj,jl) * pst(ji,jj,jl)
566               zdesidt  = zesi * ( 9.5 * LOG( 10.0 ) * ( rtt - 7.66 )  / zticemb2 )
567               
568               !  Transfer cofficients assumed to be constant (Parkinson 1979 ; Maykut 1982)
569               zcshi    = 1.75e-03
570               zclei    = zcshi
571               
572               !  sensible and latent fluxes over ice
573               zrhova     = zrhoa(ji,jj) * sf(jp_wndm)%fnow(ji,jj,1)      ! computation of intermediate values
574               zrhovaclei = zrhova * zcshi * 2.834e+06
575               zrhovacshi = zrhova * zclei * 1004.0
576           
577               !  sensible heat flux
578               z_qsb(ji,jj,jl) = zrhovacshi * ( pst(ji,jj,jl) - ztatm(ji,jj) )
579           
580               !  latent heat flux
581               p_qla(ji,jj,jl) = MAX(  0.e0, zrhovaclei * ( zqsati - zqatm(ji,jj) )  )
582             
583               !  sensitivity of non solar fluxes (dQ/dT) (long-wave, sensible and latent fluxes)
584               zdqlw = 4.0 * emic * stefan * ztice3
585               zdqsb = zrhovacshi
586               zdqla = zrhovaclei * ( zdesidt * ( zqsati * zqsati / ( zesi * zesi ) ) * ( zpatm / 0.622 ) )   
587               !
588               p_dqla(ji,jj,jl) = zdqla                           ! latent flux sensitivity
589               p_dqns(ji,jj,jl) = -( zdqlw + zdqsb + zdqla )      !  total non solar sensitivity
590            END DO
591            !
592         END DO
593         !
594      END DO
595      !
596      ! ----------------------------------------------------------------------------- !
597      !    Total FLUXES                                                       !
598      ! ----------------------------------------------------------------------------- !
599      !
600!CDIR COLLAPSE
601      p_qns(:,:,:) = z_qlw (:,:,:) - z_qsb (:,:,:) - p_qla (:,:,:)      ! Downward Non Solar flux
602!CDIR COLLAPSE
603      p_tpr(:,:)   = sf(jp_prec)%fnow(:,:,1) / rday                     ! total precipitation [kg/m2/s]
604      !
605!!gm : not necessary as all input data are lbc_lnk...
606      CALL lbc_lnk( p_fr1  (:,:) , 'T', 1. )
607      CALL lbc_lnk( p_fr2  (:,:) , 'T', 1. )
608      DO jl = 1, ijpl
609         CALL lbc_lnk( p_qns (:,:,jl) , 'T', 1. )
610         CALL lbc_lnk( p_dqns(:,:,jl) , 'T', 1. )
611         CALL lbc_lnk( p_qla (:,:,jl) , 'T', 1. )
612         CALL lbc_lnk( p_dqla(:,:,jl) , 'T', 1. )
613      END DO
614
615!!gm : mask is not required on forcing
616      DO jl = 1, ijpl
617         p_qns (:,:,jl) = p_qns (:,:,jl) * tmask(:,:,1)
618         p_qla (:,:,jl) = p_qla (:,:,jl) * tmask(:,:,1)
619         p_dqns(:,:,jl) = p_dqns(:,:,jl) * tmask(:,:,1)
620         p_dqla(:,:,jl) = p_dqla(:,:,jl) * tmask(:,:,1)
621      END DO
622
623      IF(ln_ctl) THEN
624         CALL prt_ctl(tab3d_1=z_qsb  , clinfo1=' blk_ice_clio: z_qsb  : ', tab3d_2=z_qlw  , clinfo2=' z_qlw  : ', kdim=ijpl)
625         CALL prt_ctl(tab3d_1=p_qla  , clinfo1=' blk_ice_clio: z_qla  : ', tab3d_2=p_qsr  , clinfo2=' p_qsr  : ', kdim=ijpl)
626         CALL prt_ctl(tab3d_1=p_dqns , clinfo1=' blk_ice_clio: p_dqns : ', tab3d_2=p_qns  , clinfo2=' p_qns  : ', kdim=ijpl)
627         CALL prt_ctl(tab3d_1=p_dqla , clinfo1=' blk_ice_clio: p_dqla : ', tab3d_2=pst    , clinfo2=' pst    : ', kdim=ijpl)
628         CALL prt_ctl(tab2d_1=p_tpr  , clinfo1=' blk_ice_clio: p_tpr  : ', tab2d_2=p_spr  , clinfo2=' p_spr  : ')
629         CALL prt_ctl(tab2d_1=p_taui , clinfo1=' blk_ice_clio: p_taui : ', tab2d_2=p_tauj , clinfo2=' p_tauj : ')
630      ENDIF
631
632      CALL wrk_dealloc( jpi,jpj, ztatm, zqatm, zevsqr, zrhoa )
633      CALL wrk_dealloc( jpi,jpj,pdim, z_qlw, z_qsb )
634      !
635      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_clio')
636      !
637   END SUBROUTINE blk_ice_clio
638
639
640   SUBROUTINE blk_clio_qsr_oce( pqsr_oce )
641      !!---------------------------------------------------------------------------
642      !!                     ***  ROUTINE blk_clio_qsr_oce  ***
643      !!                 
644      !!  ** Purpose :   Computation of the shortwave radiation at the ocean and the
645      !!               snow/ice surfaces.
646      !!         
647      !!  ** Method  : - computed qsr from the cloud cover for both ice and ocean
648      !!               - also initialise sbudyko and stauc once for all
649      !!----------------------------------------------------------------------
650      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)     ::   pqsr_oce    ! shortwave radiation  over the ocean
651      !!
652      INTEGER, PARAMETER  ::   jp24 = 24   ! sampling of the daylight period (sunrise to sunset) into 24 equal parts
653      !!     
654      INTEGER  ::   ji, jj, jt    ! dummy loop indices
655      INTEGER  ::   indaet            !  = -1, 0, 1 for odd, normal and leap years resp.
656      INTEGER  ::   iday              ! integer part of day
657      INTEGER  ::   indxb, indxc      ! index for cloud depth coefficient
658
659      REAL(wp)  ::   zalat , zclat, zcmue, zcmue2    ! local scalars
660      REAL(wp)  ::   zmt1, zmt2, zmt3                !
661      REAL(wp)  ::   zdecl, zsdecl , zcdecl          !
662      REAL(wp)  ::   za_oce, ztamr                   !
663
664      REAL(wp) ::   zdl, zlha                        ! local scalars
665      REAL(wp) ::   zlmunoon, zcldcor, zdaycor       !   
666      REAL(wp) ::   zxday, zdist, zcoef, zcoef1      !
667      REAL(wp) ::   zes
668     
669      REAL(wp), DIMENSION(:,:), POINTER ::   zev          ! vapour pressure
670      REAL(wp), DIMENSION(:,:), POINTER ::   zdlha, zlsrise, zlsset     ! 2D workspace
671      REAL(wp), DIMENSION(:,:), POINTER ::   zps, zpc   ! sine (cosine) of latitude per sine (cosine) of solar declination
672      !!---------------------------------------------------------------------
673      !
674      IF( nn_timing == 1 )  CALL timing_start('blk_clio_qsr_oce')
675      !
676      CALL wrk_alloc( jpi,jpj, zev, zdlha, zlsrise, zlsset, zps, zpc )
677
678      IF( lbulk_init ) THEN             !   Initilization at first time step only
679         rdtbs2 = nn_fsbc * rdt * 0.5
680         ! cloud optical depths as a function of latitude (Chou et al., 1981).
681         ! and the correction factor for taking into account  the effect of clouds
682         DO jj = 1, jpj
683            DO ji = 1 , jpi
684               zalat          = ( 90.e0 - ABS( gphit(ji,jj) ) ) /  5.e0
685               zclat          = ( 95.e0 -      gphit(ji,jj)   ) / 10.e0
686               indxb          = 1 + INT( zalat )
687               indxc          = 1 + INT( zclat )
688               zdl            = zclat - INT( zclat )
689               !  correction factor to account for the effect of clouds
690               sbudyko(ji,jj) = budyko(indxb)
691               stauc  (ji,jj) = ( 1.e0 - zdl ) * tauco( indxc ) + zdl * tauco( indxc + 1 )
692            END DO
693         END DO
694         lbulk_init = .FALSE.
695      ENDIF
696
697
698      ! Saturated water vapour and vapour pressure
699      ! ------------------------------------------
700!CDIR NOVERRCHK
701!CDIR COLLAPSE
702      DO jj = 1, jpj
703!CDIR NOVERRCHK
704         DO ji = 1, jpi
705            ztamr = sf(jp_tair)%fnow(ji,jj,1) - rtt
706            zmt1  = SIGN( 17.269,  ztamr )
707            zmt2  = SIGN( 21.875,  ztamr )
708            zmt3  = SIGN( 28.200, -ztamr )
709            zes = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &              ! Saturation water vapour
710               &                     / ( sf(jp_tair)%fnow(ji,jj,1) - 35.86  + MAX( 0.e0, zmt3 ) )  )
711            zev(ji,jj) = sf(jp_humi)%fnow(ji,jj,1) * zes * 1.0e-05                 ! vapour pressure 
712         END DO
713      END DO
714
715      !-----------------------------------!
716      !  Computation of solar irradiance  !
717      !-----------------------------------!
718!!gm : hard coded  leap year ???
719      indaet   = 1                                    ! = -1, 0, 1 for odd, normal and leap years resp.
720      zxday = nday_year + rdtbs2 / rday               ! day of the year at which the fluxes are calculated
721      iday  = INT( zxday )                            ! (centred at the middle of the ice time step)
722      CALL flx_blk_declin( indaet, iday, zdecl )      ! solar declination of the current day
723      zsdecl = SIN( zdecl * rad )                     ! its sine
724      zcdecl = COS( zdecl * rad )                     ! its cosine
725
726
727      !  correction factor added for computation of shortwave flux to take into account the variation of
728      !  the distance between the sun and the earth during the year (Oberhuber 1988)
729      zdist    = zxday * 2. * rpi / REAL(nyear_len(1), wp)
730      zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
731
732!CDIR NOVERRCHK
733      DO jj = 1, jpj
734!CDIR NOVERRCHK
735         DO ji = 1, jpi
736            !  product of sine (cosine) of latitude and sine (cosine) of solar declination
737            zps(ji,jj) = SIN( gphit(ji,jj) * rad ) * zsdecl
738            zpc(ji,jj) = COS( gphit(ji,jj) * rad ) * zcdecl
739            !  computation of the both local time of sunrise and sunset
740            zlsrise(ji,jj) = ACOS( - SIGN( 1.e0, zps(ji,jj) )    &
741               &                   * MIN(  1.e0, SIGN( 1.e0, zps(ji,jj) ) * ( zps(ji,jj) / zpc(ji,jj) )  )   )
742            zlsset (ji,jj) = - zlsrise(ji,jj)
743            !  dividing the solar day into jp24 segments of length zdlha
744            zdlha  (ji,jj) = ( zlsrise(ji,jj) - zlsset(ji,jj) ) / REAL( jp24, wp )
745         END DO
746      END DO
747
748
749      !---------------------------------------------!
750      !  shortwave radiation absorbed by the ocean  !
751      !---------------------------------------------!
752      pqsr_oce(:,:)   = 0.e0      ! set ocean qsr to zero     
753
754      ! compute and sum ocean qsr over the daylight (i.e. between sunrise and sunset)
755!CDIR NOVERRCHK   
756      DO jt = 1, jp24
757         zcoef = FLOAT( jt ) - 0.5
758!CDIR NOVERRCHK     
759!CDIR COLLAPSE
760         DO jj = 1, jpj
761!CDIR NOVERRCHK
762            DO ji = 1, jpi
763               zlha = COS(  zlsrise(ji,jj) - zcoef * zdlha(ji,jj)  )                  ! local hour angle
764               zcmue              = MAX( 0.e0 ,   zps(ji,jj) + zpc(ji,jj) * zlha  )   ! cos of local solar altitude
765               zcmue2             = 1368.0 * zcmue * zcmue
766
767               ! ocean albedo depending on the cloud cover (Payne, 1972)
768               za_oce     = ( 1.0 - sf(jp_ccov)%fnow(ji,jj,1) ) * 0.05 / ( 1.1 * zcmue**1.4 + 0.15 )   &   ! clear sky
769                  &       +         sf(jp_ccov)%fnow(ji,jj,1)   * 0.06                                     ! overcast
770
771                  ! solar heat flux absorbed by the ocean (Zillman, 1972)
772               pqsr_oce(ji,jj) = pqsr_oce(ji,jj)                                         &
773                  &            + ( 1.0 - za_oce ) * zdlha(ji,jj) * zcmue2                &
774                  &            / ( ( zcmue + 2.7 ) * zev(ji,jj) + 1.085 * zcmue +  0.10 )
775            END DO
776         END DO
777      END DO
778      ! Taking into account the ellipsity of the earth orbit, the clouds AND masked if sea-ice cover > 0%
779      zcoef1 = srgamma * zdaycor / ( 2. * rpi )
780!CDIR COLLAPSE
781      DO jj = 1, jpj
782         DO ji = 1, jpi
783            zlmunoon = ASIN( zps(ji,jj) + zpc(ji,jj) ) / rad                         ! local noon solar altitude
784            zcldcor  = MIN(  1.e0, ( 1.e0 - 0.62 * sf(jp_ccov)%fnow(ji,jj,1)   &     ! cloud correction (Reed 1977)
785               &                          + 0.0019 * zlmunoon )                 )
786            pqsr_oce(ji,jj) = zcoef1 * zcldcor * pqsr_oce(ji,jj) * tmask(ji,jj,1)    ! and zcoef1: ellipsity
787         END DO
788      END DO
789
790      CALL wrk_dealloc( jpi,jpj, zev, zdlha, zlsrise, zlsset, zps, zpc )
791      !
792      IF( nn_timing == 1 )  CALL timing_stop('blk_clio_qsr_oce')
793      !
794   END SUBROUTINE blk_clio_qsr_oce
795
796
797   SUBROUTINE blk_clio_qsr_ice( pa_ice_cs, pa_ice_os, pqsr_ice )
798      !!---------------------------------------------------------------------------
799      !!                     ***  ROUTINE blk_clio_qsr_ice  ***
800      !!                 
801      !!  ** Purpose :   Computation of the shortwave radiation at the ocean and the
802      !!               snow/ice surfaces.
803      !!         
804      !!  ** Method  : - computed qsr from the cloud cover for both ice and ocean
805      !!               - also initialise sbudyko and stauc once for all
806      !!----------------------------------------------------------------------
807      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pa_ice_cs   ! albedo of ice under clear sky
808      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pa_ice_os   ! albedo of ice under overcast sky
809      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pqsr_ice    ! shortwave radiation over the ice/snow
810      !!
811      INTEGER, PARAMETER  ::   jp24 = 24   ! sampling of the daylight period (sunrise to sunset) into 24 equal parts
812      !!
813      INTEGER  ::   ji, jj, jl, jt    ! dummy loop indices
814      INTEGER  ::   ijpl              ! number of ice categories (3rd dim of pqsr_ice)
815      INTEGER  ::   indaet            !  = -1, 0, 1 for odd, normal and leap years resp.
816      INTEGER  ::   iday              ! integer part of day
817      !!
818      REAL(wp) ::   zcmue, zcmue2, ztamr          ! temporary scalars
819      REAL(wp) ::   zmt1, zmt2, zmt3              !    -         -
820      REAL(wp) ::   zdecl, zsdecl, zcdecl         !    -         -
821      REAL(wp) ::   zlha, zdaycor, zes            !    -         -
822      REAL(wp) ::   zxday, zdist, zcoef, zcoef1   !    -         -
823      REAL(wp) ::   zqsr_ice_cs, zqsr_ice_os      !    -         -
824
825      REAL(wp), DIMENSION(:,:), POINTER ::   zev                      ! vapour pressure
826      REAL(wp), DIMENSION(:,:), POINTER ::   zdlha, zlsrise, zlsset   ! 2D workspace
827      REAL(wp), DIMENSION(:,:), POINTER ::   zps, zpc   ! sine (cosine) of latitude per sine (cosine) of solar declination
828      !!---------------------------------------------------------------------
829      !
830      IF( nn_timing == 1 )  CALL timing_start('blk_clio_qsr_ice')
831      !
832      CALL wrk_alloc( jpi,jpj, zev, zdlha, zlsrise, zlsset, zps, zpc )
833
834      ijpl = SIZE(pqsr_ice, 3 )      ! number of ice categories
835     
836      ! Saturated water vapour and vapour pressure
837      ! ------------------------------------------
838!CDIR NOVERRCHK
839!CDIR COLLAPSE
840      DO jj = 1, jpj
841!CDIR NOVERRCHK
842         DO ji = 1, jpi           
843            ztamr = sf(jp_tair)%fnow(ji,jj,1) - rtt           
844            zmt1  = SIGN( 17.269,  ztamr )
845            zmt2  = SIGN( 21.875,  ztamr )
846            zmt3  = SIGN( 28.200, -ztamr )
847            zes = 611.0 * EXP(  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &              ! Saturation water vapour
848               &                     / ( sf(jp_tair)%fnow(ji,jj,1) - 35.86  + MAX( 0.e0, zmt3 ) )  )
849            zev(ji,jj) = sf(jp_humi)%fnow(ji,jj,1) * zes * 1.0e-05                 ! vapour pressure 
850         END DO
851      END DO
852
853      !-----------------------------------!
854      !  Computation of solar irradiance  !
855      !-----------------------------------!
856!!gm : hard coded  leap year ???
857      indaet   = 1                                    ! = -1, 0, 1 for odd, normal and leap years resp.
858      zxday = nday_year + rdtbs2 / rday               ! day of the year at which the fluxes are calculated
859      iday  = INT( zxday )                            ! (centred at the middle of the ice time step)
860      CALL flx_blk_declin( indaet, iday, zdecl )      ! solar declination of the current day
861      zsdecl = SIN( zdecl * rad )                     ! its sine
862      zcdecl = COS( zdecl * rad )                     ! its cosine
863
864     
865      !  correction factor added for computation of shortwave flux to take into account the variation of
866      !  the distance between the sun and the earth during the year (Oberhuber 1988)
867      zdist    = zxday * 2. * rpi / REAL(nyear_len(1), wp)
868      zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
869
870!CDIR NOVERRCHK
871      DO jj = 1, jpj
872!CDIR NOVERRCHK
873         DO ji = 1, jpi
874            !  product of sine (cosine) of latitude and sine (cosine) of solar declination
875            zps(ji,jj) = SIN( gphit(ji,jj) * rad ) * zsdecl
876            zpc(ji,jj) = COS( gphit(ji,jj) * rad ) * zcdecl
877            !  computation of the both local time of sunrise and sunset
878            zlsrise(ji,jj) = ACOS( - SIGN( 1.e0, zps(ji,jj) )    &
879               &                   * MIN(  1.e0, SIGN( 1.e0, zps(ji,jj) ) * ( zps(ji,jj) / zpc(ji,jj) )  )   ) 
880            zlsset (ji,jj) = - zlsrise(ji,jj)
881            !  dividing the solar day into jp24 segments of length zdlha
882            zdlha  (ji,jj) = ( zlsrise(ji,jj) - zlsset(ji,jj) ) / REAL( jp24, wp )
883         END DO
884      END DO
885
886
887      !---------------------------------------------!
888      !  shortwave radiation absorbed by the ice    !
889      !---------------------------------------------!
890      ! compute and sum ice qsr over the daylight for each ice categories
891      pqsr_ice(:,:,:) = 0.e0
892      zcoef1 = zdaycor / ( 2. * rpi )       ! Correction for the ellipsity of the earth orbit
893     
894      !                    !----------------------------!
895      DO jl = 1, ijpl      !  loop over ice categories  !
896         !                 !----------------------------!
897!CDIR NOVERRCHK   
898         DO jt = 1, jp24   
899            zcoef = FLOAT( jt ) - 0.5
900!CDIR NOVERRCHK     
901!CDIR COLLAPSE
902            DO jj = 1, jpj
903!CDIR NOVERRCHK
904               DO ji = 1, jpi
905                  zlha = COS(  zlsrise(ji,jj) - zcoef * zdlha(ji,jj)  )                  ! local hour angle
906                  zcmue              = MAX( 0.e0 ,   zps(ji,jj) + zpc(ji,jj) * zlha  )   ! cos of local solar altitude
907                  zcmue2             = 1368.0 * zcmue * zcmue
908                 
909                  !  solar heat flux absorbed by the ice/snow system (Shine and Crane 1984 adapted to high albedo)
910                  zqsr_ice_cs =  ( 1.0 - pa_ice_cs(ji,jj,jl) ) * zdlha(ji,jj) * zcmue2        &   ! clear sky
911                     &        / ( ( 1.0 + zcmue ) * zev(ji,jj) + 1.2 * zcmue + 0.0455 )
912                  zqsr_ice_os = zdlha(ji,jj) * SQRT( zcmue )                                  &   ! overcast sky
913                     &        * ( 53.5 + 1274.5 * zcmue )      * ( 1.0 - 0.996  * pa_ice_os(ji,jj,jl) )    &
914                     &        / (  1.0 + 0.139  * stauc(ji,jj) * ( 1.0 - 0.9435 * pa_ice_os(ji,jj,jl) ) )       
915             
916                  pqsr_ice(ji,jj,jl) = pqsr_ice(ji,jj,jl) + (  ( 1.0 - sf(jp_ccov)%fnow(ji,jj,1) ) * zqsr_ice_cs    &
917                     &                                       +         sf(jp_ccov)%fnow(ji,jj,1)   * zqsr_ice_os  )
918               END DO
919            END DO
920         END DO
921         !
922         ! Correction : Taking into account the ellipsity of the earth orbit
923         pqsr_ice(:,:,jl) = pqsr_ice(:,:,jl) * zcoef1 * tmask(:,:,1)
924         !
925         !                 !--------------------------------!
926      END DO               !  end loop over ice categories  !
927      !                    !--------------------------------!
928
929
930!!gm  : this should be suppress as input data have been passed through lbc_lnk
931      DO jl = 1, ijpl
932         CALL lbc_lnk( pqsr_ice(:,:,jl) , 'T', 1. )
933      END DO
934      !
935      CALL wrk_dealloc( jpi,jpj, zev, zdlha, zlsrise, zlsset, zps, zpc )
936      !
937      IF( nn_timing == 1 )  CALL timing_stop('blk_clio_qsr_ice')
938      !
939   END SUBROUTINE blk_clio_qsr_ice
940
941
942   SUBROUTINE flx_blk_declin( ky, kday, pdecl )
943      !!---------------------------------------------------------------------------
944      !!               ***  ROUTINE flx_blk_declin  ***
945      !!         
946      !! ** Purpose :   Computation of the solar declination for the day
947      !!       
948      !! ** Method  :   ???
949      !!---------------------------------------------------------------------
950      INTEGER , INTENT(in   ) ::   ky      ! = -1, 0, 1 for odd, normal and leap years resp.
951      INTEGER , INTENT(in   ) ::   kday    ! day of the year ( kday = 1 on january 1)
952      REAL(wp), INTENT(  out) ::   pdecl   ! solar declination
953      !!
954      REAL(wp) ::   a0  =  0.39507671      ! coefficients for solar declinaison computation
955      REAL(wp) ::   a1  = 22.85684301      !     "              ""                 "
956      REAL(wp) ::   a2  = -0.38637317      !     "              ""                 "
957      REAL(wp) ::   a3  =  0.15096535      !     "              ""                 "
958      REAL(wp) ::   a4  = -0.00961411      !     "              ""                 "
959      REAL(wp) ::   b1  = -4.29692073      !     "              ""                 "
960      REAL(wp) ::   b2  =  0.05702074      !     "              ""                 "
961      REAL(wp) ::   b3  = -0.09028607      !     "              ""                 "
962      REAL(wp) ::   b4  =  0.00592797
963      !!
964      REAL(wp) ::   zday   ! corresponding day of type year (cf. ky)
965      REAL(wp) ::   zp     ! temporary scalars
966      !!---------------------------------------------------------------------
967           
968      IF    ( ky == 1 )  THEN   ;   zday = REAL( kday, wp ) - 0.5
969      ELSEIF( ky == 3 )  THEN   ;   zday = REAL( kday, wp ) - 1.
970      ELSE                      ;   zday = REAL( kday, wp )
971      ENDIF
972     
973      zp = rpi * ( 2.0 * zday - 367.0 ) / REAL(nyear_len(1), wp)
974     
975      pdecl  = a0                                                                      &
976         &   + a1 * COS( zp ) + a2 * COS( 2. * zp ) + a3 * COS( 3. * zp ) + a4 * COS( 4. * zp )   &
977         &   + b1 * SIN( zp ) + b2 * SIN( 2. * zp ) + b3 * SIN( 3. * zp ) + b4 * SIN( 4. * zp )
978      !
979   END SUBROUTINE flx_blk_declin
980
981   !!======================================================================
982END MODULE sbcblk_clio
Note: See TracBrowser for help on using the repository browser.