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_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90 @ 8502

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

Bug fix - one variable was calculated using the wrong component

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