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 branches/2014/dev_r4650_UKMO2_ice_shelves/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2014/dev_r4650_UKMO2_ice_shelves/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90 @ 4724

Last change on this file since 4724 was 4724, checked in by mathiot, 10 years ago

ISF branch: add comments, fix mpp and restar issues, add test to stop if incompatible options and fix mask issue in sbcice and sbcblk.

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