Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/readchlorophyll.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/readchlorophyll.F90	(revision 3024)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/readchlorophyll.F90	(revision 3356)
@@ -2,55 +2,52 @@
 ! $Id$
 !
+!--This routine is to be tested with MPI / OMP parallelism 
+!--OB 26/03/2018
 
-subroutine readchlorophyll(debut)
+SUBROUTINE readchlorophyll(debut)
 
-    use netcdf95, only: nf95_close, nf95_gw_var, nf95_inq_dimid, & 
-                        nf95_inq_varid, nf95_open
-    use netcdf, only: nf90_get_var, nf90_noerr, nf90_nowrite
-
-    USE phys_cal_mod, ONLY : mth_cur
-    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo, &
-                                 grid2dto1d_glo
-    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    USE netcdf95, ONLY: nf95_close, nf95_gw_var, nf95_inq_dimid, nf95_inq_varid, nf95_open
+    USE netcdf, ONLY: nf90_get_var, nf90_noerr, nf90_nowrite
+    USE phys_cal_mod, ONLY: mth_cur
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo, grid2dto1d_glo
+    USE mod_phys_lmdz_mpi_data, ONLY: is_mpi_root
+    USE mod_phys_lmdz_omp_data, ONLY: is_omp_root
     USE mod_phys_lmdz_para, ONLY: scatter 
     USE phys_state_var_mod, ONLY: chl_con
 
-    implicit none
+    IMPLICIT NONE
 
-    include "YOMCST.h"
+    INCLUDE "YOMCST.h"
 
 ! Variable input
-    logical debut
+    LOGICAL debut
 
 ! Variables locales
-    integer n_lat   ! number of latitudes in the input data
-    integer n_lon   ! number of longitudes in the input data
-    integer n_lev   ! number of levels in the input data
-    integer n_month ! number of months in the input data
-    real, pointer:: latitude(:)
-    real, pointer:: longitude(:)
-    real, pointer:: time(:)
-    integer i, k
-    integer, save :: mth_pre
+    INTEGER n_lat   ! number of latitudes in the input data
+    INTEGER n_lon   ! number of longitudes in the input data
+    INTEGER n_lev   ! number of levels in the input data
+    INTEGER n_month ! number of months in the input data
+    REAL, POINTER :: latitude(:)
+    REAL, POINTER :: longitude(:)
+    REAL, POINTER :: time(:)
+    INTEGER i, k
+    INTEGER, SAVE :: mth_pre
 !$OMP THREADPRIVATE(mth_pre)
 
 ! Champs reconstitues
-    real, allocatable:: chlorocon(:, :, :)
-    real, allocatable:: chlorocon_mois(:, :)
-    real, allocatable:: chlorocon_mois_glo(:)
+    REAL, ALLOCATABLE :: chlorocon(:, :, :)
+    REAL, ALLOCATABLE :: chlorocon_mois(:, :)
+    REAL, ALLOCATABLE :: chlorocon_mois_glo(:)
 
 ! For NetCDF:
-    integer ncid_in  ! IDs for input files
-    integer varid, ncerr
-
+    INTEGER ncid_in  ! IDs for input files
+    INTEGER varid, ncerr
 
 !--------------------------------------------------------
-
 
 !--only read file if beginning of run or start of new month
     IF (debut.OR.mth_cur.NE.mth_pre) THEN
 
-    IF (is_mpi_root) THEN
-
+    IF (is_mpi_root.AND.is_omp_root) THEN
 
     CALL nf95_open("chlorophyll.nc", nf90_nowrite, ncid_in)
@@ -64,5 +61,4 @@
        STOP
     ENDIF
-
 
     CALL nf95_inq_varid(ncid_in, "lat", varid)
@@ -104,14 +100,10 @@
     CALL grid2dTo1d_glo(chlorocon_mois,chlorocon_mois_glo)
 
-
-    print*,"chrolophyll current month",mth_cur
-    do i=1,klon_glo
+    print *,"chrolophyll current month",mth_cur
+    DO i=1,klon_glo
 !      if(isnan(chlorocon_mois_glo(i)))then ! isnan() is not in the Fortran standard...
 !      Another way to check for NaN:
-       if(chlorocon_mois_glo(i).ne.chlorocon_mois_glo(i)) then
-         chlorocon_mois_glo(i)=0.
-      endif
-      !print*,"high chl con",i,chlorocon_mois_glo(i)
-    enddo
+       IF (chlorocon_mois_glo(i).NE.chlorocon_mois_glo(i)) chlorocon_mois_glo(i)=0.
+    ENDDO
 
 !    DEALLOCATE(chlorocon)
@@ -119,5 +111,5 @@
 !    DEALLOCATE(chlorocon_mois_glo)
   
-    ENDIF !--is_mpi_root
+    ENDIF !--is_mpi_root and is_omp_root
 
 !--scatter on all proc
@@ -129,3 +121,3 @@
     ENDIF !--debut ou nouveau mois
 
-end subroutine readchlorophyll
+END SUBROUTINE readchlorophyll
