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 on Ticket #465 – Attachment – NEMO

Ticket #465: sbcrnf.F90

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