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.
sbcflx.F90 in branches/UKMO/r6232_INGV1_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/r6232_INGV1_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90 @ 7739

Last change on this file since 7739 was 7739, checked in by jcastill, 7 years ago

Add a 'standard formulation' for calculating momentum from forcing winds using a constant drag coefficient; remove drag coefficient checks after fixing the wave model

File size: 12.4 KB
Line 
1MODULE sbcflx
2   !!======================================================================
3   !!                       ***  MODULE  sbcflx  ***
4   !! Ocean forcing:  momentum, heat and freshwater flux formulation
5   !!=====================================================================
6   !! History :  1.0  !  2006-06  (G. Madec)  Original code
7   !!            3.3  !  2010-10  (S. Masson)  add diurnal cycle
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   namflx   : flux formulation namlist
12   !!   sbc_flx  : flux formulation as ocean surface boundary condition (forced mode, fluxes read in NetCDF files)
13   !!----------------------------------------------------------------------
14   USE oce             ! ocean dynamics and tracers
15   USE dom_oce         ! ocean space and time domain
16   USE sbc_oce         ! surface boundary condition: ocean fields
17   USE sbcdcy          ! surface boundary condition: diurnal cycle on qsr
18   USE phycst          ! physical constants
19   USE fldread         ! read input fields
20   USE iom             ! IOM library
21   USE in_out_manager  ! I/O manager
22   USE lib_mpp         ! distribued memory computing library
23   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
24   USE sbcwave         ! wave physics
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC sbc_flx       ! routine called by step.F90
30
31   INTEGER , PARAMETER ::   jpfld   = 5   ! maximum number of files to read
32   INTEGER , PARAMETER ::   jp_utau = 1   ! index of wind stress (i-component) file
33   INTEGER , PARAMETER ::   jp_vtau = 2   ! index of wind stress (j-component) file
34   INTEGER , PARAMETER ::   jp_qtot = 3   ! index of total (non solar+solar) heat file
35   INTEGER , PARAMETER ::   jp_qsr  = 4   ! index of solar heat file
36   INTEGER , PARAMETER ::   jp_emp  = 5   ! index of evaporation-precipation file
37   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf    ! structure of input fields (file informations, fields read)
38   LOGICAL , PUBLIC    ::   ln_shelf_flx = .FALSE. ! UKMO SHELF specific flux flag
39   INTEGER             ::   jpfld_local   ! maximum number of files to read (locally modified depending on ln_shelf_flx)
40
41   INTEGER, PUBLIC            ::   nn_drag        ! type of formula to calculate wind stress from wind components
42   INTEGER, PUBLIC, PARAMETER ::   jp_ukmo  = 0        ! UKMO SHELF formulation
43   INTEGER, PUBLIC, PARAMETER ::   jp_std   = 1        ! standard formulation with forced or coupled drag coefficient
44   INTEGER, PUBLIC, PARAMETER ::   jp_const = 2        ! standard formulation with constant drag coefficient
45
46   !! * Substitutions
47#  include "domzgr_substitute.h90"
48#  include "vectopt_loop_substitute.h90"
49   !!----------------------------------------------------------------------
50   !! NEMO/OPA 3.3 , NEMO-consortium (2010)
51   !! $Id$
52   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
53   !!----------------------------------------------------------------------
54CONTAINS
55
56   SUBROUTINE sbc_flx( kt )
57      !!---------------------------------------------------------------------
58      !!                    ***  ROUTINE sbc_flx  ***
59      !!                   
60      !! ** Purpose :   provide at each time step the surface ocean fluxes
61      !!                (momentum, heat, freshwater and runoff)
62      !!
63      !! ** Method  : - READ each fluxes in NetCDF files:
64      !!                   i-component of the stress              utau  (N/m2)
65      !!                   j-component of the stress              vtau  (N/m2)
66      !!                   net downward heat flux                 qtot  (watt/m2)
67      !!                   net downward radiative flux            qsr   (watt/m2)
68      !!                   net upward freshwater (evapo - precip) emp   (kg/m2/s)
69      !!
70      !!      CAUTION :  - never mask the surface stress fields
71      !!                 - the stress is assumed to be in the (i,j) mesh referential
72      !!
73      !! ** Action  :   update at each time-step
74      !!              - utau, vtau  i- and j-component of the wind stress
75      !!              - taum        wind stress module at T-point
76      !!              - wndm        10m wind module at T-point
77      !!              - qns         non solar heat flux including heat flux due to emp
78      !!              - qsr         solar heat flux
79      !!              - emp         upward mass flux (evap. - precip.)
80      !!              - sfx         salt flux; set to zero at nit000 but possibly non-zero
81      !!                            if ice is present (computed in limsbc(_2).F90)
82      !!----------------------------------------------------------------------
83      INTEGER, INTENT(in) ::   kt   ! ocean time step
84      !!
85      INTEGER  ::   ji, jj, jf            ! dummy indices
86      INTEGER  ::   ierror                ! return error code
87      INTEGER  ::   ios                   ! Local integer output status for namelist read
88      REAL(wp) ::   zfact                 ! temporary scalar
89      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3
90      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient
91      REAL(wp) ::   totwind               ! UKMO SHELF: Module of wind speed
92      REAL(wp) ::   ztx, zty, zmod, zcoef ! temporary variables
93      !!
94      CHARACTER(len=100) ::  cn_dir                               ! Root directory for location of flx files
95      NAMELIST/namsbc_flx/ ln_shelf_flx                           ! Put here to allow merging with another UKMO branch
96      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                    ! array of namelist information structures
97      TYPE(FLD_N) ::   sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp  ! informations about the fields to be read
98      NAMELIST/namsbc_flx/ cn_dir, sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp
99      !!---------------------------------------------------------------------
100      !
101      IF( kt == nit000 ) THEN                ! First call kt=nit000 
102         ! set file information
103         REWIND( numnam_ref )              ! Namelist namsbc_flx in reference namelist : Files for fluxes
104         READ  ( numnam_ref, namsbc_flx, IOSTAT = ios, ERR = 901)
105901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_flx in reference namelist', lwp )
106
107         REWIND( numnam_cfg )              ! Namelist namsbc_flx in configuration namelist : Files for fluxes
108         READ  ( numnam_cfg, namsbc_flx, IOSTAT = ios, ERR = 902 )
109902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_flx in configuration namelist', lwp )
110         IF(lwm) WRITE ( numond, namsbc_flx ) 
111         !
112         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
113         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &
114            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
115         !
116         !                                         ! store namelist information in an array
117         slf_i(jp_utau) = sn_utau   ;   slf_i(jp_vtau) = sn_vtau
118         slf_i(jp_qtot) = sn_qtot   ;   slf_i(jp_qsr ) = sn_qsr 
119         slf_i(jp_emp ) = sn_emp
120         !
121         ALLOCATE( sf(jpfld), STAT=ierror )        ! set sf structure
122         IF( ierror > 0 ) THEN   
123            CALL ctl_stop( 'sbc_flx: unable to allocate sf structure' )   ;   RETURN 
124         ENDIF
125         DO ji= 1, jpfld
126            ALLOCATE( sf(ji)%fnow(jpi,jpj,1) )
127            IF( slf_i(ji)%ln_tint ) ALLOCATE( sf(ji)%fdta(jpi,jpj,1,2) )
128         END DO
129         !                                         ! fill sf with slf_i and control print
130         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_flx', 'flux formulation for ocean surface boundary condition', 'namsbc_flx' )
131         !
132         sfx(:,:) = 0.0_wp                         ! salt flux due to freezing/melting (non-zero only if ice is present; set in limsbc(_2).F90)
133         !
134      ENDIF
135
136      CALL fld_read( kt, nn_fsbc, sf )                            ! input fields provided at the current time-step
137     
138      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN                        ! update ocean fluxes at each SBC frequency
139
140         IF( ln_dm2dc ) THEN   ;   qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) )   ! modify now Qsr to include the diurnal cycle
141         ELSE                  ;   qsr(:,:) =          sf(jp_qsr)%fnow(:,:,1)
142         ENDIF
143!CDIR COLLAPSE
144         DO jj = 1, jpj                                           ! set the ocean fluxes from read fields
145            DO ji = 1, jpi
146               utau(ji,jj) = sf(jp_utau)%fnow(ji,jj,1)
147               vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj,1)
148               qns (ji,jj) = sf(jp_qtot)%fnow(ji,jj,1) - sf(jp_qsr)%fnow(ji,jj,1)
149               emp (ji,jj) = sf(jp_emp )%fnow(ji,jj,1)
150            END DO
151         END DO
152         !                                                        ! add modification due to drag coefficient read from wave forcing
153         !                                                        ! this code is inefficient but put here to allow merging with another UKMO branch
154         IF( ln_shelf_flx ) THEN
155            IF( ln_cdgw .AND. nn_drag == jp_std ) THEN
156               IF( cpl_wdrag ) THEN 
157                  ! reset utau and vtau to the wind components: the momentum will
158                  ! be calculated from the coupled value of the drag coefficient
159                  DO jj = 1, jpj
160                     DO ji = 1, jpi
161                        utau(ji,jj) = sf(jp_utau)%fnow(ji,jj,1)
162                        vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj,1)
163                     END DO
164                  END DO
165               ELSE
166                  DO jj = 1, jpj
167                     DO ji = 1, jpi
168                        totwind = sqrt((sf(jp_utau)%fnow(ji,jj,1))**2.0 + (sf(jp_vtau)%fnow(ji,jj,1))**2.0)
169                        utau(ji,jj) = zrhoa * cdn_wave(ji,jj) * sf(jp_utau)%fnow(ji,jj,1) * totwind
170                        vtau(ji,jj) = zrhoa * cdn_wave(ji,jj) * sf(jp_vtau)%fnow(ji,jj,1) * totwind
171                     END DO
172                  END DO
173               ENDIF
174            ELSE IF( nn_drag == jp_const ) THEN
175               DO jj = 1, jpj
176                  DO ji = 1, jpi
177                     totwind = sqrt((sf(jp_utau)%fnow(ji,jj,1))**2.0 + (sf(jp_vtau)%fnow(ji,jj,1))**2.0)
178                     utau(ji,jj) = zrhoa * zcdrag * sf(jp_utau)%fnow(ji,jj,1) * totwind
179                     vtau(ji,jj) = zrhoa * zcdrag * sf(jp_vtau)%fnow(ji,jj,1) * totwind
180                  END DO
181               END DO
182            ENDIF
183         ENDIF
184         !                                                        ! add to qns the heat due to e-p
185         qns(:,:) = qns(:,:) - emp(:,:) * sst_m(:,:) * rcp        ! mass flux is at SST
186         !
187         !                                                        ! module of wind stress and wind speed at T-point
188         zcoef = 1. / ( zrhoa * zcdrag )
189!CDIR NOVERRCHK
190         DO jj = 2, jpjm1
191!CDIR NOVERRCHK
192            DO ji = fs_2, fs_jpim1   ! vect. opt.
193               ztx = utau(ji-1,jj  ) + utau(ji,jj) 
194               zty = vtau(ji  ,jj-1) + vtau(ji,jj) 
195               zmod = 0.5 * SQRT( ztx * ztx + zty * zty )
196               taum(ji,jj) = zmod
197               IF( ln_shelf_flx ) THEN
198                  ztx = sf(jp_utau)%fnow(ji-1,jj  ) + sf(jp_utau)%fnow(ji,jj)
199                  zty = sf(jp_vtau)%fnow(ji  ,jj-1) + sf(jp_vtau)%fnow(ji,jj)
200                  wndm(ji,jj) = 0.5 * SQRT( ztx * ztx + zty * zty )
201               ELSE
202               wndm(ji,jj) = SQRT( zmod * zcoef )
203               ENDIF
204            END DO
205         END DO
206         taum(:,:) = taum(:,:) * tmask(:,:,1) ; wndm(:,:) = wndm(:,:) * tmask(:,:,1)
207         CALL lbc_lnk( taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( wndm(:,:), 'T', 1. )
208
209         IF( nitend-nit000 <= 100 .AND. lwp ) THEN                ! control print (if less than 100 time-step asked)
210            WRITE(numout,*) 
211            WRITE(numout,*) '        read daily momentum, heat and freshwater fluxes OK'
212            DO jf = 1, jpfld
213               IF( jf == jp_utau .OR. jf == jp_vtau )   zfact =     1.
214               IF( jf == jp_qtot .OR. jf == jp_qsr  )   zfact =     0.1
215               IF( jf == jp_emp                     )   zfact = 86400.
216               WRITE(numout,*) 
217               WRITE(numout,*) ' day: ', ndastp , TRIM(sf(jf)%clvar), ' * ', zfact
218               CALL prihre( sf(jf)%fnow, jpi, jpj, 1, jpi, 20, 1, jpj, 10, zfact, numout )
219            END DO
220            CALL FLUSH(numout)
221         ENDIF
222         !
223      ENDIF
224      !
225   END SUBROUTINE sbc_flx
226
227   !!======================================================================
228END MODULE sbcflx
Note: See TracBrowser for help on using the repository browser.