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/trunk/src/TOP – NEMO

source: NEMO/trunk/src/TOP/trcini.F90 @ 14373

Last change on this file since 14373 was 14227, checked in by smasson, 4 years ago

trunk: replace remaining OPA by OCE

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