Index: NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/TOP/PISCES/P4Z/p4zprod.F90
===================================================================
--- NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/TOP/PISCES/P4Z/p4zprod.F90	(revision 12210)
+++ NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/TOP/PISCES/P4Z/p4zprod.F90	(revision 12257)
@@ -89,9 +89,9 @@
       !  Allocate temporary workspace
       !
-      zprorcan(:,:,:) = 0._wp ; zprorcad(:,:,:) = 0._wp ; zprofed (:,:,:) = 0._wp
-      zprofen (:,:,:) = 0._wp ; zysopt  (:,:,:) = 0._wp
-      zpronewn(:,:,:) = 0._wp ; zpronewd(:,:,:) = 0._wp ; zprdia  (:,:,:) = 0._wp
-      zprbio  (:,:,:) = 0._wp ; zprdch  (:,:,:) = 0._wp ; zprnch  (:,:,:) = 0._wp 
-      zmxl_fac(:,:,:) = 0._wp ; zmxl_chl(:,:,:) = 0._wp 
+      zprorcan(:,:,jpk) = 0._wp ; zprorcad(:,:,jpk) = 0._wp ; zprofed (:,:,jpk) = 0._wp
+      zprofen (:,:,jpk) = 0._wp ; zysopt  (:,:,jpk) = 0._wp
+      zpronewn(:,:,jpk) = 0._wp ; zpronewd(:,:,jpk) = 0._wp ; zprdia  (:,:,jpk) = 0._wp
+      zprbio  (:,:,jpk) = 0._wp ; zprdch  (:,:,jpk) = 0._wp ; zprnch  (:,:,jpk) = 0._wp 
+      zmxl_fac(:,:,jpk) = 0._wp ; zmxl_chl(:,:,jpk) = 0._wp 
 
       ! Computation of the optimal production
@@ -320,5 +320,5 @@
      !
      IF( ln_ligand ) THEN
-         zpligprod1(:,:,:) = 0._wp    ;    zpligprod2(:,:,:) = 0._wp
+         zpligprod1(:,:,jpk) = 0._wp    ;    zpligprod2(:,:,jpk) = 0._wp
          DO jk = 1, jpkm1
             DO jj = 1, jpj
@@ -341,117 +341,25 @@
          & tpp = glob_sum( 'p4zprod', ( zprorcan(:,:,:) + zprorcad(:,:,:) ) * cvol(:,:,:) )
 
-    IF( lk_iomput ) THEN
-       IF( knt == nrdttrc ) THEN
-          ALLOCATE( zw2d(jpi,jpj), zw3d(jpi,jpj,jpk) )
-          zfact = 1.e+3 * rfact2r  !  conversion from mol/l/kt to  mol/m3/s
-          !
-          IF( iom_use( "PPPHYN" ) .OR. iom_use( "PPPHYD" ) )  THEN
-              zw3d(:,:,:) = zprorcan(:,:,:) * zfact * tmask(:,:,:)  ! primary production by nanophyto
-              CALL iom_put( "PPPHYN"  , zw3d )
-              !
-              zw3d(:,:,:) = zprorcad(:,:,:) * zfact * tmask(:,:,:)  ! primary production by diatomes
-              CALL iom_put( "PPPHYD"  , zw3d )
-          ENDIF
-          IF( iom_use( "PPNEWN" ) .OR. iom_use( "PPNEWD" ) )  THEN
-              zw3d(:,:,:) = zpronewn(:,:,:) * zfact * tmask(:,:,:)  ! new primary production by nanophyto
-              CALL iom_put( "PPNEWN"  , zw3d )
-              !
-              zw3d(:,:,:) = zpronewd(:,:,:) * zfact * tmask(:,:,:)  ! new primary production by diatomes
-              CALL iom_put( "PPNEWD"  , zw3d )
-          ENDIF
-          IF( iom_use( "PBSi" ) )  THEN
-              zw3d(:,:,:) = zprorcad(:,:,:) * zfact * tmask(:,:,:) * zysopt(:,:,:) ! biogenic silica production
-              CALL iom_put( "PBSi"  , zw3d )
-          ENDIF
-          IF( iom_use( "PFeN" ) .OR. iom_use( "PFeD" ) )  THEN
-              zw3d(:,:,:) = zprofen(:,:,:) * zfact * tmask(:,:,:)  ! biogenic iron production by nanophyto
-              CALL iom_put( "PFeN"  , zw3d )
-              !
-              zw3d(:,:,:) = zprofed(:,:,:) * zfact * tmask(:,:,:)  ! biogenic iron production by  diatomes
-              CALL iom_put( "PFeD"  , zw3d )
-          ENDIF
-          IF( iom_use( "LPRODP" ) )  THEN
-              zw3d(:,:,:) = zpligprod1(:,:,:) * 1e9 * zfact * tmask(:,:,:)
-              CALL iom_put( "LPRODP"  , zw3d )
-          ENDIF
-          IF( iom_use( "LDETP" ) )  THEN
-              zw3d(:,:,:) = zpligprod2(:,:,:) * 1e9 * zfact * tmask(:,:,:)
-              CALL iom_put( "LDETP"  , zw3d )
-          ENDIF
-          IF( iom_use( "Mumax" ) )  THEN
-              zw3d(:,:,:) = zprmaxn(:,:,:) * tmask(:,:,:)   ! Maximum growth rate
-              CALL iom_put( "Mumax"  , zw3d )
-          ENDIF
-          IF( iom_use( "MuN" ) .OR. iom_use( "MuD" ) )  THEN
-              zw3d(:,:,:) = zprbio(:,:,:) * xlimphy(:,:,:) * tmask(:,:,:)  ! Realized growth rate for nanophyto
-              CALL iom_put( "MuN"  , zw3d )
-              !
-              zw3d(:,:,:) =  zprdia(:,:,:) * xlimdia(:,:,:) * tmask(:,:,:)  ! Realized growth rate for diatoms
-              CALL iom_put( "MuD"  , zw3d )
-          ENDIF
-          IF( iom_use( "LNlight" ) .OR. iom_use( "LDlight" ) )  THEN
-              zw3d(:,:,:) = zprbio (:,:,:) / (zprmaxn(:,:,:) + rtrn) * tmask(:,:,:) ! light limitation term
-              CALL iom_put( "LNlight"  , zw3d )
-              !
-              zw3d(:,:,:) = zprdia (:,:,:) / (zprmaxd(:,:,:) + rtrn) * tmask(:,:,:)  ! light limitation term
-              CALL iom_put( "LDlight"  , zw3d )
-          ENDIF
-          IF( iom_use( "TPP" ) )  THEN
-              zw3d(:,:,:) = ( zprorcan(:,:,:) + zprorcad(:,:,:) ) * zfact * tmask(:,:,:)  ! total primary production
-              CALL iom_put( "TPP"  , zw3d )
-          ENDIF
-          IF( iom_use( "TPNEW" ) )  THEN
-              zw3d(:,:,:) = ( zpronewn(:,:,:) + zpronewd(:,:,:) ) * zfact * tmask(:,:,:)  ! total new production
-              CALL iom_put( "TPNEW"  , zw3d )
-          ENDIF
-          IF( iom_use( "TPBFE" ) )  THEN
-              zw3d(:,:,:) = ( zprofen(:,:,:) + zprofed(:,:,:) ) * zfact * tmask(:,:,:)  ! total biogenic iron production
-              CALL iom_put( "TPBFE"  , zw3d )
-          ENDIF
-          IF( iom_use( "INTPPPHYN" ) .OR. iom_use( "INTPPPHYD" ) ) THEN  
-             zw2d(:,:) = 0.
-             DO jk = 1, jpkm1
-               zw2d(:,:) = zw2d(:,:) + zprorcan(:,:,jk) * e3t_n(:,:,jk) * zfact * tmask(:,:,jk)  ! vert. integrated  primary produc. by nano
-             ENDDO
-             CALL iom_put( "INTPPPHYN" , zw2d )
-             !
-             zw2d(:,:) = 0.
-             DO jk = 1, jpkm1
-                zw2d(:,:) = zw2d(:,:) + zprorcad(:,:,jk) * e3t_n(:,:,jk) * zfact * tmask(:,:,jk) ! vert. integrated  primary produc. by diatom
-             ENDDO
-             CALL iom_put( "INTPPPHYD" , zw2d )
-          ENDIF
-          IF( iom_use( "INTPP" ) ) THEN   
-             zw2d(:,:) = 0.
-             DO jk = 1, jpkm1
-                zw2d(:,:) = zw2d(:,:) + ( zprorcan(:,:,jk) + zprorcad(:,:,jk) ) * e3t_n(:,:,jk) * zfact * tmask(:,:,jk) ! vert. integrated pp
-             ENDDO
-             CALL iom_put( "INTPP" , zw2d )
-          ENDIF
-          IF( iom_use( "INTPNEW" ) ) THEN    
-             zw2d(:,:) = 0.
-             DO jk = 1, jpkm1
-                zw2d(:,:) = zw2d(:,:) + ( zpronewn(:,:,jk) + zpronewd(:,:,jk) ) * e3t_n(:,:,jk) * zfact * tmask(:,:,jk)  ! vert. integrated new prod
-             ENDDO
-             CALL iom_put( "INTPNEW" , zw2d )
-          ENDIF
-          IF( iom_use( "INTPBFE" ) ) THEN           !   total biogenic iron production  ( vertically integrated )
-             zw2d(:,:) = 0.
-             DO jk = 1, jpkm1
-                zw2d(:,:) = zw2d(:,:) + ( zprofen(:,:,jk) + zprofed(:,:,jk) ) * e3t_n(:,:,jk) * zfact * tmask(:,:,jk) ! vert integr. bfe prod
-             ENDDO
-            CALL iom_put( "INTPBFE" , zw2d )
-          ENDIF
-          IF( iom_use( "INTPBSI" ) ) THEN           !   total biogenic silica production  ( vertically integrated )
-             zw2d(:,:) = 0.
-             DO jk = 1, jpkm1
-                zw2d(:,:) = zw2d(:,:) + zprorcad(:,:,jk) * zysopt(:,:,jk) * e3t_n(:,:,jk) * zfact * tmask(:,:,jk)  ! vert integr. bsi prod
-             ENDDO
-             CALL iom_put( "INTPBSI" , zw2d )
-          ENDIF
-          IF( iom_use( "tintpp" ) )  CALL iom_put( "tintpp" , tpp * zfact )  !  global total integrated primary production molC/s
-          !
-          DEALLOCATE( zw2d, zw3d )
-       ENDIF
+    IF( lk_iomput .AND.  knt == nrdttrc ) THEN
+       zfact = 1.e+3 * rfact2r  !  conversion from mol/l/kt to  mol/m3/s
+       !
+       CALL iom_put( "PPPHYN"  , zprorcan(:,:,:) * zfact * tmask(:,:,:) )  ! primary production by nanophyto
+       CALL iom_put( "PPPHYD"  , zprorcad(:,:,:) * zfact * tmask(:,:,:)   ) ! primary production by diatomes
+       CALL iom_put( "PPNEWN"  , zpronewn(:,:,:) * zfact * tmask(:,:,:)    ) ! new primary production by nanophyto
+       CALL iom_put( "PPNEWD"  , zpronewd(:,:,:) * zfact * tmask(:,:,:)   ) ! new primary production by diatomes
+       CALL iom_put( "PBSi"    , zprorcad(:,:,:) * zfact * tmask(:,:,:) * zysopt(:,:,:)  ) ! biogenic silica production
+       CALL iom_put( "PFeN"    , zprofen(:,:,:) * zfact * tmask(:,:,:)  ) ! biogenic iron production by nanophyto
+       CALL iom_put( "PFeD"    , zprofed(:,:,:) * zfact * tmask(:,:,:)  ) ! biogenic iron production by  diatomes
+       CALL iom_put( "LPRODP"  , zpligprod1(:,:,:) * 1e9 * zfact * tmask(:,:,:) )
+       CALL iom_put( "LDETP"   , zpligprod2(:,:,:) * 1e9 * zfact * tmask(:,:,:) )
+       CALL iom_put( "Mumax"   , zprmaxn(:,:,:) * tmask(:,:,:)  ) ! Maximum growth rate
+       CALL iom_put( "MuN"     , zprbio(:,:,:) * xlimphy(:,:,:) * tmask(:,:,:) ) ! Realized growth rate for nanophyto
+       CALL iom_put( "MuD"     , zprdia(:,:,:) * xlimdia(:,:,:) * tmask(:,:,:) ) ! Realized growth rate for diatoms
+       CALL iom_put( "LNlight" , zprbio (:,:,:) / (zprmaxn(:,:,:) + rtrn) * tmask(:,:,:)  )  ! light limitation term
+       CALL iom_put( "LDlight" , zprdia (:,:,:) / (zprmaxd(:,:,:) + rtrn) * tmask(:,:,:)   )
+       CALL iom_put( "TPP"     , ( zprorcan(:,:,:) + zprorcad(:,:,:) ) * zfact * tmask(:,:,:)  )  ! total primary production
+       CALL iom_put( "TPNEW"   , ( zpronewn(:,:,:) + zpronewd(:,:,:) ) * zfact * tmask(:,:,:)  ) ! total new production
+       CALL iom_put( "TPBFE"   , ( zprofen(:,:,:) + zprofed(:,:,:) ) * zfact * tmask(:,:,:)  )  ! total biogenic iron production
+       CALL iom_put( "tintpp"  , tpp * zfact )  !  global total integrated primary production molC/s
      ENDIF
 
