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_v2.F90 on Ticket #162 – Attachment – NEMO

Ticket #162: sbcrnf_v2.F90

File sbcrnf_v2.F90, 13.3 KB (added by ctlod, 16 years ago)
Line 
1MODULE sbcrnf
2   !!======================================================================
3   !!                       ***  MODULE  sbcrnf  ***
4   !! Ocean forcing:  river runoff
5   !!=====================================================================
6   !! History :       !  00-11  (R. Hordoir, E. Durand)  NetCDF FORMAT
7   !!            8.5  !  02-09  (G. Madec)  F90: Free form and module
8   !!            9.0  !  06-07  (G. Madec)  Surface module
9   !!----------------------------------------------------------------------
10
11   !!----------------------------------------------------------------------
12   !!   sbc_rnf      : monthly runoffs read in a NetCDF file
13   !!   sbc_rnf_init : runoffs initialisation
14   !!   rnf_mouth    : set river mouth mask
15   !!----------------------------------------------------------------------
16   USE dom_oce         ! ocean space and time domain
17   USE phycst          ! physical constants
18   USE dom_oce         ! ocean domain variables
19   USE sbc_oce         ! surface boundary condition variables
20   USE fldread         ! ???
21   USE in_out_manager  ! I/O manager
22   USE daymod          ! calendar
23   USE iom             ! I/O module
24
25   IMPLICIT NONE
26   PRIVATE
27
28   PUBLIC sbc_rnf          ! routine call in step module
29
30   !! * namsbc_rnf namelist
31   CHARACTER(len=100), PUBLIC ::   cn_dir     = './'    !: Root directory for location of ssr files
32   LOGICAL           , PUBLIC ::   ln_rnf_ipf = .true.  !: runoffs into a file to be read or already into precipitation
33   TYPE(FLD_N)       , PUBLIC ::   sn_rnf               !: information about the runoff file to be read
34   TYPE(FLD_N)       , PUBLIC ::   sn_cnf               !: information about the runoff mouth file to be read
35   LOGICAL           , PUBLIC ::   ln_rnf_avt = .false. !: specific treatment in mouths vicinity
36   REAL(wp)          , PUBLIC ::   rn_hrnf    = 0.e0    !: runoffs, depth over which enhanced vertical mixing is used
37   REAL(wp)          , PUBLIC ::   rn_avt_rnf = 0.e0    !: runoffs, value of the additional vertical mixing coef. [m2/s]
38
39   INTEGER , PUBLIC                     ::   nkrnf = 0   !: number of levels over which Kz is increased at river mouths
40   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfmsk      !: river mouth mask (hori.)
41   REAL(wp), PUBLIC, DIMENSION(jpk)     ::   rnfmsk_z    !: river mouth mask (vert.)
42
43   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_rnf   ! structure of input SST (file information, fields read)
44
45   !!----------------------------------------------------------------------
46   !!   OPA 9.0 , LOCEAN-IPSL (2006)
47   !! $Id:$
48   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
49   !!----------------------------------------------------------------------
50
51CONTAINS
52
53   SUBROUTINE sbc_rnf( kt )
54      !!----------------------------------------------------------------------
55      !!                  ***  ROUTINE sbc_rnf  ***
56      !!       
57      !! ** Purpose :   Introduce a climatological run off forcing
58      !!
59      !! ** Method  :   Set each river mouth with a monthly climatology
60      !!                provided from different data.
61      !!                CAUTION : upward water flux, runoff forced to be < 0
62      !!
63      !! ** Action  :   runoff updated runoff field at time-step kt
64      !!----------------------------------------------------------------------
65      INTEGER, INTENT(in) ::   kt          ! ocean time step
66      !
67      INTEGER  ::   ji, jj   ! dummy loop indices
68      !!----------------------------------------------------------------------
69      !                                   
70      IF( kt == nit000 )   CALL sbc_rnf_init
71
72      !                                                   !-------------------!
73      IF( ln_rnf_ipf ) THEN                               !   Update runoff   !
74         !                                                !-------------------!
75         !
76         CALL fld_read( kt, nn_fsbc, sf_rnf )   ! Read Runoffs data and provides it
77         !                                      ! at the current time-step
78
79         ! Runoff reduction only associated to the ORCA2_LIM configuration
80         ! when reading the NetCDF file runoff_1m_nomask.nc
81         IF( cp_cfg == 'orca' .AND. jp_cfg == 2 )   THEN
82            DO jj = 1, jpj
83               DO ji = 1, jpi
84                  IF( gphit(ji,jj) > 40 .AND. gphit(ji,jj) < 65 )   sf_rnf(1)%fnow(ji,jj) = 0.85 * sf_rnf(1)%fnow(ji,jj)
85               END DO
86            END DO
87         ENDIF
88
89         ! C a u t i o n : runoff is negative and in kg/m2/s
90
91         emp (:,:) = emp (:,:) - ABS( sf_rnf(1)%fnow(:,:) )
92         emps(:,:) = emps(:,:) - ABS( sf_rnf(1)%fnow(:,:) )
93         !
94      ENDIF
95      !
96   END SUBROUTINE sbc_rnf
97
98
99   SUBROUTINE sbc_rnf_init
100      !!----------------------------------------------------------------------
101      !!                  ***  ROUTINE sbc_rnf_init  ***
102      !!
103      !! ** Purpose :   Initialisation of the runoffs if (ln_rnf=T)
104      !!
105      !! ** Method  : - read the runoff namsbc_rnf namelist
106      !!
107      !! ** Action  : - read parameters
108      !!----------------------------------------------------------------------
109      INTEGER  ::   ierror   ! temporary integer
110      !!
111      NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_ipf, sn_rnf, sn_cnf, ln_rnf_avt,   &
112         &                 rn_hrnf, rn_avt_rnf
113      !!----------------------------------------------------------------------
114
115      !                                   ! ============
116      !                                   !   Namelist
117      !                                   ! ============
118      !                                         ! Default values NB: frequency>0 hours, <0 months)
119      !            !   file    ! frequency !  variable  ! time intep !  clim  ! starting !
120      !            !   name    !  (hours)  !   name     !   (T/F)    !  (0/1) !  record  !
121      sn_rnf = FLD_N( 'runoffs',   -12.    , 'sorunoff' ,  .TRUE.    ,    1   ,     0    )
122      sn_cnf = FLD_N( 'runoffs',     0.    , 'sorunoff' ,  .FALSE.   ,    1   ,     0    )
123
124      !
125      REWIND ( numnam )                         ! Read Namelist namsbc_rnf
126      READ   ( numnam, namsbc_rnf )
127
128      !                                         ! Control print
129      IF(lwp) THEN
130         WRITE(numout,*)
131         WRITE(numout,*) 'sbc_rnf : runoff '
132         WRITE(numout,*) '~~~~~~~ '
133         WRITE(numout,*) '   Namelist namsbc_rnf'
134         WRITE(numout,*) '      runoff in a file to be read                ln_rnf_ipf  = ', ln_rnf_ipf
135         WRITE(numout,*) '      specific river mouths treatment            ln_rnf_avt  = ', ln_rnf_avt
136         WRITE(numout,*) '      river mouth additional Kz                  rn_avt_rnf  = ', rn_avt_rnf
137         WRITE(numout,*) '      depth of river mouth additional mixing     rn_hrnf     = ', rn_hrnf
138      ENDIF
139
140      !                                   ! ==================
141      !                                   !   Type of runoff
142      !                                   ! ==================
143      !
144      IF( ln_rnf_ipf ) THEN                     ! runoffs read in a file : set sf_rnf structure
145         !
146         ALLOCATE( sf_rnf(1), STAT=ierror )
147         IF( ierror > 0 ) THEN
148            CALL ctl_stop( 'sbc_rnf: unable to allocate sf_rnf structure' )   ;   RETURN
149         ENDIF
150         !                                         ! namelist informations stored in sf_rnf structures
151         WRITE( sf_rnf(1)%clrootname, '(a,a)' )   TRIM( cn_dir ), TRIM( sn_rnf%clname )
152         sf_rnf(1)%freqh   = sn_rnf%freqh
153         sf_rnf(1)%clvar   = sn_rnf%clvar
154         sf_rnf(1)%ln_tint = sn_rnf%ln_tint
155         sf_rnf(1)%nclim   = sn_rnf%nclim
156         sf_rnf(1)%nstrec  = sn_rnf%nstrec
157         IF(lwp) THEN                              ! control print
158            WRITE(numout,*) '   Runoffs data read in the following file: '
159            WRITE(numout,*) '               root filename: '  , trim( sf_rnf(1)%clrootname ),   &
160               &                          ' variable name: '  , trim( sf_rnf(1)%clvar      )
161            WRITE(numout,*) '               frequency: '      ,       sf_rnf(1)%freqh       ,   &
162               &                          ' time interp: '    ,       sf_rnf(1)%ln_tint     ,   &
163               &                          ' climatology: '    ,       sf_rnf(1)%nclim       ,   &
164               &                          ' starting record: ',       sf_rnf(1)%nstrec
165         ENDIF
166         !
167      ELSE                                      ! runoffs directly provided in the precipitations
168         IF(lwp) WRITE(numout,*)
169         IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations'
170      ENDIF
171
172      !                                   ! ========================
173      !                                   !   River mouth vicinity
174      !                                   ! ========================
175      !
176      IF( ln_rnf_avt ) THEN                     ! Specific treatment in vicinity of river mouths :
177         !                                      !    - Increase Kz in surface layers ( rn_hrnf > 0 )
178         !                                      !    - set to zero SSS damping (ln_ssr=T)
179         !                                      !    - mixed upstream-centered (ln_traadv_cen2=T)
180         !
181         !                                          ! Number of level over which Kz increase
182         nkrnf = 0
183         IF( rn_hrnf > 0.e0 ) THEN
184            nkrnf = 2
185            DO WHILE( nkrnf == jpkm1 .OR. gdepw_0(nkrnf) > rn_hrnf )   ;   nkrnf = nkrnf + 1   ;   END DO
186            IF( ln_sco )   &
187               CALL ctl_warn( 'sbc_rnf: number of levels over which Kz is increased is computed for zco...' )
188         ENDIF
189         IF(lwp) WRITE(numout,*)
190         IF(lwp) WRITE(numout,*) '          Specific treatment used in vicinity of river mouths :'
191         IF(lwp) WRITE(numout,*) '             - Increase Kz in surface layers (if rn_hrnf > 0 )'
192         IF(lwp) WRITE(numout,*) '               by ', rn_avt_rnf,' m2/s  over ', nkrnf, ' w-levels'
193         IF(lwp) WRITE(numout,*) '             - set to zero SSS damping       (if ln_ssr=T)'
194         IF(lwp) WRITE(numout,*) '             - mixed upstream-centered       (if ln_traadv_cen2=T)'
195         !
196         CALL rnf_mouth                             ! set river mouth mask
197         !
198      ELSE                                      ! No treatment at river mouths
199         IF(lwp) WRITE(numout,*)
200         IF(lwp) WRITE(numout,*) '          No specific treatment at river mouths'
201         rnfmsk  (:,:) = 0.e0 
202         rnfmsk_z(:)   = 0.e0
203         nkrnf = 0
204      ENDIF
205
206   END SUBROUTINE sbc_rnf_init
207
208
209   SUBROUTINE rnf_mouth
210      !!----------------------------------------------------------------------
211      !!                  ***  ROUTINE rnf_mouth  ***
212      !!       
213      !! ** Purpose :   define the river mouths mask
214      !!
215      !! ** Method  :   read the river mouth mask (=0/1) in the river runoff
216      !!                climatological file. Defined a given vertical structure.
217      !!                CAUTION, the vertical structure is hard coded on the
218      !!                first 5 levels.
219      !!                This fields can be used to:
220      !!                 - set an upstream advection scheme 
221      !!                   (ln_rnf_avt=T and ln_traadv_cen2=T)
222      !!                 - increase vertical on the top nn_krnf vertical levels
223      !!                   at river runoff input grid point (nn_krnf>=2, see step.F90)
224      !!                 - set to zero SSS restoring flux at river mouth grid points
225      !!
226      !! ** Action  :   rnfmsk   set to 1 at river runoff input, 0 elsewhere
227      !!                rnfmsk_z vertical structure
228      !!----------------------------------------------------------------------
229      USE closea, ONLY :    nclosea, clo_rnf   ! closed sea flag, rnfmsk update routine
230      !
231      INTEGER           ::   inum        ! temporary integers
232      CHARACTER(len=32) ::   cl_rnfile   ! runoff file name
233      !!----------------------------------------------------------------------
234      !
235      IF(lwp) WRITE(numout,*)
236      IF(lwp) WRITE(numout,*) 'rnf_mouth : river mouth mask'
237      IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
238
239      WRITE(cl_rnfile, '(a,a)')   TRIM( cn_dir ), TRIM( sn_cnf%clname )
240      SELECT CASE( sn_cnf%nclim )
241      CASE( 0 )
242         WRITE(cl_rnfile, '(a,a,"_",i4,".nc")' ) TRIM( cn_dir ), TRIM( sn_cnf%clname ), nyear
243      CASE( 1 )
244         WRITE(cl_rnfile, '(a,a,  ".nc")' ) TRIM( cn_dir ), TRIM( sn_cnf%clname )
245      END SELECT
246
247      ! horizontal mask (read in NetCDF file)
248      CALL iom_open ( cl_rnfile, inum )                           ! open file
249      CALL iom_get  ( inum, jpdom_data, sn_cnf%clvar, rnfmsk )    ! read the river mouth array
250      CALL iom_close( inum )                                      ! close file
251     
252      IF( nclosea == 1 )    CALL clo_rnf( rnfmsk )                ! closed sea inflow set as ruver mouth
253
254      rnfmsk_z(:)   = 0.e0                                        ! vertical structure
255      rnfmsk_z(1)   = 1.0
256      rnfmsk_z(2)   = 1.0                                         ! **********
257      rnfmsk_z(3)   = 0.5                                         ! HARD CODED on the 5 first levels
258      rnfmsk_z(4)   = 0.25                                        ! **********
259      rnfmsk_z(5)   = 0.125
260      !         
261   END SUBROUTINE rnf_mouth
262   
263   !!======================================================================
264END MODULE sbcrnf