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.
sbcmod.F90 in NEMO/trunk/src/OCE/SBC – NEMO

source: NEMO/trunk/src/OCE/SBC/sbcmod.F90

Last change on this file was 15372, checked in by davestorkey, 2 years ago

trunk: fix for wind forcing of icebergs #2728

  • Property svn:keywords set to Id
File size: 36.1 KB
Line 
1MODULE sbcmod
2   !!======================================================================
3   !!                       ***  MODULE  sbcmod  ***
4   !! Surface module :  provide to the ocean its surface boundary condition
5   !!======================================================================
6   !! History :  3.0  ! 2006-07  (G. Madec)  Original code
7   !!            3.1  ! 2008-08  (S. Masson, A. Caubel, E. Maisonnave, G. Madec) coupled interface
8   !!            3.3  ! 2010-04  (M. Leclair, G. Madec)  Forcing averaged over 2 time steps
9   !!            3.3  ! 2010-10  (S. Masson)  add diurnal cycle
10   !!            3.3  ! 2010-09  (D. Storkey) add ice boundary conditions (BDY)
11   !!             -   ! 2010-11  (G. Madec) ice-ocean stress always computed at each ocean time-step
12   !!             -   ! 2010-10  (J. Chanut, C. Bricaud, G. Madec)  add the surface pressure forcing
13   !!            3.4  ! 2011-11  (C. Harris) CICE added as an option
14   !!            3.5  ! 2012-11  (A. Coward, G. Madec) Rethink of heat, mass and salt surface fluxes
15   !!            3.6  ! 2014-11  (P. Mathiot, C. Harris) add ice shelves melting
16   !!            4.0  ! 2016-06  (L. Brodeau) new general bulk formulation
17   !!            4.0  ! 2019-03  (F. Lemarié & G. Samson)  add ABL compatibility (ln_abl=TRUE)
18   !!            4.2  ! 2020-12  (G. Madec, E. Clementi) modified wave forcing and coupling
19   !!----------------------------------------------------------------------
20
21   !!----------------------------------------------------------------------
22   !!   sbc_init      : read namsbc namelist
23   !!   sbc           : surface ocean momentum, heat and freshwater boundary conditions
24   !!   sbc_final     : Finalize CICE ice model (if used)
25   !!----------------------------------------------------------------------
26   USE oce            ! ocean dynamics and tracers
27   USE dom_oce        ! ocean space and time domain
28   USE closea         ! closed seas
29   USE phycst         ! physical constants
30   USE sbc_phy, ONLY : pp_cldf
31   USE sbc_oce        ! Surface boundary condition: ocean fields
32   USE trc_oce        ! shared ocean-passive tracers variables
33   USE sbc_ice        ! Surface boundary condition: ice fields
34   USE sbcdcy         ! surface boundary condition: diurnal cycle
35   USE sbcssm         ! surface boundary condition: sea-surface mean variables
36   USE sbcflx         ! surface boundary condition: flux formulation
37   USE sbcblk         ! surface boundary condition: bulk formulation
38   USE sbcabl         ! atmospheric boundary layer
39   USE sbcice_if      ! surface boundary condition: ice-if sea-ice model
40#if defined key_si3
41   USE icestp         ! surface boundary condition: SI3 sea-ice model
42#endif
43   USE sbcice_cice    ! surface boundary condition: CICE sea-ice model
44   USE sbccpl         ! surface boundary condition: coupled formulation
45   USE cpl_oasis3     ! OASIS routines for coupling
46   USE sbcclo         ! surface boundary condition: closed sea correction
47   USE sbcssr         ! surface boundary condition: sea surface restoring
48   USE sbcrnf         ! surface boundary condition: runoffs
49   USE sbcapr         ! surface boundary condition: atmo pressure
50   USE sbcfwb         ! surface boundary condition: freshwater budget
51   USE icbstp         ! Icebergs
52   USE icb_oce  , ONLY : ln_passive_mode      ! iceberg interaction mode
53   USE traqsr         ! active tracers: light penetration
54   USE sbcwave        ! Wave module
55   USE bdy_oce   , ONLY: ln_bdy
56   USE usrdef_sbc     ! user defined: surface boundary condition
57   USE closea         ! closed sea
58   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
59   !
60   USE prtctl         ! Print control                    (prt_ctl routine)
61   USE iom            ! IOM library
62   USE in_out_manager ! I/O manager
63   USE lib_mpp        ! MPP library
64   USE timing         ! Timing
65   USE wet_dry
66   USE diu_bulk, ONLY:   ln_diurnal_only   ! diurnal SST diagnostic
67
68   IMPLICIT NONE
69   PRIVATE
70
71   PUBLIC   sbc        ! routine called by step.F90
72   PUBLIC   sbc_init   ! routine called by opa.F90
73
74   INTEGER ::   nsbc   ! type of surface boundary condition (deduced from namsbc informations)
75   !! * Substitutions
76#  include "do_loop_substitute.h90"
77   !!----------------------------------------------------------------------
78   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
79   !! $Id$
80   !! Software governed by the CeCILL license (see ./LICENSE)
81   !!----------------------------------------------------------------------
82CONTAINS
83
84   SUBROUTINE sbc_init( Kbb, Kmm, Kaa )
85      !!---------------------------------------------------------------------
86      !!                    ***  ROUTINE sbc_init ***
87      !!
88      !! ** Purpose :   Initialisation of the ocean surface boundary computation
89      !!
90      !! ** Method  :   Read the namsbc namelist and set derived parameters
91      !!                Call init routines for all other SBC modules that have one
92      !!
93      !! ** Action  : - read namsbc parameters
94      !!              - nsbc: type of sbc
95      !!----------------------------------------------------------------------
96      INTEGER, INTENT(in) ::   Kbb, Kmm, Kaa         ! ocean time level indices
97      INTEGER ::   ios, icpt                         ! local integer
98      LOGICAL ::   ll_purecpl, ll_opa, ll_not_nemo   ! local logical
99      !!
100      NAMELIST/namsbc/ nn_fsbc  ,                                                    &
101         &             ln_usr   , ln_flx   , ln_blk   , ln_abl,                      &
102         &             ln_cpl   , ln_mixcpl, nn_components,                          &
103         &             nn_ice   , ln_ice_embd,                                       &
104         &             ln_traqsr, ln_dm2dc ,                                         &
105         &             ln_rnf   , nn_fwb     , ln_ssr   , ln_apr_dyn,                &
106         &             ln_wave  , nn_lsm
107      !!----------------------------------------------------------------------
108      !
109      IF(lwp) THEN
110         WRITE(numout,*)
111         WRITE(numout,*) 'sbc_init : surface boundary condition setting'
112         WRITE(numout,*) '~~~~~~~~ '
113      ENDIF
114      !
115      !                       !**  read Surface Module namelist
116      READ  ( numnam_ref, namsbc, IOSTAT = ios, ERR = 901)
117901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist' )
118      READ  ( numnam_cfg, namsbc, IOSTAT = ios, ERR = 902 )
119902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist' )
120      IF(lwm) WRITE( numond, namsbc )
121      !
122#if ! defined key_mpi_off
123      ncom_fsbc = nn_fsbc    ! make nn_fsbc available for lib_mpp
124#endif
125#if ! defined key_si3
126      IF( nn_ice == 2 )    nn_ice = 0  ! without key key_si3 you cannot use si3...
127#endif
128      !
129      !
130      IF(lwp) THEN                  !* Control print
131         WRITE(numout,*) '   Namelist namsbc (partly overwritten with CPP key setting)'
132         WRITE(numout,*) '      frequency update of sbc (and ice)             nn_fsbc       = ', nn_fsbc
133         WRITE(numout,*) '      Type of air-sea fluxes : '
134         WRITE(numout,*) '         user defined formulation                   ln_usr        = ', ln_usr
135         WRITE(numout,*) '         flux         formulation                   ln_flx        = ', ln_flx
136         WRITE(numout,*) '         bulk         formulation                   ln_blk        = ', ln_blk
137         WRITE(numout,*) '         ABL          formulation                   ln_abl        = ', ln_abl
138         WRITE(numout,*) '         Surface wave (forced or coupled)           ln_wave       = ', ln_wave
139         WRITE(numout,*) '      Type of coupling (Ocean/Ice/Atmosphere) : '
140         WRITE(numout,*) '         ocean-atmosphere coupled formulation       ln_cpl        = ', ln_cpl
141         WRITE(numout,*) '         mixed forced-coupled     formulation       ln_mixcpl     = ', ln_mixcpl
142!!gm  lk_oasis is controlled by key_oasis3  ===>>>  It shoud be removed from the namelist
143         WRITE(numout,*) '         OASIS coupling (with atm or sas)           lk_oasis      = ', lk_oasis
144         WRITE(numout,*) '         components of your executable              nn_components = ', nn_components
145         WRITE(numout,*) '      Sea-ice : '
146         WRITE(numout,*) '         ice management in the sbc (=0/1/2/3)       nn_ice        = ', nn_ice
147         WRITE(numout,*) '         ice embedded into ocean                    ln_ice_embd   = ', ln_ice_embd
148         WRITE(numout,*) '      Misc. options of sbc : '
149         WRITE(numout,*) '         Light penetration in temperature Eq.       ln_traqsr     = ', ln_traqsr
150         WRITE(numout,*) '            daily mean to diurnal cycle qsr            ln_dm2dc   = ', ln_dm2dc
151         WRITE(numout,*) '         Sea Surface Restoring on SST and/or SSS    ln_ssr        = ', ln_ssr
152         WRITE(numout,*) '         FreshWater Budget control  (=0/1/2)        nn_fwb        = ', nn_fwb
153         WRITE(numout,*) '         Patm gradient added in ocean & ice Eqs.    ln_apr_dyn    = ', ln_apr_dyn
154         WRITE(numout,*) '         runoff / runoff mouths                     ln_rnf        = ', ln_rnf
155         WRITE(numout,*) '         nb of iterations if land-sea-mask applied  nn_lsm        = ', nn_lsm
156      ENDIF
157      !
158      IF( .NOT.ln_usr ) THEN     ! the model calendar needs some specificities (except in user defined case)
159         IF( MOD( rday , rn_Dt ) /= 0. )   CALL ctl_stop( 'the time step must devide the number of second of in a day' )
160         IF( MOD( rday , 2.  ) /= 0. )   CALL ctl_stop( 'the number of second of in a day must be an even number'    )
161         IF( MOD( rn_Dt  , 2.  ) /= 0. )   CALL ctl_stop( 'the time step (in second) must be an even number'           )
162      ENDIF
163      !                       !**  check option consistency
164      !
165      IF(lwp) WRITE(numout,*)       !* Single / Multi - executable (NEMO / OCE+SAS)
166      SELECT CASE( nn_components )
167      CASE( jp_iam_nemo )
168         IF(lwp) WRITE(numout,*) '   ==>>>   NEMO configured as a single executable (i.e. including both OCE and Surface module)'
169      CASE( jp_iam_oce  )
170         IF(lwp) WRITE(numout,*) '   ==>>>   Multi executable configuration. Here, OCE component'
171         IF( .NOT.lk_oasis )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but key_oasis3 disabled' )
172         IF( ln_cpl        )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but ln_cpl = T in OCE'   )
173         IF( ln_mixcpl     )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but ln_mixcpl = T in OCE' )
174      CASE( jp_iam_sas  )
175         IF(lwp) WRITE(numout,*) '   ==>>>   Multi executable configuration. Here, SAS component'
176         IF( .NOT.lk_oasis )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but key_oasis3 disabled' )
177         IF( ln_mixcpl     )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but ln_mixcpl = T in OCE' )
178      CASE DEFAULT
179         CALL ctl_stop( 'sbc_init : unsupported value for nn_components' )
180      END SELECT
181      !                             !* coupled options
182      IF( ln_cpl ) THEN
183         IF( .NOT. lk_oasis )   CALL ctl_stop( 'sbc_init : coupled mode with an atmosphere model (ln_cpl=T)',   &
184            &                                  '           required to defined key_oasis3' )
185      ENDIF
186      IF( ln_mixcpl ) THEN
187         IF( .NOT. lk_oasis )   CALL ctl_stop( 'sbc_init : mixed forced-coupled mode (ln_mixcpl=T) ',   &
188            &                                  '           required to defined key_oasis3' )
189         IF( .NOT.ln_cpl    )   CALL ctl_stop( 'sbc_init : mixed forced-coupled mode (ln_mixcpl=T) requires ln_cpl = T' )
190         IF( nn_components /= jp_iam_nemo )    &
191            &                   CALL ctl_stop( 'sbc_init : the mixed forced-coupled mode (ln_mixcpl=T) ',   &
192            &                                   '          not yet working with sas-opa coupling via oasis' )
193      ENDIF
194      !                             !* sea-ice
195      SELECT CASE( nn_ice )
196      CASE( 0 )                        !- no ice in the domain
197      CASE( 1 )                        !- Ice-cover climatology ("Ice-if" model)
198      CASE( 2 )                        !- SI3  ice model
199         IF( .NOT.( ln_blk .OR. ln_cpl .OR. ln_abl .OR. ln_usr ) )   &
200            &                   CALL ctl_stop( 'sbc_init : SI3 sea-ice model requires ln_blk or ln_cpl or ln_abl or ln_usr = T' )
201      CASE( 3 )                        !- CICE ice model
202         IF( .NOT.( ln_blk .OR. ln_cpl .OR. ln_abl .OR. ln_usr ) )   &
203            &                   CALL ctl_stop( 'sbc_init : CICE sea-ice model requires ln_blk or ln_cpl or ln_abl or ln_usr = T' )
204         IF( lk_agrif                                )   &
205            &                   CALL ctl_stop( 'sbc_init : CICE sea-ice model not currently available with AGRIF' )
206      CASE DEFAULT                     !- not supported
207      END SELECT
208      IF( ln_diurnal .AND. .NOT. (ln_blk.OR.ln_abl) )   CALL ctl_stop( "sbc_init: diurnal flux processing only implemented for bulk forcing" )
209      !
210      !                       !**  allocate and set required variables
211      !
212      !                             !* allocate sbc arrays
213      IF( sbc_oce_alloc() /= 0 )   CALL ctl_stop( 'sbc_init : unable to allocate sbc_oce arrays' )
214#if ! defined key_si3 && ! defined key_cice
215      IF( sbc_ice_alloc() /= 0 )   CALL ctl_stop( 'sbc_init : unable to allocate sbc_ice arrays' )
216#endif
217      !
218      !
219      IF( sbc_ssr_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_ssr arrays' )
220      IF( .NOT.ln_ssr ) THEN               !* Initialize qrp and erp if no restoring
221         qrp(:,:) = 0._wp
222         erp(:,:) = 0._wp
223      ENDIF
224      !
225      IF( nn_ice == 0 ) THEN        !* No sea-ice in the domain : ice fraction is always zero
226         IF( nn_components /= jp_iam_oce )   fr_i(:,:) = 0._wp    ! except for OCE in SAS-OCE coupled case
227      ENDIF
228      !
229      sfx   (:,:) = 0._wp           !* salt flux due to freezing/melting
230      fmmflx(:,:) = 0._wp           !* freezing minus melting flux
231      cloud_fra(:,:) = pp_cldf      !* cloud fraction over sea ice (used in si3)
232
233      taum(:,:) = 0._wp             !* wind stress module (needed in GLS in case of reduced restart)
234
235      !                          ! Choice of the Surface Boudary Condition (set nsbc)
236      nday_qsr = -1   ! allow initialization at the 1st call !LB: now warm-layer of COARE* calls "sbc_dcy_param" of sbcdcy.F90!
237      IF( ln_dm2dc ) THEN           !* daily mean to diurnal cycle
238         !LB:nday_qsr = -1   ! allow initialization at the 1st call
239         IF( .NOT.( ln_flx .OR. ln_blk .OR. ln_abl ) .AND. nn_components /= jp_iam_oce )   &
240            &   CALL ctl_stop( 'qsr diurnal cycle from daily values requires flux, bulk or abl formulation' )
241      ENDIF
242      !                             !* Choice of the Surface Boudary Condition
243      !                             (set nsbc)
244      !
245      ll_purecpl  = ln_cpl .AND. .NOT.ln_mixcpl
246      ll_opa      = nn_components == jp_iam_oce
247      ll_not_nemo = nn_components /= jp_iam_nemo
248      icpt = 0
249      !
250      IF( ln_usr          ) THEN   ;   nsbc = jp_usr     ; icpt = icpt + 1   ;   ENDIF       ! user defined         formulation
251      IF( ln_flx          ) THEN   ;   nsbc = jp_flx     ; icpt = icpt + 1   ;   ENDIF       ! flux                 formulation
252      IF( ln_blk          ) THEN   ;   nsbc = jp_blk     ; icpt = icpt + 1   ;   ENDIF       ! bulk                 formulation
253      IF( ln_abl          ) THEN   ;   nsbc = jp_abl     ; icpt = icpt + 1   ;   ENDIF       ! ABL                  formulation
254      IF( ll_purecpl      ) THEN   ;   nsbc = jp_purecpl ; icpt = icpt + 1   ;   ENDIF       ! Pure Coupled         formulation
255      IF( ll_opa          ) THEN   ;   nsbc = jp_none    ; icpt = icpt + 1   ;   ENDIF       ! opa coupling via SAS module
256      !
257      IF( icpt /= 1 )    CALL ctl_stop( 'sbc_init : choose ONE and only ONE sbc option' )
258      !
259      IF(lwp) THEN                     !- print the choice of surface flux formulation
260         WRITE(numout,*)
261         SELECT CASE( nsbc )
262         CASE( jp_usr     )   ;   WRITE(numout,*) '   ==>>>   user defined forcing formulation'
263         CASE( jp_flx     )   ;   WRITE(numout,*) '   ==>>>   flux formulation'
264         CASE( jp_blk     )   ;   WRITE(numout,*) '   ==>>>   bulk formulation'
265         CASE( jp_abl     )   ;   WRITE(numout,*) '   ==>>>   ABL  formulation'
266         CASE( jp_purecpl )   ;   WRITE(numout,*) '   ==>>>   pure coupled formulation'
267!!gm abusive use of jp_none ??   ===>>> need to be check and changed by adding a jp_sas parameter
268         CASE( jp_none    )   ;   WRITE(numout,*) '   ==>>>   OCE coupled to SAS via oasis'
269            IF( ln_mixcpl )       WRITE(numout,*) '               + forced-coupled mixed formulation'
270         END SELECT
271         IF( ll_not_nemo  )       WRITE(numout,*) '               + OASIS coupled SAS'
272      ENDIF
273      !
274      !                             !* OASIS initialization
275      !
276      IF( lk_oasis )   CALL sbc_cpl_init( nn_ice )   ! Must be done before: (1) first time step
277      !                                              !                      (2) the use of nn_fsbc
278      !     nn_fsbc initialization if OCE-SAS coupling via OASIS
279      !     SAS time-step has to be declared in OASIS (mandatory) -> nn_fsbc has to be modified accordingly
280      IF( nn_components /= jp_iam_nemo ) THEN
281         IF( nn_components == jp_iam_oce )   nn_fsbc = cpl_freq('O_SFLX') / NINT(rn_Dt)
282         IF( nn_components == jp_iam_sas )   nn_fsbc = cpl_freq('I_SFLX') / NINT(rn_Dt)
283         !
284         IF(lwp)THEN
285            WRITE(numout,*)
286            WRITE(numout,*)"   OCE-SAS coupled via OASIS : nn_fsbc re-defined from OASIS namcouple ", nn_fsbc
287            WRITE(numout,*)
288         ENDIF
289      ENDIF
290      !
291      !                             !* check consistency between model timeline and nn_fsbc
292      IF( ln_rst_list .OR. nn_stock /= -1 ) THEN   ! we will do restart files
293         IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 ) THEN
294            WRITE(ctmp1,*) 'sbc_init : experiment length (', nitend - nit000 + 1, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
295            CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
296         ENDIF
297         IF( .NOT. ln_rst_list .AND. MOD( nn_stock, nn_fsbc) /= 0 ) THEN   ! we don't use nn_stock if ln_rst_list
298            WRITE(ctmp1,*) 'sbc_init : nn_stock (', nn_stock, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
299            CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
300         ENDIF
301      ENDIF
302      !
303      IF( MOD( rday, REAL(nn_fsbc, wp) * rn_Dt ) /= 0 )   &
304         &  CALL ctl_warn( 'sbc_init : nn_fsbc is NOT a multiple of the number of time steps in a day' )
305      !
306      IF( ln_dm2dc .AND. NINT(rday) / ( nn_fsbc * NINT(rn_Dt) ) < 8  )   &
307         &   CALL ctl_warn( 'sbc_init : diurnal cycle for qsr: the sampling of the diurnal cycle is too small...' )
308      !
309
310      !                       !**  associated modules : initialization
311      !
312                          CALL sbc_ssm_init ( Kbb, Kmm ) ! Sea-surface mean fields initialization
313      !
314      IF( l_sbc_clo   )   CALL sbc_clo_init              ! closed sea surface initialisation
315      !
316      IF( ln_blk      )   CALL sbc_blk_init              ! bulk formulae initialization
317
318      IF( ln_abl      )   CALL sbc_abl_init              ! Atmospheric Boundary Layer (ABL)
319
320      IF( ln_ssr      )   CALL sbc_ssr_init              ! Sea-Surface Restoring initialization
321      !
322      !
323                          CALL sbc_rnf_init( Kmm )       ! Runof initialization
324      !
325      IF( ln_apr_dyn )    CALL sbc_apr_init              ! Atmo Pressure Forcing initialization
326      !
327#if defined key_si3
328      IF( lk_agrif .AND. nn_ice == 0 ) THEN            ! allocate ice arrays in case agrif + ice-model + no-ice in child grid
329                          IF( sbc_ice_alloc() /= 0 )   CALL ctl_stop('STOP', 'sbc_ice_alloc : unable to allocate arrays' )
330      ELSEIF( nn_ice == 2 ) THEN
331                          CALL ice_init( Kbb, Kmm, Kaa )         ! ICE initialization
332      ENDIF
333#endif
334      IF( nn_ice == 3 )   CALL cice_sbc_init( nsbc, Kbb, Kmm )   ! CICE initialization
335      !
336      IF( ln_wave     ) THEN
337                          CALL sbc_wave_init                     ! surface wave initialisation
338      ELSE
339                          IF(lwp) WRITE(numout,*)
340                          IF(lwp) WRITE(numout,*) '   No surface waves : all wave related logical set to false'
341                          ln_sdw       = .false.
342                          ln_stcor     = .false.
343                          ln_cdgw      = .false.
344                          ln_tauoc     = .false.
345                          ln_wave_test = .false.
346                          ln_charn     = .false.
347                          ln_taw       = .false.
348                          ln_phioc     = .false.
349                          ln_bern_srfc = .false.
350                          ln_breivikFV_2016 = .false.
351                          ln_vortex_force = .false.
352                          ln_stshear  = .false.
353      ENDIF
354      !
355   END SUBROUTINE sbc_init
356
357
358   SUBROUTINE sbc( kt, Kbb, Kmm )
359      !!---------------------------------------------------------------------
360      !!                    ***  ROUTINE sbc  ***
361      !!
362      !! ** Purpose :   provide at each time-step the ocean surface boundary
363      !!                condition (momentum, heat and freshwater fluxes)
364      !!
365      !! ** Method  :   blah blah  to be written ?????????
366      !!                CAUTION : never mask the surface stress field (tke sbc)
367      !!
368      !! ** Action  : - set the ocean surface boundary condition at before and now
369      !!                time step, i.e.
370      !!                utau_b, vtau_b, qns_b, qsr_b, emp_n, sfx_b, qrp_b, erp_b
371      !!                utau  , vtau  , qns  , qsr  , emp  , sfx  , qrp  , erp
372      !!              - updte the ice fraction : fr_i
373      !!----------------------------------------------------------------------
374      INTEGER, INTENT(in) ::   kt   ! ocean time step
375      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
376      INTEGER  ::   jj, ji          ! dummy loop argument
377      !
378      LOGICAL ::   ll_sas, ll_opa   ! local logical
379      !
380      REAL(wp) ::     zthscl        ! wd  tanh scale
381      REAL(wp), DIMENSION(jpi,jpj) ::  zwdht, zwght  ! wd dep over wd limit, wgt
382      REAL(wp), DIMENSION(jpi,jpj) ::  z2d           ! temporary array used for iom_put
383
384      !!---------------------------------------------------------------------
385      !
386      IF( ln_timing )   CALL timing_start('sbc')
387      !
388      !                                            ! ---------------------------------------- !
389      IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          !
390         !                                         ! ---------------------------------------- !
391         utau_b(:,:) = utau(:,:)                         ! Swap the ocean forcing fields
392         vtau_b(:,:) = vtau(:,:)                         ! (except at nit000 where before fields
393         qns_b (:,:) = qns (:,:)                         !  are set at the end of the routine)
394         emp_b (:,:) = emp (:,:)
395         sfx_b (:,:) = sfx (:,:)
396         IF( ln_rnf ) THEN
397            rnf_b    (:,:  ) = rnf    (:,:  )
398            rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)
399         ENDIF
400        !
401      ENDIF
402      !                                            ! ---------------------------------------- !
403      !                                            !        forcing field computation         !
404      !                                            ! ---------------------------------------- !
405      !
406      ll_sas = nn_components == jp_iam_sas               ! component flags
407      ll_opa = nn_components == jp_iam_oce
408      !
409      IF( .NOT.ll_sas )   CALL sbc_ssm ( kt, Kbb, Kmm )  ! mean ocean sea surface variables (sst_m, sss_m, ssu_m, ssv_m)
410      !
411      !                                            !==  sbc formulation  ==!
412      !
413      !
414      SELECT CASE( nsbc )                                ! Compute ocean surface boundary condition
415      !                                                  ! (i.e. utau,vtau, qns, qsr, emp, sfx)
416      CASE( jp_usr   )     ;   CALL usrdef_sbc_oce( kt, Kbb )                        ! user defined formulation
417      CASE( jp_flx     )   ;   CALL sbc_flx       ( kt )                             ! flux formulation
418      CASE( jp_blk     )
419         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-SAS coupling: SAS receiving fields from OCE
420!!!!!!!!!!! ATTENTION:ln_wave is not only used for oasis coupling !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
421         IF( ln_wave )   THEN
422             IF ( lk_oasis )  CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-wave coupling
423             CALL sbc_wave ( kt, Kmm )
424         ENDIF
425                               CALL sbc_blk       ( kt )                    ! bulk formulation for the ocean
426                               !
427      CASE( jp_abl     )
428         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-SAS coupling: SAS receiving fields from OCE
429                               CALL sbc_abl       ( kt )                    ! ABL  formulation for the ocean
430                               !
431      CASE( jp_purecpl )   ;   CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! pure coupled formulation
432      CASE( jp_none    )
433         IF( ll_opa    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )  ! OCE-SAS coupling: OCE receiving fields from SAS
434      END SELECT
435      !
436      IF( ln_mixcpl )          CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )  ! forced-coupled mixed formulation after forcing
437      !
438      IF( ln_wave .AND. ln_tauoc )  THEN            ! Wave stress reduction
439         DO_2D( 0, 0, 0, 0)
440            utau(ji,jj) = utau(ji,jj) * ( tauoc_wave(ji,jj) + tauoc_wave(ji-1,jj) ) * 0.5_wp
441            vtau(ji,jj) = vtau(ji,jj) * ( tauoc_wave(ji,jj) + tauoc_wave(ji,jj-1) ) * 0.5_wp
442         END_2D
443         !
444         CALL lbc_lnk( 'sbcwave', utau, 'U', -1. )
445         CALL lbc_lnk( 'sbcwave', vtau, 'V', -1. )
446         !
447         taum(:,:) = taum(:,:)*tauoc_wave(:,:)
448         !
449         IF( kt == nit000 )   CALL ctl_warn( 'sbc: You are subtracting the wave stress to the ocean.',   &
450            &                                'If not requested select ln_tauoc=.false.' )
451         !
452      ELSEIF( ln_wave .AND. ln_taw ) THEN                  ! Wave stress reduction
453         utau(:,:) = utau(:,:) - tawx(:,:) + twox(:,:)
454         vtau(:,:) = vtau(:,:) - tawy(:,:) + twoy(:,:)
455         CALL lbc_lnk( 'sbcwave', utau, 'U', -1. )
456         CALL lbc_lnk( 'sbcwave', vtau, 'V', -1. )
457         !
458         DO_2D( 0, 0, 0, 0)
459             taum(ji,jj) = sqrt((.5*(utau(ji-1,jj)+utau(ji,jj)))**2 + (.5*(vtau(ji,jj-1)+vtau(ji,jj)))**2)
460         END_2D
461         !
462         IF( kt == nit000 )   CALL ctl_warn( 'sbc: You are subtracting the wave stress to the ocean.',   &
463            &                                'If not requested select ln_taw=.false.' )
464         !
465      ENDIF
466      CALL lbc_lnk( 'sbcmod', taum(:,:), 'T', 1. )
467      !
468      IF( ln_icebergs ) THEN  ! save pure stresses (with no ice-ocean stress) for use by icebergs
469         utau_icb(:,:) = utau(:,:) ; vtau_icb(:,:) = vtau(:,:) 
470      ENDIF
471      !
472      !                                            !==  Misc. Options  ==!
473      !
474      SELECT CASE( nn_ice )                                       ! Update heat and freshwater fluxes over sea-ice areas
475      CASE(  1 )   ;         CALL sbc_ice_if   ( kt, Kbb, Kmm )   ! Ice-cover climatology ("Ice-if" model)
476#if defined key_si3
477      CASE(  2 )   ;         CALL ice_stp  ( kt, Kbb, Kmm, nsbc ) ! SI3 ice model
478#endif
479      CASE(  3 )   ;         CALL sbc_ice_cice ( kt, nsbc )       ! CICE ice model
480      END SELECT
481
482      IF( ln_icebergs    )   CALL icb_stp( kt, Kmm )              ! compute icebergs
483
484      ! Icebergs do not melt over the haloes.
485      ! So emp values over the haloes are no more consistent with the inner domain values.
486      ! A lbc_lnk is therefore needed to ensure reproducibility and restartability.
487      ! see ticket #2113 for discussion about this lbc_lnk.
488      ! The lbc_lnk is also needed for SI3 with nn_hls > 1 as emp is not yet defined for these points in iceupdate.F90
489      IF( (ln_icebergs .AND. .NOT. ln_passive_mode) .OR. (nn_ice == 2 .AND. nn_hls == 2) ) THEN
490         CALL lbc_lnk( 'sbcmod', emp, 'T', 1.0_wp )
491      ENDIF
492
493      IF( ln_rnf         )   CALL sbc_rnf( kt )                   ! add runoffs to fresh water fluxes
494
495      IF( ln_ssr         )   CALL sbc_ssr( kt )                        ! add SST/SSS damping term
496
497      IF( nn_fwb    /= 0 )   CALL sbc_fwb( kt, nn_fwb, nn_fsbc, Kmm )  ! control the freshwater budget
498
499      ! Special treatment of freshwater fluxes over closed seas in the model domain
500      ! Should not be run if ln_diurnal_only
501      IF( l_sbc_clo      )   CALL sbc_clo( kt )
502
503!!$!RBbug do not understand why see ticket 667
504!!$!clem: it looks like it is necessary for the north fold (in certain circumstances). Don't know why.
505!!$      CALL lbc_lnk( 'sbcmod', emp, 'T', 1.0_wp )
506      IF( ll_wd ) THEN     ! If near WAD point limit the flux for now
507         zthscl = atanh(rn_wd_sbcfra)                     ! taper frac default is .999
508         zwdht(:,:) = ssh(:,:,Kmm) + ht_0(:,:) - rn_wdmin1   ! do this calc of water
509                                                     ! depth above wd limit once
510         WHERE( zwdht(:,:) <= 0.0 )
511            taum(:,:) = 0.0
512            utau(:,:) = 0.0
513            vtau(:,:) = 0.0
514            qns (:,:) = 0.0
515            qsr (:,:) = 0.0
516            emp (:,:) = min(emp(:,:),0.0) !can allow puddles to grow but not shrink
517            sfx (:,:) = 0.0
518         END WHERE
519         zwght(:,:) = tanh(zthscl*zwdht(:,:))
520         WHERE( zwdht(:,:) > 0.0  .and. zwdht(:,:) < rn_wd_sbcdep ) !  5 m hard limit here is arbitrary
521            qsr  (:,:) =  qsr(:,:)  * zwght(:,:)
522            qns  (:,:) =  qns(:,:)  * zwght(:,:)
523            taum (:,:) =  taum(:,:) * zwght(:,:)
524            utau (:,:) =  utau(:,:) * zwght(:,:)
525            vtau (:,:) =  vtau(:,:) * zwght(:,:)
526            sfx  (:,:) =  sfx(:,:)  * zwght(:,:)
527            emp  (:,:) =  emp(:,:)  * zwght(:,:)
528         END WHERE
529      ENDIF
530      !
531      IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    !
532         !                                             ! ---------------------------------------- !
533         IF( ln_rstart .AND. .NOT.l_1st_euler ) THEN            !* Restart: read in restart file
534            IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields read in the restart file'
535            CALL iom_get( numror, jpdom_auto, 'utau_b', utau_b )   ! i-stress
536            CALL iom_get( numror, jpdom_auto, 'vtau_b', vtau_b )   ! j-stress
537            CALL iom_get( numror, jpdom_auto,  'qns_b',  qns_b )   ! non solar heat flux
538            CALL iom_get( numror, jpdom_auto,  'emp_b',  emp_b )   ! freshwater flux
539            ! NB: The 3D heat content due to qsr forcing (qsr_hc_b) is treated in traqsr
540            ! To ensure restart capability with 3.3x/3.4 restart files    !! to be removed in v3.6
541            IF( iom_varid( numror, 'sfx_b', ldstop = .FALSE. ) > 0 ) THEN
542               CALL iom_get( numror, jpdom_auto, 'sfx_b', sfx_b )  ! before salt flux (T-point)
543            ELSE
544               sfx_b (:,:) = sfx(:,:)
545            ENDIF
546         ELSE                                                   !* no restart: set from nit000 values
547            IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields set to nit000'
548            utau_b(:,:) = utau(:,:)
549            vtau_b(:,:) = vtau(:,:)
550            qns_b (:,:) = qns (:,:)
551            emp_b (:,:) = emp (:,:)
552            sfx_b (:,:) = sfx (:,:)
553         ENDIF
554      ENDIF
555      !                                                ! ---------------------------------------- !
556      IF( lrst_oce ) THEN                              !      Write in the ocean restart file     !
557         !                                             ! ---------------------------------------- !
558         IF(lwp) WRITE(numout,*)
559         IF(lwp) WRITE(numout,*) 'sbc : ocean surface forcing fields written in ocean restart file ',   &
560            &                    'at it= ', kt,' date= ', ndastp
561         IF(lwp) WRITE(numout,*) '~~~~'
562         CALL iom_rstput( kt, nitrst, numrow, 'utau_b' , utau )
563         CALL iom_rstput( kt, nitrst, numrow, 'vtau_b' , vtau )
564         CALL iom_rstput( kt, nitrst, numrow, 'qns_b'  , qns  )
565         ! The 3D heat content due to qsr forcing is treated in traqsr
566         ! CALL iom_rstput( kt, nitrst, numrow, 'qsr_b'  , qsr  )
567         CALL iom_rstput( kt, nitrst, numrow, 'emp_b'  , emp  )
568         CALL iom_rstput( kt, nitrst, numrow, 'sfx_b'  , sfx  )
569      ENDIF
570      !                                                ! ---------------------------------------- !
571      !                                                !        Outputs and control print         !
572      !                                                ! ---------------------------------------- !
573      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
574         IF( iom_use("empmr") ) THEN
575            DO_2D( 0, 0, 0, 0 )
576               z2d(ji,jj) =  emp(ji,jj) - rnf(ji,jj)
577            END_2D
578            CALL iom_put( "empmr"  , z2d      )                ! upward water flux
579         ENDIF
580         IF( iom_use("empbmr") ) THEN
581            DO_2D( 0, 0, 0, 0 )
582               z2d(ji,jj) =  emp_b(ji,jj) - rnf(ji,jj)
583            END_2D
584            CALL iom_put( "empbmr" , z2d      )                ! before upward water flux ( needed to recalculate the time evolution of ssh in offline )
585         ENDIF
586         CALL iom_put( "saltflx", sfx         )                ! downward salt flux (includes virtual salt flux beneath ice in linear free surface case)
587         CALL iom_put( "fmmflx" , fmmflx      )                ! Freezing-melting water flux
588         IF( iom_use("qt") ) THEN
589            DO_2D( 0, 0, 0, 0 )
590               z2d(ji,jj) =  qns(ji,jj) + qsr(ji,jj)
591            END_2D
592            CALL iom_put( "qt"  , z2d         )                ! total heat flux
593         ENDIF
594         CALL iom_put( "qns"    , qns         )                ! solar heat flux
595         CALL iom_put( "qsr"    , qsr         )                ! solar heat flux
596         IF( nn_ice > 0 .OR. ll_opa )   CALL iom_put( "ice_cover", fr_i )   ! ice fraction
597         CALL iom_put( "taum"   , taum        )                ! wind stress module
598         CALL iom_put( "wspd"   , wndm        )                ! wind speed  module over free ocean or leads in presence of sea-ice
599         CALL iom_put( "qrp"    , qrp         )                ! heat flux damping
600         CALL iom_put( "erp"    , erp         )                ! freshwater flux damping
601      ENDIF
602      !
603      IF(sn_cfctl%l_prtctl) THEN     ! print mean trends (used for debugging)
604         CALL prt_ctl(tab2d_1=fr_i                , clinfo1=' fr_i     - : ', mask1=tmask )
605         CALL prt_ctl(tab2d_1=(emp-rnf)           , clinfo1=' emp-rnf  - : ', mask1=tmask )
606         CALL prt_ctl(tab2d_1=(sfx-rnf)           , clinfo1=' sfx-rnf  - : ', mask1=tmask )
607         CALL prt_ctl(tab2d_1=qns                 , clinfo1=' qns      - : ', mask1=tmask )
608         CALL prt_ctl(tab2d_1=qsr                 , clinfo1=' qsr      - : ', mask1=tmask )
609         CALL prt_ctl(tab3d_1=tmask               , clinfo1=' tmask    - : ', mask1=tmask, kdim=jpk )
610         CALL prt_ctl(tab3d_1=ts(:,:,:,jp_tem,Kmm), clinfo1=' sst      - : ', mask1=tmask, kdim=1   )
611         CALL prt_ctl(tab3d_1=ts(:,:,:,jp_sal,Kmm), clinfo1=' sss      - : ', mask1=tmask, kdim=1   )
612         CALL prt_ctl(tab2d_1=utau                , clinfo1=' utau     - : ', mask1=umask,                      &
613            &         tab2d_2=vtau                , clinfo2=' vtau     - : ', mask2=vmask )
614      ENDIF
615
616      IF( kt == nitend )   CALL sbc_final         ! Close down surface module if necessary
617      !
618      IF( ln_timing )   CALL timing_stop('sbc')
619      !
620   END SUBROUTINE sbc
621
622
623   SUBROUTINE sbc_final
624      !!---------------------------------------------------------------------
625      !!                    ***  ROUTINE sbc_final  ***
626      !!
627      !! ** Purpose :   Finalize CICE (if used)
628      !!---------------------------------------------------------------------
629      !
630      IF( nn_ice == 3 )   CALL cice_sbc_final
631      !
632   END SUBROUTINE sbc_final
633
634   !!======================================================================
635END MODULE sbcmod
Note: See TracBrowser for help on using the repository browser.