Index: branches/2011/dev_r2787_PISCES_improvment/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zopt.F90
===================================================================
--- branches/2011/dev_r2787_PISCES_improvment/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 2822)
+++ branches/2011/dev_r2787_PISCES_improvment/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 2823)
@@ -7,4 +7,5 @@
    !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
    !!             3.2  !  2009-04  (C. Ethe, G. Madec)  optimisation
+   !!             3.4  !  2011-06  (O. Aumont, C. Ethe) Improve light availability of nano & diat
    !!----------------------------------------------------------------------
 #if defined  key_pisces
@@ -17,5 +18,5 @@
    USE oce_trc        ! tracer-ocean share variables
    USE sms_pisces     ! Source Minus Sink of PISCES
-   USE iom
+   USE iom            ! I/O manager
 
    IMPLICIT NONE
@@ -53,8 +54,9 @@
       !!---------------------------------------------------------------------
       USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zdepmoy => wrk_2d_1 , zetmp => wrk_2d_2
-      USE wrk_nemo, ONLY:   zekg    => wrk_3d_2 , zekr  => wrk_3d_3 , zekb => wrk_3d_4
-      USE wrk_nemo, ONLY:   ze0     => wrk_3d_5 , ze1   => wrk_3d_6
-      USE wrk_nemo, ONLY:   ze2     => wrk_3d_7 , ze3   => wrk_3d_8
+      USE wrk_nemo, ONLY:   zdepmoy => wrk_2d_1 , zetmp  => wrk_2d_2
+      USE wrk_nemo, ONLY:   zetmp1  => wrk_2d_3 , zetmp2 => wrk_2d_4
+      USE wrk_nemo, ONLY:   zekg    => wrk_3d_2 , zekr   => wrk_3d_3 , zekb => wrk_3d_4
+      USE wrk_nemo, ONLY:   ze0     => wrk_3d_5 , ze1    => wrk_3d_6
+      USE wrk_nemo, ONLY:   ze2     => wrk_3d_7 , ze3    => wrk_3d_8
       !
       INTEGER, INTENT(in) ::   kt, jnt   ! ocean time step
@@ -63,8 +65,8 @@
       INTEGER  ::   irgb
       REAL(wp) ::   zchl, zxsi0r
-      REAL(wp) ::   zc0 , zc1 , zc2, zc3
+      REAL(wp) ::   zc0 , zc1 , zc2, zc3, z1_dep
       !!---------------------------------------------------------------------
 
-      IF(  wrk_in_use(2, 1,2)   .OR.   wrk_in_use(3, 2,3,4,5,6,7,8)   ) THEN
+      IF(  wrk_in_use(2, 1,2,3,4)   .OR.   wrk_in_use(3, 2,3,4,5,6,7,8)   ) THEN
          CALL ctl_stop('p4z_opt: requested workspace arrays unavailable')   ;   RETURN
       ENDIF
@@ -83,5 +85,5 @@
             DO ji = 1, jpi
                zchl = ( trn(ji,jj,jk,jpnch) + trn(ji,jj,jk,jpdch) + rtrn ) * 1.e6
-               zchl = MIN(  10. , MAX( 0.03, zchl )  )
+               zchl = MIN(  10. , MAX( 0.05, zchl )  )
                irgb = NINT( 41 + 20.* LOG10( zchl ) + rtrn )
                !                                                         
@@ -92,8 +94,4 @@
          END DO
       END DO
-
-!!gm  Potential BUG  must discuss with Olivier about this implementation....
-!!gm           the questions are : - PAR at T-point or mean PAR over T-level....
-!!gm                               - shallow water: no penetration of light through the bottom....
 
 
@@ -145,5 +143,5 @@
          etot3(:,:,1) =          qsr(:,:) * tmask(:,:,1)
          !
-         DO jk = 2, nksrp+1
+         DO jk = 2, nksrp + 1
 !CDIR NOVERRCHK
             DO jj = 1, jpj
@@ -188,5 +186,6 @@
       zdepmoy(:,:)   = 0.e0                    !  -------------------------------
       zetmp  (:,:)   = 0.e0
-      emoy   (:,:,:) = 0.e0
+      zetmp1 (:,:)   = 0.e0
+      zetmp2 (:,:)   = 0.e0
 
       DO jk = 1, nksrp
@@ -196,5 +195,7 @@
             DO ji = 1, jpi
                IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
-                  zetmp  (ji,jj) = zetmp  (ji,jj) + etot(ji,jj,jk) * fse3t(ji,jj,jk)
+                  zetmp  (ji,jj) = zetmp  (ji,jj) + etot (ji,jj,jk) * fse3t(ji,jj,jk)
+                  zetmp1 (ji,jj) = zetmp1 (ji,jj) + enano(ji,jj,jk) * fse3t(ji,jj,jk)
+                  zetmp2 (ji,jj) = zetmp2 (ji,jj) + ediat(ji,jj,jk) * fse3t(ji,jj,jk)
                   zdepmoy(ji,jj) = zdepmoy(ji,jj) + fse3t(ji,jj,jk)
                ENDIF
@@ -210,5 +211,10 @@
 !CDIR NOVERRCHK
             DO ji = 1, jpi
-               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) )   emoy(ji,jj,jk) = zetmp(ji,jj) / ( zdepmoy(ji,jj) + rtrn )
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
+                  z1_dep = 1. / ( zdepmoy(ji,jj) + rtrn )
+                  emoy (ji,jj,jk) = zetmp (ji,jj) * z1_dep
+                  enano(ji,jj,jk) = zetmp1(ji,jj) * z1_dep
+                  ediat(ji,jj,jk) = zetmp2(ji,jj) * z1_dep
+               ENDIF
             END DO
          END DO
@@ -218,9 +224,9 @@
 # if ! defined key_iomput
       ! save for outputs
-      trc2d(:,:,  jp_pcs0_2d + 10) = heup(:,:  ) * tmask(:,:,1)  
+      trc2d(:,:,  jp_pcs0_2d + 10) = heup(:,:  ) * tmask(:,:,1)
       trc3d(:,:,:,jp_pcs0_3d + 3)  = etot(:,:,:) * tmask(:,:,:)
 # else
       ! write diagnostics 
-      IF( jnt == nrdttrc ) then 
+      IF( jnt == nrdttrc ) then
          CALL iom_put( "Heup", heup(:,:  ) * tmask(:,:,1) )  ! euphotic layer deptht
          CALL iom_put( "PAR" , etot(:,:,:) * tmask(:,:,:) )  ! Photosynthetically Available Radiation
@@ -229,6 +235,6 @@
 #endif
       !
-      IF(  wrk_not_released(2, 1,2)           .OR.   &
-           wrk_not_released(3, 2,3,4,5,6,7,8)   )   CALL ctl_stop('p4z_opt: failed to release workspace arrays')
+      IF( wrk_not_released(2, 1,2,3,4)           .OR.   &
+          wrk_not_released(3, 2,3,4,5,6,7,8)   )   CALL ctl_stop('p4z_opt: failed to release workspace arrays')
       !
    END SUBROUTINE p4z_opt
