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.
trcsed.F90 in trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER – NEMO

source: trunk/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsed.F90 @ 2715

Last change on this file since 2715 was 2715, checked in by rblod, 13 years ago

First attempt to put dynamic allocation on the trunk

  • Property svn:keywords set to Id
File size: 6.4 KB
Line 
1MODULE trcsed
2   !!======================================================================
3   !!                         ***  MODULE p4sed  ***
4   !! TOP :   PISCES Compute loss of organic matter in the sediments
5   !!======================================================================
6   !! History :    -   !  1995-06 (M. Levy)  original code
7   !!              -   !  2000-12 (E. Kestenare)  clean up
8   !!             2.0  !  2007-12  (C. Deltel, G. Madec)  F90 + simplifications
9   !!----------------------------------------------------------------------
10#if defined key_lobster
11   !!----------------------------------------------------------------------
12   !!   'key_lobster'                                     LOBSTER bio-model
13   !!----------------------------------------------------------------------
14   !!   trc_sed        :  Compute loss of organic matter in the sediments
15   !!----------------------------------------------------------------------
16   USE oce_trc         !
17   USE trc
18   USE sms_lobster
19   USE lbclnk
20   USE trdmod_oce
21   USE trdmod_trc
22   USE iom
23   USE prtctl_trc      ! Print control for debbuging
24
25   IMPLICIT NONE
26   PRIVATE
27
28   PUBLIC   trc_sed    ! called in ???
29
30   !!* Substitution
31#  include "top_substitute.h90"
32   !!----------------------------------------------------------------------
33   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
34   !! $Id$
35   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
36   !!----------------------------------------------------------------------
37
38CONTAINS
39
40   SUBROUTINE trc_sed( kt )
41      !!---------------------------------------------------------------------
42      !!                     ***  ROUTINE trc_sed  ***
43      !!
44      !! ** Purpose :   compute the now trend due to the vertical sedimentation of
45      !!              detritus and add it to the general trend of detritus equations
46      !!
47      !! ** Method  :   this ROUTINE compute not exactly the advection but the
48      !!              transport term, i.e.  dz(wt) and dz(ws)., dz(wtr)
49      !!              using an upstream scheme
50      !!              the now vertical advection of tracers is given by:
51      !!                      dz(trn wn) = 1/bt dk+1( e1t e2t vsed (trn) )
52      !!              add this trend now to the general trend of tracer (ta,sa,tra):
53      !!                             tra = tra + dz(trn wn)
54      !!       
55      !!              IF 'key_diabio' is defined, the now vertical advection
56      !!              trend of passive tracers is saved for futher diagnostics.
57      !!---------------------------------------------------------------------
58      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
59      USE wrk_nemo, ONLY: zwork => wrk_3d_2
60      USE wrk_nemo, ONLY: zw2d  => wrk_2d_1 ! only used (if defined
61                                            ! key_diatrc && defined key_iomput)
62      !!
63      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index     
64      !!
65      INTEGER  ::   ji, jj, jk, jl
66      REAL(wp) ::   ztra
67      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrbio
68      CHARACTER (len=25) :: charout
69      !!---------------------------------------------------------------------
70
71      IF( ( wrk_in_use(3,2)) .OR. ( wrk_in_use(2,1)) ) THEN
72         CALL ctl_stop('trc_sed : requested workspace arrays unavailable.')
73         RETURN
74      END IF
75
76      IF( kt == nit000 ) THEN
77         IF(lwp) WRITE(numout,*)
78         IF(lwp) WRITE(numout,*) ' trc_sed: LOBSTER sedimentation'
79         IF(lwp) WRITE(numout,*) ' ~~~~~~~'
80      ENDIF
81
82      ! sedimentation of detritus  : upstream scheme
83      ! --------------------------------------------
84
85      ! for detritus sedimentation only - jp_lob_det
86      zwork(:,:,1  ) = 0.e0      ! surface value set to zero
87      zwork(:,:,jpk) = 0.e0      ! bottom value  set to zero
88
89#if defined key_diatrc && defined key_iomput
90      zw2d(:,:) = 0.
91# endif
92
93      IF( l_trdtrc )THEN
94         ALLOCATE( ztrbio(jpi,jpj,jpk) )
95         ztrbio(:,:,:) = tra(:,:,:,jp_lob_det)
96      ENDIF
97
98      ! tracer flux at w-point: we use -vsed (downward flux)  with simplification : no e1*e2
99      DO jk = 2, jpkm1
100         zwork(:,:,jk) = -vsed * trn(:,:,jk-1,jp_lob_det)
101      END DO
102
103      ! tracer flux divergence at t-point added to the general trend
104      DO jk = 1, jpkm1
105         DO jj = 1, jpj
106            DO ji = 1,jpi
107               ztra  = - ( zwork(ji,jj,jk) - zwork(ji,jj,jk+1) ) / fse3t(ji,jj,jk)
108               tra(ji,jj,jk,jp_lob_det) = tra(ji,jj,jk,jp_lob_det) + ztra
109#if defined key_diabio
110               trbio(ji,jj,jk,jp_lob0_trd + 7) = ztra
111#endif
112#if defined key_diatrc
113# if ! defined key_iomput
114               trc2d(ji,jj,jp_lob0_2d + 7) = trc2d(ji,jj,jp_lob0_2d + 7) + ztra * fse3t(ji,jj,jk) * 86400.
115# else
116               zw2d(ji,jj) = zw2d(ji,jj) + ztra * fse3t(ji,jj,jk) * 86400.
117# endif
118#endif
119            END DO
120         END DO
121      END DO
122
123#if defined key_diabio
124      jl = jp_lob0_trd + 7
125      CALL lbc_lnk (trbio(:,:,1,jl), 'T', 1. )    ! Lateral boundary conditions on trcbio
126#endif
127#if defined key_diatrc
128# if ! defined key_iomput
129      jl = jp_lob0_2d + 7
130      CALL lbc_lnk( trc2d(:,:,jl), 'T', 1. )      ! Lateral boundary conditions on trc2d
131# else
132      CALL lbc_lnk( zw2d(:,:), 'T', 1. )      ! Lateral boundary conditions on zw2d
133      CALL iom_put( "TDETSED", zw2d )
134# endif
135#endif
136      !
137
138      IF( l_trdtrc ) THEN
139         ztrbio(:,:,:) = tra(:,:,:,jp_lob_det) - ztrbio(:,:,:)
140         jl = jp_lob0_trd + 7
141         CALL trd_mod_trc( ztrbio, jl, kt )   ! handle the trend
142      ENDIF
143
144      IF( l_trdtrc ) DEALLOCATE( ztrbio )
145
146      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
147         WRITE(charout, FMT="('sed')")
148         CALL prt_ctl_trc_info(charout)
149         CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm)
150      ENDIF
151
152      IF( ( wrk_not_released(3, 2) ) .OR. ( wrk_not_released(2, 1) ) )  &
153       &         CALL ctl_stop('trc_sed : failed to release workspace arrays.')
154
155   END SUBROUTINE trc_sed
156
157#else
158   !!======================================================================
159   !!  Dummy module :                                   No PISCES bio-model
160   !!======================================================================
161CONTAINS
162   SUBROUTINE trc_sed( kt )                   ! Empty routine
163      INTEGER, INTENT( in ) ::   kt
164      WRITE(*,*) 'trc_sed: You should not have seen this print! error?', kt
165   END SUBROUTINE trc_sed
166#endif 
167
168   !!======================================================================
169END MODULE  trcsed
Note: See TracBrowser for help on using the repository browser.