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/r8727_WAVE-2_Clementi_add_coupling/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/r8727_WAVE-2_Clementi_add_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90 @ 8755

Last change on this file since 8755 was 8755, checked in by jcastill, 6 years ago

Further changes for ticket #1980
Receive the ocean wind stress components from a wave model, both in forced and coupled mode

File size: 10.1 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   !
20   USE fldread         ! read input fields
21   USE iom             ! IOM library
22   USE in_out_manager  ! I/O manager
23   USE lib_mpp         ! distribued memory computing library
24   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC sbc_flx       ! routine called by step.F90
30
31   INTEGER             ::   jpfld         ! maximum number of files to read
32   INTEGER             ::   jp_utau       ! index of wind stress (i-component) file
33   INTEGER             ::   jp_vtau       ! index of wind stress (j-component) file
34   INTEGER             ::   jp_qtot       ! index of total (non solar+solar) heat file
35   INTEGER             ::   jp_qsr        ! index of solar heat file
36   INTEGER             ::   jp_emp        ! index of evaporation-precipation file
37   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf    ! structure of input fields (file informations, fields read)
38
39   !! * Substitutions
40#  include "vectopt_loop_substitute.h90"
41   !!----------------------------------------------------------------------
42   !! NEMO/OPA 3.3 , NEMO-consortium (2010)
43   !! $Id$
44   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE sbc_flx( kt )
49      !!---------------------------------------------------------------------
50      !!                    ***  ROUTINE sbc_flx  ***
51      !!                   
52      !! ** Purpose :   provide at each time step the surface ocean fluxes
53      !!                (momentum, heat, freshwater and runoff)
54      !!
55      !! ** Method  : - READ each fluxes in NetCDF files:
56      !!                   i-component of the stress              utau  (N/m2)
57      !!                   j-component of the stress              vtau  (N/m2)
58      !!                   net downward heat flux                 qtot  (watt/m2)
59      !!                   net downward radiative flux            qsr   (watt/m2)
60      !!                   net upward freshwater (evapo - precip) emp   (kg/m2/s)
61      !!
62      !!      CAUTION :  - never mask the surface stress fields
63      !!                 - the stress is assumed to be in the (i,j) mesh referential
64      !!
65      !! ** Action  :   update at each time-step
66      !!              - utau, vtau  i- and j-component of the wind stress
67      !!              - taum        wind stress module at T-point
68      !!              - wndm        10m wind module at T-point
69      !!              - qns         non solar heat flux including heat flux due to emp
70      !!              - qsr         solar heat flux
71      !!              - emp         upward mass flux (evap. - precip.)
72      !!              - sfx         salt flux; set to zero at nit000 but possibly non-zero
73      !!                            if ice is present (computed in limsbc(_2).F90)
74      !!----------------------------------------------------------------------
75      INTEGER, INTENT(in) ::   kt   ! ocean time step
76      !!
77      INTEGER  ::   ji, jj, jf            ! dummy indices
78      INTEGER  ::   ierror                ! return error code
79      INTEGER  ::   ios                   ! Local integer output status for namelist read
80      REAL(wp) ::   zfact                 ! temporary scalar
81      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3
82      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient
83      REAL(wp) ::   ztx, zty, zmod, zcoef ! temporary variables
84      LOGICAL  ::   ln_readtau            ! Is it necessary to read utau, vtau from file?
85      !!
86      CHARACTER(len=100) ::  cn_dir                               ! Root directory for location of flx files
87      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                    ! array of namelist information structures
88      TYPE(FLD_N) ::   sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp  ! informations about the fields to be read
89      NAMELIST/namsbc_flx/ cn_dir, sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp
90      !!---------------------------------------------------------------------
91      !
92      IF( kt == nit000 ) THEN                ! First call kt=nit000 
93         ln_readtau = .NOT. (ln_wave .AND. ln_tauw )
94
95         ! prepare the index of the fields that have to be read
96         jpfld = 0
97         IF( ln_readtau ) THEN
98            jp_utau = jpfld+1
99            jp_vtau = jpfld+2
100            jpfld = jpfld+2
101         ELSE
102            jp_utau = 0   ;  jp_vtau = 0
103         ENDIF
104         jp_qtot = jpfld+1
105         jp_qsr = jpfld+2
106         jp_emp = jpfld+3
107         jpfld = jpfld+3
108
109         ! set file information
110         REWIND( numnam_ref )              ! Namelist namsbc_flx in reference namelist : Files for fluxes
111         READ  ( numnam_ref, namsbc_flx, IOSTAT = ios, ERR = 901)
112901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_flx in reference namelist', lwp )
113
114         REWIND( numnam_cfg )              ! Namelist namsbc_flx in configuration namelist : Files for fluxes
115         READ  ( numnam_cfg, namsbc_flx, IOSTAT = ios, ERR = 902 )
116902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_flx in configuration namelist', lwp )
117         IF(lwm) WRITE ( numond, namsbc_flx ) 
118         !
119         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
120         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &
121            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
122         !
123         !                                         ! store namelist information in an array
124         IF( ln_readtau ) THEN
125            slf_i(jp_utau) = sn_utau   ;   slf_i(jp_vtau) = sn_vtau
126         ENDIF
127         slf_i(jp_qtot) = sn_qtot   ;   slf_i(jp_qsr ) = sn_qsr 
128         slf_i(jp_emp ) = sn_emp
129         !
130         ALLOCATE( sf(jpfld), STAT=ierror )        ! set sf structure
131         IF( ierror > 0 ) THEN   
132            CALL ctl_stop( 'sbc_flx: unable to allocate sf structure' )   ;   RETURN 
133         ENDIF
134         DO ji= 1, jpfld
135            ALLOCATE( sf(ji)%fnow(jpi,jpj,1) )
136            IF( slf_i(ji)%ln_tint ) ALLOCATE( sf(ji)%fdta(jpi,jpj,1,2) )
137         END DO
138         !                                         ! fill sf with slf_i and control print
139         CALL fld_fill( sf, slf_i, cn_dir, 'sbc_flx', 'flux formulation for ocean surface boundary condition', 'namsbc_flx' )
140         !
141         sfx(:,:) = 0.0_wp                         ! salt flux due to freezing/melting (non-zero only if ice is present; set in limsbc(_2).F90)
142         !
143      ENDIF
144
145      CALL fld_read( kt, nn_fsbc, sf )                            ! input fields provided at the current time-step
146     
147      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN                        ! update ocean fluxes at each SBC frequency
148
149         IF( ln_dm2dc ) THEN   ;   qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) )   ! modify now Qsr to include the diurnal cycle
150         ELSE                  ;   qsr(:,:) =          sf(jp_qsr)%fnow(:,:,1)
151         ENDIF
152         DO jj = 1, jpj                                           ! set the ocean fluxes from read fields
153            DO ji = 1, jpi
154               IF( ln_readtau ) THEN
155                  utau(ji,jj) = sf(jp_utau)%fnow(ji,jj,1)
156                  vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj,1)
157               ENDIF
158               qns (ji,jj) = sf(jp_qtot)%fnow(ji,jj,1) - sf(jp_qsr)%fnow(ji,jj,1)
159               emp (ji,jj) = sf(jp_emp )%fnow(ji,jj,1)
160            END DO
161         END DO
162         !                                                        ! add to qns the heat due to e-p
163         qns(:,:) = qns(:,:) - emp(:,:) * sst_m(:,:) * rcp        ! mass flux is at SST
164         !
165         !                                                        ! module of wind stress and wind speed at T-point
166         IF( ln_readtau ) THEN
167            zcoef = 1. / ( zrhoa * zcdrag )
168            DO jj = 2, jpjm1
169               DO ji = fs_2, fs_jpim1   ! vect. opt.
170                  ztx = utau(ji-1,jj  ) + utau(ji,jj) 
171                  zty = vtau(ji  ,jj-1) + vtau(ji,jj) 
172                  zmod = 0.5 * SQRT( ztx * ztx + zty * zty )
173                  taum(ji,jj) = zmod
174                  wndm(ji,jj) = SQRT( zmod * zcoef )
175               END DO
176            END DO
177            taum(:,:) = taum(:,:) * tmask(:,:,1) ; wndm(:,:) = wndm(:,:) * tmask(:,:,1)
178            CALL lbc_lnk( taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( wndm(:,:), 'T', 1. )
179         ENDIF
180
181         IF( nitend-nit000 <= 100 .AND. lwp ) THEN                ! control print (if less than 100 time-step asked)
182            WRITE(numout,*) 
183            WRITE(numout,*) '        read daily momentum, heat and freshwater fluxes OK'
184            DO jf = 1, jpfld
185               IF( jf == jp_utau .OR. jf == jp_vtau )   zfact =     1.
186               IF( jf == jp_qtot .OR. jf == jp_qsr  )   zfact =     0.1
187               IF( jf == jp_emp                     )   zfact = 86400.
188               WRITE(numout,*) 
189               WRITE(numout,*) ' day: ', ndastp , TRIM(sf(jf)%clvar), ' * ', zfact
190            END DO
191         ENDIF
192         !
193      ENDIF
194      !
195   END SUBROUTINE sbc_flx
196
197   !!======================================================================
198END MODULE sbcflx
Note: See TracBrowser for help on using the repository browser.