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.
asmlogchlbal_medusa.F90 in branches/UKMO/dev_r5518_GO6_package_asm_surf_bgc/NEMOGCM/NEMO/OPA_SRC/ASM – NEMO

source: branches/UKMO/dev_r5518_GO6_package_asm_surf_bgc/NEMOGCM/NEMO/OPA_SRC/ASM/asmlogchlbal_medusa.F90 @ 8440

Last change on this file since 8440 was 8440, checked in by dford, 7 years ago

Add more variables to assimilation background, so it includes all required elements of the background state.

File size: 23.2 KB
RevLine 
[8436]1MODULE asmlogchlbal_medusa
[8428]2   !!======================================================================
[8436]3   !!                       ***  MODULE asmlogchlbal_medusa  ***
4   !! Calculate increments to MEDUSA based on surface logchl increments
[8428]5   !!
6   !! IMPORTANT NOTE: This calls the bioanalysis routine of Hemmings et al.
7   !! For licensing reasons this is kept in its own internal Met Office
8   !! branch (dev/frdf/vn3.6_nitrogen_balancing) rather than in the Paris
9   !! repository, and must be merged in when building.
10   !!
11   !!======================================================================
[8436]12   !! History :  3.6  ! 2017-08 (D. Ford)  Adapted from asmlogchlbal_hadocc
[8428]13   !!----------------------------------------------------------------------
[8436]14#if defined key_asminc && defined key_medusa && defined key_foam_medusa
[8428]15   !!----------------------------------------------------------------------
16   !! 'key_asminc'          : assimilation increment interface
[8436]17   !! 'key_medusa'          : MEDUSA model
18   !! 'key_foam_medusa'     : MEDUSA extras for FOAM OBS and ASM
[8428]19   !!----------------------------------------------------------------------
[8436]20   !! asm_logchl_bal_medusa : routine to calculate increments to MEDUSA
[8428]21   !!----------------------------------------------------------------------
22   USE par_kind,      ONLY: wp             ! kind parameters
23   USE par_oce,       ONLY: jpi, jpj, jpk  ! domain array sizes
24   USE dom_oce,       ONLY: gdepw_n        ! domain information
25   USE zdfmxl                              ! mixed layer depth
26   USE iom                                 ! i/o
[8436]27   USE sms_medusa                          ! MEDUSA parameters
28   USE par_medusa                          ! MEDUSA parameters
[8428]29   USE par_trc,       ONLY: jptra          ! Tracer parameters
30   USE bioanalysis                         ! Nitrogen balancing
31
32   IMPLICIT NONE
33   PRIVATE                   
34
[8436]35   PUBLIC asm_logchl_bal_medusa
[8428]36
37   ! Default values for biological assimilation parameters
38   ! Should match Hemmings et al. (2008)
39   REAL(wp), PARAMETER :: balnutext  =  0.6    !: Default nutrient balancing factor
40   REAL(wp), PARAMETER :: balnutmin  =  0.1    !: Fraction of phytoplankton loss to nutrient
41   REAL(wp), PARAMETER :: r          =  1      !: Reliability of model specific growth rate
42   REAL(wp), PARAMETER :: beta_g     =  0.05   !: Low rate bias correction for growth rate estimator
43   REAL(wp), PARAMETER :: beta_l     =  0.05   !: Low rate bias correction for primary loss rate estimator
44   REAL(wp), PARAMETER :: beta_m     =  0.05   !: Low rate bias correction for secondary loss rate estimator
45   REAL(wp), PARAMETER :: a_g        =  0.2    !: Error s.d. for log10 of growth rate estimator
46   REAL(wp), PARAMETER :: a_l        =  0.4    !: Error s.d. for log10 of primary loss rate estimator
47   REAL(wp), PARAMETER :: a_m        =  0.7    !: Error s.d. for log10 of secondary loss rate estimator
48   REAL(wp), PARAMETER :: zfracb0    =  0.7    !: Base zooplankton fraction of loss to Z & D
49   REAL(wp), PARAMETER :: zfracb1    =  0      !: Phytoplankton sensitivity of zooplankton fraction
50   REAL(wp), PARAMETER :: qrfmax     =  1.1    !: Maximum nutrient limitation reduction factor
51   REAL(wp), PARAMETER :: qafmax     =  1.1    !: Maximum nutrient limitation amplification factor
52   REAL(wp), PARAMETER :: zrfmax     =  2      !: Maximum zooplankton reduction factor
53   REAL(wp), PARAMETER :: zafmax     =  2      !: Maximum zooplankton amplification factor
54   REAL(wp), PARAMETER :: prfmax     =  10     !: Maximum phytoplankton reduction factor (secondary)
55   REAL(wp), PARAMETER :: incphymin  =  0.0001 !: Minimum size of non-zero phytoplankton increment
56   REAL(wp), PARAMETER :: integnstep =  20     !: Number of steps for p.d.f. integral evaluation
57   REAL(wp), PARAMETER :: pthreshold =  0.01   !: Fractional threshold level for setting p.d.f.
58   !
59   LOGICAL,  PARAMETER :: diag_active           = .TRUE.  !: Depth-independent diagnostics
60   LOGICAL,  PARAMETER :: diag_fulldepth_active = .TRUE.  !: Full-depth diagnostics
61   LOGICAL,  PARAMETER :: gl_active             = .TRUE.  !: Growth/loss-based balancing
62   LOGICAL,  PARAMETER :: nbal_active           = .TRUE.  !: Nitrogen balancing
63   LOGICAL,  PARAMETER :: subsurf_active        = .TRUE.  !: Increments below MLD
64   LOGICAL,  PARAMETER :: deepneg_active        = .FALSE. !: Negative primary increments below MLD
65   LOGICAL,  PARAMETER :: deeppos_active        = .FALSE. !: Positive primary increments below MLD
66   LOGICAL,  PARAMETER :: nutprof_active        = .TRUE.  !: Secondary increments
67
68CONTAINS
69
[8436]70   SUBROUTINE asm_logchl_bal_medusa( logchl_bkginc, aincper, mld_choice_bgc, &
71      &                              k_maxchlinc, ld_logchlbal,              &
72      &                              pgrow_avg_bkg, ploss_avg_bkg,           &
73      &                              phyt_avg_bkg, mld_max_bkg,              &
[8440]74      &                              tracer_bkg, logchl_balinc )
[8428]75      !!---------------------------------------------------------------------------
[8436]76      !!                    ***  ROUTINE asm_logchl_bal_medusa  ***
[8428]77      !!
[8436]78      !! ** Purpose :   calculate increments to MEDUSA from logchl increments
[8428]79      !!
80      !! ** Method  :   convert logchl increments to chl increments
[8436]81      !!                average up MEDUSA to look like HadOCC
[8428]82      !!                call nitrogen balancing scheme
[8436]83      !!                separate back out to MEDUSA
[8428]84      !!
85      !! ** Action  :   populate logchl_balinc
86      !!
87      !! References :   Hemmings et al., 2008, J. Mar. Res.
88      !!                Ford et al., 2012, Ocean Sci.
89      !!---------------------------------------------------------------------------
90      !!
91      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)           :: logchl_bkginc  ! logchl increments
92      REAL(wp), INTENT(in   )                               :: aincper        ! Assimilation period
93      INTEGER,  INTENT(in   )                               :: mld_choice_bgc ! MLD criterion
94      REAL(wp), INTENT(in   )                               :: k_maxchlinc    ! Max chl increment
95      LOGICAL,  INTENT(in   )                               :: ld_logchlbal   ! Balancing y/n
[8436]96      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)           :: pgrow_avg_bkg  ! Avg phyto growth
97      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)           :: ploss_avg_bkg  ! Avg phyto loss
98      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)           :: phyt_avg_bkg   ! Avg phyto
99      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj)           :: mld_max_bkg    ! Max MLD
[8440]100      REAL(wp), INTENT(in   ), DIMENSION(jpi,jpj,jpk,jptra) :: tracer_bkg     ! State variables
[8428]101      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj,jpk,jptra) :: logchl_balinc  ! Balancing increments
102      !!
[8436]103      INTEGER                                               :: ji, jj, jk, jn ! Loop counters
[8428]104      INTEGER                                               :: jkmax          ! Loop index
105      INTEGER,                 DIMENSION(6)                 :: i_tracer       ! Tracer indices
[8436]106      REAL(wp)                                              :: n2be_p         ! N:biomass for total phy
107      REAL(wp)                                              :: n2be_z         ! N:biomass for total zoo
108      REAL(wp)                                              :: n2be_d         ! N:biomass for detritus
109      REAL(wp)                                              :: zfrac_chn      ! Fraction of jpchn
110      REAL(wp)                                              :: zfrac_chd      ! Fraction of jpchd
111      REAL(wp)                                              :: zfrac_phn      ! Fraction of jpphn
112      REAL(wp)                                              :: zfrac_phd      ! Fraction of jpphd
113      REAL(wp)                                              :: zfrac_zmi      ! Fraction of jpzmi
114      REAL(wp)                                              :: zfrac_zme      ! Fraction of jpzme
115      REAL(wp)                                              :: zrat_pds_phd   ! Ratio of jppds:jpphd
116      REAL(wp)                                              :: zrat_chd_phd   ! Ratio of jpchd:jpphd
117      REAL(wp)                                              :: zrat_chn_phn   ! Ratio of jpchn:jpphn
118      REAL(wp)                                              :: zrat_dtc_det   ! Ratio of jpdtc:jpdet
[8428]119      REAL(wp),                DIMENSION(jpi,jpj)           :: chl_inc        ! Chlorophyll increments
[8436]120      REAL(wp),                DIMENSION(jpi,jpj)           :: medusa_chl     ! MEDUSA total chlorophyll
121      REAL(wp),                DIMENSION(jpi,jpj)           :: cchl_p         ! C:Chl for total phy
[8428]122      REAL(wp),                DIMENSION(jpi,jpj)           :: zmld           ! Mixed layer depth
123      REAL(wp),                DIMENSION(16)                :: modparm        ! Model parameters
124      REAL(wp),                DIMENSION(20)                :: assimparm      ! Assimilation parameters
125      REAL(wp),                DIMENSION(jpi,jpj,jpk,6)     :: bstate         ! Background state
126      REAL(wp),                DIMENSION(jpi,jpj,jpk,6)     :: outincs        ! Balancing increments
127      REAL(wp),                DIMENSION(jpi,jpj,22)        :: diag           ! Depth-indep diagnostics
128      REAL(wp),                DIMENSION(jpi,jpj,jpk,22)    :: diag_fulldepth ! Full-depth diagnostics
129      !!---------------------------------------------------------------------------
130
131      ! Convert log10(chlorophyll) increment back to a chlorophyll increment
132      ! In order to transform logchl incs to chl incs, need to account for model
133      ! background, cannot simply do 10^logchl_bkginc. Need to:
134      ! 1) Add logchl inc to log10(background) to get log10(analysis)
135      ! 2) Take 10^log10(analysis) to get analysis
136      ! 3) Subtract background from analysis to get chl incs
137      ! If k_maxchlinc > 0 then cap total absolute chlorophyll increment at that value
[8440]138      medusa_chl(:,:) = tracer_bkg(:,:,1,jpchn) + tracer_bkg(:,:,1,jpchd)
[8428]139      DO jj = 1, jpj
140         DO ji = 1, jpi
[8436]141            IF ( medusa_chl(ji,jj) > 0.0 ) THEN
142               chl_inc(ji,jj) = 10**( LOG10( medusa_chl(ji,jj) ) + logchl_bkginc(ji,jj) ) - medusa_chl(ji,jj)
[8428]143               IF ( k_maxchlinc > 0.0 ) THEN
144                  chl_inc(ji,jj) = MAX( -1.0 * k_maxchlinc, MIN( chl_inc(ji,jj), k_maxchlinc ) )
145               ENDIF
146            ELSE
147               chl_inc(ji,jj) = 0.0
148            ENDIF
149         END DO
150      END DO
151     
152      ! Select mixed layer
153      SELECT CASE( mld_choice_bgc )
154      CASE ( 1 )                   ! Turbocline/mixing depth [W points]
155         zmld(:,:) = hmld(:,:)
156      CASE ( 2 )                   ! Density criterion (0.01 kg/m^3 change from 10m) [W points]
157         zmld(:,:) = hmlp(:,:)
158      CASE ( 3 )                   ! Kara MLD [Interpolated]
159#if defined key_karaml
160         IF ( ln_kara ) THEN
161            zmld(:,:) = hmld_kara(:,:)
162         ELSE
163            CALL ctl_stop( ' Kara mixed layer requested for LogChl assimilation,', &
164               &           ' but ln_kara=.false.' )
165         ENDIF
166#else
167         CALL ctl_stop( ' Kara mixed layer requested for LogChl assimilation,', &
168            &           ' but is not defined' )
169#endif
170      CASE ( 4 )                   ! Temperature criterion (0.2 K change from surface) [T points]
171         !zmld(:,:) = hmld_tref(:,:)
172         CALL ctl_stop( ' hmld_tref mixed layer requested for LogChl assimilation,', &
173            &           ' but is not available in this version' )
174      CASE ( 5 )                   ! Density criterion (0.01 kg/m^3 change from 10m) [T points]
175         zmld(:,:) = hmlpt(:,:)
176      END SELECT
177     
178      IF ( ld_logchlbal ) THEN   ! Nitrogen balancing
179
[8436]180         ! Set up model parameters to be passed into Hemmings balancing routine.
181         ! For now these are hardwired to the standard HadOCC parameter values
182         ! (except C:N ratios) as this is what the scheme was developed for.
183         ! Obviously, HadOCC and MEDUSA are rather different models, so this
184         ! isn't ideal, but there's not always direct analogues between the two
185         ! parameter sets, so it's the easiest way to get something running.
186         ! In the longer term, some serious MarMOT-based development is required.
187         modparm(1)  = 0.1                               ! grow_sat
188         modparm(2)  = 2.0                               ! psmax
189         modparm(3)  = 0.845                             ! par
190         modparm(4)  = 0.02                              ! alpha
191         modparm(5)  = 0.05                              ! resp_rate
192         modparm(6)  = 0.05                              ! pmort_rate
193         modparm(7)  = 0.01                              ! phyto_min
194         modparm(8)  = 0.05                              ! z_mort_1
195         modparm(9)  = 1.0                               ! z_mort_2
196         modparm(10) = ( xthetapn  + xthetapd  ) / 2.0   ! c2n_p
197         modparm(11) = ( xthetazmi + xthetazme ) / 2.0   ! c2n_z
198         modparm(12) = xthetad                           ! c2n_d
199         modparm(13) = 0.01                              ! graze_threshold
200         modparm(14) = 2.0                               ! holling_coef
201         modparm(15) = 0.5                               ! graze_sat
202         modparm(16) = 2.0                               ! graze_max
[8428]203
204         ! Set up assimilation parameters to be passed into balancing routine
205         ! Not sure what assimparm(1) is meant to be, but it doesn't get used
206         assimparm(2)  = balnutext
207         assimparm(3)  = balnutmin
208         assimparm(4)  = r
209         assimparm(5)  = beta_g
210         assimparm(6)  = beta_l
211         assimparm(7)  = beta_m
212         assimparm(8)  = a_g
213         assimparm(9)  = a_l
214         assimparm(10) = a_m
215         assimparm(11) = zfracb0
216         assimparm(12) = zfracb1
217         assimparm(13) = qrfmax
218         assimparm(14) = qafmax
219         assimparm(15) = zrfmax
220         assimparm(16) = zafmax
221         assimparm(17) = prfmax
222         assimparm(18) = incphymin
223         assimparm(19) = integnstep
224         assimparm(20) = pthreshold
225
226         ! Set up external tracer indices array bstate
227         i_tracer(1) = 1   ! nutrient
228         i_tracer(2) = 2   ! phytoplankton
229         i_tracer(3) = 3   ! zooplankton
230         i_tracer(4) = 4   ! detritus
231         i_tracer(5) = 5   ! DIC
232         i_tracer(6) = 6   ! Alkalinity
233
234         ! Set background state
[8440]235         bstate(:,:,:,i_tracer(1)) = tracer_bkg(:,:,:,jpdin)
236         bstate(:,:,:,i_tracer(2)) = tracer_bkg(:,:,:,jpphn) + tracer_bkg(:,:,:,jpphd)
237         bstate(:,:,:,i_tracer(3)) = tracer_bkg(:,:,:,jpzmi) + tracer_bkg(:,:,:,jpzme)
238         bstate(:,:,:,i_tracer(4)) = tracer_bkg(:,:,:,jpdet)
239         bstate(:,:,:,i_tracer(5)) = tracer_bkg(:,:,:,jpdic)
240         bstate(:,:,:,i_tracer(6)) = tracer_bkg(:,:,:,jpalk)
[8428]241
[8436]242         ! Calculate carbon to chlorophyll ratio for combined phytoplankton
243         ! and nitrogen to biomass equivalent for PZD
244         ! Hardwire nitrogen mass to 14.01 for now as it doesn't seem to be set in MEDUSA
245         cchl_p(:,:) = 0.0
246         DO jj = 1, jpj
247            DO ji = 1, jpi
[8440]248               IF ( ( tracer_bkg(ji,jj,1,jpchn) + tracer_bkg(ji,jj,1,jpchd ) ) .GT. 0.0 ) THEN
249                  cchl_p(ji,jj) = ( ( tracer_bkg(ji,jj,1,jpphn) * xthetapn ) + ( tracer_bkg(ji,jj,1,jpphd) * xthetapd ) ) / &
250                     &            ( tracer_bkg(ji,jj,1,jpchn) + tracer_bkg(ji,jj,1,jpchd ) )
[8436]251               ENDIF
252            END DO
253         END DO
254         n2be_p = 14.01 + ( xmassc * ( ( xthetapn  + xthetapd  ) / 2.0 ) )
255         n2be_z = 14.01 + ( xmassc * ( ( xthetazmi + xthetazme ) / 2.0 ) )
256         n2be_d = 14.01 + ( xmassc * xthetad )
257
[8428]258         ! Call nitrogen balancing routine
[8436]259         CALL bio_analysis( jpi, jpj, jpk, gdepw_n(:,:,2:jpk), i_tracer, modparm,   &
260            &               n2be_p, n2be_z, n2be_d, assimparm,                      &
261            &               INT(aincper), 1, INT(SUM(tmask,3)), tmask(:,:,:),       &
262            &               zmld(:,:), mld_max_bkg(:,:), chl_inc(:,:), cchl_p(:,:), &
263            &               nbal_active, phyt_avg_bkg(:,:),                         &
264            &               gl_active, pgrow_avg_bkg(:,:), ploss_avg_bkg(:,:),      &
265            &               subsurf_active, deepneg_active,                         &
266            &               deeppos_active, nutprof_active,                         &
267            &               bstate, outincs,                                        &
268            &               diag_active, diag,                                      &
[8428]269            &               diag_fulldepth_active, diag_fulldepth )
[8436]270         
271         ! Loop over each grid point partioning the increments
272         logchl_balinc(:,:,:,:) = 0.0
273         DO jk = 1, jpk
274            DO jj = 1, jpj
275               DO ji = 1, jpi
276
[8440]277                  IF ( ( tracer_bkg(ji,jj,jk,jpphn) > 0.0 ) .AND. ( tracer_bkg(ji,jj,jk,jpphd) > 0.0 ) ) THEN
[8436]278                     ! Phytoplankton nitrogen and silicate split up based on existing ratios
[8440]279                     zfrac_phn = tracer_bkg(ji,jj,jk,jpphn) / (tracer_bkg(ji,jj,jk,jpphn) + tracer_bkg(ji,jj,jk,jpphd))
[8436]280                     zfrac_phd = 1.0 - zfrac_phn
[8440]281                     zrat_pds_phd = tracer_bkg(ji,jj,jk,jppds) / tracer_bkg(ji,jj,jk,jpphd)
[8436]282                     logchl_balinc(ji,jj,jk,jpphn) = outincs(ji,jj,jk,i_tracer(2)) * zfrac_phn
283                     logchl_balinc(ji,jj,jk,jpphd) = outincs(ji,jj,jk,i_tracer(2)) * zfrac_phd
284                     logchl_balinc(ji,jj,jk,jppds) = logchl_balinc(ji,jj,jk,jpphd) * zrat_pds_phd
285
286                     ! Chlorophyll split up based on existing ratios to phytoplankton nitrogen
287                     ! Not using chl_inc directly as it's only 2D
288                     ! This method should give same results at surface as splitting chl_inc would
[8440]289                     zrat_chn_phn = tracer_bkg(ji,jj,jk,jpchn) / tracer_bkg(ji,jj,jk,jpphn)
290                     zrat_chd_phd = tracer_bkg(ji,jj,jk,jpchd) / tracer_bkg(ji,jj,jk,jpphd)
[8436]291                     logchl_balinc(ji,jj,jk,jpchn) = logchl_balinc(ji,jj,jk,jpphn) * zrat_chn_phn
292                     logchl_balinc(ji,jj,jk,jpchd) = logchl_balinc(ji,jj,jk,jpphd) * zrat_chd_phd
293                  ENDIF
294
[8440]295                  IF ( ( tracer_bkg(ji,jj,jk,jpzmi) > 0.0 ) .AND. ( tracer_bkg(ji,jj,jk,jpzme) > 0.0 ) ) THEN
[8436]296                     ! Zooplankton nitrogen split up based on existing ratios
[8440]297                     zfrac_zmi = tracer_bkg(ji,jj,jk,jpzmi) / (tracer_bkg(ji,jj,jk,jpzmi) + tracer_bkg(ji,jj,jk,jpzme))
[8436]298                     zfrac_zme = 1.0 - zfrac_zmi
299                     logchl_balinc(ji,jj,jk,jpzmi) = outincs(ji,jj,jk,i_tracer(3)) * zfrac_zmi
300                     logchl_balinc(ji,jj,jk,jpzme) = outincs(ji,jj,jk,i_tracer(3)) * zfrac_zme
301                  ENDIF
302
303                  ! Nitrogen nutrient straight from balancing scheme
304                  logchl_balinc(ji,jj,jk,jpdin) = outincs(ji,jj,jk,i_tracer(1))
305
306                  ! Nitrogen detritus straight from balancing scheme
307                  logchl_balinc(ji,jj,jk,jpdet) = outincs(ji,jj,jk,i_tracer(4))
308
309                  ! DIC straight from balancing scheme
310                  logchl_balinc(ji,jj,jk,jpdic) = outincs(ji,jj,jk,i_tracer(5))
311
312                  ! Alkalinity straight from balancing scheme
313                  logchl_balinc(ji,jj,jk,jpalk) = outincs(ji,jj,jk,i_tracer(6))
314
315                  ! Remove diatom silicate increment from nutrient silicate to conserve mass
[8440]316                  IF ( ( tracer_bkg(ji,jj,jk,jpsil) - logchl_balinc(ji,jj,jk,jppds) ) > 0.0 ) THEN
[8436]317                     logchl_balinc(ji,jj,jk,jpsil) = logchl_balinc(ji,jj,jk,jppds) * (-1.0)
318                  ENDIF
319
[8440]320                  IF ( ( tracer_bkg(ji,jj,jk,jpdet) > 0.0 ) .AND. ( tracer_bkg(ji,jj,jk,jpdtc) > 0.0 ) ) THEN
[8436]321                     ! Carbon detritus based on existing ratios
[8440]322                     zrat_dtc_det = tracer_bkg(ji,jj,jk,jpdtc) / tracer_bkg(ji,jj,jk,jpdet)
[8436]323                     logchl_balinc(ji,jj,jk,jpdtc) = logchl_balinc(ji,jj,jk,jpdet) * zrat_dtc_det
324                  ENDIF
325
326                  ! Do nothing with iron or oxygen for the time being
327                  logchl_balinc(ji,jj,jk,jpfer) = 0.0
328                  logchl_balinc(ji,jj,jk,jpoxy) = 0.0
329                 
330               END DO
331            END DO
332         END DO
[8428]333     
334      ELSE   ! No nitrogen balancing
335     
[8436]336         ! Initialise individual chlorophyll increments to zero
337         logchl_balinc(:,:,:,jpchn) = 0.0
338         logchl_balinc(:,:,:,jpchd) = 0.0
[8428]339         
[8436]340         ! Split up total surface chlorophyll increments
341         DO jj = 1, jpj
342            DO ji = 1, jpi
343               IF ( medusa_chl(ji,jj) > 0.0 ) THEN
[8440]344                  zfrac_chn = tracer_bkg(ji,jj,1,jpchn) / medusa_chl(ji,jj)
[8436]345                  zfrac_chd = 1.0 - zfrac_chn
346                  logchl_balinc(ji,jj,1,jpchn) = chl_inc(ji,jj) * zfrac_chn
347                  logchl_balinc(ji,jj,1,jpchd) = chl_inc(ji,jj) * zfrac_chd
348               ENDIF
349            END DO
350         END DO
[8428]351         
352         ! Propagate through mixed layer
353         DO jj = 1, jpj
354            DO ji = 1, jpi
355               !
356               jkmax = jpk-1
357               DO jk = jpk-1, 1, -1
358                  IF ( ( zmld(ji,jj) >  gdepw_n(ji,jj,jk)   ) .AND. &
359                     & ( zmld(ji,jj) <= gdepw_n(ji,jj,jk+1) ) ) THEN
360                     zmld(ji,jj) = gdepw_n(ji,jj,jk+1)
361                     jkmax = jk
362                  ENDIF
363               END DO
364               !
365               DO jk = 2, jkmax
[8436]366                  logchl_balinc(ji,jj,jk,jpchn) = logchl_balinc(ji,jj,1,jpchn)
367                  logchl_balinc(ji,jj,jk,jpchd) = logchl_balinc(ji,jj,1,jpchd)
[8428]368               END DO
369               !
370            END DO
371         END DO
372
373         ! Set other balancing increments to zero
[8436]374         logchl_balinc(:,:,:,jpphn) = 0.0
375         logchl_balinc(:,:,:,jpphd) = 0.0
376         logchl_balinc(:,:,:,jppds) = 0.0
377         logchl_balinc(:,:,:,jpzmi) = 0.0
378         logchl_balinc(:,:,:,jpzme) = 0.0
379         logchl_balinc(:,:,:,jpdin) = 0.0
380         logchl_balinc(:,:,:,jpsil) = 0.0
381         logchl_balinc(:,:,:,jpfer) = 0.0
382         logchl_balinc(:,:,:,jpdet) = 0.0
383         logchl_balinc(:,:,:,jpdtc) = 0.0
384         logchl_balinc(:,:,:,jpdic) = 0.0
385         logchl_balinc(:,:,:,jpalk) = 0.0
386         logchl_balinc(:,:,:,jpoxy) = 0.0
387
[8428]388      ENDIF
389
[8436]390   END SUBROUTINE asm_logchl_bal_medusa
[8428]391
392#else
393   !!----------------------------------------------------------------------
394   !!   Default option : Empty routine
395   !!----------------------------------------------------------------------
396CONTAINS
[8436]397   SUBROUTINE asm_logchl_bal_medusa( logchl_bkginc, aincper, mld_choice_bgc, &
[8440]398      &                              k_maxchlinc, ld_logchlbal,              &
399      &                              pgrow_avg_bkg, ploss_avg_bkg,           &
400      &                              phyt_avg_bkg, mld_max_bkg,              &
401      &                              tracer_bkg, logchl_balinc )
[8428]402      REAL    :: logchl_bkginc(:,:)
403      REAL    :: aincper
404      INTEGER :: mld_choice_bgc
405      REAL    :: k_maxchlinc
[8440]406      LOGICAL :: ld_logchlbal
407      REAL    :: pgrow_avg_bkg(:,:)
408      REAL    :: ploss_avg_bkg(:,:)
409      REAL    :: phyt_avg_bkg(:,:)
410      REAL    :: mld_max_bkg(:,:)
411      REAL    :: tracer_bkg(:,:,:,:)
412      REAL    :: logchl_balinc(:,:,:,:)
[8436]413      WRITE(*,*) 'asm_logchl_bal_medusa: You should not have seen this print! error?'
414   END SUBROUTINE asm_logchl_bal_medusa
[8428]415#endif
416
417   !!======================================================================
[8436]418END MODULE asmlogchlbal_medusa
Note: See TracBrowser for help on using the repository browser.