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 @ 6913

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

Made identical twin to dev_r5518_haney_arctic_mask and commited

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