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.
sbcrnf.F90 in branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC – NEMO

source: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcrnf.F90 @ 2200

Last change on this file since 2200 was 2148, checked in by cetlod, 14 years ago

merge LOCEAN 2010 developments branches

  • Property svn:keywords set to Id
File size: 17.6 KB
Line 
1MODULE sbcrnf
2   !!======================================================================
3   !!                       ***  MODULE  sbcrnf  ***
4   !! Ocean forcing:  river runoff
5   !!=====================================================================
6   !! History :  OPA  !  2000-11  (R. Hordoir, E. Durand)  NetCDF FORMAT
7   !!   NEMO     1.0  !  2002-09  (G. Madec)  F90: Free form and module
8   !!            3.0  !  2006-07  (G. Madec)  Surface module
9   !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   sbc_rnf      : monthly runoffs read in a NetCDF file
14   !!   sbc_rnf_init : runoffs initialisation
15   !!   rnf_mouth    : set river mouth mask
16   !!----------------------------------------------------------------------
17   USE dom_oce         ! ocean space and time domain
18   USE phycst          ! physical constants
19   USE sbc_oce         ! surface boundary condition variables
20   USE fldread         ! ???
21   USE in_out_manager  ! I/O manager
22   USE iom             ! I/O module
23
24   IMPLICIT NONE
25   PRIVATE
26
27   PUBLIC sbc_rnf          ! routine call in step module
28
29   !                                                     !!* namsbc_rnf namelist *
30   CHARACTER(len=100), PUBLIC ::   cn_dir       = './'    !: Root directory for location of ssr files
31   LOGICAL           , PUBLIC ::   ln_rnf_emp   = .false. !: runoffs into a file to be read or already into precipitation
32   TYPE(FLD_N)       , PUBLIC ::   sn_rnf                 !: information about the runoff file to be read
33   TYPE(FLD_N)       , PUBLIC ::   sn_cnf                 !: information about the runoff mouth file to be read
34   TYPE(FLD_N)                ::   sn_sal_rnf             !: information about the salinities of runoff file to be read 
35   TYPE(FLD_N)                ::   sn_tmp_rnf             !: information about the temperatures of runoff file to be read 
36   TYPE(FLD_N)                ::   sn_dep_rnf             !: information about the depth which river inflow affects
37   LOGICAL           , PUBLIC ::   ln_rnf_mouth = .false. !: specific treatment in mouths vicinity
38   REAL(wp)          , PUBLIC ::   rn_hrnf      = 0.e0    !: runoffs, depth over which enhanced vertical mixing is used
39   REAL(wp)          , PUBLIC ::   rn_avt_rnf   = 0.e0    !: runoffs, value of the additional vertical mixing coef. [m2/s]
40   LOGICAL           , PUBLIC ::   ln_rnf_att   = .false. !: river runoffs attributes (temp, sal & depth) are specified in a file
41   REAL(wp)          , PUBLIC ::   rn_rfact     = 1.e0    !: multiplicative factor for runoff
42
43   INTEGER , PUBLIC                     ::   nkrnf = 0   !: number of levels over which Kz is increased at river mouths
44   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfmsk      !: river mouth mask (hori.)
45   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   rnfmsk_z    !: river mouth mask (vert.)
46
47   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_rnf        !: structure of input river runoff (file information, fields read)
48
49   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_sal_rnf    !: structure of input river runoff salinity (file information, fields read) 
50   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_tem_rnf    !: structure of input river runoff temperature (file information, fields read) 
51 
52   REAL,    PUBLIC, DIMENSION(jpi,jpj) ::  rnf_dep         !: depth of runoff in m 
53   INTEGER, PUBLIC, DIMENSION(jpi,jpj) ::  rnf_mod_dep     !: depth of runoff in model levels 
54   REAL,    PUBLIC, DIMENSION(jpi,jpj) ::  rnf_sal         !: salinity of river runoff 
55   REAL,    PUBLIC, DIMENSION(jpi,jpj) ::  rnf_tmp         !: temperature of river runoff 
56 
57   INTEGER  ::  ji, jj ,jk    ! dummy loop indices 
58   INTEGER  ::  inum          ! temporary logical unit 
59 
60   !! * Substitutions 
61#  include "domzgr_substitute.h90" 
62
63   !!----------------------------------------------------------------------
64   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
65   !! $Id$
66   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
67   !!----------------------------------------------------------------------
68
69CONTAINS
70
71   SUBROUTINE sbc_rnf( kt )
72      !!----------------------------------------------------------------------
73      !!                  ***  ROUTINE sbc_rnf  ***
74      !!       
75      !! ** Purpose :   Introduce a climatological run off forcing
76      !!
77      !! ** Method  :   Set each river mouth with a monthly climatology
78      !!                provided from different data.
79      !!                CAUTION : upward water flux, runoff forced to be < 0
80      !!
81      !! ** Action  :   runoff updated runoff field at time-step kt
82      !!----------------------------------------------------------------------
83      INTEGER, INTENT(in) ::   kt          ! ocean time step
84      !!
85      INTEGER  ::   ji, jj   ! dummy loop indices
86      !!----------------------------------------------------------------------
87      !                                   
88      IF( kt == nit000 )  CALL sbc_rnf_init     ! Read namelist and allocate structures
89
90      !                                                   !-------------------!
91      IF( .NOT. ln_rnf_emp ) THEN                         !   Update runoff   !
92         !                                                !-------------------!
93         !
94         CALL fld_read( kt, nn_fsbc, sf_rnf )   ! Read Runoffs data and provides it
95         !                                      ! at the current time-step
96         IF ( ln_rnf_att ) THEN 
97            CALL fld_read ( kt, nn_fsbc, sf_sal_rnf ) 
98            CALL fld_read ( kt, nn_fsbc, sf_tem_rnf ) 
99         ENDIF 
100
101         ! Runoff reduction only associated to the ORCA2_LIM configuration
102         ! when reading the NetCDF file runoff_1m_nomask.nc
103         IF( cp_cfg == 'orca' .AND. jp_cfg == 2 )   THEN
104            DO jj = 1, jpj
105               DO ji = 1, jpi
106                  IF( gphit(ji,jj) > 40 .AND. gphit(ji,jj) < 65 )   sf_rnf(1)%fnow(ji,jj,1) = 0.85 * sf_rnf(1)%fnow(ji,jj,1)
107               END DO
108            END DO
109         ENDIF
110
111         ! C a u t i o n : runoff is negative and in kg/m2/s
112
113         IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
114            rnf(:,:)  = rn_rfact * ( sf_rnf(1)%fnow(:,:,1) ) 
115            IF ( ln_rnf_att ) THEN 
116               rnf_sal(:,:) = ( sf_sal_rnf(1)%fnow(:,:,1) ) 
117               rnf_tmp(:,:) = ( sf_tem_rnf(1)%fnow(:,:,1) ) 
118            ELSE 
119               rnf_sal(:,:) = 0 
120               rnf_tmp(:,:) = -999 
121            ENDIF 
122            CALL iom_put( "runoffs", rnf )         ! runoffs
123         ENDIF
124         !
125      ENDIF
126      !
127   END SUBROUTINE sbc_rnf
128
129
130   SUBROUTINE sbc_rnf_init
131      !!----------------------------------------------------------------------
132      !!                  ***  ROUTINE sbc_rnf_init  ***
133      !!
134      !! ** Purpose :   Initialisation of the runoffs if (ln_rnf=T)
135      !!
136      !! ** Method  : - read the runoff namsbc_rnf namelist
137      !!
138      !! ** Action  : - read parameters
139      !!----------------------------------------------------------------------
140      INTEGER  ::   ierror   ! temporary integer
141      CHARACTER(len=32) ::   rn_dep_file   ! runoff file name 
142      !!
143      NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, sn_rnf, sn_cnf, sn_sal_rnf, sn_tmp_rnf, sn_dep_rnf,   & 
144         &                 ln_rnf_mouth, ln_rnf_att, rn_hrnf, rn_avt_rnf, rn_rfact 
145      !!----------------------------------------------------------------------
146
147      !                                   ! ============
148      !                                   !   Namelist
149      !                                   ! ============
150      ! (NB: frequency positive => hours, negative => months)
151      !            !   file    ! frequency !  variable  ! time intep !  clim  ! 'yearly' or ! weights  ! rotation   !
152      !            !   name    !  (hours)  !   name     !   (T/F)    !  (T/F) !  'monthly'  ! filename ! pairs      !
153      sn_rnf = FLD_N( 'runoffs',    -1     , 'sorunoff' ,  .TRUE.    , .true. ,   'yearly'  , ''       , ''         )
154      sn_cnf = FLD_N( 'runoffs',     0     , 'sorunoff' ,  .FALSE.   , .true. ,   'yearly'  , ''       , ''         )
155
156      sn_sal_rnf = FLD_N( 'runoffs',  24.  , 'rosaline' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  ) 
157      sn_tmp_rnf = FLD_N( 'runoffs',  24.  , 'rotemper' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  ) 
158      sn_dep_rnf = FLD_N( 'runoffs',   0.  , 'rodepth'  ,  .FALSE.   , .true. ,   'yearly'  , ''    , ''  ) 
159      !
160      REWIND ( numnam )                         ! Read Namelist namsbc_rnf
161      READ   ( numnam, namsbc_rnf )
162
163      !                                         ! Control print
164      IF(lwp) THEN
165         WRITE(numout,*)
166         WRITE(numout,*) 'sbc_rnf : runoff '
167         WRITE(numout,*) '~~~~~~~ '
168         WRITE(numout,*) '   Namelist namsbc_rnf'
169         WRITE(numout,*) '      runoff in a file to be read                ln_rnf_emp   = ', ln_rnf_emp
170         WRITE(numout,*) '      specific river mouths treatment            ln_rnf_mouth = ', ln_rnf_mouth
171         WRITE(numout,*) '      river mouth additional Kz                  rn_avt_rnf   = ', rn_avt_rnf
172         WRITE(numout,*) '      depth of river mouth additional mixing     rn_hrnf      = ', rn_hrnf
173         WRITE(numout,*) '      multiplicative factor for runoff           rn_rfact     = ', rn_rfact   
174      ENDIF
175
176      !                                   ! ==================
177      !                                   !   Type of runoff
178      !                                   ! ==================
179      !
180      IF( ln_rnf_emp ) THEN                     ! runoffs directly provided in the precipitations
181         IF(lwp) WRITE(numout,*)
182         IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations'
183         IF ( ln_rnf_att ) THEN
184           CALL ctl_warn( 'runoffs already included in precipitations & so runoff attributes will not be used' ) 
185           ln_rnf_att = .FALSE.
186         ENDIF
187         !
188      ELSE                                      ! runoffs read in a file : set sf_rnf structure
189         !
190         ! Allocate sf_rnf structure and (if required) sf_sal_rnf and sf_tem_rnf structures
191         ALLOCATE( sf_rnf(1), STAT=ierror )
192         IF( ierror > 0 ) THEN
193            CALL ctl_stop( 'sbc_rnf: unable to allocate sf_rnf structure' )   ;   RETURN
194         ENDIF
195         ALLOCATE( sf_rnf(1)%fnow(jpi,jpj,1) )
196         ALLOCATE( sf_rnf(1)%fdta(jpi,jpj,1,2) )
197
198         IF( ln_rnf_att ) THEN
199            ALLOCATE( sf_sal_rnf(1), STAT=ierror )
200            IF( ierror > 0 ) THEN
201               CALL ctl_stop( 'sbc_sal_rnf: unable to allocate sf_sal_rnf structure' )   ;   RETURN
202            ENDIF
203            ALLOCATE( sf_sal_rnf(1)%fnow(jpi,jpj,1) )
204            ALLOCATE( sf_sal_rnf(1)%fdta(jpi,jpj,1,2) )
205
206            ALLOCATE( sf_tem_rnf(1), STAT=ierror )
207            IF( ierror > 0 ) THEN
208                CALL ctl_stop( 'sbc_tmp_rnf: unable to allocate sf_tem_rnf structure' )   ;   RETURN
209            ENDIF
210            ALLOCATE( sf_tem_rnf(1)%fnow(jpi,jpj,1) )
211            ALLOCATE( sf_tem_rnf(1)%fdta(jpi,jpj,1,2) )
212         ENDIF
213         ! fill sf_rnf with sn_rnf and control print
214         CALL fld_fill( sf_rnf, (/ sn_rnf /), cn_dir, 'sbc_rnf_init', 'read runoffs data', 'namsbc_rnf' )
215 
216         IF ( ln_rnf_att ) THEN 
217            CALL fld_fill (sf_sal_rnf, (/ sn_sal_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' ) 
218            CALL fld_fill (sf_tem_rnf, (/ sn_tmp_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' ) 
219 
220            rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname ) 
221            CALL iom_open ( rn_dep_file, inum )                           ! open file 
222            CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, rnf_dep )    ! read the river mouth array 
223            CALL iom_close( inum )                                      ! close file 
224 
225            rnf_mod_dep(:,:) = 0. 
226            DO jj = 1, jpj 
227              DO ji = 1, jpi 
228                IF ( rnf_dep(ji,jj) > 0.e0 ) THEN 
229                  jk = 2 
230                  DO WHILE ( jk /= jpkm1 .AND. fsdept(ji,jj,jk) < rnf_dep(ji,jj) ) ;  jk = jk + 1 ;   ENDDO 
231                  rnf_mod_dep(ji,jj) = jk 
232                ELSE IF ( rnf_dep(ji,jj) == -1. ) THEN 
233                  rnf_mod_dep(ji,jj) = 1. 
234                ELSE IF ( rnf_dep(ji,jj) == -999 ) THEN 
235                  rnf_mod_dep(ji,jj) = jpkm1 
236                ELSE IF ( rnf_dep(ji,jj) /= 0. ) THEN 
237                  CALL ctl_stop( 'runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  ) 
238                  WRITE(999,*) 'ji, jj, rnf(ji,jj) :', ji, jj, rnf(ji,jj) 
239                ENDIF 
240              ENDDO 
241            ENDDO 
242         ELSE 
243            rnf_mod_dep(:,:) = 1. 
244         ENDIF 
245      !
246      ENDIF
247      !
248
249      !                                   ! ========================
250      !                                   !   River mouth vicinity
251      !                                   ! ========================
252      !
253      IF( ln_rnf_mouth ) THEN                   ! Specific treatment in vicinity of river mouths :
254         !                                      !    - Increase Kz in surface layers ( rn_hrnf > 0 )
255         !                                      !    - set to zero SSS damping (ln_ssr=T)
256         !                                      !    - mixed upstream-centered (ln_traadv_cen2=T)
257         !
258         !                                          ! Number of level over which Kz increase
259         IF ( ln_rnf_att )  & 
260              &  CALL ctl_warn( 'increased mixing turned on but effects may already be spread through depth by ln_rnf_att' ) 
261         nkrnf = 0
262         IF( rn_hrnf > 0.e0 ) THEN
263            nkrnf = 2
264            DO WHILE( nkrnf /= jpkm1 .AND. gdepw_0(nkrnf+1) < rn_hrnf )   ;   nkrnf = nkrnf + 1   ;   END DO
265            IF( ln_sco )   &
266               CALL ctl_warn( 'sbc_rnf: number of levels over which Kz is increased is computed for zco...' )
267         ENDIF
268         IF(lwp) WRITE(numout,*)
269         IF(lwp) WRITE(numout,*) '          Specific treatment used in vicinity of river mouths :'
270         IF(lwp) WRITE(numout,*) '             - Increase Kz in surface layers (if rn_hrnf > 0 )'
271         IF(lwp) WRITE(numout,*) '               by ', rn_avt_rnf,' m2/s  over ', nkrnf, ' w-levels'
272         IF(lwp) WRITE(numout,*) '             - set to zero SSS damping       (if ln_ssr=T)'
273         IF(lwp) WRITE(numout,*) '             - mixed upstream-centered       (if ln_traadv_cen2=T)'
274         !
275         CALL rnf_mouth                             ! set river mouth mask
276         !
277      ELSE                                      ! No treatment at river mouths
278         IF(lwp) WRITE(numout,*)
279         IF(lwp) WRITE(numout,*) '          No specific treatment at river mouths'
280         rnfmsk  (:,:) = 0.e0 
281         rnfmsk_z(:)   = 0.e0
282         nkrnf = 0
283      ENDIF
284
285   END SUBROUTINE sbc_rnf_init
286
287
288   SUBROUTINE rnf_mouth
289      !!----------------------------------------------------------------------
290      !!                  ***  ROUTINE rnf_mouth  ***
291      !!       
292      !! ** Purpose :   define the river mouths mask
293      !!
294      !! ** Method  :   read the river mouth mask (=0/1) in the river runoff
295      !!                climatological file. Defined a given vertical structure.
296      !!                CAUTION, the vertical structure is hard coded on the
297      !!                first 5 levels.
298      !!                This fields can be used to:
299      !!                 - set an upstream advection scheme 
300      !!                   (ln_rnf_mouth=T and ln_traadv_cen2=T)
301      !!                 - increase vertical on the top nn_krnf vertical levels
302      !!                   at river runoff input grid point (nn_krnf>=2, see step.F90)
303      !!                 - set to zero SSS restoring flux at river mouth grid points
304      !!
305      !! ** Action  :   rnfmsk   set to 1 at river runoff input, 0 elsewhere
306      !!                rnfmsk_z vertical structure
307      !!----------------------------------------------------------------------
308      USE closea, ONLY :    clo_rnf   ! rnfmsk update routine
309      !
310      INTEGER           ::   inum        ! temporary integers
311      CHARACTER(len=32) ::   cl_rnfile   ! runoff file name
312      !!----------------------------------------------------------------------
313      !
314      IF(lwp) WRITE(numout,*)
315      IF(lwp) WRITE(numout,*) 'rnf_mouth : river mouth mask'
316      IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
317
318      cl_rnfile = TRIM( cn_dir )//TRIM( sn_cnf%clname )
319      IF( .NOT. sn_cnf%ln_clim ) THEN   ;   WRITE(cl_rnfile, '(a,"_y",i4)' ) TRIM( cl_rnfile ), nyear    ! add year
320         IF( sn_cnf%cltype == 'monthly' )   WRITE(cl_rnfile, '(a,"m",i2)'  ) TRIM( cl_rnfile ), nmonth   ! add month
321      ENDIF
322 
323      ! horizontal mask (read in NetCDF file)
324      CALL iom_open ( cl_rnfile, inum )                           ! open file
325      CALL iom_get  ( inum, jpdom_data, sn_cnf%clvar, rnfmsk )    ! read the river mouth array
326      CALL iom_close( inum )                                      ! close file
327     
328      IF( nclosea == 1 )    CALL clo_rnf( rnfmsk )                ! closed sea inflow set as ruver mouth
329
330      rnfmsk_z(:)   = 0.e0                                        ! vertical structure
331      rnfmsk_z(1)   = 1.0
332      rnfmsk_z(2)   = 1.0                                         ! **********
333      rnfmsk_z(3)   = 0.5                                         ! HARD CODED on the 5 first levels
334      rnfmsk_z(4)   = 0.25                                        ! **********
335      rnfmsk_z(5)   = 0.125
336      !         
337   END SUBROUTINE rnf_mouth
338   
339   !!======================================================================
340END MODULE sbcrnf
Note: See TracBrowser for help on using the repository browser.