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.
trcbc.F90 in branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC – NEMO

source: branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC/trcbc.F90 @ 5845

Last change on this file since 5845 was 5845, checked in by gm, 9 years ago

#1613: vvl by default: suppression of domzgr_substitute.h90

  • Property svn:keywords set to Id
File size: 15.3 KB
Line 
1MODULE trcbc
2   !!======================================================================
3   !!                     ***  MODULE  trcbc  ***
4   !! TOP :  module for passive tracer boundary conditions
5   !!=====================================================================
6   !!----------------------------------------------------------------------
7#if  defined key_top 
8   !!----------------------------------------------------------------------
9   !!   'key_top'                                                TOP model
10   !!----------------------------------------------------------------------
11   !!   trc_dta    : read and time interpolated passive tracer data
12   !!----------------------------------------------------------------------
13   USE par_trc       !  passive tracers parameters
14   USE oce_trc       !  shared variables between ocean and passive tracers
15   USE trc           !  passive tracers common variables
16   USE iom           !  I/O manager
17   USE lib_mpp       !  MPP library
18   USE fldread       !  read input fields
19
20   IMPLICIT NONE
21   PRIVATE
22
23   PUBLIC   trc_bc_init    ! called in trcini.F90
24   PUBLIC   trc_bc_read    ! called in trcstp.F90 or within
25
26   INTEGER  , SAVE, PUBLIC                             :: nb_trcobc   ! number of tracers with open BC
27   INTEGER  , SAVE, PUBLIC                             :: nb_trcsbc   ! number of tracers with surface BC
28   INTEGER  , SAVE, PUBLIC                             :: nb_trccbc   ! number of tracers with coastal BC
29   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_indobc ! index of tracer with OBC data
30   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_indsbc ! index of tracer with SBC data
31   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_indcbc ! index of tracer with CBC data
32   INTEGER  , SAVE, PUBLIC                             :: ntra_obc     ! MAX( 1, nb_trcxxx ) to avoid compilation error with bounds checking
33   INTEGER  , SAVE, PUBLIC                             :: ntra_sbc     ! MAX( 1, nb_trcxxx ) to avoid compilation error with bounds checking
34   INTEGER  , SAVE, PUBLIC                             :: ntra_cbc     ! MAX( 1, nb_trcxxx ) to avoid compilation error with bounds checking
35   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trofac   ! multiplicative factor for OBCtracer values
36   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: sf_trcobc   ! structure of data input OBC (file informations, fields read)
37   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trsfac   ! multiplicative factor for SBC tracer values
38   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: sf_trcsbc   ! structure of data input SBC (file informations, fields read)
39   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trcfac   ! multiplicative factor for CBC tracer values
40   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: sf_trccbc   ! structure of data input CBC (file informations, fields read)
41
42   !!----------------------------------------------------------------------
43   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
44   !! $Id$
45   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
46   !!----------------------------------------------------------------------
47CONTAINS
48
49   SUBROUTINE trc_bc_init(ntrc)
50      !!----------------------------------------------------------------------
51      !!                   ***  ROUTINE trc_bc_init  ***
52      !!                   
53      !! ** Purpose :   initialisation of passive tracer BC data
54      !!
55      !! ** Method  : - Read namtsd namelist
56      !!              - allocates passive tracer BC data structure
57      !!----------------------------------------------------------------------
58      INTEGER,INTENT(IN) :: ntrc                           ! number of tracers
59      INTEGER            :: jl, jn                         ! dummy loop indices
60      INTEGER            :: ierr0, ierr1, ierr2, ierr3     ! temporary integers
61      INTEGER            ::  ios                           ! Local integer output status for namelist read
62      CHARACTER(len=100) :: clndta, clntrc
63      !
64      CHARACTER(len=100) :: cn_dir
65      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_i  ! local array of namelist informations on the fields to read
66      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcobc    ! open
67      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcsbc    ! surface
68      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trccbc    ! coastal
69      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trofac    ! multiplicative factor for tracer values
70      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trsfac    ! multiplicative factor for tracer values
71      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trcfac    ! multiplicative factor for tracer values
72      !!
73      NAMELIST/namtrc_bc/ cn_dir, sn_trcobc, rn_trofac, sn_trcsbc, rn_trsfac, sn_trccbc, rn_trcfac 
74      !!----------------------------------------------------------------------
75      IF( nn_timing == 1 )  CALL timing_start('trc_bc_init')
76      !
77      !  Initialisation and local array allocation
78      ierr0 = 0  ;  ierr1 = 0  ;  ierr2 = 0  ;  ierr3 = 0 
79      ALLOCATE( slf_i(ntrc), STAT=ierr0 )
80      IF( ierr0 > 0 ) THEN
81         CALL ctl_stop( 'trc_bc_init: unable to allocate local slf_i' )   ;   RETURN
82      ENDIF
83
84      ! Compute the number of tracers to be initialised with open, surface and boundary data
85      ALLOCATE( n_trc_indobc(ntrc), STAT=ierr0 )
86      IF( ierr0 > 0 ) THEN
87         CALL ctl_stop( 'trc_bc_init: unable to allocate n_trc_indobc' )   ;   RETURN
88      ENDIF
89      nb_trcobc      = 0
90      n_trc_indobc(:) = 0
91      !
92      ALLOCATE( n_trc_indsbc(ntrc), STAT=ierr0 )
93      IF( ierr0 > 0 ) THEN
94         CALL ctl_stop( 'trc_bc_init: unable to allocate n_trc_indsbc' )   ;   RETURN
95      ENDIF
96      nb_trcsbc      = 0
97      n_trc_indsbc(:) = 0
98      !
99      ALLOCATE( n_trc_indcbc(ntrc), STAT=ierr0 )
100      IF( ierr0 > 0 ) THEN
101         CALL ctl_stop( 'trc_bc_init: unable to allocate n_trc_indcbc' )   ;   RETURN
102      ENDIF
103      nb_trccbc      = 0
104      n_trc_indcbc(:) = 0
105      !
106      DO jn = 1, ntrc
107         IF( ln_trc_obc(jn) ) THEN
108             nb_trcobc       = nb_trcobc + 1 
109             n_trc_indobc(jn) = nb_trcobc 
110         ENDIF
111         IF( ln_trc_sbc(jn) ) THEN
112             nb_trcsbc       = nb_trcsbc + 1
113             n_trc_indsbc(jn) = nb_trcsbc
114         ENDIF
115         IF( ln_trc_cbc(jn) ) THEN
116             nb_trccbc       = nb_trccbc + 1
117             n_trc_indcbc(jn) = nb_trccbc
118         ENDIF
119      ENDDO
120      ntra_obc = MAX( 1, nb_trcobc )   ! To avoid compilation error with bounds checking
121      IF( lwp ) WRITE(numout,*) ' '
122      IF( lwp ) WRITE(numout,*) ' Number of passive tracers to be initialized with open boundary data :', nb_trcobc
123      IF( lwp ) WRITE(numout,*) ' '
124      ntra_sbc = MAX( 1, nb_trcsbc )   ! To avoid compilation error with bounds checking
125      IF( lwp ) WRITE(numout,*) ' '
126      IF( lwp ) WRITE(numout,*) ' Number of passive tracers to be initialized with surface boundary data :', nb_trcsbc
127      IF( lwp ) WRITE(numout,*) ' '
128      ntra_cbc = MAX( 1, nb_trccbc )   ! To avoid compilation error with bounds checking
129      IF( lwp ) WRITE(numout,*) ' '
130      IF( lwp ) WRITE(numout,*) ' Number of passive tracers to be initialized with coastal boundary data :', nb_trccbc
131      IF( lwp ) WRITE(numout,*) ' '
132
133      REWIND( numnat_ref )              ! Namelist namtrc_bc in reference namelist : Passive tracer data structure
134      READ  ( numnat_ref, namtrc_bc, IOSTAT = ios, ERR = 901)
135901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bc in reference namelist', lwp )
136
137      REWIND( numnat_cfg )              ! Namelist namtrc_bc in configuration namelist : Passive tracer data structure
138      READ  ( numnat_cfg, namtrc_bc, IOSTAT = ios, ERR = 902 )
139902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bc in configuration namelist', lwp )
140      IF(lwm) WRITE ( numont, namtrc_bc )
141
142      ! print some information for each
143      IF( lwp ) THEN
144         DO jn = 1, ntrc
145            IF( ln_trc_obc(jn) )  THEN   
146               clndta = TRIM( sn_trcobc(jn)%clvar ) 
147               IF(lwp) WRITE(numout,*) 'Preparing to read OBC data file for passive tracer number :', jn, ' name : ', clndta, & 
148               &               ' multiplicative factor : ', rn_trofac(jn)
149            ENDIF
150            IF( ln_trc_sbc(jn) )  THEN   
151               clndta = TRIM( sn_trcsbc(jn)%clvar ) 
152               IF(lwp) WRITE(numout,*) 'Preparing to read SBC data file for passive tracer number :', jn, ' name : ', clndta, & 
153               &               ' multiplicative factor : ', rn_trsfac(jn)
154            ENDIF
155            IF( ln_trc_cbc(jn) )  THEN   
156               clndta = TRIM( sn_trccbc(jn)%clvar ) 
157               IF(lwp) WRITE(numout,*) 'Preparing to read CBC data file for passive tracer number :', jn, ' name : ', clndta, & 
158               &               ' multiplicative factor : ', rn_trcfac(jn)
159            ENDIF
160         END DO
161      ENDIF
162      !
163      ! The following code is written this way to reduce memory usage and repeated for each boundary data
164      ! MAV: note that this is just a placeholder and the dimensions must be changed according to
165      !      what will be done with BDY. A new structure will probably need to be included
166      !
167      ! OPEN Lateral boundary conditions
168      IF( nb_trcobc > 0 ) THEN       !  allocate only if the number of tracer to initialise is greater than zero
169         ALLOCATE( sf_trcobc(nb_trcobc), rf_trofac(nb_trcobc), STAT=ierr1 )
170         IF( ierr1 > 0 ) THEN
171            CALL ctl_stop( 'trc_bc_init: unable to allocate  sf_trcobc structure' )   ;   RETURN
172         ENDIF
173         !
174         DO jn = 1, ntrc
175            IF( ln_trc_obc(jn) ) THEN      ! update passive tracers arrays with input data read from file
176               jl = n_trc_indobc(jn)
177               slf_i(jl)    = sn_trcobc(jn)
178               rf_trofac(jl) = rn_trofac(jn)
179                                            ALLOCATE( sf_trcobc(jl)%fnow(jpi,jpj,jpk)   , STAT=ierr2 )
180               IF( sn_trcobc(jn)%ln_tint )  ALLOCATE( sf_trcobc(jl)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 )
181               IF( ierr2 + ierr3 > 0 ) THEN
182                 CALL ctl_stop( 'trc_bc_init : unable to allocate passive tracer OBC data arrays' )   ;   RETURN
183               ENDIF
184            ENDIF
185            !   
186         ENDDO
187         !                         ! fill sf_trcdta with slf_i and control print
188         CALL fld_fill( sf_trcobc, slf_i, cn_dir, 'trc_bc_init', 'Passive tracer OBC data', 'namtrc_bc' )
189         !
190      ENDIF
191      !
192      ! SURFACE Boundary conditions
193      IF( nb_trcsbc > 0 ) THEN       !  allocate only if the number of tracer to initialise is greater than zero
194         ALLOCATE( sf_trcsbc(nb_trcsbc), rf_trsfac(nb_trcsbc), STAT=ierr1 )
195         IF( ierr1 > 0 ) THEN
196            CALL ctl_stop( 'trc_bc_init: unable to allocate  sf_trcsbc structure' )   ;   RETURN
197         ENDIF
198         !
199         DO jn = 1, ntrc
200            IF( ln_trc_sbc(jn) ) THEN      ! update passive tracers arrays with input data read from file
201               jl = n_trc_indsbc(jn)
202               slf_i(jl)    = sn_trcsbc(jn)
203               rf_trsfac(jl) = rn_trsfac(jn)
204                                            ALLOCATE( sf_trcsbc(jl)%fnow(jpi,jpj,1)   , STAT=ierr2 )
205               IF( sn_trcsbc(jn)%ln_tint )  ALLOCATE( sf_trcsbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 )
206               IF( ierr2 + ierr3 > 0 ) THEN
207                 CALL ctl_stop( 'trc_bc_init : unable to allocate passive tracer SBC data arrays' )   ;   RETURN
208               ENDIF
209            ENDIF
210            !   
211         ENDDO
212         !                         ! fill sf_trcsbc with slf_i and control print
213         CALL fld_fill( sf_trcsbc, slf_i, cn_dir, 'trc_bc_init', 'Passive tracer SBC data', 'namtrc_bc' )
214         !
215      ENDIF
216      !
217      ! COSTAL Boundary conditions
218      IF( nb_trccbc > 0 ) THEN       !  allocate only if the number of tracer to initialise is greater than zero
219         ALLOCATE( sf_trccbc(nb_trccbc), rf_trcfac(nb_trccbc), STAT=ierr1 )
220         IF( ierr1 > 0 ) THEN
221            CALL ctl_stop( 'trc_bc_ini: unable to allocate  sf_trccbc structure' )   ;   RETURN
222         ENDIF
223         !
224         DO jn = 1, ntrc
225            IF( ln_trc_cbc(jn) ) THEN      ! update passive tracers arrays with input data read from file
226               jl = n_trc_indcbc(jn)
227               slf_i(jl)    = sn_trccbc(jn)
228               rf_trcfac(jl) = rn_trcfac(jn)
229                                            ALLOCATE( sf_trccbc(jl)%fnow(jpi,jpj,1)   , STAT=ierr2 )
230               IF( sn_trccbc(jn)%ln_tint )  ALLOCATE( sf_trccbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 )
231               IF( ierr2 + ierr3 > 0 ) THEN
232                 CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer CBC data arrays' )   ;   RETURN
233               ENDIF
234            ENDIF
235            !   
236         ENDDO
237         !                         ! fill sf_trccbc with slf_i and control print
238         CALL fld_fill( sf_trccbc, slf_i, cn_dir, 'trc_bc_init', 'Passive tracer CBC data', 'namtrc_bc' )
239         !
240      ENDIF
241      !
242      DEALLOCATE( slf_i )          ! deallocate local field structure
243      IF( nn_timing == 1 )  CALL timing_stop('trc_bc_init')
244      !
245   END SUBROUTINE trc_bc_init
246
247
248   SUBROUTINE trc_bc_read(kt)
249      !!----------------------------------------------------------------------
250      !!                   ***  ROUTINE trc_bc_init  ***
251      !!
252      !! ** Purpose :  Read passive tracer Boundary Conditions data
253      !!
254      !! ** Method  :  Read BC inputs and update data structures using fldread
255      !!             
256      !!----------------------------------------------------------------------
257      USE fldread
258      !
259      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
260      !!---------------------------------------------------------------------
261      !
262      IF( nn_timing == 1 )  CALL timing_start('trc_bc_read')
263
264      IF( kt == nit000 ) THEN
265         IF(lwp) WRITE(numout,*)
266         IF(lwp) WRITE(numout,*) 'trc_bc_read : Surface boundary conditions for passive tracers.'
267         IF(lwp) WRITE(numout,*) '~~~~~~~ '
268      ENDIF
269
270      ! OPEN boundary conditions: DOES NOT WORK. Waiting for stable BDY
271      IF( nb_trcobc > 0 ) THEN
272        if (lwp) write(numout,'(a,i5,a,i5)') '   reading OBC data for ', nb_trcobc ,' variables at step ', kt
273        CALL fld_read(kt,1,sf_trcobc)
274        ! vertical interpolation on s-grid and partial step to be added
275      ENDIF
276
277      ! SURFACE boundary conditions       
278      IF( nb_trcsbc > 0 ) THEN
279        if (lwp) write(numout,'(a,i5,a,i5)') '   reading SBC data for ', nb_trcsbc ,' variables at step ', kt
280        CALL fld_read(kt,1,sf_trcsbc)
281      ENDIF
282
283      ! COASTAL boundary conditions       
284      IF( nb_trccbc > 0 ) THEN
285        if (lwp) write(numout,'(a,i5,a,i5)') '   reading CBC data for ', nb_trccbc ,' variables at step ', kt
286        CALL fld_read(kt,1,sf_trccbc)
287      ENDIF   
288      !
289      IF( nn_timing == 1 )  CALL timing_stop('trc_bc_read')
290      !
291   END SUBROUTINE trc_bc_read
292
293#else
294   !!----------------------------------------------------------------------
295   !!   Dummy module                              NO 3D passive tracer data
296   !!----------------------------------------------------------------------
297CONTAINS
298   SUBROUTINE trc_bc_read( kt )        ! Empty routine
299      WRITE(*,*) 'trc_bc_read: You should not have seen this print! error?', kt
300   END SUBROUTINE trc_bc_read
301#endif
302
303   !!======================================================================
304END MODULE trcbc
Note: See TracBrowser for help on using the repository browser.