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/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/TOP – NEMO

source: NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/TOP/trcini.F90 @ 13257

Last change on this file since 13257 was 13257, checked in by orioltp, 4 years ago

Updated with trunk at r13245 and small change allocating variables in icb_oce.F90.

  • Property svn:keywords set to Id
File size: 13.2 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)
[5836]23   USE trcrst
[4306]24   USE lib_mpp         ! distribued memory computing library
[5385]25   USE trcice          ! tracers in sea ice
[12377]26   USE trcbc           ! generalized Boundary Conditions
[4306]27 
[335]28   IMPLICIT NONE
29   PRIVATE
[1011]30   
[2528]31   PUBLIC   trc_init   ! called by opa
[268]32
[13257]33#  include "domzgr_substitute.h90"
[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   
[12377]41   SUBROUTINE trc_init( Kbb, Kmm, Kaa )
[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      !!---------------------------------------------------------------------
[12377]53      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa   ! time level indices
[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      !
[5836]61      CALL trc_nam       ! read passive tracers namelists
[7646]62      CALL top_alloc()   ! allocate TOP arrays
[12377]63
[5836]64      !
[7646]65      IF(.NOT.ln_trcdta )   ln_trc_ini(:) = .FALSE.
[4152]66      !
[3294]67      IF(lwp) WRITE(numout,*)
[7646]68      IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
69      IF(lwp) WRITE(numout,*)
[5836]70      !
[12377]71      CALL trc_ini_sms( Kmm )   ! SMS
72      CALL trc_ini_trp          ! passive tracers transport
73      CALL trc_ice_ini          ! Tracers in sea ice
[5836]74      !
[10570]75      IF( lwm .AND. sn_cfctl%l_trcstat ) THEN
76         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
77      ENDIF
[5836]78      !
[12377]79      CALL trc_ini_state( Kbb, Kmm, Kaa )  !  passive tracers initialisation : from a restart or from clim
[5836]80      !
[12377]81      CALL trc_ini_inv( Kmm )              ! Inventories
[8542]82      !
[9124]83      IF( ln_timing )   CALL timing_stop('trc_init')
[5836]84      !
85   END SUBROUTINE trc_init
86
87
[12377]88   SUBROUTINE trc_ini_inv( Kmm )
[5836]89      !!----------------------------------------------------------------------
90      !!                     ***  ROUTINE trc_ini_stat  ***
91      !! ** Purpose :      passive tracers inventories at initialsation phase
92      !!----------------------------------------------------------------------
[12377]93      INTEGER, INTENT(in) ::   Kmm    ! time level index
94      INTEGER             ::  jk, jn  ! dummy loop indices
[5836]95      CHARACTER (len=25) :: charout
96      !!----------------------------------------------------------------------
[9169]97      !
98      IF(lwp) WRITE(numout,*)
99      IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories'
100      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
101      !
102      !                          ! masked grid volume
[3294]103      DO jk = 1, jpk
[12377]104         cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk)
[3294]105      END DO
[9169]106      !                          ! total volume of the ocean
[10425]107      areatot = glob_sum( 'trcini', cvol(:,:,:) )
[5836]108      !
[9169]109      trai(:) = 0._wp            ! initial content of all tracers
[5836]110      DO jn = 1, jptra
[12377]111         trai(jn) = trai(jn) + glob_sum( 'trcini', tr(:,:,:,jn,Kmm) * cvol(:,:,:)   )
[5836]112      END DO
[1011]113
[5836]114      IF(lwp) THEN               ! control print
115         WRITE(numout,*)
[9169]116         WRITE(numout,*) '   ==>>>   Total number of passive tracer jptra = ', jptra
117         WRITE(numout,*) '           Total volume of ocean                = ', areatot
118         WRITE(numout,*) '           Total inital content of all tracers '
[5836]119         WRITE(numout,*)
120         DO jn = 1, jptra
121            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
122         ENDDO
123         WRITE(numout,*)
124      ENDIF
125      IF(lwp) WRITE(numout,*)
[12377]126      IF(sn_cfctl%l_prttrc) THEN            ! print mean trends (used for debugging)
[5836]127         CALL prt_ctl_trc_init
128         WRITE(charout, FMT="('ini ')")
129         CALL prt_ctl_trc_info( charout )
[12377]130         CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Kmm), mask=tmask, clinfo=ctrcnm )
[5836]131      ENDIF
[9169]1329000  FORMAT('      tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
[5836]133      !
134   END SUBROUTINE trc_ini_inv
135
136
[12377]137   SUBROUTINE trc_ini_sms( Kmm )
[5836]138      !!----------------------------------------------------------------------
139      !!                     ***  ROUTINE trc_ini_sms  ***
140      !! ** Purpose :   SMS initialisation
141      !!----------------------------------------------------------------------
[7646]142      USE trcini_pisces  ! PISCES   initialisation
143      USE trcini_cfc     ! CFC      initialisation
144      USE trcini_c14     ! C14  initialisation
145      USE trcini_age     ! age initialisation
146      USE trcini_my_trc  ! MY_TRC   initialisation
147      !
[12377]148      INTEGER, INTENT(in) ::   Kmm ! time level indices
[7646]149      INTEGER :: jn
[5836]150      !!----------------------------------------------------------------------
151      !
[7646]152      ! Pass sn_tracer fields to specialized arrays
153      DO jn = 1, jp_bgc
154         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
155         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
156         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
157         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
158         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
159         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
160         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
161      END DO
[12377]162      !
163      IF( .NOT.ln_trcbc ) THEN
164         DO jn = 1, jp_bgc
165            ln_trc_sbc(jn) = .FALSE.
166            ln_trc_cbc(jn) = .FALSE.
167            ln_trc_obc(jn) = .FALSE.
168         END DO
169      ENDIF
170     
171      lltrcbc = ( COUNT(ln_trc_sbc) + COUNT(ln_trc_obc) + COUNT(ln_trc_cbc) ) > 0 
[7646]172      !   
[12377]173      IF( ln_pisces      )   CALL trc_ini_pisces( Kmm )     !  PISCES model
174      IF( ln_my_trc      )   CALL trc_ini_my_trc( Kmm )     !  MY_TRC model
175      IF( ll_cfc         )   CALL trc_ini_cfc   ( Kmm )     !  CFC's
176      IF( ln_c14         )   CALL trc_ini_c14   ( Kmm )     !  C14 model
177      IF( ln_age         )   CALL trc_ini_age   ( Kmm )     !  AGE
[7646]178      !
179      IF(lwp) THEN                   ! control print
180         WRITE(numout,*)
[9169]181         WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers'
182         WRITE(numout,*) '~~~~~~~~~~~~'
183         WRITE(numout,*) '    ID     NAME     INI  SBC  CBC  OBC'
[7646]184         DO jn = 1, jptra
185            WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn)
186         END DO
187      ENDIF
[12377]188      IF( lwp .AND. ln_trcbc .AND. lltrcbc ) THEN
189         WRITE(numout,*)
190         WRITE(numout,*) ' Applying tracer boundary conditions '
191      ENDIF
192     
[9169]1939001  FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2)
[7646]194      !
[5836]195   END SUBROUTINE trc_ini_sms
[2528]196
[9169]197
[5836]198   SUBROUTINE trc_ini_trp
199      !!----------------------------------------------------------------------
200      !!                     ***  ROUTINE trc_ini_trp  ***
201      !!
202      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
203      !!----------------------------------------------------------------------
204      USE trcdmp , ONLY:  trc_dmp_ini
205      USE trcadv , ONLY:  trc_adv_ini
206      USE trcldf , ONLY:  trc_ldf_ini
207      USE trcrad , ONLY:  trc_rad_ini
[10375]208      USE trcsink, ONLY:  trc_sink_ini
[5836]209      !
210      INTEGER :: ierr
211      !!----------------------------------------------------------------------
212      !
213      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
214                       CALL  trc_adv_ini          ! advection
215                       CALL  trc_ldf_ini          ! lateral diffusion
[9019]216                       !                          ! vertical diffusion: always implicit time stepping scheme
[5836]217                       CALL  trc_rad_ini          ! positivity of passive tracers
[10375]218                       CALL  trc_sink_ini         ! Vertical sedimentation of particles
[5836]219      !
220   END SUBROUTINE trc_ini_trp
[5385]221
[1254]222
[12377]223   SUBROUTINE trc_ini_state( Kbb, Kmm, Kaa )
[5836]224      !!----------------------------------------------------------------------
225      !!                     ***  ROUTINE trc_ini_state ***
226      !! ** Purpose :          Initialisation of passive tracer concentration
227      !!----------------------------------------------------------------------
228      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
229      USE trcrst          ! passive tracers restart
230      USE trcdta          ! initialisation from files
231      !
[12377]232      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa   ! time level index
233      INTEGER             :: jn, jl          ! dummy loop indices
[5836]234      !!----------------------------------------------------------------------
235      !
[12377]236      IF( ln_trcdta )   CALL trc_dta_ini( jptra )           ! set initial tracers values
[9169]237      !
[12377]238      IF( ln_trcbc .AND. lltrcbc )  THEN
239        CALL trc_bc_ini ( jptra, Kmm  )            ! set tracers Boundary Conditions
240        CALL trc_bc     ( nit000, Kmm, tr, Kaa )   ! tracers: surface and lateral Boundary Conditions
241      ENDIF
[9169]242      !
243      !
[9019]244      IF( ln_rsttr ) THEN              ! restart from a file
[2528]245        !
[12377]246        CALL trc_rst_read( Kbb, Kmm )
[2528]247        !
[9019]248      ELSE                             ! Initialisation of tracer from a file that may also be used for damping
249!!gm BUG ?   if damping and restart, what's happening ?
[7646]250        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
251            ! update passive tracers arrays with input data read from file
[6607]252            DO jn = 1, jptra
[7646]253               IF( ln_trc_ini(jn) ) THEN
[3294]254                  jl = n_trc_index(jn) 
[12377]255                  CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) )
[6701]256                  !
[7646]257                  ! deallocate data structure if data are not used for damping
258                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
[9169]259                     IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run'
[7646]260                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
[6701]261                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
262                     !
263                  ENDIF
[3294]264               ENDIF
[9019]265            END DO
[6309]266            !
[2528]267        ENDIF
[3294]268        !
[12377]269        tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm)
[2528]270        !
[1011]271      ENDIF
[9169]272      !
[12377]273      tr(:,:,:,:,Kaa) = 0._wp
274      !                                                         ! Partial top/bottom cell: GRADh(tr(Kmm))
[5836]275   END SUBROUTINE trc_ini_state
[1177]276
[9019]277
[2715]278   SUBROUTINE top_alloc
279      !!----------------------------------------------------------------------
280      !!                     ***  ROUTINE top_alloc  ***
281      !!
282      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
283      !!----------------------------------------------------------------------
284      USE trc           , ONLY:   trc_alloc
[4990]285      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
286#if defined key_trdmxl_trc 
287      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
[2715]288#endif
289      !
[9169]290      INTEGER ::   ierr   ! local integer
[2715]291      !!----------------------------------------------------------------------
292      !
[6140]293      ierr =        trc_alloc()
[4990]294      ierr = ierr + trd_trc_oce_alloc()
295#if defined key_trdmxl_trc 
296      ierr = ierr + trd_mxl_trc_alloc()
[2715]297#endif
298      !
[10425]299      CALL mpp_sum( 'trcini', ierr )
[2715]300      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
301      !
302   END SUBROUTINE top_alloc
303
[1011]304#else
305   !!----------------------------------------------------------------------
306   !!  Empty module :                                     No passive tracer
307   !!----------------------------------------------------------------------
308CONTAINS
[2528]309   SUBROUTINE trc_init                      ! Dummy routine   
310   END SUBROUTINE trc_init
[1011]311#endif
312
[335]313   !!======================================================================
[268]314END MODULE trcini
Note: See TracBrowser for help on using the repository browser.