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

source: branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90 @ 3432

Last change on this file since 3432 was 3432, checked in by trackstand2, 12 years ago

Merge branch 'ksection_partition'

  • Property svn:keywords set to Id
File size: 27.1 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   !!            3.3  ! 2010-10  (R. Furner, G. Madec) runoff distributed over ocean levels
11   !!----------------------------------------------------------------------
12
13   !!----------------------------------------------------------------------
14   !!   sbc_rnf      : monthly runoffs read in a NetCDF file
15   !!   sbc_rnf_init : runoffs initialisation
16   !!   rnf_mouth    : set river mouth mask
17   !!----------------------------------------------------------------------
18   USE dom_oce         ! ocean space and time domain
19   USE phycst          ! physical constants
20   USE sbc_oce         ! surface boundary condition variables
21   USE closea          ! closed seas
22   USE fldread         ! read input field at current time step
23   USE restart         ! restart
24   USE in_out_manager  ! I/O manager
25   USE iom             ! I/O module
26   USE lib_mpp         ! MPP library
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   sbc_rnf       ! routine call in sbcmod module
32   PUBLIC   sbc_rnf_div   ! routine called in sshwzv module
33   PUBLIC   sbc_rnf_alloc ! routine call in sbcmod module
34
35   !                                                     !!* namsbc_rnf namelist *
36   CHARACTER(len=100), PUBLIC ::   cn_dir       = './'    !: Root directory for location of ssr files
37   LOGICAL           , PUBLIC ::   ln_rnf_depth = .false. !: depth       river runoffs attribute specified in a file
38   LOGICAL           , PUBLIC ::   ln_rnf_tem   = .false. !: temperature river runoffs attribute specified in a file
39   LOGICAL           , PUBLIC ::   ln_rnf_sal   = .false. !: salinity    river runoffs attribute specified in a file
40   LOGICAL           , PUBLIC ::   ln_rnf_emp   = .false. !: runoffs into a file to be read or already into precipitation
41   TYPE(FLD_N)       , PUBLIC ::   sn_rnf                 !: information about the runoff file to be read
42   TYPE(FLD_N)       , PUBLIC ::   sn_cnf                 !: information about the runoff mouth file to be read
43   TYPE(FLD_N)                ::   sn_s_rnf               !: information about the salinities of runoff file to be read 
44   TYPE(FLD_N)                ::   sn_t_rnf               !: information about the temperatures of runoff file to be read 
45   TYPE(FLD_N)                ::   sn_dep_rnf             !: information about the depth which river inflow affects
46   LOGICAL           , PUBLIC ::   ln_rnf_mouth = .false. !: specific treatment in mouths vicinity
47   REAL(wp)          , PUBLIC ::   rn_hrnf      = 0._wp   !: runoffs, depth over which enhanced vertical mixing is used
48   REAL(wp)          , PUBLIC ::   rn_avt_rnf   = 0._wp   !: runoffs, value of the additional vertical mixing coef. [m2/s]
49   REAL(wp)          , PUBLIC ::   rn_rfact     = 1._wp   !: multiplicative factor for runoff
50
51   INTEGER , PUBLIC  ::   nkrnf = 0         !: nb of levels over which Kz is increased at river mouths
52   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rnfmsk              !: river mouth mask (hori.)
53   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)     ::   rnfmsk_z            !: river mouth mask (vert.)
54   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   h_rnf               !: depth of runoff in m
55   INTEGER,  ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   nk_rnf              !: depth of runoff in model levels
56   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   rnf_tsc_b, rnf_tsc  !: before & now T & S runoff contents [K.m/s & PSU.m/s]
57   ! ARP put PUBLIC qualifier here to bring length of above line below 132 chars
58   PUBLIC :: rnfmsk, rnfmsk_z, h_rnf, nk_rnf, rnf_tsc_b, rnf_tsc
59
60   REAL(wp) ::   r1_rau0   ! = 1 / rau0
61
62   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_rnf       ! structure: river runoff (file information, fields read)
63   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_s_rnf     ! structure: river runoff salinity (file information, fields read) 
64   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_t_rnf     ! structure: river runoff temperature (file information, fields read) 
65
66   !! * Control permutation of array indices
67#  include "dom_oce_ftrans.h90"
68#  include "sbc_oce_ftrans.h90"
69 
70   !! * Substitutions 
71#  include "domzgr_substitute.h90" 
72   !!----------------------------------------------------------------------
73   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
74   !! $Id$
75   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
76   !!----------------------------------------------------------------------
77CONTAINS
78
79   INTEGER FUNCTION sbc_rnf_alloc()
80      !!----------------------------------------------------------------------
81      !!                ***  ROUTINE sbc_rnf_alloc  ***
82      !!----------------------------------------------------------------------
83      ALLOCATE( rnfmsk(jpi,jpj)         , rnfmsk_z(jpk)          ,     &
84         &      h_rnf (jpi,jpj)         , nk_rnf  (jpi,jpj)      ,     &
85         &      rnf_tsc_b(jpi,jpj,jpts) , rnf_tsc (jpi,jpj,jpts) , STAT=sbc_rnf_alloc )
86         !
87      IF( lk_mpp            )   CALL mpp_sum ( sbc_rnf_alloc )
88      IF( sbc_rnf_alloc > 0 )   CALL ctl_warn('sbc_rnf_alloc: allocation of arrays failed')
89   END FUNCTION sbc_rnf_alloc
90
91   SUBROUTINE sbc_rnf( kt )
92      !!----------------------------------------------------------------------
93      !!                  ***  ROUTINE sbc_rnf  ***
94      !!       
95      !! ** Purpose :   Introduce a climatological run off forcing
96      !!
97      !! ** Method  :   Set each river mouth with a monthly climatology
98      !!                provided from different data.
99      !!                CAUTION : upward water flux, runoff forced to be < 0
100      !!
101      !! ** Action  :   runoff updated runoff field at time-step kt
102      !!----------------------------------------------------------------------
103      INTEGER, INTENT(in) ::   kt          ! ocean time step
104      !!
105      INTEGER  ::   ji, jj   ! dummy loop indices
106      !!----------------------------------------------------------------------
107      !                                   
108      IF( kt == nit000 )   CALL sbc_rnf_init                           ! Read namelist and allocate structures
109
110      !                                            ! ---------------------------------------- !
111      IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          !
112         !                                         ! ---------------------------------------- !
113         rnf_b    (:,:  ) = rnf    (:,:  )               ! Swap the ocean forcing fields except at nit000
114         rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)               ! where before fields are set at the end of the routine
115         !
116      ENDIF
117
118      !                                                   !-------------------!
119      IF( .NOT. ln_rnf_emp ) THEN                         !   Update runoff   !
120         !                                                !-------------------!
121         !
122                             CALL fld_read ( kt, nn_fsbc, sf_rnf   )    ! Read Runoffs data and provide it at kt
123         IF( ln_rnf_tem  )   CALL fld_read ( kt, nn_fsbc, sf_t_rnf )    ! idem for runoffs temperature if required
124         IF( ln_rnf_sal  )   CALL fld_read ( kt, nn_fsbc, sf_s_rnf )    ! idem for runoffs salinity    if required
125         !
126         ! Runoff reduction only associated to the ORCA2_LIM configuration
127         ! when reading the NetCDF file runoff_1m_nomask.nc
128         IF( cp_cfg == 'orca' .AND. jp_cfg == 2 )   THEN
129            WHERE( 40._wp < gphit(:,:) .AND. gphit(:,:) < 65._wp )
130               sf_rnf(1)%fnow(:,:,1) = 0.85 * sf_rnf(1)%fnow(:,:,1)
131            END WHERE
132         ENDIF
133         !
134         IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
135            rnf(:,:) = rn_rfact * ( sf_rnf(1)%fnow(:,:,1) ) 
136            !
137            r1_rau0 = 1._wp / rau0
138            !                                                     ! set temperature & salinity content of runoffs
139            IF( ln_rnf_tem ) THEN                                       ! use runoffs temperature data
140               rnf_tsc(:,:,jp_tem) = ( sf_t_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0
141               WHERE( sf_t_rnf(1)%fnow(:,:,1) == -999 )                 ! if missing data value use SST as runoffs temperature 
142                   rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0
143               END WHERE
144            ELSE                                                        ! use SST as runoffs temperature
145               rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0
146            ENDIF 
147            !                                                           ! use runoffs salinity data
148            IF( ln_rnf_sal )   rnf_tsc(:,:,jp_sal) = ( sf_s_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0
149            !                                                           ! else use S=0 for runoffs (done one for all in the init)
150            !
151            IF( ln_rnf_tem .OR. ln_rnf_sal ) THEN                 ! runoffs as outflow: use ocean SST and SSS
152               WHERE( rnf(:,:) < 0._wp )                                 ! example baltic model when flow is out of domain
153                  rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0
154                  rnf_tsc(:,:,jp_sal) = sss_m(:,:) * rnf(:,:) * r1_rau0
155               END WHERE
156            ENDIF
157            !
158            CALL iom_put( "runoffs", rnf )         ! output runoffs arrays
159         ENDIF
160         !
161      ENDIF
162      !
163      IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    !
164         !                                             ! ---------------------------------------- !
165         IF( ln_rstart .AND.    &                               !* Restart: read in restart file
166            & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN
167            IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields red in the restart file'
168            CALL iom_get( numror, jpdom_autoglo, 'rnf_b', rnf_b )     ! before runoff
169            CALL iom_get( numror, jpdom_autoglo, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem) )   ! before heat content of runoff
170            CALL iom_get( numror, jpdom_autoglo, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal) )   ! before salinity content of runoff
171         ELSE                                                   !* no restart: set from nit000 values
172            IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000'
173             rnf_b    (:,:  ) = rnf    (:,:  ) 
174             rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)   
175         ENDIF
176      ENDIF
177      !                                                ! ---------------------------------------- !
178      IF( lrst_oce ) THEN                              !      Write in the ocean restart file     !
179         !                                             ! ---------------------------------------- !
180         IF(lwp) WRITE(numout,*)
181         IF(lwp) WRITE(numout,*) 'sbcrnf : runoff forcing fields written in ocean restart file ',   &
182            &                    'at it= ', kt,' date= ', ndastp
183         IF(lwp) WRITE(numout,*) '~~~~'
184         CALL iom_rstput( kt, nitrst, numrow, 'rnf_b' , rnf )
185         CALL iom_rstput( kt, nitrst, numrow, 'rnf_hc_b', rnf_tsc(:,:,jp_tem) )
186         CALL iom_rstput( kt, nitrst, numrow, 'rnf_sc_b', rnf_tsc(:,:,jp_sal) )
187      ENDIF
188      !
189   END SUBROUTINE sbc_rnf
190
191
192   SUBROUTINE sbc_rnf_div( phdivn )
193      !!----------------------------------------------------------------------
194      !!                  ***  ROUTINE sbc_rnf  ***
195      !!       
196      !! ** Purpose :   update the horizontal divergence with the runoff inflow
197      !!
198      !! ** Method  :   
199      !!                CAUTION : rnf is positive (inflow) decreasing the
200      !!                          divergence and expressed in m/s
201      !!
202      !! ** Action  :   phdivn   decreased by the runoff inflow
203      !!----------------------------------------------------------------------
204      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   phdivn   ! horizontal divergence
205!FTRANS phdivn :I :I :z
206      !!
207      INTEGER  ::   ji, jj, jk   ! dummy loop indices
208      REAL(wp) ::   r1_rau0   ! local scalar
209      REAL(wp) ::   zfact     ! local scalar
210      !!----------------------------------------------------------------------
211      !
212      zfact = 0.5_wp
213      !
214      r1_rau0 = 1._wp / rau0
215      IF( ln_rnf_depth ) THEN      !==   runoff distributed over several levels   ==!
216         IF( lk_vvl ) THEN             ! variable volume case
217            DO jj = 1, jpj                   ! update the depth over which runoffs are distributed
218               DO ji = 1, jpi
219                  h_rnf(ji,jj) = 0._wp 
220                  DO jk = 1, nk_rnf(ji,jj)                           ! recalculates h_rnf to be the depth in metres
221                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk)   ! to the bottom of the relevant grid box
222                  END DO 
223                  !                          ! apply the runoff input flow
224                  DO jk = 1, nk_rnf(ji,jj)
225                     phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - ( rnf(ji,jj) + rnf_b(ji,jj) ) * zfact * r1_rau0 / h_rnf(ji,jj)
226                  END DO
227               END DO
228            END DO
229         ELSE                          ! constant volume case : just apply the runoff input flow
230            DO jj = 1, jpj
231               DO ji = 1, jpi
232                  DO jk = 1, nk_rnf(ji,jj)
233                     phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - ( rnf(ji,jj) + rnf_b(ji,jj) ) * zfact * r1_rau0 / h_rnf(ji,jj)
234                  END DO
235               END DO
236            END DO
237         ENDIF
238      ELSE                       !==   runoff put only at the surface   ==!
239         IF( lk_vvl ) THEN              ! variable volume case
240            h_rnf(:,:) = fse3t(:,:,1)   ! recalculate h_rnf to be depth of top box
241         ENDIF
242         phdivn(:,:,1) = phdivn(:,:,1) - ( rnf(:,:) + rnf_b(:,:) ) * zfact * r1_rau0 / fse3t(:,:,1)
243      ENDIF
244      !
245   END SUBROUTINE sbc_rnf_div
246
247   !! * Reset control of array index permutation
248#  include "dom_oce_ftrans.h90"
249#  include "sbc_oce_ftrans.h90"
250
251   SUBROUTINE sbc_rnf_init
252      !!----------------------------------------------------------------------
253      !!                  ***  ROUTINE sbc_rnf_init  ***
254      !!
255      !! ** Purpose :   Initialisation of the runoffs if (ln_rnf=T)
256      !!
257      !! ** Method  : - read the runoff namsbc_rnf namelist
258      !!
259      !! ** Action  : - read parameters
260      !!----------------------------------------------------------------------
261      CHARACTER(len=32) ::   rn_dep_file   ! runoff file name 
262      INTEGER           ::   ji, jj, jk    ! dummy loop indices
263      INTEGER           ::   ierror, inum  ! temporary integer
264      !!
265      NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, ln_rnf_depth, ln_rnf_tem, ln_rnf_sal,   &
266         &                 sn_rnf, sn_cnf    , sn_s_rnf    , sn_t_rnf  , sn_dep_rnf,   & 
267         &                 ln_rnf_mouth      , rn_hrnf     , rn_avt_rnf, rn_rfact 
268      !!----------------------------------------------------------------------
269
270      !                                   ! ============
271      !                                   !   Namelist
272      !                                   ! ============
273      ! (NB: frequency positive => hours, negative => months)
274      !            !   file    ! frequency !  variable  ! time intep !  clim  ! 'yearly' or ! weights  ! rotation   !
275      !            !   name    !  (hours)  !   name     !   (T/F)    !  (T/F) !  'monthly'  ! filename ! pairs      !
276      sn_rnf = FLD_N( 'runoffs',    -1     , 'sorunoff' ,  .TRUE.    , .true. ,   'yearly'  , ''       , ''         )
277      sn_cnf = FLD_N( 'runoffs',     0     , 'sorunoff' ,  .FALSE.   , .true. ,   'yearly'  , ''       , ''         )
278
279      sn_s_rnf = FLD_N( 'runoffs',  24.  , 'rosaline' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  ) 
280      sn_t_rnf = FLD_N( 'runoffs',  24.  , 'rotemper' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  ) 
281      sn_dep_rnf = FLD_N( 'runoffs',   0.  , 'rodepth'  ,  .FALSE.   , .true. ,   'yearly'  , ''    , ''  ) 
282      !
283      REWIND ( numnam )                         ! Read Namelist namsbc_rnf
284      READ   ( numnam, namsbc_rnf )
285
286      !                                         ! Control print
287      IF(lwp) THEN
288         WRITE(numout,*)
289         WRITE(numout,*) 'sbc_rnf : runoff '
290         WRITE(numout,*) '~~~~~~~ '
291         WRITE(numout,*) '   Namelist namsbc_rnf'
292         WRITE(numout,*) '      runoff in a file to be read                ln_rnf_emp   = ', ln_rnf_emp
293         WRITE(numout,*) '      specific river mouths treatment            ln_rnf_mouth = ', ln_rnf_mouth
294         WRITE(numout,*) '      river mouth additional Kz                  rn_avt_rnf   = ', rn_avt_rnf
295         WRITE(numout,*) '      depth of river mouth additional mixing     rn_hrnf      = ', rn_hrnf
296         WRITE(numout,*) '      multiplicative factor for runoff           rn_rfact     = ', rn_rfact   
297      ENDIF
298
299      !                                   ! ==================
300      !                                   !   Type of runoff
301      !                                   ! ==================
302      !                                         !==  allocate runoff arrays
303      IF( sbc_rnf_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_rnf_alloc : unable to allocate arrays' )
304      !
305      IF( ln_rnf_emp ) THEN                     !==  runoffs directly provided in the precipitations  ==!
306         IF(lwp) WRITE(numout,*)
307         IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations'
308         IF( ln_rnf_depth .OR. ln_rnf_tem .OR. ln_rnf_sal ) THEN
309           CALL ctl_warn( 'runoffs already included in precipitations, so runoff (T,S, depth) attributes will not be used' ) 
310           ln_rnf_depth = .FALSE.   ;   ln_rnf_tem = .FALSE.   ;   ln_rnf_sal = .FALSE.
311         ENDIF
312         !
313      ELSE                                      !==  runoffs read in a file : set sf_rnf structure  ==!
314         !
315         ALLOCATE( sf_rnf(1), STAT=ierror )         ! Create sf_rnf structure (runoff inflow)
316         IF(lwp) WRITE(numout,*)
317         IF(lwp) WRITE(numout,*) '          runoffs inflow read in a file'
318         IF( ierror > 0 ) THEN
319            CALL ctl_stop( 'sbc_rnf: unable to allocate sf_rnf structure' )   ;   RETURN
320         ENDIF
321         ALLOCATE( sf_rnf(1)%fnow(jpi,jpj,1)   )
322         IF( sn_rnf%ln_tint ) ALLOCATE( sf_rnf(1)%fdta(jpi,jpj,1,2) )
323         !                                          ! fill sf_rnf with the namelist (sn_rnf) and control print
324         CALL fld_fill( sf_rnf, (/ sn_rnf /), cn_dir, 'sbc_rnf_init', 'read runoffs data', 'namsbc_rnf' )
325         !
326         IF( ln_rnf_tem ) THEN                      ! Create (if required) sf_t_rnf structure
327            IF(lwp) WRITE(numout,*)
328            IF(lwp) WRITE(numout,*) '          runoffs temperatures read in a file'
329            ALLOCATE( sf_t_rnf(1), STAT=ierror  )
330            IF( ierror > 0 ) THEN
331               CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_t_rnf structure' )   ;   RETURN
332            ENDIF
333            ALLOCATE( sf_t_rnf(1)%fnow(jpi,jpj,1)   )
334            IF( sn_t_rnf%ln_tint ) ALLOCATE( sf_t_rnf(1)%fdta(jpi,jpj,1,2) )
335            CALL fld_fill (sf_t_rnf, (/ sn_t_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' ) 
336         ENDIF
337         !
338         IF( ln_rnf_sal  ) THEN                     ! Create (if required) sf_s_rnf and sf_t_rnf structures
339            IF(lwp) WRITE(numout,*)
340            IF(lwp) WRITE(numout,*) '          runoffs salinities read in a file'
341            ALLOCATE( sf_s_rnf(1), STAT=ierror  )
342            IF( ierror > 0 ) THEN
343               CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_s_rnf structure' )   ;   RETURN
344            ENDIF
345            ALLOCATE( sf_s_rnf(1)%fnow(jpi,jpj,1)   )
346            IF( sn_s_rnf%ln_tint ) ALLOCATE( sf_s_rnf(1)%fdta(jpi,jpj,1,2) )
347            CALL fld_fill (sf_s_rnf, (/ sn_s_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' ) 
348         ENDIF
349         !
350         IF( ln_rnf_depth ) THEN                    ! depth of runoffs set from a file
351            IF(lwp) WRITE(numout,*)
352            IF(lwp) WRITE(numout,*) '          runoffs depth read in a file'
353            rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname ) 
354            CALL iom_open ( rn_dep_file, inum )                           ! open file 
355            CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array 
356            CALL iom_close( inum )                                        ! close file 
357            !
358            nk_rnf(:,:) = 0                               ! set the number of level over which river runoffs are applied
359            DO jj = 1, jpj 
360               DO ji = 1, jpi 
361                  IF( h_rnf(ji,jj) > 0._wp ) THEN 
362                     jk = 2 
363                     DO WHILE ( jk /= mbkt(ji,jj) .AND. fsdept(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 ;  END DO 
364                     nk_rnf(ji,jj) = jk 
365                  ELSEIF( h_rnf(ji,jj) == -1   ) THEN   ;  nk_rnf(ji,jj) = 1 
366                  ELSEIF( h_rnf(ji,jj) == -999 ) THEN   ;  nk_rnf(ji,jj) = mbkt(ji,jj)
367                  ELSEIF( h_rnf(ji,jj) /=  0   ) THEN 
368                     CALL ctl_stop( 'runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  ) 
369                     WRITE(999,*) 'ji, jj, rnf(ji,jj) :', ji, jj, rnf(ji,jj) 
370                  ENDIF 
371               END DO 
372            END DO 
373            DO jj = 1, jpj                                ! set the associated depth
374               DO ji = 1, jpi 
375                  h_rnf(ji,jj) = 0._wp
376                  DO jk = 1, nk_rnf(ji,jj)                       
377                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk) 
378                  END DO
379               END DO
380            END DO
381         ELSE                                       ! runoffs applied at the surface
382            nk_rnf(:,:) = 1 
383            h_rnf (:,:) = fse3t(:,:,1)
384         ENDIF 
385         !
386      ENDIF
387      !
388      rnf_tsc(:,:,:) = 0._wp                    ! runoffs temperature & salinty contents initilisation
389      !
390      !                                   ! ========================
391      !                                   !   River mouth vicinity
392      !                                   ! ========================
393      !
394      IF( ln_rnf_mouth ) THEN                   ! Specific treatment in vicinity of river mouths :
395         !                                      !    - Increase Kz in surface layers ( rn_hrnf > 0 )
396         !                                      !    - set to zero SSS damping (ln_ssr=T)
397         !                                      !    - mixed upstream-centered (ln_traadv_cen2=T)
398         !
399         IF ( ln_rnf_depth )   CALL ctl_warn( 'sbc_rnf_init: increased mixing turned on but effects may already',   &
400            &                                              'be spread through depth by ln_rnf_depth'               ) 
401         !
402         nkrnf = 0                                  ! Number of level over which Kz increase
403         IF( rn_hrnf > 0._wp ) THEN
404            nkrnf = 2
405            DO WHILE( nkrnf /= jpkm1 .AND. gdepw_0(nkrnf+1) < rn_hrnf )   ;   nkrnf = nkrnf + 1   ;   END DO
406            IF( ln_sco )   &
407               CALL ctl_warn( 'sbc_rnf: number of levels over which Kz is increased is computed for zco...' )
408         ENDIF
409         IF(lwp) WRITE(numout,*)
410         IF(lwp) WRITE(numout,*) '          Specific treatment used in vicinity of river mouths :'
411         IF(lwp) WRITE(numout,*) '             - Increase Kz in surface layers (if rn_hrnf > 0 )'
412         IF(lwp) WRITE(numout,*) '               by ', rn_avt_rnf,' m2/s  over ', nkrnf, ' w-levels'
413         IF(lwp) WRITE(numout,*) '             - set to zero SSS damping       (if ln_ssr=T)'
414         IF(lwp) WRITE(numout,*) '             - mixed upstream-centered       (if ln_traadv_cen2=T)'
415         !
416         CALL rnf_mouth                             ! set river mouth mask
417         !
418      ELSE                                      ! No treatment at river mouths
419         IF(lwp) WRITE(numout,*)
420         IF(lwp) WRITE(numout,*) '          No specific treatment at river mouths'
421         rnfmsk  (:,:) = 0._wp 
422         rnfmsk_z(:)   = 0._wp
423         nkrnf = 0
424      ENDIF
425
426   END SUBROUTINE sbc_rnf_init
427
428
429   SUBROUTINE rnf_mouth
430      !!----------------------------------------------------------------------
431      !!                  ***  ROUTINE rnf_mouth  ***
432      !!       
433      !! ** Purpose :   define the river mouths mask
434      !!
435      !! ** Method  :   read the river mouth mask (=0/1) in the river runoff
436      !!                climatological file. Defined a given vertical structure.
437      !!                CAUTION, the vertical structure is hard coded on the
438      !!                first 5 levels.
439      !!                This fields can be used to:
440      !!                 - set an upstream advection scheme 
441      !!                   (ln_rnf_mouth=T and ln_traadv_cen2=T)
442      !!                 - increase vertical on the top nn_krnf vertical levels
443      !!                   at river runoff input grid point (nn_krnf>=2, see step.F90)
444      !!                 - set to zero SSS restoring flux at river mouth grid points
445      !!
446      !! ** Action  :   rnfmsk   set to 1 at river runoff input, 0 elsewhere
447      !!                rnfmsk_z vertical structure
448      !!----------------------------------------------------------------------
449      !
450      INTEGER            ::   inum        ! temporary integers
451      CHARACTER(len=140) ::   cl_rnfile   ! runoff file name
452      !!----------------------------------------------------------------------
453      !
454      IF(lwp) WRITE(numout,*)
455      IF(lwp) WRITE(numout,*) 'rnf_mouth : river mouth mask'
456      IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
457
458      cl_rnfile = TRIM( cn_dir )//TRIM( sn_cnf%clname )
459      IF( .NOT. sn_cnf%ln_clim ) THEN   ;   WRITE(cl_rnfile, '(a,"_y",i4)' ) TRIM( cl_rnfile ), nyear    ! add year
460         IF( sn_cnf%cltype == 'monthly' )   WRITE(cl_rnfile, '(a,"m",i2)'  ) TRIM( cl_rnfile ), nmonth   ! add month
461      ENDIF
462 
463      ! horizontal mask (read in NetCDF file)
464      CALL iom_open ( cl_rnfile, inum )                           ! open file
465      CALL iom_get  ( inum, jpdom_data, sn_cnf%clvar, rnfmsk )    ! read the river mouth array
466      CALL iom_close( inum )                                      ! close file
467     
468      IF( nclosea == 1 )    CALL clo_rnf( rnfmsk )                ! closed sea inflow set as ruver mouth
469
470      rnfmsk_z(:)   = 0._wp                                        ! vertical structure
471      rnfmsk_z(1)   = 1.0
472      rnfmsk_z(2)   = 1.0                                         ! **********
473      rnfmsk_z(3)   = 0.5                                         ! HARD CODED on the 5 first levels
474      rnfmsk_z(4)   = 0.25                                        ! **********
475      rnfmsk_z(5)   = 0.125
476      !         
477   END SUBROUTINE rnf_mouth
478   
479   !!======================================================================
480END MODULE sbcrnf
Note: See TracBrowser for help on using the repository browser.