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.
p4zsink.F90 in NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P4Z/p4zsink.F90 @ 14219

Last change on this file since 14219 was 14219, checked in by mcastril, 4 years ago

Add Mixed Precision support by Oriol Tintó

  • Property svn:keywords set to Id
File size: 9.5 KB
Line 
1MODULE p4zsink
2   !!======================================================================
3   !!                         ***  MODULE p4zsink  ***
4   !! TOP :  PISCES  vertical flux of particulate matter due to gravitational sinking
5   !!======================================================================
6   !! History :   1.0  !  2004     (O. Aumont) Original code
7   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
8   !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Change aggregation formula
9   !!             3.5  !  2012-07  (O. Aumont) Introduce potential time-splitting
10   !!----------------------------------------------------------------------
11   !!   p4z_sink       :  Compute vertical flux of particulate matter due to gravitational sinking
12   !!   p4z_sink_init  :  Unitialisation of sinking speed parameters
13   !!   p4z_sink_alloc :  Allocate sinking speed variables
14   !!----------------------------------------------------------------------
15   USE oce_trc         !  shared variables between ocean and passive tracers
16   USE trc             !  passive tracers common variables
17   USE sms_pisces      !  PISCES Source Minus Sink variables
18   USE trcsink         !  General routine to compute sedimentation
19   USE prtctl          !  print control for debugging
20   USE iom             !  I/O manager
21   USE lib_mpp
22
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC   p4z_sink         ! called in p4zbio.F90
27   PUBLIC   p4z_sink_init    ! called in trcsms_pisces.F90
28   PUBLIC   p4z_sink_alloc
29
30   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinking, sinking2  !: POC sinking fluxes
31   !                                                          !  (different meanings depending on the parameterization)
32   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkingn, sinking2n  !: POC sinking fluxes
33   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkingp, sinking2p  !: POC sinking fluxes
34   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkcal, sinksil   !: CaCO3 and BSi sinking fluxes
35   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkfer            !: Small BFe sinking fluxes
36   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sinkfer2           !: Big iron sinking fluxes
37
38   INTEGER  :: ik100
39
40   !! * Substitutions
41#  include "do_loop_substitute.h90"
42#  include "domzgr_substitute.h90"
43#  include "single_precision_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
46   !! $Id$
47   !! Software governed by the CeCILL license (see ./LICENSE)
48   !!----------------------------------------------------------------------
49CONTAINS
50
51   !!----------------------------------------------------------------------
52   !!   'standard sinking parameterisation'                  ???
53   !!----------------------------------------------------------------------
54
55   SUBROUTINE p4z_sink ( kt, knt, Kbb, Kmm, Krhs )
56      !!---------------------------------------------------------------------
57      !!                     ***  ROUTINE p4z_sink  ***
58      !!
59      !! ** Purpose :   Compute vertical flux of particulate matter due to
60      !!                gravitational sinking
61      !!
62      !! ** Method  : - ???
63      !!---------------------------------------------------------------------
64      INTEGER, INTENT(in) :: kt, knt
65      INTEGER, INTENT(in) :: Kbb, Kmm, Krhs  ! time level indices
66      INTEGER  ::   ji, jj, jk
67      CHARACTER (len=25) :: charout
68      REAL(wp) :: zmax, zfact
69      !!---------------------------------------------------------------------
70      !
71      IF( ln_timing )   CALL timing_start('p4z_sink')
72
73      ! Initialization of some global variables
74      ! ---------------------------------------
75      prodpoc(:,:,:) = 0.
76      conspoc(:,:,:) = 0.
77      prodgoc(:,:,:) = 0.
78      consgoc(:,:,:) = 0.
79
80      !
81      !    Sinking speeds of detritus is increased with depth as shown
82      !    by data and from the coagulation theory
83      !    -----------------------------------------------------------
84      DO_3D( 1, 1, 1, 1, 1, jpkm1 )
85         zmax  = MAX( heup_01(ji,jj), hmld(ji,jj) )
86         zfact = MAX( 0., gdepw(ji,jj,jk+1,Kmm) - zmax ) / wsbio2scale
87         wsbio4(ji,jj,jk) = wsbio2 + MAX(0., ( wsbio2max - wsbio2 )) * zfact
88      END_3D
89
90      ! limit the values of the sinking speeds to avoid numerical instabilities 
91      wsbio3(:,:,:) = wsbio
92
93      !
94      !  Initializa to zero all the sinking arrays
95      !   -----------------------------------------
96      sinking (:,:,:) = 0.e0
97      sinking2(:,:,:) = 0.e0
98      sinkcal (:,:,:) = 0.e0
99      sinkfer (:,:,:) = 0.e0
100      sinksil (:,:,:) = 0.e0
101      sinkfer2(:,:,:) = 0.e0
102
103      !   Compute the sedimentation term using p4zsink2 for all the sinking particles
104      !   -----------------------------------------------------
105      CALL trc_sink( kt, Kbb, Kmm, wsbio3, sinking , jppoc, rfact2 )
106      CALL trc_sink( kt, Kbb, Kmm, wsbio3, sinkfer , jpsfe, rfact2 )
107      CALL trc_sink( kt, Kbb, Kmm, wsbio4, sinking2, jpgoc, rfact2 )
108      CALL trc_sink( kt, Kbb, Kmm, wsbio4, sinkfer2, jpbfe, rfact2 )
109      CALL trc_sink( kt, Kbb, Kmm, wsbio4, sinksil , jpgsi, rfact2 )
110      CALL trc_sink( kt, Kbb, Kmm, wsbio4, sinkcal , jpcal, rfact2 )
111
112      IF( ln_p5z ) THEN
113         sinkingn (:,:,:) = 0.e0
114         sinking2n(:,:,:) = 0.e0
115         sinkingp (:,:,:) = 0.e0
116         sinking2p(:,:,:) = 0.e0
117
118         !   Compute the sedimentation term using p4zsink2 for all the sinking particles
119         !   -----------------------------------------------------
120         CALL trc_sink( kt, Kbb, Kmm, wsbio3, sinkingn , jppon, rfact2 )
121         CALL trc_sink( kt, Kbb, Kmm, wsbio3, sinkingp , jppop, rfact2 )
122         CALL trc_sink( kt, Kbb, Kmm, wsbio4, sinking2n, jpgon, rfact2 )
123         CALL trc_sink( kt, Kbb, Kmm, wsbio4, sinking2p, jpgop, rfact2 )
124      ENDIF
125
126     ! Total carbon export per year
127     IF( iom_use( "tcexp" ) .OR. ( ln_check_mass .AND. kt == nitend .AND. knt == nrdttrc )  )  &
128        &   t_oce_co2_exp = glob_sum( 'p4zsink', ( sinking(:,:,ik100) + sinking2(:,:,ik100) ) * e1e2t(:,:) * tmask(:,:,1) )
129     !
130     IF( lk_iomput .AND.  knt == nrdttrc ) THEN
131       zfact = 1.e+3 * rfact2r  !  conversion from mol/l/kt to  mol/m3/s
132       !
133       CALL iom_put( "EPC100"  , ( sinking(:,:,ik100) + sinking2(:,:,ik100) ) * zfact * tmask(:,:,1) ) ! Export of carbon at 100m
134       CALL iom_put( "EPFE100" , ( sinkfer(:,:,ik100) + sinkfer2(:,:,ik100) ) * zfact * tmask(:,:,1) ) ! Export of iron at 100m
135       CALL iom_put( "EPCAL100", sinkcal(:,:,ik100) * zfact * tmask(:,:,1) )      ! Export of calcite at 100m
136       CALL iom_put( "EPSI100" , sinksil(:,:,ik100) * zfact * tmask(:,:,1) )          ! Export of bigenic silica at 100m
137       CALL iom_put( "EXPC"    , ( sinking(:,:,:) + sinking2(:,:,:) ) * zfact * tmask(:,:,:) ) ! Export of carbon in the water column
138       CALL iom_put( "EXPFE"   , ( sinkfer(:,:,:) + sinkfer2(:,:,:) ) * zfact * tmask(:,:,:) ) ! Export of iron 
139       CALL iom_put( "EXPCAL"  , sinkcal(:,:,:) * zfact * tmask(:,:,:) )      ! Export of calcite
140       CALL iom_put( "EXPSI"   , sinksil(:,:,:) * zfact * tmask(:,:,:) )      ! Export of bigenic silica
141       CALL iom_put( "tcexp"   , t_oce_co2_exp * zfact )   ! molC/s
142       !
143      ENDIF
144      !
145      IF(sn_cfctl%l_prttrc)   THEN  ! print mean trends (used for debugging)
146         WRITE(charout, FMT="('sink')")
147         CALL prt_ctl_info( charout, cdcomp = 'top' )
148         CALL prt_ctl(tab4d_1=CASTWP(tr(:,:,:,:,Krhs)), mask1=tmask, clinfo=ctrcnm)
149      ENDIF
150      !
151      IF( ln_timing )   CALL timing_stop('p4z_sink')
152      !
153   END SUBROUTINE p4z_sink
154
155
156   SUBROUTINE p4z_sink_init
157      !!----------------------------------------------------------------------
158      !!                  ***  ROUTINE p4z_sink_init  ***
159      !!----------------------------------------------------------------------
160      INTEGER :: jk
161      !!----------------------------------------------------------------------
162      !
163      ik100 = 10        !  last level where depth less than 100 m
164      DO jk = jpkm1, 1, -1
165         IF( gdept_1d(jk) > 100. )  ik100 = jk - 1
166      END DO
167      IF (lwp) WRITE(numout,*)
168      IF (lwp) WRITE(numout,*) ' Level corresponding to 100m depth ',  ik100 + 1
169      IF (lwp) WRITE(numout,*)
170      !
171      t_oce_co2_exp = 0._wp
172      !
173   END SUBROUTINE p4z_sink_init
174
175   INTEGER FUNCTION p4z_sink_alloc()
176      !!----------------------------------------------------------------------
177      !!                     ***  ROUTINE p4z_sink_alloc  ***
178      !!----------------------------------------------------------------------
179      INTEGER :: ierr(2)
180      !!----------------------------------------------------------------------
181      !
182      ierr(:) = 0
183      !
184      ALLOCATE( sinking(jpi,jpj,jpk) , sinking2(jpi,jpj,jpk)                    ,     &               
185         &      sinkcal(jpi,jpj,jpk) , sinksil (jpi,jpj,jpk)                    ,     &               
186         &      sinkfer2(jpi,jpj,jpk)                                           ,     &               
187         &      sinkfer(jpi,jpj,jpk)                                            , STAT=ierr(1) )               
188         !
189      IF( ln_p5z    ) ALLOCATE( sinkingn(jpi,jpj,jpk), sinking2n(jpi,jpj,jpk)   ,     &
190         &                      sinkingp(jpi,jpj,jpk), sinking2p(jpi,jpj,jpk)   , STAT=ierr(2) )
191      !
192      p4z_sink_alloc = MAXVAL( ierr )
193      IF( p4z_sink_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p4z_sink_alloc : failed to allocate arrays.' )
194      !
195   END FUNCTION p4z_sink_alloc
196   
197   !!======================================================================
198END MODULE p4zsink
Note: See TracBrowser for help on using the repository browser.