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.
trcini.F90 in NEMO/branches/2019/dev_r11219_TOP-01_cethe_PISCES_LBC/src/TOP – NEMO

source: NEMO/branches/2019/dev_r11219_TOP-01_cethe_PISCES_LBC/src/TOP/trcini.F90 @ 11222

Last change on this file since 11222 was 11222, checked in by cetlod, 5 years ago

PISCES_LBC : 1st step of dev

  • Property svn:keywords set to Id
File size: 13.5 KB
RevLine 
[268]1MODULE trcini
[945]2   !!======================================================================
3   !!                         ***  MODULE trcini  ***
4   !! TOP :   Manage the passive tracer initialization
5   !!======================================================================
[2715]6   !! History :   -   ! 1991-03 (O. Marti)  original code
7   !!            1.0  ! 2005-03 (O. Aumont, A. El Moussaoui) F90
8   !!            2.0  ! 2005-10 (C. Ethe, G. Madec) revised architecture
9   !!            4.0  ! 2011-01 (A. R. Porter, STFC Daresbury) dynamical allocation
[274]10   !!----------------------------------------------------------------------
[1011]11#if defined key_top
12   !!----------------------------------------------------------------------
13   !!   'key_top'                                                TOP models
14   !!----------------------------------------------------------------------
[2715]15   !!   trc_init  :   Initialization for passive tracer
16   !!   top_alloc :   allocate the TOP arrays
[1011]17   !!----------------------------------------------------------------------
[3294]18   USE oce_trc         ! shared variables between ocean and passive tracers
19   USE trc             ! passive tracers common variables
[2528]20   USE trcnam          ! Namelist read
[3294]21   USE daymod          ! calendar manager
[1011]22   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
[4306]23   USE trcsub          ! variables to substep passive tracers
[5836]24   USE trcrst
[4306]25   USE lib_mpp         ! distribued memory computing library
[5385]26   USE trcice          ! tracers in sea ice
[11222]27   USE trcbc           ! generalized Boundary Conditions
[4306]28 
[335]29   IMPLICIT NONE
30   PRIVATE
[1011]31   
[2528]32   PUBLIC   trc_init   ! called by opa
[268]33
[2715]34   !!----------------------------------------------------------------------
[9598]35   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
[2715]36   !! $Id$
[10068]37   !! Software governed by the CeCILL license (see ./LICENSE)
[2715]38   !!----------------------------------------------------------------------
[335]39CONTAINS
[1011]40   
[2528]41   SUBROUTINE trc_init
[1011]42      !!---------------------------------------------------------------------
[2528]43      !!                     ***  ROUTINE trc_init  ***
[335]44      !!
[1011]45      !! ** Purpose :   Initialization of the passive tracer fields
46      !!
47      !! ** Method  : - read namelist
48      !!              - control the consistancy
49      !!              - compute specific initialisations
50      !!              - set initial tracer fields (either read restart
51      !!                or read data or analytical formulation
52      !!---------------------------------------------------------------------
[3294]53      !
[9124]54      IF( ln_timing )   CALL timing_start('trc_init')
[3294]55      !
[945]56      IF(lwp) WRITE(numout,*)
[2528]57      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
[9169]58      IF(lwp) WRITE(numout,*) '~~~~~~~~'
[3294]59      !
[5836]60      CALL trc_ini_ctl   ! control
61      CALL trc_nam       ! read passive tracers namelists
[7646]62      CALL top_alloc()   ! allocate TOP arrays
[5836]63      !
[7646]64      IF(.NOT.ln_trcdta )   ln_trc_ini(:) = .FALSE.
[4152]65      !
[3294]66      IF(lwp) WRITE(numout,*)
[7646]67      IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
68      IF(lwp) WRITE(numout,*)
[5836]69      !
70      CALL trc_ini_sms   ! SMS
71      CALL trc_ini_trp   ! passive tracers transport
72      CALL trc_ice_ini   ! Tracers in sea ice
73      !
[10570]74      IF( lwm .AND. sn_cfctl%l_trcstat ) THEN
75         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
76      ENDIF
[5836]77      !
78      CALL trc_ini_state  !  passive tracers initialisation : from a restart or from clim
[7646]79      IF( nn_dttrc /= 1 ) &
80      CALL trc_sub_ini    ! Initialize variables for substepping passive tracers
[5836]81      !
[8542]82      CALL trc_ini_inv   ! Inventories
83      !
[9124]84      IF( ln_timing )   CALL timing_stop('trc_init')
[5836]85      !
86   END SUBROUTINE trc_init
87
88
89   SUBROUTINE trc_ini_ctl
90      !!----------------------------------------------------------------------
91      !!                     ***  ROUTINE trc_ini_ctl  ***
92      !! ** Purpose :        Control  + ocean volume
93      !!----------------------------------------------------------------------
94      INTEGER ::   jk    ! dummy loop indices
95      !
96      ! Define logical parameter ton control dirunal cycle in TOP
97      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
[7646]98      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. l_offline
[5836]99      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
100         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
101      !
102   END SUBROUTINE trc_ini_ctl
103
104
105   SUBROUTINE trc_ini_inv
106      !!----------------------------------------------------------------------
107      !!                     ***  ROUTINE trc_ini_stat  ***
108      !! ** Purpose :      passive tracers inventories at initialsation phase
109      !!----------------------------------------------------------------------
[7753]110      INTEGER ::  jk, jn    ! dummy loop indices
[5836]111      CHARACTER (len=25) :: charout
112      !!----------------------------------------------------------------------
[9169]113      !
114      IF(lwp) WRITE(numout,*)
115      IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories'
116      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
117      !
118      !                          ! masked grid volume
[3294]119      DO jk = 1, jpk
[7753]120         cvol(:,:,jk) = e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk)
[3294]121      END DO
[9169]122      !                          ! total volume of the ocean
[10425]123      areatot = glob_sum( 'trcini', cvol(:,:,:) )
[5836]124      !
[9169]125      trai(:) = 0._wp            ! initial content of all tracers
[5836]126      DO jn = 1, jptra
[10425]127         trai(jn) = trai(jn) + glob_sum( 'trcini', trn(:,:,:,jn) * cvol(:,:,:)   )
[5836]128      END DO
[1011]129
[5836]130      IF(lwp) THEN               ! control print
131         WRITE(numout,*)
[9169]132         WRITE(numout,*) '   ==>>>   Total number of passive tracer jptra = ', jptra
133         WRITE(numout,*) '           Total volume of ocean                = ', areatot
134         WRITE(numout,*) '           Total inital content of all tracers '
[5836]135         WRITE(numout,*)
136         DO jn = 1, jptra
137            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
138         ENDDO
139         WRITE(numout,*)
140      ENDIF
141      IF(lwp) WRITE(numout,*)
142      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
143         CALL prt_ctl_trc_init
144         WRITE(charout, FMT="('ini ')")
145         CALL prt_ctl_trc_info( charout )
146         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
147      ENDIF
[9169]1489000  FORMAT('      tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
[5836]149      !
150   END SUBROUTINE trc_ini_inv
151
152
153   SUBROUTINE trc_ini_sms
154      !!----------------------------------------------------------------------
155      !!                     ***  ROUTINE trc_ini_sms  ***
156      !! ** Purpose :   SMS initialisation
157      !!----------------------------------------------------------------------
[7646]158      USE trcini_pisces  ! PISCES   initialisation
159      USE trcini_cfc     ! CFC      initialisation
160      USE trcini_c14     ! C14  initialisation
161      USE trcini_age     ! age initialisation
162      USE trcini_my_trc  ! MY_TRC   initialisation
163      !
164      INTEGER :: jn
[5836]165      !!----------------------------------------------------------------------
166      !
[7646]167      ! Pass sn_tracer fields to specialized arrays
168      DO jn = 1, jp_bgc
169         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
170         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
171         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
172         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
173         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
174         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
175         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
176      END DO
[11222]177      lltrcbc = ( COUNT(ln_trc_sbc) + COUNT(ln_trc_obc) + COUNT(ln_trc_cbc) ) > 0 
[7646]178      !   
[10222]179      IF( ln_pisces      )   CALL trc_ini_pisces     !  PISCES model
180      IF( ln_my_trc      )   CALL trc_ini_my_trc     !  MY_TRC model
181      IF( ll_cfc         )   CALL trc_ini_cfc        !  CFC's
182      IF( ln_c14         )   CALL trc_ini_c14        !  C14 model
183      IF( ln_age         )   CALL trc_ini_age        !  AGE
[7646]184      !
185      IF(lwp) THEN                   ! control print
186         WRITE(numout,*)
[9169]187         WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers'
188         WRITE(numout,*) '~~~~~~~~~~~~'
189         WRITE(numout,*) '    ID     NAME     INI  SBC  CBC  OBC'
[7646]190         DO jn = 1, jptra
191            WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn)
192         END DO
193      ENDIF
[11222]194      IF( lwp .AND. lltrcbc ) THEN
195         WRITE(numout,*)
196         WRITE(numout,*) ' Applying tracer boundary conditions '
197      ENDIF
198     
[9169]1999001  FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2)
[7646]200      !
[5836]201   END SUBROUTINE trc_ini_sms
[2528]202
[9169]203
[5836]204   SUBROUTINE trc_ini_trp
205      !!----------------------------------------------------------------------
206      !!                     ***  ROUTINE trc_ini_trp  ***
207      !!
208      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
209      !!----------------------------------------------------------------------
210      USE trcdmp , ONLY:  trc_dmp_ini
211      USE trcadv , ONLY:  trc_adv_ini
212      USE trcldf , ONLY:  trc_ldf_ini
213      USE trcrad , ONLY:  trc_rad_ini
[10375]214      USE trcsink, ONLY:  trc_sink_ini
[5836]215      !
216      INTEGER :: ierr
217      !!----------------------------------------------------------------------
218      !
219      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
220                       CALL  trc_adv_ini          ! advection
221                       CALL  trc_ldf_ini          ! lateral diffusion
[9019]222                       !                          ! vertical diffusion: always implicit time stepping scheme
[5836]223                       CALL  trc_rad_ini          ! positivity of passive tracers
[10375]224                       CALL  trc_sink_ini         ! Vertical sedimentation of particles
[5836]225      !
226   END SUBROUTINE trc_ini_trp
[5385]227
[1254]228
[5836]229   SUBROUTINE trc_ini_state
230      !!----------------------------------------------------------------------
231      !!                     ***  ROUTINE trc_ini_state ***
232      !! ** Purpose :          Initialisation of passive tracer concentration
233      !!----------------------------------------------------------------------
234      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
235      USE trcrst          ! passive tracers restart
236      USE trcdta          ! initialisation from files
237      !
[7753]238      INTEGER :: jn, jl   ! dummy loop indices
[5836]239      !!----------------------------------------------------------------------
240      !
[9019]241      IF( ln_trcdta )   CALL trc_dta_ini( jptra )      ! set initial tracers values
[9169]242      !
[11222]243      IF( lltrcbc   )  THEN
244        CALL trc_bc_ini ( jptra  )      ! set tracers Boundary Conditions
245        CALL trc_bc     ( nit000 )      ! tracers: surface and lateral Boundary Conditions
246      ENDIF
[9169]247      !
248      !
[9019]249      IF( ln_rsttr ) THEN              ! restart from a file
[2528]250        !
[9019]251        CALL trc_rst_read
[2528]252        !
[9019]253      ELSE                             ! Initialisation of tracer from a file that may also be used for damping
254!!gm BUG ?   if damping and restart, what's happening ?
[7646]255        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
256            ! update passive tracers arrays with input data read from file
[6607]257            DO jn = 1, jptra
[7646]258               IF( ln_trc_ini(jn) ) THEN
[3294]259                  jl = n_trc_index(jn) 
[7646]260                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl), trn(:,:,:,jn) )
[6701]261                  !
[7646]262                  ! deallocate data structure if data are not used for damping
263                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
[9169]264                     IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run'
[7646]265                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
[6701]266                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
267                     !
268                  ENDIF
[3294]269               ENDIF
[9019]270            END DO
[6309]271            !
[2528]272        ENDIF
[3294]273        !
[7753]274        trb(:,:,:,:) = trn(:,:,:,:)
[2528]275        !
[1011]276      ENDIF
[9169]277      !
[7753]278      tra(:,:,:,:) = 0._wp
[5836]279      !                                                         ! Partial top/bottom cell: GRADh(trn)
280   END SUBROUTINE trc_ini_state
[1177]281
[9019]282
[2715]283   SUBROUTINE top_alloc
284      !!----------------------------------------------------------------------
285      !!                     ***  ROUTINE top_alloc  ***
286      !!
287      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
288      !!----------------------------------------------------------------------
289      USE trc           , ONLY:   trc_alloc
[4990]290      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
291#if defined key_trdmxl_trc 
292      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
[2715]293#endif
294      !
[9169]295      INTEGER ::   ierr   ! local integer
[2715]296      !!----------------------------------------------------------------------
297      !
[6140]298      ierr =        trc_alloc()
[4990]299      ierr = ierr + trd_trc_oce_alloc()
300#if defined key_trdmxl_trc 
301      ierr = ierr + trd_mxl_trc_alloc()
[2715]302#endif
303      !
[10425]304      CALL mpp_sum( 'trcini', ierr )
[2715]305      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
306      !
307   END SUBROUTINE top_alloc
308
[1011]309#else
310   !!----------------------------------------------------------------------
311   !!  Empty module :                                     No passive tracer
312   !!----------------------------------------------------------------------
313CONTAINS
[2528]314   SUBROUTINE trc_init                      ! Dummy routine   
315   END SUBROUTINE trc_init
[1011]316#endif
317
[335]318   !!======================================================================
[268]319END MODULE trcini
Note: See TracBrowser for help on using the repository browser.