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_r12740_TOP-01_rlod_Antarctic_ice_Sheet_Fe_Source/src/TOP – NEMO

source: NEMO/branches/2020/dev_r12740_TOP-01_rlod_Antarctic_ice_Sheet_Fe_Source/src/TOP/trcini.F90 @ 13524

Last change on this file since 13524 was 13524, checked in by rlod, 4 years ago

First step of nutrient sources from Antarctic Ice Sheet

  • Property svn:keywords set to Id
File size: 13.6 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
[13524]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
[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
[13524]161         ln_trc_ais(jn) =       sn_tracer(jn)%llais
[7646]162      END DO
[12377]163      !
164      IF( .NOT.ln_trcbc ) THEN
165         DO jn = 1, jp_bgc
166            ln_trc_sbc(jn) = .FALSE.
167            ln_trc_cbc(jn) = .FALSE.
168            ln_trc_obc(jn) = .FALSE.
169         END DO
170      ENDIF
171     
172      lltrcbc = ( COUNT(ln_trc_sbc) + COUNT(ln_trc_obc) + COUNT(ln_trc_cbc) ) > 0 
[7646]173      !   
[12377]174      IF( ln_pisces      )   CALL trc_ini_pisces( Kmm )     !  PISCES model
175      IF( ln_my_trc      )   CALL trc_ini_my_trc( Kmm )     !  MY_TRC model
176      IF( ll_cfc         )   CALL trc_ini_cfc   ( Kmm )     !  CFC's
177      IF( ln_c14         )   CALL trc_ini_c14   ( Kmm )     !  C14 model
178      IF( ln_age         )   CALL trc_ini_age   ( Kmm )     !  AGE
[7646]179      !
180      IF(lwp) THEN                   ! control print
181         WRITE(numout,*)
[9169]182         WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers'
183         WRITE(numout,*) '~~~~~~~~~~~~'
[13524]184         WRITE(numout,*) '    ID     NAME     INI  SBC  CBC  OBC  AIS'
[7646]185         DO jn = 1, jptra
[13524]186            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]187         END DO
188      ENDIF
[12377]189      IF( lwp .AND. ln_trcbc .AND. lltrcbc ) THEN
190         WRITE(numout,*)
191         WRITE(numout,*) ' Applying tracer boundary conditions '
192      ENDIF
[13524]193      !
194      IF( lwp .AND. ln_trcais ) THEN
195         WRITE(numout,*)
196         WRITE(numout,*) ' Applying tracer from Antarctic Ice Sheet '
197      ENDIF
[12377]198     
[13524]1999001  FORMAT(3x,i3,1x,a10,3x,l2,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
[12377]229   SUBROUTINE trc_ini_state( Kbb, Kmm, Kaa )
[5836]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      !
[12377]238      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa   ! time level index
239      INTEGER             :: jn, jl          ! dummy loop indices
[5836]240      !!----------------------------------------------------------------------
241      !
[12377]242      IF( ln_trcdta )   CALL trc_dta_ini( jptra )           ! set initial tracers values
[9169]243      !
[12377]244      IF( ln_trcbc .AND. lltrcbc )  THEN
245        CALL trc_bc_ini ( jptra, Kmm  )            ! set tracers Boundary Conditions
246        CALL trc_bc     ( nit000, Kmm, tr, Kaa )   ! tracers: surface and lateral Boundary Conditions
247      ENDIF
[9169]248      !
[13524]249      IF( ln_trcais ) CALL trc_ais_ini   ! set tracers from Antarctic Ice Sheet
[9169]250      !
[9019]251      IF( ln_rsttr ) THEN              ! restart from a file
[2528]252        !
[12377]253        CALL trc_rst_read( Kbb, Kmm )
[2528]254        !
[9019]255      ELSE                             ! Initialisation of tracer from a file that may also be used for damping
256!!gm BUG ?   if damping and restart, what's happening ?
[7646]257        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
258            ! update passive tracers arrays with input data read from file
[6607]259            DO jn = 1, jptra
[7646]260               IF( ln_trc_ini(jn) ) THEN
[3294]261                  jl = n_trc_index(jn) 
[12377]262                  CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) )
[6701]263                  !
[7646]264                  ! deallocate data structure if data are not used for damping
265                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
[9169]266                     IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run'
[7646]267                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
[6701]268                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
269                     !
270                  ENDIF
[3294]271               ENDIF
[9019]272            END DO
[6309]273            !
[2528]274        ENDIF
[3294]275        !
[12377]276        tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm)
[2528]277        !
[1011]278      ENDIF
[9169]279      !
[12377]280      tr(:,:,:,:,Kaa) = 0._wp
281      !                                                         ! Partial top/bottom cell: GRADh(tr(Kmm))
[5836]282   END SUBROUTINE trc_ini_state
[1177]283
[9019]284
[2715]285   SUBROUTINE top_alloc
286      !!----------------------------------------------------------------------
287      !!                     ***  ROUTINE top_alloc  ***
288      !!
289      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
290      !!----------------------------------------------------------------------
291      USE trc           , ONLY:   trc_alloc
[4990]292      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
293#if defined key_trdmxl_trc 
294      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
[2715]295#endif
296      !
[9169]297      INTEGER ::   ierr   ! local integer
[2715]298      !!----------------------------------------------------------------------
299      !
[6140]300      ierr =        trc_alloc()
[4990]301      ierr = ierr + trd_trc_oce_alloc()
302#if defined key_trdmxl_trc 
303      ierr = ierr + trd_mxl_trc_alloc()
[2715]304#endif
305      !
[10425]306      CALL mpp_sum( 'trcini', ierr )
[2715]307      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
308      !
309   END SUBROUTINE top_alloc
310
[1011]311#else
312   !!----------------------------------------------------------------------
313   !!  Empty module :                                     No passive tracer
314   !!----------------------------------------------------------------------
315CONTAINS
[2528]316   SUBROUTINE trc_init                      ! Dummy routine   
317   END SUBROUTINE trc_init
[1011]318#endif
319
[335]320   !!======================================================================
[268]321END MODULE trcini
Note: See TracBrowser for help on using the repository browser.