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, 3 years ago

trunk: fix for wind forcing of icebergs #2728

  • Property svn:keywords set to Id
File size: 36.1 KB
RevLine 
[888]1MODULE sbcmod
2   !!======================================================================
3   !!                       ***  MODULE  sbcmod  ***
4   !! Surface module :  provide to the ocean its surface boundary condition
5   !!======================================================================
[2528]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
[3294]13   !!            3.4  ! 2011-11  (C. Harris) CICE added as an option
[3625]14   !!            3.5  ! 2012-11  (A. Coward, G. Madec) Rethink of heat, mass and salt surface fluxes
[7646]15   !!            3.6  ! 2014-11  (P. Mathiot, C. Harris) add ice shelves melting
16   !!            4.0  ! 2016-06  (L. Brodeau) new general bulk formulation
[12377]17   !!            4.0  ! 2019-03  (F. Lemarié & G. Samson)  add ABL compatibility (ln_abl=TRUE)
[14072]18   !!            4.2  ! 2020-12  (G. Madec, E. Clementi) modified wave forcing and coupling
[888]19   !!----------------------------------------------------------------------
20
21   !!----------------------------------------------------------------------
[6140]22   !!   sbc_init      : read namsbc namelist
23   !!   sbc           : surface ocean momentum, heat and freshwater boundary conditions
[7646]24   !!   sbc_final     : Finalize CICE ice model (if used)
[888]25   !!----------------------------------------------------------------------
[6140]26   USE oce            ! ocean dynamics and tracers
27   USE dom_oce        ! ocean space and time domain
[12377]28   USE closea         ! closed seas
[6140]29   USE phycst         ! physical constants
[14072]30   USE sbc_phy, ONLY : pp_cldf
[6140]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
[7646]37   USE sbcblk         ! surface boundary condition: bulk formulation
[12377]38   USE sbcabl         ! atmospheric boundary layer
[6140]39   USE sbcice_if      ! surface boundary condition: ice-if sea-ice model
[9570]40#if defined key_si3
[9656]41   USE icestp         ! surface boundary condition: SI3 sea-ice model
[9019]42#endif
[9656]43   USE sbcice_cice    ! surface boundary condition: CICE sea-ice model
[7646]44   USE sbccpl         ! surface boundary condition: coupled formulation
[6140]45   USE cpl_oasis3     ! OASIS routines for coupling
[12377]46   USE sbcclo         ! surface boundary condition: closed sea correction
[6140]47   USE sbcssr         ! surface boundary condition: sea surface restoring
48   USE sbcrnf         ! surface boundary condition: runoffs
[14072]49   USE sbcapr         ! surface boundary condition: atmo pressure
[6140]50   USE sbcfwb         ! surface boundary condition: freshwater budget
51   USE icbstp         ! Icebergs
[9940]52   USE icb_oce  , ONLY : ln_passive_mode      ! iceberg interaction mode
[6140]53   USE traqsr         ! active tracers: light penetration
54   USE sbcwave        ! Wave module
[7646]55   USE bdy_oce   , ONLY: ln_bdy
56   USE usrdef_sbc     ! user defined: surface boundary condition
[9161]57   USE closea         ! closed sea
[14007]58   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
[6140]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
[10499]65   USE wet_dry
[12377]66   USE diu_bulk, ONLY:   ln_diurnal_only   ! diurnal SST diagnostic
[888]67
68   IMPLICIT NONE
69   PRIVATE
70
71   PUBLIC   sbc        ! routine called by step.F90
[1725]72   PUBLIC   sbc_init   ! routine called by opa.F90
[7646]73
[888]74   INTEGER ::   nsbc   ! type of surface boundary condition (deduced from namsbc informations)
[14007]75   !! * Substitutions
76#  include "do_loop_substitute.h90"
[888]77   !!----------------------------------------------------------------------
[10068]78   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[1146]79   !! $Id$
[10068]80   !! Software governed by the CeCILL license (see ./LICENSE)
[888]81   !!----------------------------------------------------------------------
82CONTAINS
83
[12377]84   SUBROUTINE sbc_init( Kbb, Kmm, Kaa )
[888]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
[3607]91      !!                Call init routines for all other SBC modules that have one
[888]92      !!
93      !! ** Action  : - read namsbc parameters
94      !!              - nsbc: type of sbc
95      !!----------------------------------------------------------------------
[12377]96      INTEGER, INTENT(in) ::   Kbb, Kmm, Kaa         ! ocean time level indices
[7646]97      INTEGER ::   ios, icpt                         ! local integer
98      LOGICAL ::   ll_purecpl, ll_opa, ll_not_nemo   ! local logical
[1037]99      !!
[7646]100      NAMELIST/namsbc/ nn_fsbc  ,                                                    &
[12377]101         &             ln_usr   , ln_flx   , ln_blk   , ln_abl,                      &
[9019]102         &             ln_cpl   , ln_mixcpl, nn_components,                          &
103         &             nn_ice   , ln_ice_embd,                                       &
[7646]104         &             ln_traqsr, ln_dm2dc ,                                         &
[14007]105         &             ln_rnf   , nn_fwb     , ln_ssr   , ln_apr_dyn,                &
106         &             ln_wave  , nn_lsm
[1037]107      !!----------------------------------------------------------------------
[6140]108      !
[888]109      IF(lwp) THEN
110         WRITE(numout,*)
111         WRITE(numout,*) 'sbc_init : surface boundary condition setting'
112         WRITE(numout,*) '~~~~~~~~ '
113      ENDIF
[6140]114      !
[7646]115      !                       !**  read Surface Module namelist
[4147]116      READ  ( numnam_ref, namsbc, IOSTAT = ios, ERR = 901)
[11536]117901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist' )
[4147]118      READ  ( numnam_cfg, namsbc, IOSTAT = ios, ERR = 902 )
[11536]119902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist' )
[6140]120      IF(lwm) WRITE( numond, namsbc )
121      !
[14229]122#if ! defined key_mpi_off
[10425]123      ncom_fsbc = nn_fsbc    ! make nn_fsbc available for lib_mpp
124#endif
[13477]125#if ! defined key_si3
126      IF( nn_ice == 2 )    nn_ice = 0  ! without key key_si3 you cannot use si3...
127#endif
[7646]128      !
[13216]129      !
[7646]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
[12377]137         WRITE(numout,*) '         ABL          formulation                   ln_abl        = ', ln_abl
[14007]138         WRITE(numout,*) '         Surface wave (forced or coupled)           ln_wave       = ', ln_wave
[7646]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
[14072]142!!gm  lk_oasis is controlled by key_oasis3  ===>>>  It shoud be removed from the namelist
[7646]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
[9019]147         WRITE(numout,*) '         ice embedded into ocean                    ln_ice_embd   = ', ln_ice_embd
[7646]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
[888]156      ENDIF
[6140]157      !
[7646]158      IF( .NOT.ln_usr ) THEN     ! the model calendar needs some specificities (except in user defined case)
[12489]159         IF( MOD( rday , rn_Dt ) /= 0. )   CALL ctl_stop( 'the time step must devide the number of second of in a day' )
[7646]160         IF( MOD( rday , 2.  ) /= 0. )   CALL ctl_stop( 'the number of second of in a day must be an even number'    )
[12489]161         IF( MOD( rn_Dt  , 2.  ) /= 0. )   CALL ctl_stop( 'the time step (in second) must be an even number'           )
[888]162      ENDIF
[7646]163      !                       !**  check option consistency
[4161]164      !
[14227]165      IF(lwp) WRITE(numout,*)       !* Single / Multi - executable (NEMO / OCE+SAS)
[7646]166      SELECT CASE( nn_components )
167      CASE( jp_iam_nemo )
[14227]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' )
[7646]174      CASE( jp_iam_sas  )
[9190]175         IF(lwp) WRITE(numout,*) '   ==>>>   Multi executable configuration. Here, SAS component'
[14227]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' )
[7646]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
[14072]197      CASE( 1 )                        !- Ice-cover climatology ("Ice-if" model)
[9656]198      CASE( 2 )                        !- SI3  ice model
[12377]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' )
[9019]201      CASE( 3 )                        !- CICE ice model
[12377]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                                )   &
[14072]205            &                   CALL ctl_stop( 'sbc_init : CICE sea-ice model not currently available with AGRIF' )
[7646]206      CASE DEFAULT                     !- not supported
207      END SELECT
[13722]208      IF( ln_diurnal .AND. .NOT. (ln_blk.OR.ln_abl) )   CALL ctl_stop( "sbc_init: diurnal flux processing only implemented for bulk forcing" )
[7646]209      !
210      !                       !**  allocate and set required variables
211      !
212      !                             !* allocate sbc arrays
[5836]213      IF( sbc_oce_alloc() /= 0 )   CALL ctl_stop( 'sbc_init : unable to allocate sbc_oce arrays' )
[9570]214#if ! defined key_si3 && ! defined key_cice
[9019]215      IF( sbc_ice_alloc() /= 0 )   CALL ctl_stop( 'sbc_init : unable to allocate sbc_ice arrays' )
216#endif
[7646]217      !
[12276]218      !
219      IF( sbc_ssr_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_ssr arrays' )
[14072]220      IF( .NOT.ln_ssr ) THEN               !* Initialize qrp and erp if no restoring
[12276]221         qrp(:,:) = 0._wp
222         erp(:,:) = 0._wp
223      ENDIF
224      !
[7646]225      IF( nn_ice == 0 ) THEN        !* No sea-ice in the domain : ice fraction is always zero
[14227]226         IF( nn_components /= jp_iam_oce )   fr_i(:,:) = 0._wp    ! except for OCE in SAS-OCE coupled case
[7646]227      ENDIF
228      !
[7753]229      sfx   (:,:) = 0._wp           !* salt flux due to freezing/melting
230      fmmflx(:,:) = 0._wp           !* freezing minus melting flux
[13546]231      cloud_fra(:,:) = pp_cldf      !* cloud fraction over sea ice (used in si3)
[1037]232
[7753]233      taum(:,:) = 0._wp             !* wind stress module (needed in GLS in case of reduced restart)
234
[2528]235      !                          ! Choice of the Surface Boudary Condition (set nsbc)
[12377]236      nday_qsr = -1   ! allow initialization at the 1st call !LB: now warm-layer of COARE* calls "sbc_dcy_param" of sbcdcy.F90!
[7646]237      IF( ln_dm2dc ) THEN           !* daily mean to diurnal cycle
[12377]238         !LB:nday_qsr = -1   ! allow initialization at the 1st call
[14227]239         IF( .NOT.( ln_flx .OR. ln_blk .OR. ln_abl ) .AND. nn_components /= jp_iam_oce )   &
[12377]240            &   CALL ctl_stop( 'qsr diurnal cycle from daily values requires flux, bulk or abl formulation' )
[7646]241      ENDIF
242      !                             !* Choice of the Surface Boudary Condition
243      !                             (set nsbc)
[5407]244      !
[7646]245      ll_purecpl  = ln_cpl .AND. .NOT.ln_mixcpl
[14227]246      ll_opa      = nn_components == jp_iam_oce
[7646]247      ll_not_nemo = nn_components /= jp_iam_nemo
[888]248      icpt = 0
[7646]249      !
250      IF( ln_usr          ) THEN   ;   nsbc = jp_usr     ; icpt = icpt + 1   ;   ENDIF       ! user defined         formulation
[5407]251      IF( ln_flx          ) THEN   ;   nsbc = jp_flx     ; icpt = icpt + 1   ;   ENDIF       ! flux                 formulation
[7646]252      IF( ln_blk          ) THEN   ;   nsbc = jp_blk     ; icpt = icpt + 1   ;   ENDIF       ! bulk                 formulation
[12377]253      IF( ln_abl          ) THEN   ;   nsbc = jp_abl     ; icpt = icpt + 1   ;   ENDIF       ! ABL                  formulation
[5407]254      IF( ll_purecpl      ) THEN   ;   nsbc = jp_purecpl ; icpt = icpt + 1   ;   ENDIF       ! Pure Coupled         formulation
[7646]255      IF( ll_opa          ) THEN   ;   nsbc = jp_none    ; icpt = icpt + 1   ;   ENDIF       ! opa coupling via SAS module
[2528]256      !
[7646]257      IF( icpt /= 1 )    CALL ctl_stop( 'sbc_init : choose ONE and only ONE sbc option' )
[5836]258      !
[7646]259      IF(lwp) THEN                     !- print the choice of surface flux formulation
[888]260         WRITE(numout,*)
[6140]261         SELECT CASE( nsbc )
[9190]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'
[12377]265         CASE( jp_abl     )   ;   WRITE(numout,*) '   ==>>>   ABL  formulation'
[9190]266         CASE( jp_purecpl )   ;   WRITE(numout,*) '   ==>>>   pure coupled formulation'
[7646]267!!gm abusive use of jp_none ??   ===>>> need to be check and changed by adding a jp_sas parameter
[14227]268         CASE( jp_none    )   ;   WRITE(numout,*) '   ==>>>   OCE coupled to SAS via oasis'
[9190]269            IF( ln_mixcpl )       WRITE(numout,*) '               + forced-coupled mixed formulation'
[6140]270         END SELECT
[9190]271         IF( ll_not_nemo  )       WRITE(numout,*) '               + OASIS coupled SAS'
[888]272      ENDIF
273      !
[7646]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
[14227]278      !     nn_fsbc initialization if OCE-SAS coupling via OASIS
[7646]279      !     SAS time-step has to be declared in OASIS (mandatory) -> nn_fsbc has to be modified accordingly
[6140]280      IF( nn_components /= jp_iam_nemo ) THEN
[14227]281         IF( nn_components == jp_iam_oce )   nn_fsbc = cpl_freq('O_SFLX') / NINT(rn_Dt)
[12489]282         IF( nn_components == jp_iam_sas )   nn_fsbc = cpl_freq('I_SFLX') / NINT(rn_Dt)
[5407]283         !
284         IF(lwp)THEN
285            WRITE(numout,*)
[14227]286            WRITE(numout,*)"   OCE-SAS coupled via OASIS : nn_fsbc re-defined from OASIS namcouple ", nn_fsbc
[5407]287            WRITE(numout,*)
288         ENDIF
289      ENDIF
[6140]290      !
[7646]291      !                             !* check consistency between model timeline and nn_fsbc
[11536]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
[5407]301      ENDIF
302      !
[12489]303      IF( MOD( rday, REAL(nn_fsbc, wp) * rn_Dt ) /= 0 )   &
[7646]304         &  CALL ctl_warn( 'sbc_init : nn_fsbc is NOT a multiple of the number of time steps in a day' )
[5407]305      !
[12489]306      IF( ln_dm2dc .AND. NINT(rday) / ( nn_fsbc * NINT(rn_Dt) ) < 8  )   &
[7646]307         &   CALL ctl_warn( 'sbc_init : diurnal cycle for qsr: the sampling of the diurnal cycle is too small...' )
[4152]308      !
[14072]309
[7646]310      !                       !**  associated modules : initialization
[3764]311      !
[12377]312                          CALL sbc_ssm_init ( Kbb, Kmm ) ! Sea-surface mean fields initialization
[5385]313      !
[12377]314      IF( l_sbc_clo   )   CALL sbc_clo_init              ! closed sea surface initialisation
315      !
[13546]316      IF( ln_blk      )   CALL sbc_blk_init              ! bulk formulae initialization
[7646]317
[13546]318      IF( ln_abl      )   CALL sbc_abl_init              ! Atmospheric Boundary Layer (ABL)
[12377]319
[13546]320      IF( ln_ssr      )   CALL sbc_ssr_init              ! Sea-Surface Restoring initialization
[6140]321      !
[7788]322      !
[12377]323                          CALL sbc_rnf_init( Kmm )       ! Runof initialization
[6140]324      !
[12377]325      IF( ln_apr_dyn )    CALL sbc_apr_init              ! Atmo Pressure Forcing initialization
[8524]326      !
[9570]327#if defined key_si3
[9019]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
[12377]331                          CALL ice_init( Kbb, Kmm, Kaa )         ! ICE initialization
[9019]332      ENDIF
333#endif
[12377]334      IF( nn_ice == 3 )   CALL cice_sbc_init( nsbc, Kbb, Kmm )   ! CICE initialization
[6140]335      !
[14007]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
[7646]354      !
[888]355   END SUBROUTINE sbc_init
356
357
[12377]358   SUBROUTINE sbc( kt, Kbb, Kmm )
[888]359      !!---------------------------------------------------------------------
360      !!                    ***  ROUTINE sbc  ***
[7646]361      !!
[888]362      !! ** Purpose :   provide at each time-step the ocean surface boundary
363      !!                condition (momentum, heat and freshwater fluxes)
364      !!
[7646]365      !! ** Method  :   blah blah  to be written ?????????
[888]366      !!                CAUTION : never mask the surface stress field (tke sbc)
367      !!
[7646]368      !! ** Action  : - set the ocean surface boundary condition at before and now
369      !!                time step, i.e.
[3625]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
[1037]372      !!              - updte the ice fraction : fr_i
[888]373      !!----------------------------------------------------------------------
[7646]374      INTEGER, INTENT(in) ::   kt   ! ocean time step
[12377]375      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
[14007]376      INTEGER  ::   jj, ji          ! dummy loop argument
[7646]377      !
378      LOGICAL ::   ll_sas, ll_opa   ! local logical
[10499]379      !
380      REAL(wp) ::     zthscl        ! wd  tanh scale
[14072]381      REAL(wp), DIMENSION(jpi,jpj) ::  zwdht, zwght  ! wd dep over wd limit, wgt
[15145]382      REAL(wp), DIMENSION(jpi,jpj) ::  z2d           ! temporary array used for iom_put
[10499]383
[888]384      !!---------------------------------------------------------------------
[3294]385      !
[9124]386      IF( ln_timing )   CALL timing_start('sbc')
[3294]387      !
[2528]388      !                                            ! ---------------------------------------- !
389      IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          !
390         !                                         ! ---------------------------------------- !
[7753]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 (:,:)
[12377]396         IF( ln_rnf ) THEN
[7753]397            rnf_b    (:,:  ) = rnf    (:,:  )
398            rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)
[6460]399         ENDIF
[7788]400        !
[2528]401      ENDIF
402      !                                            ! ---------------------------------------- !
403      !                                            !        forcing field computation         !
404      !                                            ! ---------------------------------------- !
[1482]405      !
[7646]406      ll_sas = nn_components == jp_iam_sas               ! component flags
[14227]407      ll_opa = nn_components == jp_iam_oce
[7646]408      !
[12377]409      IF( .NOT.ll_sas )   CALL sbc_ssm ( kt, Kbb, Kmm )  ! mean ocean sea surface variables (sst_m, sss_m, ssu_m, ssv_m)
[7646]410      !
411      !                                            !==  sbc formulation  ==!
[14007]412      !
[14072]413      !
[2528]414      SELECT CASE( nsbc )                                ! Compute ocean surface boundary condition
[3625]415      !                                                  ! (i.e. utau,vtau, qns, qsr, emp, sfx)
[14072]416      CASE( jp_usr   )     ;   CALL usrdef_sbc_oce( kt, Kbb )                        ! user defined formulation
[12377]417      CASE( jp_flx     )   ;   CALL sbc_flx       ( kt )                             ! flux formulation
[7646]418      CASE( jp_blk     )
[14227]419         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-SAS coupling: SAS receiving fields from OCE
[14007]420!!!!!!!!!!! ATTENTION:ln_wave is not only used for oasis coupling !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
421         IF( ln_wave )   THEN
[14227]422             IF ( lk_oasis )  CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-wave coupling
[14007]423             CALL sbc_wave ( kt, Kmm )
424         ENDIF
[7646]425                               CALL sbc_blk       ( kt )                    ! bulk formulation for the ocean
426                               !
[12377]427      CASE( jp_abl     )
[14227]428         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-SAS coupling: SAS receiving fields from OCE
[12377]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
[7646]432      CASE( jp_none    )
[14227]433         IF( ll_opa    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )  ! OCE-SAS coupling: OCE receiving fields from SAS
[888]434      END SELECT
[7646]435      !
[12377]436      IF( ln_mixcpl )          CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )  ! forced-coupled mixed formulation after forcing
[6140]437      !
[14007]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. )
[9023]467      !
[15372]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      !
[2528]472      !                                            !==  Misc. Options  ==!
[6140]473      !
[3632]474      SELECT CASE( nn_ice )                                       ! Update heat and freshwater fluxes over sea-ice areas
[12377]475      CASE(  1 )   ;         CALL sbc_ice_if   ( kt, Kbb, Kmm )   ! Ice-cover climatology ("Ice-if" model)
[9570]476#if defined key_si3
[12377]477      CASE(  2 )   ;         CALL ice_stp  ( kt, Kbb, Kmm, nsbc ) ! SI3 ice model
[9019]478#endif
479      CASE(  3 )   ;         CALL sbc_ice_cice ( kt, nsbc )       ! CICE ice model
[7646]480      END SELECT
[888]481
[14834]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 )
[9940]491      ENDIF
[3609]492
[3632]493      IF( ln_rnf         )   CALL sbc_rnf( kt )                   ! add runoffs to fresh water fluxes
[7646]494
[12377]495      IF( ln_ssr         )   CALL sbc_ssr( kt )                        ! add SST/SSS damping term
[888]496
[12377]497      IF( nn_fwb    /= 0 )   CALL sbc_fwb( kt, nn_fwb, nn_fsbc, Kmm )  ! control the freshwater budget
[888]498
[9161]499      ! Special treatment of freshwater fluxes over closed seas in the model domain
500      ! Should not be run if ln_diurnal_only
[14072]501      IF( l_sbc_clo      )   CALL sbc_clo( kt )
[6140]502
[9439]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.
[13226]505!!$      CALL lbc_lnk( 'sbcmod', emp, 'T', 1.0_wp )
[12377]506      IF( ll_wd ) THEN     ! If near WAD point limit the flux for now
[14072]507         zthscl = atanh(rn_wd_sbcfra)                     ! taper frac default is .999
[12377]508         zwdht(:,:) = ssh(:,:,Kmm) + ht_0(:,:) - rn_wdmin1   ! do this calc of water
[10499]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
[2502]530      !
[2528]531      IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    !
532         !                                             ! ---------------------------------------- !
[14053]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
[3625]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
[13970]542               CALL iom_get( numror, jpdom_auto, 'sfx_b', sfx_b )  ! before salt flux (T-point)
[3625]543            ELSE
[7753]544               sfx_b (:,:) = sfx(:,:)
[3625]545            ENDIF
[2528]546         ELSE                                                   !* no restart: set from nit000 values
547            IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields set to nit000'
[7753]548            utau_b(:,:) = utau(:,:)
549            vtau_b(:,:) = vtau(:,:)
550            qns_b (:,:) = qns (:,:)
551            emp_b (:,:) = emp (:,:)
552            sfx_b (:,:) = sfx (:,:)
[2528]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,*) '~~~~'
[13970]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  )
[2528]565         ! The 3D heat content due to qsr forcing is treated in traqsr
566         ! CALL iom_rstput( kt, nitrst, numrow, 'qsr_b'  , qsr  )
[13970]567         CALL iom_rstput( kt, nitrst, numrow, 'emp_b'  , emp  )
568         CALL iom_rstput( kt, nitrst, numrow, 'sfx_b'  , sfx  )
[2528]569      ENDIF
570      !                                                ! ---------------------------------------- !
571      !                                                !        Outputs and control print         !
572      !                                                ! ---------------------------------------- !
[1482]573      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
[15145]574         IF( iom_use("empmr") ) THEN
575            DO_2D( 0, 0, 0, 0 )
[15149]576               z2d(ji,jj) =  emp(ji,jj) - rnf(ji,jj)
[15145]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 )
[15149]582               z2d(ji,jj) =  emp_b(ji,jj) - rnf(ji,jj)
[15145]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
[14053]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
[15145]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
[14053]594         CALL iom_put( "qns"    , qns         )                ! solar heat flux
[15145]595         CALL iom_put( "qsr"    , qsr         )                ! solar heat flux
[7646]596         IF( nn_ice > 0 .OR. ll_opa )   CALL iom_put( "ice_cover", fr_i )   ! ice fraction
[14053]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
[1482]601      ENDIF
602      !
[12377]603      IF(sn_cfctl%l_prtctl) THEN     ! print mean trends (used for debugging)
[14053]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 )
[12377]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 )
[888]614      ENDIF
[3294]615
616      IF( kt == nitend )   CALL sbc_final         ! Close down surface module if necessary
[888]617      !
[9124]618      IF( ln_timing )   CALL timing_stop('sbc')
[3294]619      !
[888]620   END SUBROUTINE sbc
621
[3764]622
[3294]623   SUBROUTINE sbc_final
624      !!---------------------------------------------------------------------
625      !!                    ***  ROUTINE sbc_final  ***
[3764]626      !!
627      !! ** Purpose :   Finalize CICE (if used)
[3294]628      !!---------------------------------------------------------------------
[3764]629      !
[9019]630      IF( nn_ice == 3 )   CALL cice_sbc_final
[3294]631      !
632   END SUBROUTINE sbc_final
633
[888]634   !!======================================================================
635END MODULE sbcmod
Note: See TracBrowser for help on using the repository browser.