Index: branches/UKMO/dev_r5518_convadj/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90
===================================================================
--- branches/UKMO/dev_r5518_convadj/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 6836)
+++ branches/UKMO/dev_r5518_convadj/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 6839)
@@ -10,5 +10,6 @@
    !!             -   !  2005-11  (G. Madec) zco, zps, sco coordinate
    !!            3.2  !  2009-04  (G. Madec & NEMO team) 
-   !!            4.0  !  2012-05  (C. Rousset) store attenuation coef for use in ice model 
+   !!            3.4  !  2012-05  (C. Rousset) store attenuation coef for use in ice model 
+   !!            3.6  !  2015-12  (O. Aumont, J. Jouanno, C. Ethe) use vertical profile of chlorophyll
    !!----------------------------------------------------------------------
 
@@ -93,4 +94,5 @@
       !! Reference  : Jerlov, N. G., 1968 Optical Oceanography, Elsevier, 194pp.
       !!              Lengaigne et al. 2007, Clim. Dyn., V28, 5, 503-516.
+      !!              Morel, A. et Berthon, JF, 1989, Limnol Oceanogr 34(8), 1545-1562
       !!----------------------------------------------------------------------
       !
@@ -101,14 +103,15 @@
       REAL(wp) ::   zchl, zcoef, zfact   ! local scalars
       REAL(wp) ::   zc0, zc1, zc2, zc3   !    -         -
-      REAL(wp) ::   zzc0, zzc1, zzc2, zzc3   !    -         -
       REAL(wp) ::   zz0, zz1, z1_e3t     !    -         -
+      REAL(wp) ::   zCb, zCmax, zze, zpsi, zpsimax, zdelpsi, zCtot, zCze
+      REAL(wp) ::   zlogc, zlogc2, zlogc3 
       REAL(wp), POINTER, DIMENSION(:,:  ) :: zekb, zekg, zekr
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: ze0, ze1, ze2, ze3, zea, ztrdt
-      !!----------------------------------------------------------------------
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: ze0, ze1, ze2, ze3, zea, ztrdt, zchl3d
+      !!--------------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('tra_qsr')
       !
       CALL wrk_alloc( jpi, jpj,      zekb, zekg, zekr        ) 
-      CALL wrk_alloc( jpi, jpj, jpk, ze0, ze1, ze2, ze3, zea ) 
+      CALL wrk_alloc( jpi, jpj, jpk, ze0, ze1, ze2, ze3, zea, zchl3d ) 
       !
       IF( kt == nit000 ) THEN
@@ -183,31 +186,47 @@
             !                                             ! ------------------------- !
             ! Set chlorophyl concentration
-            IF( nn_chldta == 1 .OR. lk_vvl ) THEN            !*  Variable Chlorophyll or ocean volume
-               !
-               IF( nn_chldta == 1 ) THEN                             !*  Variable Chlorophyll
-                  !
-                  CALL fld_read( kt, 1, sf_chl )                         ! Read Chl data and provides it at the current time step
-                  !         
-!CDIR COLLAPSE
+            IF( nn_chldta == 1 .OR. nn_chldta == 2 .OR. lk_vvl ) THEN    !*  Variable Chlorophyll or ocean volume
+               !
+               IF( nn_chldta == 1 ) THEN        !*  2D Variable Chlorophyll
+                  !
+                  CALL fld_read( kt, 1, sf_chl )            ! Read Chl data and provides it at the current time step
+                  DO jk = 1, nksr + 1
+                     zchl3d(:,:,jk) = sf_chl(1)%fnow(:,:,1) 
+                  ENDDO
+                  !
+               ELSE IF( nn_chldta == 2 ) THEN    !*   -3-D Variable Chlorophyll
+                  !
+                  CALL fld_read( kt, 1, sf_chl )            ! Read Chl data and provides it at the current time step
+!CDIR NOVERRCHK   !
+                  DO jj = 1, jpj
 !CDIR NOVERRCHK
-                  DO jj = 1, jpj                                         ! Separation in R-G-B depending of the surface Chl
-!CDIR NOVERRCHK
-                     DO ji = 1, jpi
-                        zchl = MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) )
-                        irgb = NINT( 41 + 20.*LOG10(zchl) + 1.e-15 )
-                        zekb(ji,jj) = rkrgb(1,irgb)
-                        zekg(ji,jj) = rkrgb(2,irgb)
-                        zekr(ji,jj) = rkrgb(3,irgb)
-                     END DO
-                  END DO
-               ELSE                                            ! Variable ocean volume but constant chrlorophyll
-                  zchl = 0.05                                     ! constant chlorophyll
-                  irgb = NINT( 41 + 20.*LOG10( zchl ) + 1.e-15 )
-                  zekb(:,:) = rkrgb(1,irgb)                       ! Separation in R-G-B depending of the chlorophyll 
-                  zekg(:,:) = rkrgb(2,irgb)
-                  zekr(:,:) = rkrgb(3,irgb)
+                     DO ji = 1, jpi
+                        zchl    = sf_chl(1)%fnow(ji,jj,1)
+                        zCtot   = 40.6  * zchl**0.459
+                        zze     = 568.2 * zCtot**(-0.746)
+                        IF( zze > 102. ) zze = 200.0 * zCtot**(-0.293)
+                        zlogc   = LOG( zchl )
+                        zlogc2  = zlogc * zlogc
+                        zlogc3  = zlogc * zlogc * zlogc
+                        zCb     = 0.768 + 0.087 * zlogc - 0.179 * zlogc2 - 0.025 * zlogc3
+                        zCmax   = 0.299 - 0.289 * zlogc + 0.579 * zlogc2
+                        zpsimax = 0.6   - 0.640 * zlogc + 0.021 * zlogc2 + 0.115 * zlogc3
+                        zdelpsi = 0.710 + 0.159 * zlogc + 0.021 * zlogc2
+                        zCze    = 1.12  * (zchl)**0.803 
+                        DO jk = 1, nksr + 1
+                           zpsi = fsdept(ji,jj,jk) / zze
+                           zchl3d(ji,jj,jk) = zCze * ( zCb + zCmax * EXP( -( (zpsi - zpsimax) / zdelpsi )**2 ) )
+                        END DO
+                        !
+                      END DO
+                   END DO
+                     !
+               ELSE                              !* Variable ocean volume but constant chrlorophyll
+                  DO jk = 1, nksr + 1
+                     zchl3d(:,:,jk) = 0.05 
+                  ENDDO
                ENDIF
                !
-               zcoef  = ( 1. - rn_abs ) / 3.e0                        ! equi-partition in R-G-B
+               zcoef  = ( 1. - rn_abs ) / 3.e0                        !  equi-partition in R-G-B
                ze0(:,:,1) = rn_abs  * qsr(:,:)
                ze1(:,:,1) = zcoef * qsr(:,:)
@@ -217,4 +236,15 @@
                !
                DO jk = 2, nksr+1
+                  !
+                  DO jj = 1, jpj                                         ! Separation in R-G-B depending of vertical profile of Chl
+!CDIR NOVERRCHK
+                     DO ji = 1, jpi
+                        zchl = MIN( 10. , MAX( 0.03, zchl3d(ji,jj,jk) ) )
+                        irgb = NINT( 41 + 20.*LOG10(zchl) + 1.e-15 )
+                        zekb(ji,jj) = rkrgb(1,irgb)
+                        zekg(ji,jj) = rkrgb(2,irgb)
+                        zekr(ji,jj) = rkrgb(3,irgb)
+                     END DO
+                  END DO
 !CDIR NOVERRCHK
                   DO jj = 1, jpj
@@ -233,16 +263,4 @@
                   END DO
                END DO
-               ! clem: store attenuation coefficient of the first ocean level
-               IF ( ln_qsr_ice ) THEN
-                  DO jj = 1, jpj
-                     DO ji = 1, jpi
-                        zzc0 = rn_abs * EXP( - fse3t(ji,jj,1) * xsi0r     )
-                        zzc1 = zcoef  * EXP( - fse3t(ji,jj,1) * zekb(ji,jj) )
-                        zzc2 = zcoef  * EXP( - fse3t(ji,jj,1) * zekg(ji,jj) )
-                        zzc3 = zcoef  * EXP( - fse3t(ji,jj,1) * zekr(ji,jj) )
-                        fraqsr_1lev(ji,jj) = 1.0 - ( zzc0 + zzc1 + zzc2  + zzc3  ) * tmask(ji,jj,2) 
-                     END DO
-                  END DO
-               ENDIF
                !
                DO jk = 1, nksr                                        ! compute and add qsr trend to ta
@@ -251,4 +269,29 @@
                zea(:,:,nksr+1:jpk) = 0.e0     ! below 400m set to zero
                CALL iom_put( 'qsr3d', zea )   ! Shortwave Radiation 3D distribution
+               !
+               IF ( ln_qsr_ice ) THEN    ! store attenuation coefficient of the first ocean level
+!CDIR NOVERRCHK
+                  DO jj = 1, jpj                                         ! Separation in R-G-B depending of the surface Chl
+!CDIR NOVERRCHK
+                     DO ji = 1, jpi
+                        zchl = MIN( 10. , MAX( 0.03, zchl3d(ji,jj,1) ) )
+                        irgb = NINT( 41 + 20.*LOG10(zchl) + 1.e-15 )
+                        zekb(ji,jj) = rkrgb(1,irgb)
+                        zekg(ji,jj) = rkrgb(2,irgb)
+                        zekr(ji,jj) = rkrgb(3,irgb)
+                     END DO
+                  END DO
+                  ! 
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        zc0 = rn_abs * EXP( - fse3t(ji,jj,1) * xsi0r     )
+                        zc1 = zcoef  * EXP( - fse3t(ji,jj,1) * zekb(ji,jj) )
+                        zc2 = zcoef  * EXP( - fse3t(ji,jj,1) * zekg(ji,jj) )
+                        zc3 = zcoef  * EXP( - fse3t(ji,jj,1) * zekr(ji,jj) )
+                        fraqsr_1lev(ji,jj) = 1.0 - ( zc0 + zc1 + zc2  + zc3  ) * tmask(ji,jj,2) 
+                     END DO
+                  END DO
+                  !
+               ENDIF
                !
             ELSE                                                 !*  Constant Chlorophyll
@@ -256,6 +299,6 @@
                   qsr_hc(:,:,jk) =  etot3(:,:,jk) * qsr(:,:)
                END DO
-               ! clem: store attenuation coefficient of the first ocean level
-               IF ( ln_qsr_ice ) THEN
+               !  store attenuation coefficient of the first ocean level
+               IF( ln_qsr_ice ) THEN
                   fraqsr_1lev(:,:) = etot3(:,:,1) / r1_rau0_rcp
                ENDIF
@@ -339,5 +382,5 @@
       !
       CALL wrk_dealloc( jpi, jpj,      zekb, zekg, zekr        ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, ze0, ze1, ze2, ze3, zea ) 
+      CALL wrk_dealloc( jpi, jpj, jpk, ze0, ze1, ze2, ze3, zea, zchl3d ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_qsr')
@@ -405,5 +448,5 @@
          WRITE(numout,*) '      bio-model            light penetration   ln_qsr_bio = ', ln_qsr_bio
          WRITE(numout,*) '      light penetration for ice-model LIM3     ln_qsr_ice = ', ln_qsr_ice
-         WRITE(numout,*) '      RGB : Chl data (=1) or cst value (=0)    nn_chldta  = ', nn_chldta
+         WRITE(numout,*) '      RGB : Chl data (=1/2) or cst value (=0)  nn_chldta  = ', nn_chldta
          WRITE(numout,*) '      RGB & 2 bands: fraction of light (rn_si1)    rn_abs = ', rn_abs
          WRITE(numout,*) '      RGB & 2 bands: shortess depth of extinction  rn_si0 = ', rn_si0
@@ -429,13 +472,15 @@
          IF( ln_qsr_rgb .AND. nn_chldta == 0 )   nqsr =  1 
          IF( ln_qsr_rgb .AND. nn_chldta == 1 )   nqsr =  2
-         IF( ln_qsr_2bd                      )   nqsr =  3
-         IF( ln_qsr_bio                      )   nqsr =  4
+         IF( ln_qsr_rgb .AND. nn_chldta == 2 )   nqsr =  3
+         IF( ln_qsr_2bd                      )   nqsr =  4
+         IF( ln_qsr_bio                      )   nqsr =  5
          !
          IF(lwp) THEN                   ! Print the choice
             WRITE(numout,*)
             IF( nqsr ==  1 )   WRITE(numout,*) '         R-G-B   light penetration - Constant Chlorophyll'
-            IF( nqsr ==  2 )   WRITE(numout,*) '         R-G-B   light penetration - Chl data '
-            IF( nqsr ==  3 )   WRITE(numout,*) '         2 bands light penetration'
-            IF( nqsr ==  4 )   WRITE(numout,*) '         bio-model light penetration'
+            IF( nqsr ==  2 )   WRITE(numout,*) '         R-G-B   light penetration - 2D Chl data '
+            IF( nqsr ==  3 )   WRITE(numout,*) '         R-G-B   light penetration - 3D Chl data '
+            IF( nqsr ==  4 )   WRITE(numout,*) '         2 bands light penetration'
+            IF( nqsr ==  5 )   WRITE(numout,*) '         bio-model light penetration'
          ENDIF
          !
@@ -460,5 +505,5 @@
             IF(lwp) WRITE(numout,*) '        level of light extinction = ', nksr, ' ref depth = ', gdepw_1d(nksr+1), ' m'
             !
-            IF( nn_chldta == 1 ) THEN           !* Chl data : set sf_chl structure
+            IF( nn_chldta == 1  .OR. nn_chldta == 2 ) THEN           !* Chl data : set sf_chl structure
                IF(lwp) WRITE(numout,*)
                IF(lwp) WRITE(numout,*) '        Chlorophyll read in a file'
