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.
trcopt_medusa.F90 in branches/UKMO/dev_r5518_GO6_package_FOAMv14_biophys/NEMOGCM/NEMO/TOP_SRC/MEDUSA – NEMO

source: branches/UKMO/dev_r5518_GO6_package_FOAMv14_biophys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcopt_medusa.F90 @ 13677

Last change on this file since 13677 was 13677, checked in by dford, 4 years ago

Add option for MEDUSA to use RGB light scheme.

File size: 10.6 KB
Line 
1MODULE trcopt_medusa
2   !!======================================================================
3   !!                         ***  MODULE trcopt_medusa  ***
4   !! TOP :   MEDUSA Compute the light availability in the water column
5   !!======================================================================
6   !! History :    -   !  1995-05  (M. Levy) Original code
7   !!              -   !  1999-09  (J.-M. Andre, M. Levy)
8   !!              -   !  1999-11  (C. Menkes, M.-A. Foujols) itabe initial
9   !!              -   !  2000-02  (M.A. Foujols) change x**y par exp(y*log(x))
10   !!             2.0  !  2007-12  (C. Deltel, G. Madec)  F90
11   !!              -   !  2008-08  (K. Popova) adaptation for MEDUSA
12   !!              -   !  2008-11  (A. Yool) continuing adaptation for MEDUSA
13   !!              -   !  2010-03  (A. Yool) updated for branch inclusion
14   !!----------------------------------------------------------------------
15#if defined key_medusa
16   !!----------------------------------------------------------------------
17   !!   'key_medusa'                                      MEDUSA bio-model
18   !!----------------------------------------------------------------------
19   !!   trc_opt_medusa        :   Compute the light availability in the water column
20   !!----------------------------------------------------------------------
21   USE oce_trc         !
22   USE trc
23   USE prtctl_trc      ! Print control for debbuging
24   USE sms_medusa
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   trc_opt_medusa   ! called in trcprg.F90
30
31   REAL(wp), DIMENSION(3,61) :: okrgb   !: tabulated attenuation coefficients for RGB absorption
32
33   !!* Substitution
34#  include "domzgr_substitute.h90"
35   !!----------------------------------------------------------------------
36   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007)
37   !! $Id$
38   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
39   !!----------------------------------------------------------------------
40
41CONTAINS
42
43   SUBROUTINE trc_opt_medusa( kt )
44      !!---------------------------------------------------------------------
45      !!                     ***  ROUTINE trc_opt_medusa  ***
46      !!
47      !! ** Purpose :   computes the light propagation in the water column
48      !!              and the euphotic layer depth
49      !!
50      !! ** Method  :   local par is computed in w layers using light propagation
51      !!              mean par in t layers are computed by integration
52      !!---------------------------------------------------------------------
53      INTEGER, INTENT( in ) ::   kt   ! index of the time stepping
54      INTEGER  ::   ji, jj, jk, irgb
55      REAL(wp) ::   zpig                                    ! total pigment
56      REAL(wp) ::   zkr                                     ! total absorption coefficient in red
57      REAL(wp) ::   zkg                                     ! total absorption coefficient in green
58      REAL(wp) ::   totchl                                  ! total Chl concentreation
59      REAL(wp), DIMENSION(jpi,jpj)     ::   zpar100         ! irradiance at euphotic layer depth
60      REAL(wp), DIMENSION(jpi,jpj)     ::   zpar0m          ! irradiance just below the surface
61      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zparr, zparg    ! red and green compound of par
62      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zekb, zekg, zekr
63      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ze1, ze2, ze3
64
65      CHARACTER (len=25) :: charout
66      !!---------------------------------------------------------------------
67
68      !! AXY (20/11/14): alter this to report on first MEDUSA call
69      !! IF( kt == nit000 ) THEN
70      IF( kt == nittrc000 ) THEN
71         IF(lwp) WRITE(numout,*)
72         IF(lwp) WRITE(numout,*) ' trc_opt_medusa: MEDUSA optic-model'
73         IF(lwp) WRITE(numout,*) ' ~~~~~~~'
74    IF(lwp) WRITE(numout,*) ' kt =',kt
75      ENDIF
76
77      ! determination of surface irradiance
78      ! -----------------------------------
79      ! AXY (23/07/15): the inclusion of empirical DMS calculations requires
80      !                 daily averages of a series of properties that are
81      !                 used as inputs; these include surface irradiance;
82      !                 here, this is taken advantage of to allow MEDUSA to
83      !                 base its submarine light field on daily average
84      !                 rather than "instantaneous" irradiance; largely
85      !                 because MEDUSA was originally formulated to work
86      !                 with diel average irradiance rather than a diel
87      !                 cycle; using key_avgqsr_medusa activates this
88      !                 functionality, while its absence gives default
89      !                 MEDUSA (which is whatever is supplied by NEMO)
90# if defined key_avgqsr_medusa
91      ! surface irradiance input is rolling average irradiance
92      zpar0m (:,:)   = zn_dms_qsr(:,:) * 0.43
93# else     
94      ! surface irradiance input is   instantaneous irradiance
95      zpar0m (:,:)   =        qsr(:,:) * 0.43
96# endif
97      ! AXY (22/08/14): when zpar0m = 0, zpar100 is also zero and calculating
98      !                 euphotic depth is not possible (cf. the Arctic Octopus);
99      !                 a "solution" to this is to set zpar0m to some minimal
100      !                 value such that zpar100 also has a non-zero value and
101      !                 euphotic depth can be calculated properly; note that,
102      !                 in older, non-diurnal versions of NEMO, this was much
103      !                 less of a problem; note also that, if pushed, I will
104      !                 claim that my minimal value of zpar0m refers to light
105      !                 from stars
106      DO jj = 1, jpj
107         DO ji = 1, jpi
108            IF( zpar0m(ji,jj) <= 0.0 ) zpar0m(ji,jj) = 0.001  ! = 1 mW/m2
109         ENDDO
110      ENDDO
111      zpar100(:,:)   = zpar0m(:,:) * 0.01
112      xpar   (:,:,1) = zpar0m(:,:)
113      zparr  (:,:,1) = 0.5 * zpar0m(:,:)
114      zparg  (:,:,1) = 0.5 * zpar0m(:,:)
115
116      ! determination of xpar
117      ! ---------------------
118
119      IF ( ln_rgb ) THEN
120         ! Mean PAR in T levels using RGB scheme
121         ! Should be same as in traqsr, but T rather than W levels
122         IF( kt == nittrc000 ) THEN
123            CALL trc_oce_rgb( okrgb )
124         ENDIF
125         DO jk = 1, jpkm1
126            DO jj = 1, jpj
127               DO ji = 1, jpi
128                  totchl = trn(ji,jj,jk,jpchn) + trn(ji,jj,jk,jpchd)
129                  totchl = MIN( 10. , MAX( 0.05, totchl ) )
130                  irgb = NINT( 41 + 20.* LOG10( totchl ) + 1.e-15 )
131                  !                                                         
132                  zekb(ji,jj,jk) = okrgb(1,irgb) * fse3t(ji,jj,jk)
133                  zekg(ji,jj,jk) = okrgb(2,irgb) * fse3t(ji,jj,jk)
134                  zekr(ji,jj,jk) = okrgb(3,irgb) * fse3t(ji,jj,jk)
135               END DO
136            END DO
137         END DO
138         ze1(:,:,1) = zpar0m(:,:) * EXP( -0.5 * zekb(:,:,1) ) / 3.0
139         ze2(:,:,1) = zpar0m(:,:) * EXP( -0.5 * zekg(:,:,1) ) / 3.0
140         ze3(:,:,1) = zpar0m(:,:) * EXP( -0.5 * zekr(:,:,1) ) / 3.0
141         !
142         DO jk = 2, jpk
143            DO jj = 1, jpj
144               DO ji = 1, jpi
145                  ze1(ji,jj,jk) = ze1(ji,jj,jk-1) * EXP( -0.5 * ( zekb(ji,jj,jk-1) + zekb(ji,jj,jk) ) )
146                  ze2(ji,jj,jk) = ze2(ji,jj,jk-1) * EXP( -0.5 * ( zekg(ji,jj,jk-1) + zekg(ji,jj,jk) ) )
147                  ze3(ji,jj,jk) = ze3(ji,jj,jk-1) * EXP( -0.5 * ( zekr(ji,jj,jk-1) + zekr(ji,jj,jk) ) )
148                  xpar(ji,jj,jk) = MAX( ze1(ji,jj,jk) + ze2(ji,jj,jk) + ze3(ji,jj,jk), 1.e-15 )
149               END DO
150            END DO
151         END DO
152      ELSE
153         DO jk = 2, jpk                     ! determination of local par in w levels
154            DO jj = 1, jpj
155               DO ji = 1, jpi
156                  totchl =trn(ji,jj,jk-1,jpchn)+trn(ji,jj,jk-1,jpchd)
157                  zpig = MAX( TINY(0.), totchl/rpig) 
158                  zkr  = xkr0 + xkrp * EXP( xlr * LOG( zpig ) )
159                  zkg  = xkg0 + xkgp * EXP( xlg * LOG( zpig ) )
160                  zparr(ji,jj,jk) = zparr(ji,jj,jk-1) * EXP( -zkr * fse3t(ji,jj,jk-1) )
161                  zparg(ji,jj,jk) = zparg(ji,jj,jk-1) * EXP( -zkg * fse3t(ji,jj,jk-1) )
162               END DO
163           END DO
164         END DO
165
166         DO jk = 1, jpkm1                   ! mean par in t levels
167            DO jj = 1, jpj
168               DO ji = 1, jpi
169                  totchl =trn(ji,jj,jk  ,jpchn)+trn(ji,jj,jk  ,jpchd)
170                  zpig = MAX( TINY(0.), totchl/rpig) 
171                  zkr  = xkr0 + xkrp * EXP( xlr * LOG( zpig ) )
172                  zkg  = xkg0 + xkgp * EXP( xlg * LOG( zpig ) )
173                  zparr(ji,jj,jk)    = zparr(ji,jj,jk) / zkr / fse3t(ji,jj,jk) * ( 1 - EXP( -zkr*fse3t(ji,jj,jk) ) )
174                  zparg(ji,jj,jk)    = zparg(ji,jj,jk) / zkg / fse3t(ji,jj,jk) * ( 1 - EXP( -zkg*fse3t(ji,jj,jk) ) )
175                  xpar (ji,jj,jk) = MAX( zparr(ji,jj,jk) + zparg(ji,jj,jk), 1.e-15 )
176               END DO
177            END DO
178         END DO
179      ENDIF
180
181      ! 3. Determination of euphotic layer depth
182      ! ----------------------------------------
183
184      ! Euphotic layer bottom level
185      neln(:,:) = 1                                           ! initialisation of EL level
186      DO jk = 1, jpkm1
187         DO jj = 1, jpj
188           DO ji = 1, jpi
189              IF( xpar(ji,jj,jk) >= zpar100(ji,jj) )   neln(ji,jj) = jk+1 ! 1rst T-level strictly below EL bottom
190              !                                                  ! nb. this is to ensure compatibility with
191              !                                                  ! nmld_trc definition in trd_mld_trc_zint
192           END DO
193         END DO
194      ENDDO
195
196      ! Euphotic layer depth
197      !! Jpalm -- 06-03-2017 -- add init xze, to avoid halo problems within the
198      !!                        writing process
199      xze(:,:) = 0.0
200      DO jj = 1, jpj
201         DO ji = 1, jpi
202            xze(ji,jj) = fsdepw( ji, jj, neln(ji,jj) )            ! exact EL depth
203         END DO
204      ENDDO 
205
206      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
207         WRITE(charout, FMT="('opt')")
208         CALL prt_ctl_trc_info(charout)
209         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
210      ENDIF
211
212   END SUBROUTINE trc_opt_medusa
213
214#else
215   !!======================================================================
216   !!  Dummy module :                                   No MEDUSA bio-model
217   !!======================================================================
218CONTAINS
219   SUBROUTINE trc_opt_medusa( kt )                   ! Empty routine
220      INTEGER, INTENT( in ) ::   kt
221      WRITE(*,*) 'trc_opt_medusa: You should not have seen this print! error?', kt
222   END SUBROUTINE trc_opt_medusa
223#endif 
224
225   !!======================================================================
226END MODULE  trcopt_medusa
Note: See TracBrowser for help on using the repository browser.