Index: LMDZ5/trunk/libf/phylmd/iophy.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/iophy.F90	(revision 2319)
+++ LMDZ5/trunk/libf/phylmd/iophy.F90	(revision 2344)
@@ -54,5 +54,5 @@
 #endif
   IMPLICIT NONE
-  INCLUDE 'dimensions.h'
+!  INCLUDE 'dimensions.h'
     REAL,DIMENSION(klon),INTENT(IN) :: rlon
     REAL,DIMENSION(klon),INTENT(IN) :: rlat
@@ -77,15 +77,20 @@
     
 !$OMP MASTER  
-    ALLOCATE(io_lat(jjm+1-1/(iim*jjm)))
+    ALLOCATE(io_lat(nbp_lat-1/(nbp_lon*(nbp_lat-1))))
     io_lat(1)=rlat_glo(1)
-    io_lat(jjm+1-1/(iim*jjm))=rlat_glo(klon_glo)
-    IF ((iim*jjm) > 1) then
-      DO i=2,jjm
-        io_lat(i)=rlat_glo(2+(i-2)*iim)
+    io_lat(nbp_lat-1/(nbp_lon*(nbp_lat-1)))=rlat_glo(klon_glo)
+    IF ((nbp_lon*nbp_lat) > 1) then
+      DO i=2,nbp_lat-1
+        io_lat(i)=rlat_glo(2+(i-2)*nbp_lon)
       ENDDO
     ENDIF
 
-    ALLOCATE(io_lon(iim))
-    io_lon(:)=rlon_glo(2-1/(iim*jjm):iim+1-1/(iim*jjm))
+    ALLOCATE(io_lon(nbp_lon))
+    IF (klon_glo == 1) THEN
+      io_lon(1)=rlon_glo(1)
+    ELSE 
+      io_lon(1:nbp_lon)=rlon_glo(2:nbp_lon+1)
+    ENDIF
+
 !! (I) dtnb   : total number of domains
 !! (I) dnb    : domain number
@@ -104,13 +109,13 @@
 
     ddid=(/ 1,2 /)
-    dsg=(/ iim, jjm+1-1/(iim*jjm) /)
-    dsl=(/ iim, jj_nb /)
+    dsg=(/ nbp_lon, nbp_lat /)
+    dsl=(/ nbp_lon, jj_nb /)
     dpf=(/ 1,jj_begin /)
-    dpl=(/ iim, jj_end /)
+    dpl=(/ nbp_lon, jj_end /)
     dhs=(/ ii_begin-1,0 /)
     IF (mpi_rank==mpi_size-1) THEN
       dhe=(/0,0/)
     ELSE
-      dhe=(/ iim-ii_end,0 /)  
+      dhe=(/ nbp_lon-ii_end,0 /)  
     ENDIF
 
@@ -155,8 +160,8 @@
                                 mpi_size, mpi_rank 
   USE ioipsl, only: flio_dom_set
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   IMPLICIT NONE
-  INCLUDE 'dimensions.h'   
-    REAL,DIMENSION(iim),INTENT(IN) :: lon
-    REAL,DIMENSION(jjm+1-1/(iim*jjm)),INTENT(IN) :: lat
+    REAL,DIMENSION(nbp_lon),INTENT(IN) :: lon
+    REAL,DIMENSION(nbp_lat),INTENT(IN) :: lat
 
     INTEGER,DIMENSION(2) :: ddid
@@ -169,19 +174,19 @@
 
 !$OMP MASTER  
-    allocate(io_lat(jjm+1-1/(iim*jjm)))
+    allocate(io_lat(nbp_lat))
     io_lat(:)=lat(:)
-    allocate(io_lon(iim))
+    allocate(io_lon(nbp_lon))
     io_lon(:)=lon(:)
    
     ddid=(/ 1,2 /)
-    dsg=(/ iim, jjm+1-1/(iim*jjm) /)
-    dsl=(/ iim, jj_nb /)
+    dsg=(/ nbp_lon, nbp_lat /)
+    dsl=(/ nbp_lon, jj_nb /)
     dpf=(/ 1,jj_begin /)
-    dpl=(/ iim, jj_end /)
+    dpl=(/ nbp_lon, jj_end /)
     dhs=(/ ii_begin-1,0 /)
     if (mpi_rank==mpi_size-1) then
       dhe=(/0,0/)
     else
-      dhe=(/ iim-ii_end,0 /)  
+      dhe=(/ nbp_lon-ii_end,0 /)  
     endif
     
@@ -198,4 +203,5 @@
   USE mod_phys_lmdz_para, only: is_sequential, is_using_mpi, is_mpi_root, &
                                 jj_begin, jj_end, jj_nb
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   use ioipsl, only: histbeg
 #ifdef CPP_XIOS
@@ -203,5 +209,4 @@
 #endif
   IMPLICIT NONE
-  include 'dimensions.h'
   include 'clesphys.h'
     
@@ -217,9 +222,9 @@
 !$OMP MASTER    
     if (is_sequential) then
-      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
-                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
+      call histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
     else
-      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
-                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
+      call histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
     endif
 
@@ -240,8 +245,8 @@
 
   USE mod_phys_lmdz_para, only: jj_begin, jj_end, jj_nb, is_sequential
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   use ioipsl, only: histbeg
 
   IMPLICIT NONE
-  include 'dimensions.h'
     
     character*(*), INTENT(IN) :: name
@@ -255,9 +260,9 @@
 #ifndef CPP_IOIPSL_NO_OUTPUT 
     if (is_sequential) then
-      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
-                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
+      call histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
     else
-      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
-                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
+      call histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
     endif
 #endif
@@ -274,9 +279,8 @@
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 mpi_rank
-  USE mod_grid_phy_lmdz, only: klon_glo
+  USE mod_grid_phy_lmdz, only: klon_glo, nbp_lon, nbp_lat
   use ioipsl, only: histbeg
 
   IMPLICIT NONE
-  include 'dimensions.h' 
 
     REAL,DIMENSION(klon),INTENT(IN) :: rlon
@@ -304,6 +308,5 @@
     REAL, allocatable, DIMENSION(:) :: npplat, npplon
     REAL, allocatable, DIMENSION(:,:) :: npplat_bounds, npplon_bounds
-    INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
-    REAL, DIMENSION(iim,jjmp1) :: zx_lon, zx_lat
+    REAL, DIMENSION(nbp_lon,nbp_lat) :: zx_lon, zx_lat
 
     CALL gather(rlat,rlat_glo)
@@ -330,10 +333,10 @@
      endif
 !
-     IF ( tabij(i).LE.iim) THEN
+     IF ( tabij(i).LE.nbp_lon) THEN
       plat_bounds(i,1)=rlat_glo(tabij(i))
      ELSE
-      plat_bounds(i,1)=rlat_glo(tabij(i)-iim)
+      plat_bounds(i,1)=rlat_glo(tabij(i)-nbp_lon)
      ENDIF
-     plat_bounds(i,2)=rlat_glo(tabij(i)+iim)
+     plat_bounds(i,2)=rlat_glo(tabij(i)+nbp_lon)
 !
 !    print*,'CFMIP_iophy point i lon lon_bds',i,plon_bounds(i,1),rlon_glo(tabij(i)),plon_bounds(i,2) 
@@ -351,12 +354,12 @@
      ENDDO
 
-       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon_glo,zx_lon)
-       if ((iim*jjm).gt.1) then
-       DO i = 1, iim
+       CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,rlon_glo,zx_lon)
+       if ((nbp_lon*nbp_lat).gt.1) then
+       DO i = 1, nbp_lon
          zx_lon(i,1) = rlon_glo(i+1)
-         zx_lon(i,jjmp1) = rlon_glo(i+1)
+         zx_lon(i,nbp_lat) = rlon_glo(i+1)
        ENDDO
        endif
-       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat_glo,zx_lat)
+       CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,rlat_glo,zx_lat)
 
     DO i=1,pim
@@ -367,9 +370,9 @@
 
      if (ipt(i).EQ.1) then
-      plon_bounds(i,1)=zx_lon(iim,jpt(i))
+      plon_bounds(i,1)=zx_lon(nbp_lon,jpt(i))
       plon_bounds(i,2)=360.+zx_lon(ipt(i)+1,jpt(i))
      endif
  
-     if (ipt(i).EQ.iim) then
+     if (ipt(i).EQ.nbp_lon) then
       plon_bounds(i,2)=360.+zx_lon(1,jpt(i))
      endif
@@ -383,7 +386,7 @@
      endif
  
-     if (jpt(i).EQ.jjmp1) then
-      plat_bounds(i,1)=zx_lat(ipt(i),jjmp1)+0.001
-      plat_bounds(i,2)=zx_lat(ipt(i),jjmp1)-0.001
+     if (jpt(i).EQ.nbp_lat) then
+      plat_bounds(i,1)=zx_lat(ipt(i),nbp_lat)+0.001
+      plat_bounds(i,2)=zx_lat(ipt(i),nbp_lat)-0.001
      endif
 !
@@ -451,8 +454,7 @@
     use phys_output_var_mod, only: type_ecri, zoutm, zdtime_moy, lev_files, &
                                    nid_files, nhorim, swaero_diag, nfiles
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     IMPLICIT NONE
 
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
     INCLUDE "clesphys.h"
 
@@ -478,5 +480,5 @@
        IF ( flag_var(iff)<=lev_files(iff) ) THEN
           CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
-               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
+               nbp_lon,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
                type_ecri(iff), zstophym,zoutm(iff))                
        ENDIF
@@ -507,9 +509,7 @@
                                    nhorim, zdtime_moy, levmin, levmax, &
                                    nvertm, nfiles
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     IMPLICIT NONE
 
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
-!    INCLUDE "indicesol.h"
     INCLUDE "clesphys.h"
 
@@ -535,5 +535,5 @@
        IF ( flag_var(iff)<=lev_files(iff) ) THEN
           CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
-               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
+               nbp_lon, jj_nb, nhorim(iff), klev, levmin(iff), &
                levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), &
                zstophym, zoutm(iff))
@@ -564,4 +564,5 @@
                                    nid_files, nhorim, swaero_diag
     USE print_control_mod, ONLY: prt_level,lunout 
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
 #ifdef CPP_XIOS
     use wxios, only: wxios_add_field_to_file
@@ -569,6 +570,4 @@
     IMPLICIT NONE
 
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
     INCLUDE "clesphys.h"
 
@@ -621,5 +620,5 @@
        IF ( var%flag(iff)<=lev_files(iff) ) THEN
           CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
-               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
+               nbp_lon,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
                typeecrit, zstophym,zoutm(iff))                
        ENDIF
@@ -651,4 +650,5 @@
                                    levmax, nvertm
     USE print_control_mod, ONLY: prt_level,lunout
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
 #ifdef CPP_XIOS
     use wxios, only: wxios_add_field_to_file
@@ -656,6 +656,4 @@
     IMPLICIT NONE
 
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
     INCLUDE "clesphys.h"
 
@@ -708,5 +706,5 @@
        IF ( var%flag(iff)<=lev_files(iff) ) THEN
           CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
-               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
+               nbp_lon, jj_nb, nhorim(iff), klev, levmin(iff), &
                levmax(iff)-levmin(iff)+1, nvertm(iff), 32, typeecrit, &
                zstophym, zoutm(iff))
@@ -750,6 +748,6 @@
   USE ioipsl, only: histwrite
   USE print_control_mod, ONLY: prt_level,lunout
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   IMPLICIT NONE
-  include 'dimensions.h'
     
     integer,INTENT(IN) :: nid
@@ -760,5 +758,5 @@
     REAL,DIMENSION(klon_mpi) :: buffer_omp
     INTEGER, allocatable, DIMENSION(:) :: index2d
-    REAL :: Field2d(iim,jj_nb)
+    REAL :: Field2d(nbp_lon,jj_nb)
 
     integer :: ip
@@ -772,8 +770,8 @@
     CALL grid1Dto2D_mpi(buffer_omp,Field2d)
     if(.NOT.lpoint) THEN
-     ALLOCATE(index2d(iim*jj_nb))
-     ALLOCATE(fieldok(iim*jj_nb))
+     ALLOCATE(index2d(nbp_lon*jj_nb))
+     ALLOCATE(fieldok(nbp_lon*jj_nb))
      IF (prt_level >= 10) write(lunout,*)'Sending ',name,' to IOIPSL'
-     CALL histwrite(nid,name,itau,Field2d,iim*jj_nb,index2d)
+     CALL histwrite(nid,name,itau,Field2d,nbp_lon*jj_nb,index2d)
      IF (prt_level >= 10) write(lunout,*)'Finished sending ',name,' to IOIPSL'
     else
@@ -813,8 +811,8 @@
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 jj_nb, klon_mpi
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   use ioipsl, only: histwrite
   USE print_control_mod, ONLY: prt_level,lunout
   IMPLICIT NONE
-  include 'dimensions.h'
     
     integer,INTENT(IN) :: nid
@@ -824,5 +822,5 @@
     REAL,DIMENSION(:,:),INTENT(IN) :: field  ! --> field(klon,:)
     REAL,DIMENSION(klon_mpi,size(field,2)) :: buffer_omp
-    REAL :: Field3d(iim,jj_nb,size(field,2))
+    REAL :: Field3d(nbp_lon,jj_nb,size(field,2))
     INTEGER :: ip, n, nlev
     INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
@@ -837,8 +835,8 @@
     CALL grid1Dto2D_mpi(buffer_omp,field3d)
     if(.NOT.lpoint) THEN
-     ALLOCATE(index3d(iim*jj_nb*nlev))
-     ALLOCATE(fieldok(iim*jj_nb,nlev))
+     ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
+     ALLOCATE(fieldok(nbp_lon*jj_nb,nlev))
      IF (prt_level >= 10) write(lunout,*)'Sending ',name,' to IOIPSL'
-     CALL histwrite(nid,name,itau,Field3d,iim*jj_nb*nlev,index3d)
+     CALL histwrite(nid,name,itau,Field3d,nbp_lon*jj_nb*nlev,index3d)
      IF (prt_level >= 10) write(lunout,*)'Finished sending ',name,' to IOIPSL'
    else
@@ -889,4 +887,5 @@
                                  nid_files
   USE print_control_mod, ONLY: prt_level,lunout
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
 #ifdef CPP_XIOS
   USE xios, only: xios_send_field
@@ -895,5 +894,4 @@
 
   IMPLICIT NONE
-  INCLUDE 'dimensions.h'
   include 'clesphys.h'
 
@@ -908,5 +906,5 @@
     REAL,DIMENSION(klon_mpi) :: buffer_omp
     INTEGER, allocatable, DIMENSION(:) :: index2d
-    REAL :: Field2d(iim,jj_nb)
+    REAL :: Field2d(nbp_lon,jj_nb)
 
     INTEGER :: ip
@@ -989,8 +987,8 @@
 
                   IF(.NOT.clef_stations(iff)) THEN
-                        ALLOCATE(index2d(iim*jj_nb))
-                        ALLOCATE(fieldok(iim*jj_nb))
+                        ALLOCATE(index2d(nbp_lon*jj_nb))
+                        ALLOCATE(fieldok(nbp_lon*jj_nb))
 #ifndef CPP_IOIPSL_NO_OUTPUT 
-                        CALL histwrite(nid_files(iff),var%name,itau_iophy,Field2d,iim*jj_nb,index2d)
+                        CALL histwrite(nid_files(iff),var%name,itau_iophy,Field2d,nbp_lon*jj_nb,index2d)
 #endif
 !#ifdef CPP_XIOS
@@ -1048,4 +1046,5 @@
                                  nfiles, vars_defined, clef_stations, &
                                  nid_files
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
 #ifdef CPP_XIOS
   USE xios, only: xios_send_field
@@ -1054,5 +1053,4 @@
 
   IMPLICIT NONE
-  INCLUDE 'dimensions.h'
   include 'clesphys.h'
 
@@ -1065,5 +1063,5 @@
 !$OMP THREADPRIVATE(firstx)
     REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp
-    REAL :: Field3d(iim,jj_nb,SIZE(field,2))
+    REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2))
     INTEGER :: ip, n, nlev, nlevx
     INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
@@ -1131,5 +1129,5 @@
                   write(lunout,*)'histwrite3d_phy: call xios_send_field for ', &
                                   trim(var%name), ' with iim jjm nlevx = ', &
-                                  iim,jj_nb,nlevx
+                                  nbp_lon,jj_nb,nlevx
                 endif
                 CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
@@ -1138,9 +1136,9 @@
 #endif
                 IF (.NOT.clef_stations(iff)) THEN
-                        ALLOCATE(index3d(iim*jj_nb*nlev))
-                        ALLOCATE(fieldok(iim*jj_nb,nlev))
+                        ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
+                        ALLOCATE(fieldok(nbp_lon*jj_nb,nlev))
 
 #ifndef CPP_IOIPSL_NO_OUTPUT 
-                        CALL histwrite(nid_files(iff),var%name,itau_iophy,Field3d,iim*jj_nb*nlev,index3d)
+                        CALL histwrite(nid_files(iff),var%name,itau_iophy,Field3d,nbp_lon*jj_nb*nlev,index3d)
 #endif
 
@@ -1194,9 +1192,9 @@
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 jj_nb, klon_mpi
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   USE xios, only: xios_send_field
   USE print_control_mod, ONLY: prt_level,lunout
 
   IMPLICIT NONE
-  INCLUDE 'dimensions.h'
 
     CHARACTER(LEN=*), INTENT(IN) :: field_name
@@ -1205,5 +1203,5 @@
     REAL,DIMENSION(klon_mpi) :: buffer_omp
     INTEGER, allocatable, DIMENSION(:) :: index2d
-    REAL :: Field2d(iim,jj_nb)
+    REAL :: Field2d(nbp_lon,jj_nb)
 
     INTEGER :: ip
@@ -1224,6 +1222,6 @@
     !IF(.NOT.clef_stations(iff)) THEN
     IF (.TRUE.) THEN
-        ALLOCATE(index2d(iim*jj_nb))
-        ALLOCATE(fieldok(iim*jj_nb))
+        ALLOCATE(index2d(nbp_lon*jj_nb))
+        ALLOCATE(fieldok(nbp_lon*jj_nb))
 
 
@@ -1265,8 +1263,8 @@
                                 jj_nb, klon_mpi
   USE xios, only: xios_send_field
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
   USE print_control_mod, ONLY: prt_level,lunout
 
   IMPLICIT NONE
-  INCLUDE 'dimensions.h'
 
     CHARACTER(LEN=*), INTENT(IN) :: field_name
@@ -1274,5 +1272,5 @@
 
     REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp
-    REAL :: Field3d(iim,jj_nb,SIZE(field,2))
+    REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2))
     INTEGER :: ip, n, nlev
     INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
@@ -1295,6 +1293,6 @@
     !IF (.NOT.clef_stations(iff)) THEN
     IF(.TRUE.)THEN
-        ALLOCATE(index3d(iim*jj_nb*nlev))
-        ALLOCATE(fieldok(iim*jj_nb,nlev))
+        ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
+        ALLOCATE(fieldok(nbp_lon*jj_nb,nlev))
         CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
                         
