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.
sbcana.F90 in branches/UKMO/test_moci_test_suite_namelist_read/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/test_moci_test_suite_namelist_read/NEMOGCM/NEMO/OPA_SRC/SBC/sbcana.F90 @ 9366

Last change on this file since 9366 was 9366, checked in by andmirek, 6 years ago

#2050 first version. Compiled OK in moci test suite

File size: 17.3 KB
Line 
1MODULE sbcana
2   !!======================================================================
3   !!                       ***  MODULE  sbcana  ***
4   !! Ocean forcing:  analytical momentum, heat and freshwater forcings
5   !!=====================================================================
6   !! History :  3.0   ! 2006-06  (G. Madec)  Original code
7   !!            3.2   ! 2009-07  (G. Madec)  Style only
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   sbc_ana  : set an analytical ocean forcing
12   !!   sbc_gyre : set the GYRE configuration analytical forcing
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 phycst          ! physical constants
18   USE in_out_manager  ! I/O manager
19   USE lib_mpp         ! distribued memory computing library
20   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
21   USE lib_fortran
22
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC   sbc_ana    ! routine called in sbcmod module
27   PUBLIC   sbc_gyre   ! routine called in sbcmod module
28   PRIVATE  ana_namelist
29
30   !                       !!* Namelist namsbc_ana *
31   INTEGER  ::   nn_tau000  ! nb of time-step during which the surface stress
32   !                        ! increase from 0 to its nominal value
33   REAL(wp) ::   rn_utau0   ! constant wind stress value in i-direction
34   REAL(wp) ::   rn_vtau0   ! constant wind stress value in j-direction
35   REAL(wp) ::   rn_qns0    ! non solar heat flux
36   REAL(wp) ::   rn_qsr0    !     solar heat flux
37   REAL(wp) ::   rn_emp0    ! net freshwater flux
38   
39   !! * Substitutions
40#  include "domzgr_substitute.h90"
41#  include "vectopt_loop_substitute.h90"
42   !!----------------------------------------------------------------------
43   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
44   !! $Id$
45   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
46   !!----------------------------------------------------------------------
47CONTAINS
48
49   SUBROUTINE sbc_ana( kt )
50      !!---------------------------------------------------------------------
51      !!                    ***  ROUTINE sbc_ana ***
52      !!             
53      !! ** Purpose :   provide at each time-step the ocean surface boundary
54      !!              condition, i.e. the momentum, heat and freshwater fluxes.
55      !!
56      !! ** Method  :   Constant and uniform surface forcing specified from
57      !!              namsbc_ana namelist parameters. All the fluxes are time
58      !!              independant except the stresses which increase from zero
59      !!              during the first nn_tau000 time-step
60      !!
61      !! ** Action  : - set the ocean surface boundary condition, i.e. 
62      !!                   utau, vtau, taum, wndm, qns, qsr, emp, sfx
63      !!----------------------------------------------------------------------
64      INTEGER, INTENT(in) ::   kt   ! ocean time step
65      !
66      INTEGER  ::   ios                   ! local integer
67      REAL(wp) ::   zrhoa  = 1.22_wp      ! air density kg/m3
68      REAL(wp) ::   zcdrag = 1.5e-3_wp    ! drag coefficient
69      REAL(wp) ::   zfact, ztx            ! local scalars
70      REAL(wp) ::   zcoef, zty, zmod      !   -      -
71      !!
72      NAMELIST/namsbc_ana/ nn_tau000, rn_utau0, rn_vtau0, rn_qns0, rn_qsr0, rn_emp0
73      !!---------------------------------------------------------------------
74      !
75      IF( kt == nit000 ) THEN
76         !
77         IF(lwm) THEN
78            REWIND( numnam_ref )              ! Namelist namsbc_ana in reference namelist : Analytical surface fluxes
79            READ  ( numnam_ref, namsbc_ana, IOSTAT = ios, ERR = 901)
80901         IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ana in reference namelist', lwm )
81            REWIND( numnam_cfg )              ! Namelist namsbc_ana in configuration namelist : Analytical surface fluxes
82            READ  ( numnam_cfg, namsbc_ana, IOSTAT = ios, ERR = 902 )
83902         IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ana in configuration namelist', lwm )
84         ENDIF
85
86         IF(lwm) WRITE ( numond, namsbc_ana )
87
88         CALL ana_namelist()
89         !
90         IF(lwp) WRITE(numout,*)' '
91         IF(lwp) WRITE(numout,*)' sbc_ana : Constant surface fluxes read in namsbc_ana namelist'
92         IF(lwp) WRITE(numout,*)' ~~~~~~~ '
93         IF(lwp) WRITE(numout,*)'              spin up of the stress  nn_tau000 = ', nn_tau000, ' time-steps'
94         IF(lwp) WRITE(numout,*)'              constant i-stress      rn_utau0  = ', rn_utau0 , ' N/m2'
95         IF(lwp) WRITE(numout,*)'              constant j-stress      rn_vtau0  = ', rn_vtau0 , ' N/m2'
96         IF(lwp) WRITE(numout,*)'              non solar heat flux    rn_qns0   = ', rn_qns0  , ' W/m2'
97         IF(lwp) WRITE(numout,*)'              solar heat flux        rn_qsr0   = ', rn_qsr0  , ' W/m2'
98         IF(lwp) WRITE(numout,*)'              net heat flux          rn_emp0   = ', rn_emp0  , ' Kg/m2/s'
99         !
100         nn_tau000 = MAX( nn_tau000, 1 )     ! must be >= 1
101         !
102         utau(:,:) = rn_utau0
103         vtau(:,:) = rn_vtau0
104         taum(:,:) = SQRT ( rn_utau0 * rn_utau0 + rn_vtau0 * rn_vtau0 )
105         wndm(:,:) = SQRT ( taum(1,1) /  ( zrhoa * zcdrag ) )
106         !
107         emp (:,:) = rn_emp0
108         sfx (:,:) = 0.0_wp
109         qns (:,:) = rn_qns0 - emp(:,:) * sst_m(:,:) * rcp      ! including heat content associated with mass flux at SST
110         qsr (:,:) = rn_qsr0
111         !         
112      ENDIF
113
114      IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN 
115         !
116         IF( kt <= nn_tau000 ) THEN       ! Increase the stress to its nominal value
117            !                             ! during the first nn_tau000 time-steps
118            zfact = 0.5 * (  1. - COS( rpi * REAL( kt, wp ) / REAL( nn_tau000, wp ) )  )
119            zcoef = 1. / ( zrhoa * zcdrag ) 
120            ztx   = zfact * rn_utau0
121            zty   = zfact * rn_vtau0
122            zmod  = SQRT( ztx * ztx + zty * zty )
123            utau(:,:) = ztx
124            vtau(:,:) = zty
125            taum(:,:) = zmod
126            zmod = SQRT( zmod * zcoef )
127            wndm(:,:) = zmod
128         ENDIF
129         !                                ! update heat and fresh water fluxes
130         !                                ! as they may have been changed by sbcssr module
131         emp (:,:) = rn_emp0              ! NB: qns changes with SST if emp /= 0
132         sfx (:,:) = 0._wp
133         qns (:,:) = rn_qns0 - emp(:,:) * sst_m(:,:) * rcp
134         qsr (:,:) = rn_qsr0
135         !
136      ENDIF
137      !
138   END SUBROUTINE sbc_ana
139
140
141   SUBROUTINE sbc_gyre( kt )
142      !!---------------------------------------------------------------------
143      !!                    ***  ROUTINE sbc_ana ***
144      !!             
145      !! ** Purpose :   provide at each time-step the GYRE surface boundary
146      !!              condition, i.e. the momentum, heat and freshwater fluxes.
147      !!
148      !! ** Method  :   analytical seasonal cycle for GYRE configuration.
149      !!                CAUTION : never mask the surface stress field !
150      !!
151      !! ** Action  : - set the ocean surface boundary condition, i.e.   
152      !!                   utau, vtau, taum, wndm, qns, qsr, emp, sfx
153      !!
154      !! Reference : Hazeleger, W., and S. Drijfhout, JPO, 30, 677-695, 2000.
155      !!----------------------------------------------------------------------
156      INTEGER, INTENT(in) ::   kt          ! ocean time step
157      !!
158      INTEGER  ::   ji, jj                 ! dummy loop indices
159      INTEGER  ::   zyear0                 ! initial year
160      INTEGER  ::   zmonth0                ! initial month
161      INTEGER  ::   zday0                  ! initial day
162      INTEGER  ::   zday_year0             ! initial day since january 1st
163      REAL(wp) ::   ztau     , ztau_sais   ! wind intensity and of the seasonal cycle
164      REAL(wp) ::   ztime                  ! time in hour
165      REAL(wp) ::   ztimemax , ztimemin    ! 21th June, and 21th decem. if date0 = 1st january
166      REAL(wp) ::   ztimemax1, ztimemin1   ! 21th June, and 21th decem. if date0 = 1st january
167      REAL(wp) ::   ztimemax2, ztimemin2   ! 21th June, and 21th decem. if date0 = 1st january
168      REAL(wp) ::   ztaun                  ! intensity
169      REAL(wp) ::   zemp_s, zemp_n, zemp_sais, ztstar
170      REAL(wp) ::   zcos_sais1, zcos_sais2, ztrp, zconv, t_star
171      REAL(wp) ::   zsumemp, zsurf
172      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3
173      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient
174      REAL(wp) ::   ztx, zty, zmod, zcoef ! temporary variables
175      REAL(wp) ::   zyydd                 ! number of days in one year
176      !!---------------------------------------------------------------------
177      zyydd = REAL(nyear_len(1),wp)
178
179      ! ---------------------------- !
180      !  heat and freshwater fluxes  !
181      ! ---------------------------- !
182      !same temperature, E-P as in HAZELEGER 2000
183
184      zyear0     =   ndate0 / 10000                             ! initial year
185      zmonth0    = ( ndate0 - zyear0 * 10000 ) / 100            ! initial month
186      zday0      =   ndate0 - zyear0 * 10000 - zmonth0 * 100    ! initial day betwen 1 and 30
187      zday_year0 = ( zmonth0 - 1 ) * 30.+zday0                  ! initial day betwen 1 and 360
188
189      ! current day (in hours) since january the 1st of the current year
190      ztime = REAL( kt ) * rdt / (rmmss * rhhmm)   &       !  total incrementation (in hours)
191         &      - (nyear  - 1) * rjjhh * zyydd             !  minus years since beginning of experiment (in hours)
192
193      ztimemax1 = ((5.*30.)+21.)* 24.                      ! 21th june     at 24h in hours
194      ztimemin1 = ztimemax1 + rjjhh * zyydd / 2            ! 21th december        in hours
195      ztimemax2 = ((6.*30.)+21.)* 24.                      ! 21th july     at 24h in hours
196      ztimemin2 = ztimemax2 - rjjhh * zyydd / 2            ! 21th january         in hours
197      !                                                    ! NB: rjjhh * zyydd / 4 = one seasonal cycle in hours
198
199      ! amplitudes
200      zemp_S    = 0.7       ! intensity of COS in the South
201      zemp_N    = 0.8       ! intensity of COS in the North
202      zemp_sais = 0.1
203      zTstar    = 28.3      ! intemsity from 28.3 a -5 deg
204
205      ! 1/2 period between 21th June and 21th December and between 21th July and 21th January
206      zcos_sais1 = COS( (ztime - ztimemax1) / (ztimemin1 - ztimemax1) * rpi ) 
207      zcos_sais2 = COS( (ztime - ztimemax2) / (ztimemax2 - ztimemin2) * rpi )
208
209      ztrp= - 40.e0        ! retroaction term on heat fluxes (W/m2/K)
210      zconv = 3.16e-5      ! convertion factor: 1 m/yr => 3.16e-5 mm/s
211      DO jj = 1, jpj
212         DO ji = 1, jpi
213            ! domain from 15 deg to 50 deg between 27 and 28  degC at 15N, -3
214            ! and 13 degC at 50N 53.5 + or - 11 = 1/4 period :
215            ! 64.5 in summer, 42.5 in winter
216            t_star = zTstar * ( 1 + 1. / 50. * zcos_sais2 )                &
217               &                    * COS( rpi * (gphit(ji,jj) - 5.)               &
218               &                    / ( 53.5 * ( 1 + 11 / 53.5 * zcos_sais2 ) * 2.) )
219            ! 23.5 deg : tropics
220            qsr (ji,jj) =  230 * COS( 3.1415 * ( gphit(ji,jj) - 23.5 * zcos_sais1 ) / ( 0.9 * 180 ) )
221            qns (ji,jj) = ztrp * ( tsb(ji,jj,1,jp_tem) - t_star ) - qsr(ji,jj)
222            IF( gphit(ji,jj) >= 14.845 .AND. 37.2 >= gphit(ji,jj) ) THEN    ! zero at 37.8 deg, max at 24.6 deg
223               emp  (ji,jj) =   zemp_S * zconv   &
224                  &         * SIN( rpi / 2 * (gphit(ji,jj) - 37.2) / (24.6 - 37.2) )  &
225                  &         * ( 1 - zemp_sais / zemp_S * zcos_sais1)
226            ELSE
227               emp (ji,jj) =  - zemp_N * zconv   &
228                  &         * SIN( rpi / 2 * (gphit(ji,jj) - 37.2) / (46.8 - 37.2) )  &
229                  &         * ( 1 - zemp_sais / zemp_N * zcos_sais1 )
230            ENDIF
231         END DO
232      END DO
233
234      ! Compute the emp flux such as its integration on the whole domain at each time is zero
235      IF( nbench /= 1 ) THEN
236         zsumemp = GLOB_SUM( emp(:,:) ) 
237         zsurf   = GLOB_SUM( tmask(:,:,1) ) 
238         ! Default GYRE configuration
239         zsumemp = zsumemp / zsurf
240      ELSE
241         ! Benchmark GYRE configuration (to allow the bit to bit comparison between Mpp/Mono case)
242         zsumemp = 0.e0   ;    zsurf = 0.e0
243      ENDIF
244
245      ! freshwater (mass flux) and update of qns with heat content of emp
246      emp (:,:) = emp(:,:) - zsumemp * tmask(:,:,1)        ! freshwater flux (=0 in domain average)
247      sfx (:,:) = 0.0_wp                                   ! no salt flux
248      qns (:,:) = qns(:,:) - emp(:,:) * sst_m(:,:) * rcp   ! evap and precip are at SST
249
250
251      ! ---------------------------- !
252      !       momentum fluxes        !
253      ! ---------------------------- !
254      ! same wind as in Wico
255      !test date0 : ndate0 = 010203
256      zyear0  =   ndate0 / 10000
257      zmonth0 = ( ndate0 - zyear0 * 10000 ) / 100
258      zday0   =   ndate0 - zyear0 * 10000 - zmonth0 * 100
259      !Calculates nday_year, day since january 1st
260      zday_year0 = (zmonth0-1)*30.+zday0
261
262      !accumulates days of previous months of this year
263      ! day (in hours) since january the 1st
264      ztime = FLOAT( kt ) * rdt / (rmmss * rhhmm)  &  ! incrementation in hour
265         &     - (nyear - 1) * rjjhh * zyydd          !  - nber of hours the precedent years
266      ztimemax = ((5.*30.)+21.)* 24.               ! 21th june     in hours
267      ztimemin = ztimemax + rjjhh * zyydd / 2      ! 21th december in hours
268      !                                            ! NB: rjjhh * zyydd / 4 = 1 seasonal cycle in hours
269
270      ! mean intensity at 0.105 ; srqt(2) because projected with 45deg angle
271      ztau = 0.105 / SQRT( 2. )
272      ! seasonal oscillation intensity
273      ztau_sais = 0.015
274      ztaun = ztau - ztau_sais * COS( (ztime - ztimemax) / (ztimemin - ztimemax) * rpi )
275      DO jj = 1, jpj
276         DO ji = 1, jpi
277           ! domain from 15deg to 50deg and 1/2 period along 14deg
278           ! so 5/4 of half period with seasonal cycle
279           utau(ji,jj) = - ztaun * SIN( rpi * (gphiu(ji,jj) - 15.) / (29.-15.) )
280           vtau(ji,jj) =   ztaun * SIN( rpi * (gphiv(ji,jj) - 15.) / (29.-15.) )
281         END DO
282      END DO
283
284      ! module of wind stress and wind speed at T-point
285      zcoef = 1. / ( zrhoa * zcdrag ) 
286!CDIR NOVERRCHK
287      DO jj = 2, jpjm1
288!CDIR NOVERRCHK
289         DO ji = fs_2, fs_jpim1   ! vect. opt.
290            ztx = utau(ji-1,jj  ) + utau(ji,jj) 
291            zty = vtau(ji  ,jj-1) + vtau(ji,jj) 
292            zmod = 0.5 * SQRT( ztx * ztx + zty * zty )
293            taum(ji,jj) = zmod
294            wndm(ji,jj) = SQRT( zmod * zcoef )
295         END DO
296      END DO
297      CALL lbc_lnk( taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( wndm(:,:), 'T', 1. )
298
299      ! ---------------------------------- !
300      !  control print at first time-step  !
301      ! ---------------------------------- !
302      IF( kt == nit000 .AND. lwp ) THEN
303         WRITE(numout,*)
304         WRITE(numout,*)'sbc_gyre : analytical surface fluxes for GYRE configuration'               
305         WRITE(numout,*)'~~~~~~~~ ' 
306         WRITE(numout,*)'           nyear      = ', nyear
307         WRITE(numout,*)'           nmonth     = ', nmonth
308         WRITE(numout,*)'           nday       = ', nday
309         WRITE(numout,*)'           nday_year  = ', nday_year
310         WRITE(numout,*)'           ztime      = ', ztime
311         WRITE(numout,*)'           ztimemax   = ', ztimemax
312         WRITE(numout,*)'           ztimemin   = ', ztimemin
313         WRITE(numout,*)'           ztimemax1  = ', ztimemax1
314         WRITE(numout,*)'           ztimemin1  = ', ztimemin1
315         WRITE(numout,*)'           ztimemax2  = ', ztimemax2
316         WRITE(numout,*)'           ztimemin2  = ', ztimemin2
317         WRITE(numout,*)'           zyear0     = ', zyear0
318         WRITE(numout,*)'           zmonth0    = ', zmonth0
319         WRITE(numout,*)'           zday0      = ', zday0
320         WRITE(numout,*)'           zday_year0 = ', zday_year0
321         WRITE(numout,*)'           zyydd      = ', zyydd
322         WRITE(numout,*)'           zemp_S     = ', zemp_S
323         WRITE(numout,*)'           zemp_N     = ', zemp_N
324         WRITE(numout,*)'           zemp_sais  = ', zemp_sais
325         WRITE(numout,*)'           zTstar     = ', zTstar
326         WRITE(numout,*)'           zsumemp    = ', zsumemp
327         WRITE(numout,*)'           zsurf      = ', zsurf
328         WRITE(numout,*)'           ztrp       = ', ztrp
329         WRITE(numout,*)'           zconv      = ', zconv
330         WRITE(numout,*)'           ndastp     = ', ndastp
331         WRITE(numout,*)'           adatrj     = ', adatrj
332      ENDIF
333      !
334   END SUBROUTINE sbc_gyre
335
336   SUBROUTINE ana_namelist()
337     !!---------------------------------------------------------------------
338     !!                   ***  ROUTINE ana_namelist  ***
339     !!                     
340     !! ** Purpose :   Broadcast namelist variables read by procesor lwm
341     !!
342     !! ** Method  :   use lib_mpp
343     !!----------------------------------------------------------------------
344#if defined key_mpp_mpi
345      CALL mpp_bcast(nn_tau000)
346      CALL mpp_bcast(rn_utau0)
347      CALL mpp_bcast(rn_vtau0)
348      CALL mpp_bcast(rn_qns0)
349      CALL mpp_bcast(rn_qsr0)
350      CALL mpp_bcast(rn_emp0)
351#endif
352   END SUBROUTINE ana_namelist
353
354   !!======================================================================
355END MODULE sbcana
Note: See TracBrowser for help on using the repository browser.