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

source: branches/UKMO/dev_r5518_GO6_under_ice_relax_dr_hook/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90 @ 11738

Last change on this file since 11738 was 11738, checked in by marc, 5 years ago

The Dr Hook changes from my perl code.

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