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_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/trcini.F90 @ 11480

Last change on this file since 11480 was 11480, checked in by davestorkey, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Merge in changes from branch of branch.
Main changes:

  1. "nxt" modules renamed as "atf" and now just do Asselin time filtering. The time level swapping is achieved by swapping indices.
  2. Some additional prognostic grid variables changed to use a time dimension.

Notes:

  1. This merged branch passes SETTE tests but does not identical results to the SETTE tests with the trunk@10721 unless minor bugs to do with Euler timestepping and the OFF timestepping are fixed in the trunk (NEMO tickets #2310 and #2311).
  2. The nn_dttrc > 1 option for TOP (TOP has a different timestep to OCE) doesn't work. But it doesn't work in the trunk or NEMO 4.0 release either.
  • Property svn:keywords set to Id
File size: 13.8 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
[7646]27   USE trcbc,   only : trc_bc_ini ! generalized Boundary Conditions
[10880]28   USE trcstp          ! for time level indices (to be initialised)
[4306]29 
[335]30   IMPLICIT NONE
31   PRIVATE
[1011]32   
[2528]33   PUBLIC   trc_init   ! called by opa
[268]34
[2715]35   !!----------------------------------------------------------------------
[9598]36   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
[2715]37   !! $Id$
[10068]38   !! Software governed by the CeCILL license (see ./LICENSE)
[2715]39   !!----------------------------------------------------------------------
[335]40CONTAINS
[1011]41   
[11480]42   SUBROUTINE trc_init
[1011]43      !!---------------------------------------------------------------------
[2528]44      !!                     ***  ROUTINE trc_init  ***
[335]45      !!
[1011]46      !! ** Purpose :   Initialization of the passive tracer fields
47      !!
48      !! ** Method  : - read namelist
49      !!              - control the consistancy
50      !!              - compute specific initialisations
51      !!              - set initial tracer fields (either read restart
52      !!                or read data or analytical formulation
53      !!---------------------------------------------------------------------
[3294]54      !
[9124]55      IF( ln_timing )   CALL timing_start('trc_init')
[3294]56      !
[945]57      IF(lwp) WRITE(numout,*)
[2528]58      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
[9169]59      IF(lwp) WRITE(numout,*) '~~~~~~~~'
[3294]60      !
[11480]61      ! Initialise time level indices
62      Nbb_trc = 1; Nnn_trc = 2; Naa_trc = 3; Nrhs_trc = Naa_trc
63      !
[5836]64      CALL trc_ini_ctl   ! control
65      CALL trc_nam       ! read passive tracers namelists
[7646]66      CALL top_alloc()   ! allocate TOP arrays
[10880]67
[5836]68      !
[7646]69      IF(.NOT.ln_trcdta )   ln_trc_ini(:) = .FALSE.
[4152]70      !
[3294]71      IF(lwp) WRITE(numout,*)
[7646]72      IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
73      IF(lwp) WRITE(numout,*)
[5836]74      !
[11480]75      CALL trc_ini_sms( Nnn_trc )   ! SMS
[10975]76      CALL trc_ini_trp          ! passive tracers transport
77      CALL trc_ice_ini          ! Tracers in sea ice
[5836]78      !
[10570]79      IF( lwm .AND. sn_cfctl%l_trcstat ) THEN
80         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
81      ENDIF
[5836]82      !
[11480]83      CALL trc_ini_state( Nbb_trc, Nnn_trc, Naa_trc )  !  passive tracers initialisation : from a restart or from clim
[7646]84      IF( nn_dttrc /= 1 ) &
[11480]85      CALL trc_sub_ini( Nnn_trc )    ! Initialize variables for substepping passive tracers
[5836]86      !
[11480]87      CALL trc_ini_inv( Nnn_trc )    ! Inventories
[8542]88      !
[9124]89      IF( ln_timing )   CALL timing_stop('trc_init')
[5836]90      !
91   END SUBROUTINE trc_init
92
93
94   SUBROUTINE trc_ini_ctl
95      !!----------------------------------------------------------------------
96      !!                     ***  ROUTINE trc_ini_ctl  ***
97      !! ** Purpose :        Control  + ocean volume
98      !!----------------------------------------------------------------------
99      INTEGER ::   jk    ! dummy loop indices
100      !
101      ! Define logical parameter ton control dirunal cycle in TOP
102      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
[7646]103      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. l_offline
[5836]104      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
105         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
106      !
107   END SUBROUTINE trc_ini_ctl
108
109
[10963]110   SUBROUTINE trc_ini_inv( Kmm )
[5836]111      !!----------------------------------------------------------------------
112      !!                     ***  ROUTINE trc_ini_stat  ***
113      !! ** Purpose :      passive tracers inventories at initialsation phase
114      !!----------------------------------------------------------------------
[10963]115      INTEGER, INTENT(in) ::   Kmm    ! time level index
116      INTEGER             ::  jk, jn  ! dummy loop indices
[5836]117      CHARACTER (len=25) :: charout
118      !!----------------------------------------------------------------------
[9169]119      !
120      IF(lwp) WRITE(numout,*)
121      IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories'
122      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
123      !
124      !                          ! masked grid volume
[3294]125      DO jk = 1, jpk
[10963]126         cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk)
[3294]127      END DO
[9169]128      !                          ! total volume of the ocean
[10425]129      areatot = glob_sum( 'trcini', cvol(:,:,:) )
[5836]130      !
[9169]131      trai(:) = 0._wp            ! initial content of all tracers
[5836]132      DO jn = 1, jptra
[10963]133         trai(jn) = trai(jn) + glob_sum( 'trcini', tr(:,:,:,jn,Kmm) * cvol(:,:,:)   )
[5836]134      END DO
[1011]135
[5836]136      IF(lwp) THEN               ! control print
137         WRITE(numout,*)
[9169]138         WRITE(numout,*) '   ==>>>   Total number of passive tracer jptra = ', jptra
139         WRITE(numout,*) '           Total volume of ocean                = ', areatot
140         WRITE(numout,*) '           Total inital content of all tracers '
[5836]141         WRITE(numout,*)
142         DO jn = 1, jptra
143            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
144         ENDDO
145         WRITE(numout,*)
146      ENDIF
147      IF(lwp) WRITE(numout,*)
148      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
149         CALL prt_ctl_trc_init
150         WRITE(charout, FMT="('ini ')")
151         CALL prt_ctl_trc_info( charout )
[10963]152         CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Kmm), mask=tmask, clinfo=ctrcnm )
[5836]153      ENDIF
[9169]1549000  FORMAT('      tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
[5836]155      !
156   END SUBROUTINE trc_ini_inv
157
158
[10975]159   SUBROUTINE trc_ini_sms( Kmm )
[5836]160      !!----------------------------------------------------------------------
161      !!                     ***  ROUTINE trc_ini_sms  ***
162      !! ** Purpose :   SMS initialisation
163      !!----------------------------------------------------------------------
[7646]164      USE trcini_pisces  ! PISCES   initialisation
165      USE trcini_cfc     ! CFC      initialisation
166      USE trcini_c14     ! C14  initialisation
167      USE trcini_age     ! age initialisation
168      USE trcini_my_trc  ! MY_TRC   initialisation
169      !
[10975]170      INTEGER, INTENT(in) ::   Kmm ! time level indices
[7646]171      INTEGER :: jn
[5836]172      !!----------------------------------------------------------------------
173      !
[7646]174      ! Pass sn_tracer fields to specialized arrays
175      DO jn = 1, jp_bgc
176         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
177         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
178         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
179         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
180         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
181         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
182         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
183      END DO
184      !   
[10975]185      IF( ln_pisces      )   CALL trc_ini_pisces( Kmm )     !  PISCES model
186      IF( ln_my_trc      )   CALL trc_ini_my_trc( Kmm )     !  MY_TRC model
187      IF( ll_cfc         )   CALL trc_ini_cfc   ( Kmm )     !  CFC's
188      IF( ln_c14         )   CALL trc_ini_c14   ( Kmm )     !  C14 model
189      IF( ln_age         )   CALL trc_ini_age   ( Kmm )     !  AGE
[10222]190      IF( .NOT.ln_pisces ) ALLOCATE( profsed(2) )
[7646]191      !
192      IF(lwp) THEN                   ! control print
193         WRITE(numout,*)
[9169]194         WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers'
195         WRITE(numout,*) '~~~~~~~~~~~~'
196         WRITE(numout,*) '    ID     NAME     INI  SBC  CBC  OBC'
[7646]197         DO jn = 1, jptra
198            WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn)
199         END DO
200      ENDIF
[9169]2019001  FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2)
[7646]202      !
[5836]203   END SUBROUTINE trc_ini_sms
[2528]204
[9169]205
[5836]206   SUBROUTINE trc_ini_trp
207      !!----------------------------------------------------------------------
208      !!                     ***  ROUTINE trc_ini_trp  ***
209      !!
210      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
211      !!----------------------------------------------------------------------
212      USE trcdmp , ONLY:  trc_dmp_ini
213      USE trcadv , ONLY:  trc_adv_ini
214      USE trcldf , ONLY:  trc_ldf_ini
215      USE trcrad , ONLY:  trc_rad_ini
[10375]216      USE trcsink, ONLY:  trc_sink_ini
[5836]217      !
218      INTEGER :: ierr
219      !!----------------------------------------------------------------------
220      !
221      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
222                       CALL  trc_adv_ini          ! advection
223                       CALL  trc_ldf_ini          ! lateral diffusion
[9019]224                       !                          ! vertical diffusion: always implicit time stepping scheme
[5836]225                       CALL  trc_rad_ini          ! positivity of passive tracers
[10375]226                       CALL  trc_sink_ini         ! Vertical sedimentation of particles
[5836]227      !
228   END SUBROUTINE trc_ini_trp
[5385]229
[1254]230
[10963]231   SUBROUTINE trc_ini_state( Kbb, Kmm, Kaa )
[5836]232      !!----------------------------------------------------------------------
233      !!                     ***  ROUTINE trc_ini_state ***
234      !! ** Purpose :          Initialisation of passive tracer concentration
235      !!----------------------------------------------------------------------
236      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
237      USE trcrst          ! passive tracers restart
238      USE trcdta          ! initialisation from files
239      !
[10963]240      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa   ! time level index
241      INTEGER             :: jn, jl          ! dummy loop indices
[5836]242      !!----------------------------------------------------------------------
243      !
[10963]244      IF( ln_trcdta )   CALL trc_dta_ini( jptra )           ! set initial tracers values
[9169]245      !
[10963]246      IF( ln_my_trc )   CALL trc_bc_ini ( jptra, Kmm )      ! set tracers Boundary Conditions
[9169]247      !
248      !
[9019]249      IF( ln_rsttr ) THEN              ! restart from a file
[2528]250        !
[10963]251        CALL trc_rst_read( Kbb, Kmm )
[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) 
[10963]260                  CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) )
[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        !
[10963]274        tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm)
[2528]275        !
[1011]276      ENDIF
[9169]277      !
[10963]278      tr(:,:,:,:,Kaa) = 0._wp
279      !                                                         ! Partial top/bottom cell: GRADh(tr(Kmm))
[5836]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.