Index: branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90
===================================================================
--- branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 9125)
+++ branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 9169)
@@ -4,8 +4,8 @@
    !! TOP - PISCES : Compute the light availability in the water column
    !!======================================================================
-   !! History :   1.0  !  2004     (O. Aumont) Original code
-   !!             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
+   !! History :  1.0  !  2004     (O. Aumont) Original code
+   !!            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
    !!----------------------------------------------------------------------
    !!   p4z_opt       : light availability in the water column
@@ -15,6 +15,6 @@
    USE sms_pisces     ! Source Minus Sink of PISCES
    USE iom            ! I/O manager
-   USE fldread         !  time interpolation
-   USE prtctl_trc      !  print control for debugging
+   USE fldread        !  time interpolation
+   USE prtctl_trc     !  print control for debugging
 
    IMPLICIT NONE
@@ -27,18 +27,18 @@
    !! * Shared module variables
 
-   LOGICAL  :: ln_varpar   !: boolean for variable PAR fraction
-   REAL(wp) :: parlux      !: Fraction of shortwave as PAR
-   REAL(wp) :: xparsw                 !: parlux/3
-   REAL(wp) :: xsi0r                 !:  1. /rn_si0
+   LOGICAL  ::   ln_varpar   ! boolean for variable PAR fraction
+   REAL(wp) ::   parlux      ! Fraction of shortwave as PAR
+   REAL(wp) ::   xparsw      ! parlux/3
+   REAL(wp) ::   xsi0r       ! 1. /rn_si0
 
    TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_par      ! structure of input par
    INTEGER , PARAMETER :: nbtimes = 366  !: maximum number of times record in a file
    INTEGER  :: ntimes_par                ! number of time steps in a file
-   REAL(wp), ALLOCATABLE, SAVE,   DIMENSION(:,:) :: par_varsw    !: PAR fraction of shortwave
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ekb, ekg, ekr  !: wavelength (Red-Green-Blue)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   par_varsw      ! PAR fraction of shortwave
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ekb, ekg, ekr  ! wavelength (Red-Green-Blue)
 
    INTEGER  ::   nksrp   ! levels below which the light cannot penetrate ( depth larger than 391 m)
 
-   REAL(wp), DIMENSION(3,61) ::   xkrgb   !: tabulated attenuation coefficients for RGB absorption
+   REAL(wp), DIMENSION(3,61) ::   xkrgb   ! tabulated attenuation coefficients for RGB absorption
    
    !!----------------------------------------------------------------------
@@ -70,10 +70,8 @@
       !!---------------------------------------------------------------------
       !
-      IF( ln_timing )  CALL timing_start('p4z_opt')
-      !
-      ! Allocate temporary workspace
-      IF( ln_p5z ) ALLOCATE( zetmp5(jpi,jpj) )
-
-      IF( knt == 1 .AND. ln_varpar ) CALL p4z_opt_sbc( kt )
+      IF( ln_timing )   CALL timing_start('p4z_opt')
+      IF( ln_p5z    )   ALLOCATE( zetmp5(jpi,jpj) )
+
+      IF( knt == 1 .AND. ln_varpar )   CALL p4z_opt_sbc( kt )
 
       !     Initialisation of variables used to compute PAR
@@ -84,7 +82,7 @@
       !
       !                                        !* attenuation coef. function of Chlorophyll and wavelength (Red-Green-Blue)
-                                               !  --------------------------------------------------------
-                    zchl3d(:,:,:) = trb(:,:,:,jpnch) + trb(:,:,:,jpdch)
-      IF( ln_p5z )  zchl3d(:,:,:) = zchl3d(:,:,:) + trb(:,:,:,jppch)
+      !                                        !  --------------------------------------------------------
+                     zchl3d(:,:,:) = trb(:,:,:,jpnch) + trb(:,:,:,jpdch)
+      IF( ln_p5z )   zchl3d(:,:,:) = zchl3d(:,:,:)    + trb(:,:,:,jppch)
       !
       DO jk = 1, jpkm1   
@@ -105,5 +103,5 @@
       IF( l_trcdm2dc ) THEN                     !  diurnal cycle
          !
-         zqsr_corr(:,:) = qsr_mean(:,:) / ( 1. - fr_i(:,:) + rtrn )
+         zqsr_corr(:,:) = qsr_mean(:,:) / ( 1.-fr_i(:,:) + rtrn )
          !
          CALL p4z_opt_par( kt, zqsr_corr, ze1, ze2, ze3, pqsr100 = zqsr100 ) 
@@ -120,5 +118,5 @@
          ENDIF
          !
-         zqsr_corr(:,:) = qsr(:,:) / ( 1. - fr_i(:,:) + rtrn )
+         zqsr_corr(:,:) = qsr(:,:) / ( 1.-fr_i(:,:) + rtrn )
          !
          CALL p4z_opt_par( kt, zqsr_corr, ze1, ze2, ze3 ) 
@@ -130,5 +128,5 @@
       ELSE
          !
-         zqsr_corr(:,:) = qsr(:,:) / ( 1. - fr_i(:,:) + rtrn )
+         zqsr_corr(:,:) = qsr(:,:) / ( 1.-fr_i(:,:) + rtrn )
          !
          CALL p4z_opt_par( kt, zqsr_corr, ze1, ze2, ze3, pqsr100 = zqsr100  ) 
@@ -240,7 +238,6 @@
       ENDIF
       !
-      IF( ln_p5z ) DEALLOCATE( zetmp5 )
-      !
-      IF( ln_timing )  CALL timing_stop('p4z_opt')
+      IF( ln_p5z    )   DEALLOCATE( zetmp5 )
+      IF( ln_timing )   CALL timing_stop('p4z_opt')
       !
    END SUBROUTINE p4z_opt
@@ -255,13 +252,12 @@
       !!
       !!----------------------------------------------------------------------
-      !! * arguments
-      INTEGER, INTENT(in)                                       ::  kt            !   ocean time-step
-      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in)              ::  pqsr          !   shortwave
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::  pe1 , pe2 , pe3   !  PAR ( R-G-B)
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout), OPTIONAL ::  pe0  
-      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(out)  , OPTIONAL  ::  pqsr100  
-      !! * local variables
+      INTEGER                         , INTENT(in)              ::   kt                ! ocean time-step
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   )           ::   pqsr              ! shortwave
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::   pe1 , pe2 , pe3   ! PAR ( R-G-B)
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout), OPTIONAL ::   pe0               !
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(  out), OPTIONAL ::   pqsr100           !
+      !
       INTEGER    ::   ji, jj, jk     ! dummy loop indices
-      REAL(wp), DIMENSION(jpi,jpj)     ::  zqsr          !   shortwave
+      REAL(wp), DIMENSION(jpi,jpj) ::  zqsr   ! shortwave
       !!----------------------------------------------------------------------
 
@@ -272,5 +268,5 @@
       
       !  Light at the euphotic depth 
-      IF( PRESENT( pqsr100 ) )  pqsr100(:,:) = 0.01 * 3. * zqsr(:,:)
+      IF( PRESENT( pqsr100 ) )   pqsr100(:,:) = 0.01 * 3. * zqsr(:,:)
 
       IF( PRESENT( pe0 ) ) THEN     !  W-level
@@ -285,7 +281,7 @@
                DO ji = 1, jpi
                   pe0(ji,jj,jk) = pe0(ji,jj,jk-1) * EXP( -e3t_n(ji,jj,jk-1) * xsi0r )
-                  pe1(ji,jj,jk) = pe1(ji,jj,jk-1) * EXP( -ekb(ji,jj,jk-1 ) )
-                  pe2(ji,jj,jk) = pe2(ji,jj,jk-1) * EXP( -ekg(ji,jj,jk-1 ) )
-                  pe3(ji,jj,jk) = pe3(ji,jj,jk-1) * EXP( -ekr(ji,jj,jk-1 ) )
+                  pe1(ji,jj,jk) = pe1(ji,jj,jk-1) * EXP( -ekb  (ji,jj,jk-1 )        )
+                  pe2(ji,jj,jk) = pe2(ji,jj,jk-1) * EXP( -ekg  (ji,jj,jk-1 )        )
+                  pe3(ji,jj,jk) = pe3(ji,jj,jk-1) * EXP( -ekr  (ji,jj,jk-1 )        )
                END DO
               !
@@ -327,5 +323,5 @@
       !!
       !!----------------------------------------------------------------------
-      INTEGER ,                INTENT(in) ::   kt     ! ocean time step
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
       !
       INTEGER  :: ji,jj
@@ -357,8 +353,6 @@
       !! ** Input   :   external ascii and netcdf files
       !!----------------------------------------------------------------------
-      INTEGER :: numpar
-      INTEGER :: ierr
-      INTEGER :: ios                 ! Local integer output status for namelist read
-      REAL(wp), DIMENSION(nbtimes) :: zsteps                 ! times records
+      INTEGER :: numpar, ierr, ios   ! Local integer 
+      REAL(wp), DIMENSION(nbtimes) ::   zsteps   ! times records
       !
       CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
@@ -367,20 +361,21 @@
       NAMELIST/nampisopt/cn_dir, sn_par, ln_varpar, parlux
       !!----------------------------------------------------------------------
-
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'p4z_opt_init : '
+         WRITE(numout,*) '~~~~~~~~~~~~ '
+      ENDIF
       REWIND( numnatp_ref )              ! Namelist nampisopt in reference namelist : Pisces attenuation coef. and PAR
       READ  ( numnatp_ref, nampisopt, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisopt in reference namelist', lwp )
-
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisopt in reference namelist', lwp )
       REWIND( numnatp_cfg )              ! Namelist nampisopt in configuration namelist : Pisces attenuation coef. and PAR
       READ  ( numnatp_cfg, nampisopt, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisopt in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisopt in configuration namelist', lwp )
       IF(lwm) WRITE ( numonp, nampisopt )
 
       IF(lwp) THEN
-         WRITE(numout,*) ' '
-         WRITE(numout,*) ' namelist : nampisopt '
-         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~ '
-         WRITE(numout,*) '    PAR as a variable fraction of SW     ln_varpar      = ', ln_varpar
-         WRITE(numout,*) '    Default value for the PAR fraction   parlux         = ', parlux
+         WRITE(numout,*) '   Namelist : nampisopt '
+         WRITE(numout,*) '      PAR as a variable fraction of SW     ln_varpar      = ', ln_varpar
+         WRITE(numout,*) '      Default value for the PAR fraction   parlux         = ', parlux
       ENDIF
       !
@@ -391,6 +386,6 @@
       ! ----------------------------------------
       IF( ln_varpar ) THEN
-         IF(lwp) WRITE(numout,*) '    initialize variable par fraction '
-         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   ==>>>   initialize variable par fraction (ln_varpar=T)'
          !
          ALLOCATE( par_varsw(jpi,jpj) )
