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 @ 14032

Last change on this file since 14032 was 14032, checked in by rlod, 3 years ago

merging r13541_TOP-01_rlod_Antarctic_ice_Sheet_Fe_Source into trunk@14031

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