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

source: branches/UKMO/dev_r5518_flux_adjust/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx_adj.F90 @ 6716

Last change on this file since 6716 was 6716, checked in by kuniko, 8 years ago

Reverted to multiplying by sss_m in sbcflx_adj.f90

File size: 13.4 KB
Line 
1MODULE sbcflx_adj
2   !!======================================================================
3   !!                       ***  MODULE  sbcflx_adj  ***
4   !! Surface module :  flux adjustment of heat/freshwater. Add qrp/erp obtained from sbcssr
5   !!======================================================================
6   !! History :  0.0  !  2015-10-14  (K. Yamazaki)  Original code
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   sbc_flx_adj       : add qrp/erp to sbc to perform flux adjustment
11   !!   sbc_flx_adj_init  : initialisation of flux adjustment
12   !!----------------------------------------------------------------------
13   USE oce            ! ocean dynamics and tracers
14   USE dom_oce        ! ocean space and time domain
15   USE sbc_oce        ! surface boundary condition
16   USE phycst         ! physical constants
17   USE sbcrnf         ! surface boundary condition : runoffs
18   !
19   USE fldread        ! read input fields
20   USE iom            ! I/O manager
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 timing         ! Timing
25   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
26
27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC   sbc_flx_adj        ! routine called in sbcmod
31   PUBLIC   sbc_flx_adj_init   ! routine called in sbcmod
32
33   !ky 11/12/2015 recommented below two lines
34   !!ky 3/12/2015 uncommented below two lines for FA test!
35   !REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   erp   !: evaporation damping   [kg/m2/s]
36   !REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   qrp   !: heat flux damping        [w/m2]
37
38   !                                   !!* Namelist namsbc_flx_adj *
39   INTEGER, PUBLIC ::   nn_flxadjht     ! Heat/freshwater flux adjustment indicator
40   INTEGER, PUBLIC ::   nn_flxadjfw     ! Heat/freshwater flux adjustment indicator
41   LOGICAL         ::   ln_sssr_bnd     ! flag to bound erp term
42   REAL(wp)        ::   rn_sssr_bnd     ! ABS(Max./Min.) value of erp term [mm/day]
43
44   REAL(wp) , ALLOCATABLE, DIMENSION(:) ::   buffer   ! Temporary buffer for exchange
45   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_erp   ! structure of input erp (file informations, fields read)
46   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_qrp   ! structure of input qrp (file informations, fields read)
47
48   !! * Substitutions
49#  include "domzgr_substitute.h90"
50   !!----------------------------------------------------------------------
51   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
52   !! $Id: sbcssr.F90 4990 2014-12-15 16:42:49Z timgraham $
53   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
54   !!----------------------------------------------------------------------
55CONTAINS
56
57   SUBROUTINE sbc_flx_adj( kt )
58      !!---------------------------------------------------------------------
59      !!                     ***  ROUTINE sbc_flx_adj  ***
60      !!
61      !! ** Purpose :   Add to heat and/or freshwater fluxes a qrp and/or erp
62      !!                to flux adjust temperature/salinity
63      !!
64      !! ** Method  : - Read namelist namsbc_flx_adj
65      !!              - Read calculated qrp and/or erp
66      !!              - at each nscb time step
67      !!                   add qrp on qns    (nn_flxadjht = 1)
68      !!                   add erp on sfx        (nn_flxadjfw = 1)
69      !!                   add erp on emp        (nn_flxadjfw = 2)
70      !!---------------------------------------------------------------------
71      INTEGER, INTENT(in   ) ::   kt   ! ocean time step
72      !!
73      INTEGER  ::   ji, jj   ! dummy loop indices
74      REAL(wp) ::   zerp     ! local scalar for evaporation damping
75      REAL(wp) ::   zqrp     ! local scalar for heat flux damping
76      REAL(wp) ::   zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
77      INTEGER  ::   ierror   ! return error code
78      !!
79      CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
80      TYPE(FLD_N) ::   sn_qrp, sn_erp        ! informations about the fields to be read
81      !!----------------------------------------------------------------------
82      !
83      !!write(numout,*) '*** In sbcflx_adj ***'
84
85      IF( nn_timing == 1 )  CALL timing_start('sbc_flx_adj')
86      !
87      IF( nn_flxadjht + nn_flxadjfw /= 0 ) THEN
88         !
89         IF( nn_flxadjht == 1)   CALL fld_read( kt, nn_fsbc, sf_qrp )   ! Read qrp data and provides it at kt
90         IF( nn_flxadjfw >= 1)   CALL fld_read( kt, nn_fsbc, sf_erp )   ! Read erp data and provides it at kt
91         !
92         !                                         ! ========================= !
93         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN      !    Add restoring term     !
94            !                                      ! ========================= !
95            !
96            IF( nn_flxadjht == 1 ) THEN                                   !* Anomalous heat flux term (qrp)
97               DO jj = 1, jpj
98                  DO ji = 1, jpi
99                     zqrp = sf_qrp(1)%fnow(ji,jj,1)
100                     !ky 11/12/2015 commented out 1 line below
101                     !!ky 3/12/2015 1 line below for FA test!
102                     !qrp(ji,jj) = sf_qrp(1)%fnow(ji,jj,1)
103                     qns(ji,jj) = qns(ji,jj) + zqrp
104                  END DO
105               END DO
106               !ky 11/12/2015 recommented out below 1 line below
107               !!ky 3/12/2015 uncommented below 1 line below for FA test!
108               !CALL iom_put( "qrp", qrp )                             ! heat flux damping
109            ENDIF
110            !
111            IF( nn_flxadjfw == 1 ) THEN                               !* Anomalous freshwater term !(salt flux only (sfx))
112!CDIR COLLAPSE
113               DO jj = 1, jpj
114                  !!write(numout,*) 'sf_qrp(1)%fnow(30,',jj,',1)=',sf_qrp(1)%fnow(30,jj,1), &
115                  !!  &            'sf_erp(1)%fnow(30,',jj,',1)=',sf_erp(1)%fnow(30,jj,1), &
116                  !!  &            'sst_m(30,',jj,')=',sst_m(30,jj),'sss_m(30,',jj,')=',sss_m(30,jj)
117                  DO ji = 1, jpi
118                     zerp = ( 1. - 2.*rnfmsk(ji,jj) )  &              ! No damping in vicinity of river mouths
119                        &        * sf_erp(1)%fnow(ji,jj,1)
120                        &        * MAX( sss_m(ji,jj), 1.e-20 )! reconverted into salinity flux
121                     !ky 16/06/2016 restored above line (multiplication by MAX...)
122                     !ky 11/12/2015 recommented out 1 line below
123                     !!ky 3/12/2015 1 line below for FA test!
124                     !erp(ji,jj) = sf_erp(1)%fnow(ji,jj,1)
125                     sfx(ji,jj) = sfx(ji,jj) + zerp                 ! salt flux
126                  END DO
127               END DO
128               !ky 11/12/2015 recommented out below one line
129               !!ky 3/12/2015 uncommented below one line for FA test!
130               !CALL iom_put( "erp", erp )                             ! freshwater flux damping
131               !
132            ELSEIF( nn_flxadjfw == 2 ) THEN                               !* Salinity damping term (volume flux (emp) and associated heat flux (qns)
133               zerp_bnd = rn_sssr_bnd / rday                          !       -              -   
134!CDIR COLLAPSE
135               DO jj = 1, jpj
136                  DO ji = 1, jpi                           
137                     zerp = ( 1. - 2.*rnfmsk(ji,jj) )  &              ! No damping in vicinity of river mouths
138                        &        * sf_erp(1)%fnow(ji,jj,1)
139                     IF( ln_sssr_bnd )   zerp = SIGN( 1., zerp ) * MIN( zerp_bnd, ABS(zerp) )
140                     !ky 11/12/2015 recommented out 1 line below
141                     !!ky 3/12/2015 1 line below for FA test!
142                     !erp(ji,jj) = sf_erp(1)%fnow(ji,jj,1)
143                     emp(ji,jj) = emp (ji,jj) + zerp
144                     qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj)
145                  END DO
146               END DO
147               !ky 11/12/2015 recommented out below 1 line
148               !!ky 3/12/2015 uncommented below 1 line for FA test!
149               !CALL iom_put( "erp", erp )                             ! freshwater flux damping
150            ENDIF
151            !
152         ENDIF
153         !
154      ENDIF
155      !
156      IF( nn_timing == 1 )  CALL timing_stop('sbc_flx_adj')
157      !
158   END SUBROUTINE sbc_flx_adj
159
160 
161   SUBROUTINE sbc_flx_adj_init
162      !!---------------------------------------------------------------------
163      !!                  ***  ROUTINE sbc_flx_adj_init  ***
164      !!
165      !! ** Purpose :   initialisation of surface damping term
166      !!
167      !! ** Method  : - Read namelist namsbc_flx_adj
168      !ky!!!              - Read observed SST and/or SSS if required
169      !!---------------------------------------------------------------------
170      INTEGER  ::   ji, jj   ! dummy loop indices
171      REAL(wp) ::   zerp     ! local scalar for evaporation damping
172      REAL(wp) ::   zqrp     ! local scalar for heat flux damping
173      REAL(wp) ::   zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
174      INTEGER  ::   ierror   ! return error code
175      !!
176      CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
177      TYPE(FLD_N) ::   sn_qrp, sn_erp        ! informations about the fields to be read
178      NAMELIST/namsbc_flx_adj/ cn_dir, nn_flxadjht, nn_flxadjfw, sn_qrp, sn_erp,   &
179         &                     ln_sssr_bnd, rn_sssr_bnd
180      INTEGER     ::  ios
181      !!----------------------------------------------------------------------
182      !
183 
184      !!write(numout,*) '*** in sbcflx_adj_init ***'
185
186      REWIND( numnam_ref )              ! Namelist namsbc_flx_adj in reference namelist :
187      READ  ( numnam_ref, namsbc_flx_adj, IOSTAT = ios, ERR = 901)
188901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_flx_adj in reference namelist', lwp )
189
190      REWIND( numnam_cfg )              ! Namelist namsbc_flx_adj in configuration namelist :
191      READ  ( numnam_cfg, namsbc_flx_adj, IOSTAT = ios, ERR = 902 )
192902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_flx_adj in configuration namelist', lwp )
193      IF(lwm) WRITE ( numond, namsbc_flx_adj )
194
195      IF(lwp) THEN                 !* control print
196         WRITE(numout,*)
197         WRITE(numout,*) 'sbc_flx_adj : Heat and/or freshwater flux adjustment term '
198         WRITE(numout,*) '~~~~~~~ '
199         WRITE(numout,*) '   Namelist namsbc_flx_adj :'
200         WRITE(numout,*) '      Anom. heat flux (qrp) term (Yes=1)             nn_flxadjht     = ', nn_flxadjht
201         WRITE(numout,*) '      Anom. fw flux (erp) term (Yes=1, salt flux)    nn_flxadjfw     = ', nn_flxadjfw
202         WRITE(numout,*) '                                           (Yes=2, volume flux) '
203         WRITE(numout,*) '      flag to bound erp term                 ln_sssr_bnd = ', ln_sssr_bnd
204         WRITE(numout,*) '      ABS(Max./Min.) erp threshold           rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
205      ENDIF
206      !
207      !                            !* Allocate erp and qrp array
208      !ky 11/12/2015 recommented out below two lines
209      !!ky 3/12/2015 uncommented below two lines for FA test!
210      !ALLOCATE( qrp(jpi,jpj), erp(jpi,jpj), STAT=ierror )
211      !IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erp and qrp array' )
212      !
213      IF( nn_flxadjht == 1 ) THEN      !* set sf_qrp structure & allocate arrays
214         !
215         ALLOCATE( sf_qrp(1), STAT=ierror )
216         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_flx_adj: unable to allocate sf_qrp structure' )
217         ALLOCATE( sf_qrp(1)%fnow(jpi,jpj,1), STAT=ierror )
218         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_flx_adj: unable to allocate sf_qrp now array' )
219         !
220         ! fill sf_qrp with sn_qrp and control print
221         CALL fld_fill( sf_qrp, (/ sn_qrp /), cn_dir, 'sbc_qrp', 'Heat flux adjustment', 'namsbc_flx_adj' )
222         IF( sf_qrp(1)%ln_tint )   ALLOCATE( sf_qrp(1)%fdta(jpi,jpj,1,2), STAT=ierror )
223         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_flx_adj: unable to allocate sf_qrp data array' )
224         !
225      ENDIF
226      !
227      IF( nn_flxadjfw >= 1 ) THEN      !* set sf_erp structure & allocate arrays
228         !
229         ALLOCATE( sf_erp(1), STAT=ierror )
230         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_flx_adj: unable to allocate sf_erp structure' )
231         ALLOCATE( sf_erp(1)%fnow(jpi,jpj,1), STAT=ierror )
232         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_flx_adj: unable to allocate sf_erp now array' )
233         !
234         ! fill sf_erp with sn_erp and control print
235         CALL fld_fill( sf_erp, (/ sn_erp /), cn_dir, 'sbc_erp', 'Freshwater flux adjustment term', 'namsbc_flx_adj' )
236         IF( sf_erp(1)%ln_tint )   ALLOCATE( sf_erp(1)%fdta(jpi,jpj,1,2), STAT=ierror )
237         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_flx_adj: unable to allocate sf_erp data array' )
238         !
239      ENDIF
240      !
241      !ky!!                            !* Initialize qrp and erp if no restoring
242      !ky 11/12/2015 commented out below two lines
243      !!ky 3/12/2015 below two lines for FA test!
244      !IF( nn_flxadjht /= 1                   )   qrp(:,:) = 0._wp
245      !IF( nn_flxadjfw /= 1 .OR. nn_flxadjfw /= 2 )   erp(:,:) = 0._wp
246      !!ky!!IF( nn_sstr /= 1                   )   qrp(:,:) = 0._wp
247      !!ky!!IF( nn_sssr /= 1 .OR. nn_sssr /= 2 )   erp(:,:) = 0._wp
248      !
249   END SUBROUTINE sbc_flx_adj_init
250     
251   !!======================================================================
252END MODULE sbcflx_adj
Note: See TracBrowser for help on using the repository browser.