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

source: branches/UKMO/dev_r5518_haney_arctic_mask_for_tests/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx_adj.F90 @ 7031

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

test mode

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