Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/inigeom_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/inigeom_mod.F90	(revision 1563)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/inigeom_mod.F90	(revision 1563)
@@ -0,0 +1,231 @@
+MODULE inigeom_mod
+
+CONTAINS
+
+SUBROUTINE inigeom(iim,jjm,nlayer, &
+                     nbp, communicator, &
+                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv)
+  USE dimphy, ONLY: init_dimphy
+  USE mod_grid_phy_lmdz, ONLY: klon_glo,  & ! number of atmospheric columns (on full grid)
+                               regular_lonlat, &  ! regular longitude-latitude grid type
+                               nbp_lon, nbp_lat, nbp_lev
+  USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
+                                klon_omp_begin, & ! start index of local omp subgrid
+                                klon_omp_end, & ! end index of local omp subgrid
+                                klon_mpi_begin ! start indes of columns (on local mpi grid)
+  USE geometry_mod, ONLY : init_geometry
+!  USE comgeomphy, ONLY: initcomgeomphy, &
+!                        airephy, & ! physics grid area (m2)
+!                        cuphy, & ! cu coeff. (u_covariant = cu * u)
+!                        cvphy, & ! cv coeff. (v_covariant = cv * v)
+!                        rlond, & ! longitudes
+!                        rlatd ! latitudes
+  USE physics_distribution_mod, ONLY : init_physics_distribution
+  USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
+                                 east, west, north, south, &
+                                 north_east, north_west, &
+                                 south_west, south_east
+  USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
+  USE nrtype, ONLY: pi
+  IMPLICIT NONE
+
+  ! =======================================================================
+  ! Initialisation of the physical constants and some positional and
+  ! geometrical arrays for the physics
+  ! =======================================================================
+
+  include "iniprint.h"
+
+  INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
+  INTEGER, INTENT (IN) :: iim ! number of atmospheric columns along longitudes
+  INTEGER, INTENT (IN) :: jjm ! number of atompsheric columns along latitudes
+  INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
+  INTEGER, INTENT(IN) :: communicator ! MPI communicator
+  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
+  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
+  REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid
+  REAL, INTENT (IN) :: rlonu(iim+1) ! longitude boundaries of the physics grid
+  REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2)
+  REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u)
+  REAL, INTENT (IN) :: cv((iim+1)*jjm) ! cv coeff. (v_covariant = cv * v)
+
+  INTEGER :: ibegin, iend, offset
+  INTEGER :: i,j,k
+  CHARACTER (LEN=20) :: modname = 'iniphysiq'
+  CHARACTER (LEN=80) :: abort_message
+  REAL :: total_area_phy, total_area_dyn
+
+  ! boundaries, on global grid
+  REAL,ALLOCATABLE :: boundslon_reg(:,:)
+  REAL,ALLOCATABLE :: boundslat_reg(:,:)
+
+  ! global array, on full physics grid:
+  REAL,ALLOCATABLE :: latfi_glo(:)
+  REAL,ALLOCATABLE :: lonfi_glo(:)
+  REAL,ALLOCATABLE :: cufi_glo(:)
+  REAL,ALLOCATABLE :: cvfi_glo(:)
+  REAL,ALLOCATABLE :: airefi_glo(:)
+  REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
+  REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
+
+  ! local arrays, on given MPI/OpenMP domain:
+  REAL,ALLOCATABLE,SAVE :: latfi(:)
+  REAL,ALLOCATABLE,SAVE :: lonfi(:)
+  REAL,ALLOCATABLE,SAVE :: cufi(:)
+  REAL,ALLOCATABLE,SAVE :: cvfi(:)
+  REAL,ALLOCATABLE,SAVE :: airefi(:)
+  REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
+  REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
+!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
+
+  ! Initialize Physics distibution and parameters and interface with dynamics
+  IF (iim*jjm>1) THEN ! general 3D case
+    CALL init_physics_distribution(regular_lonlat,4, &
+                                 nbp,iim,jjm+1,nlayer,communicator)
+  ELSE ! For 1D model
+    CALL init_physics_distribution(regular_lonlat,4, &
+                                 1,1,1,nlayer,communicator)
+  ENDIF
+  CALL init_interface_dyn_phys
+  
+  ! init regular global longitude-latitude grid points and boundaries
+  ALLOCATE(boundslon_reg(iim,2))
+  ALLOCATE(boundslat_reg(jjm+1,2))
+  
+  DO i=1,iim
+   boundslon_reg(i,east)=rlonu(i) 
+   boundslon_reg(i,west)=rlonu(i+1) 
+  ENDDO
+
+  boundslat_reg(1,north)= PI/2 
+  boundslat_reg(1,south)= rlatv(1)
+  DO j=2,jjm
+   boundslat_reg(j,north)=rlatv(j-1) 
+   boundslat_reg(j,south)=rlatv(j) 
+  ENDDO
+  boundslat_reg(jjm+1,north)= rlatv(jjm) 
+  boundslat_reg(jjm+1,south)= -PI/2
+
+  ! Write values in module regular_lonlat_mod
+  CALL init_regular_lonlat(iim,jjm+1, rlonv(1:iim), rlatu, &
+                           boundslon_reg, boundslat_reg)
+
+  ! Generate global arrays on full physics grid
+  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
+  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
+  ALLOCATE(airefi_glo(klon_glo))
+  ALLOCATE(boundslonfi_glo(klon_glo,4))
+  ALLOCATE(boundslatfi_glo(klon_glo,4))
+
+  IF (klon_glo>1) THEN ! general case
+    ! North pole
+    latfi_glo(1)=rlatu(1)
+    lonfi_glo(1)=0.
+    cufi_glo(1) = cu(1)
+    cvfi_glo(1) = cv(1)
+    boundslonfi_glo(1,north_east)=0
+    boundslatfi_glo(1,north_east)=PI/2
+    boundslonfi_glo(1,north_west)=2*PI
+    boundslatfi_glo(1,north_west)=PI/2
+    boundslonfi_glo(1,south_west)=2*PI
+    boundslatfi_glo(1,south_west)=rlatv(1)
+    boundslonfi_glo(1,south_east)=0
+    boundslatfi_glo(1,south_east)=rlatv(1)
+    DO j=2,jjm
+      DO i=1,iim
+        k=(j-2)*iim+1+i
+        latfi_glo(k)= rlatu(j)
+        lonfi_glo(k)= rlonv(i)
+        cufi_glo(k) = cu((j-1)*(iim+1)+i)
+        cvfi_glo(k) = cv((j-1)*(iim+1)+i)
+        boundslonfi_glo(k,north_east)=rlonu(i)
+        boundslatfi_glo(k,north_east)=rlatv(j-1)
+        boundslonfi_glo(k,north_west)=rlonu(i+1)
+        boundslatfi_glo(k,north_west)=rlatv(j-1)
+        boundslonfi_glo(k,south_west)=rlonu(i+1)
+        boundslatfi_glo(k,south_west)=rlatv(j)
+        boundslonfi_glo(k,south_east)=rlonu(i)
+        boundslatfi_glo(k,south_east)=rlatv(j)
+      ENDDO
+    ENDDO
+    ! South pole
+    latfi_glo(klon_glo)= rlatu(jjm+1)
+    lonfi_glo(klon_glo)= 0.
+    cufi_glo(klon_glo) = cu((iim+1)*jjm+1)
+    cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim)
+    boundslonfi_glo(klon_glo,north_east)= 0
+    boundslatfi_glo(klon_glo,north_east)= rlatv(jjm)
+    boundslonfi_glo(klon_glo,north_west)= 2*PI
+    boundslatfi_glo(klon_glo,north_west)= rlatv(jjm)
+    boundslonfi_glo(klon_glo,south_west)= 2*PI
+    boundslatfi_glo(klon_glo,south_west)= -PI/2
+    boundslonfi_glo(klon_glo,south_east)= 0
+    boundslatfi_glo(klon_glo,south_east)= -Pi/2
+
+    ! build airefi(), mesh area on physics grid
+    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo)
+    ! Poles are single points on physics grid
+    airefi_glo(1)=sum(aire(1:iim,1))
+    airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
+
+    ! Sanity check: do total planet area match between physics and dynamics?
+    total_area_dyn=sum(aire(1:iim,1:jjm+1))
+    total_area_phy=sum(airefi_glo(1:klon_glo))
+    IF (total_area_dyn/=total_area_phy) THEN
+      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
+      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
+      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
+      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
+        ! stop here if the relative difference is more than 0.001%
+        abort_message = 'planet total surface discrepancy'
+        CALL abort_gcm(modname, abort_message, 1)
+      ENDIF
+    ENDIF
+  ELSE ! klon_glo==1, running the 1D model
+    ! just copy over input values
+    latfi_glo(1)=rlatu(1)
+    lonfi_glo(1)=rlonv(1)
+    cufi_glo(1)=cu(1)
+    cvfi_glo(1)=cv(1)
+    airefi_glo(1)=aire(1,1)
+    boundslonfi_glo(1,north_east)=rlonu(1)
+    boundslatfi_glo(1,north_east)=PI/2
+    boundslonfi_glo(1,north_west)=rlonu(2)
+    boundslatfi_glo(1,north_west)=PI/2
+    boundslonfi_glo(1,south_west)=rlonu(2)
+    boundslatfi_glo(1,south_west)=rlatv(1)
+    boundslonfi_glo(1,south_east)=rlonu(1)
+    boundslatfi_glo(1,south_east)=rlatv(1)
+  ENDIF ! of IF (klon_glo>1)
+
+!$OMP PARALLEL 
+  ! Now generate local lon/lat/cu/cv/area/bounds arrays
+  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
+  ALLOCATE(airefi(klon_omp))
+  ALLOCATE(boundslonfi(klon_omp,4))
+  ALLOCATE(boundslatfi(klon_omp,4))
+!  CALL initcomgeomphy
+
+  offset = klon_mpi_begin - 1
+  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
+  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
+
+  ! copy over local grid longitudes and latitudes
+  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
+                     airefi,cufi,cvfi)
+
+
+  ! Initialize dimphy module
+  CALL init_dimphy(klon_omp,nlayer)
+
+!$OMP END PARALLEL
+
+
+END SUBROUTINE inigeom
+
+END MODULE inigeom_mod
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan/iniphysiq_mod.F90	(revision 1562)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan/iniphysiq_mod.F90	(revision 1563)
@@ -6,34 +6,13 @@
 CONTAINS
 
-SUBROUTINE iniphysiq(iim,jjm,nlayer, &
+SUBROUTINE iniphysiq(ii,jj,nlayer, &
                      nbp, communicator, &
                      punjours, pdayref,ptimestep, &
-                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv, &
+                     rlatudyn,rlatvdyn,rlonudyn,rlonvdyn, &
+                     airedyn,cudyn,cvdyn, &
                      prad,pg,pr,pcpp,iflag_phys)
-  USE dimphy, ONLY: init_dimphy
-  USE mod_grid_phy_lmdz, ONLY: klon_glo,  & ! number of atmospheric columns (on full grid)
-                               regular_lonlat, &  ! regular longitude-latitude grid type
-                               nbp_lon, nbp_lat, nbp_lev
-  USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
-                                klon_omp_begin, & ! start index of local omp subgrid
-                                klon_omp_end, & ! end index of local omp subgrid
-                                klon_mpi_begin ! start indes of columns (on local mpi grid)
-  USE control_mod, ONLY: nday
-  USE geometry_mod, ONLY : init_geometry
-!  USE comgeomphy, ONLY: initcomgeomphy, &
-!                        airephy, & ! physics grid area (m2)
-!                        cuphy, & ! cu coeff. (u_covariant = cu * u)
-!                        cvphy, & ! cv coeff. (v_covariant = cv * v)
-!                        rlond, & ! longitudes
-!                        rlatd ! latitudes
+
   USE temps_mod, ONLY: annee_ref, day_ref, day_ini, day_end
   USE time_phylmdz_mod, ONLY: init_time
-  USE physics_distribution_mod, ONLY : init_physics_distribution
-  USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
-                                 east, west, north, south, &
-                                 north_east, north_west, &
-                                 south_west, south_east
-  USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
-  USE nrtype, ONLY: pi
   IMPLICIT NONE
 
@@ -52,188 +31,35 @@
   REAL, INTENT (IN) :: punjours ! length (in s) of a standard day
   INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
-  INTEGER, INTENT (IN) :: iim ! number of atmospheric columns along longitudes
-  INTEGER, INTENT (IN) :: jjm ! number of atompsheric columns along latitudes
+  INTEGER, INTENT (IN) :: ii ! number of atmospheric columns along longitudes
+  INTEGER, INTENT (IN) :: jj ! number of atompsheric columns along latitudes
   INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
   INTEGER, INTENT(IN) :: communicator ! MPI communicator
-  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
-  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
-  REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid
-  REAL, INTENT (IN) :: rlonu(iim+1) ! longitude boundaries of the physics grid
-  REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2)
-  REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u)
-  REAL, INTENT (IN) :: cv((iim+1)*jjm) ! cv coeff. (v_covariant = cv * v)
+  REAL, INTENT (IN) :: rlatudyn(jj+1) ! latitudes of the physics grid
+  REAL, INTENT (IN) :: rlatvdyn(jj) ! latitude boundaries of the physics grid
+  REAL, INTENT (IN) :: rlonvdyn(ii+1) ! longitudes of the physics grid
+  REAL, INTENT (IN) :: rlonudyn(ii+1) ! longitude boundaries of the physics grid
+  REAL, INTENT (IN) :: airedyn(ii+1,jj+1) ! area of the dynamics grid (m2)
+  REAL, INTENT (IN) :: cudyn((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
+  REAL, INTENT (IN) :: cvdyn((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
   INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation
   REAL, INTENT (IN) :: ptimestep !physics time step (s)
   INTEGER, INTENT (IN) :: iflag_phys ! type of physics to be called
 
-  INTEGER :: ibegin, iend, offset
-  INTEGER :: i,j,k
   CHARACTER (LEN=20) :: modname = 'iniphysiq'
   CHARACTER (LEN=80) :: abort_message
-  REAL :: total_area_phy, total_area_dyn
 
-  ! boundaries, on global grid
-  REAL,ALLOCATABLE :: boundslon_reg(:,:)
-  REAL,ALLOCATABLE :: boundslat_reg(:,:)
+  ! the common part for all planetary physics
+  !------------------------------------------
+  ! --> initialize physics distribution, global fields and geometry
+  CALL inigeom(ii,jj,nlayer, &
+               nbp, communicator, &
+               rlatudyn,rlatvdyn, &
+               rlonudyn,rlonvdyn, &
+               airedyn,cudyn,cvdyn)
 
-  ! global array, on full physics grid:
-  REAL,ALLOCATABLE :: latfi_glo(:)
-  REAL,ALLOCATABLE :: lonfi_glo(:)
-  REAL,ALLOCATABLE :: cufi_glo(:)
-  REAL,ALLOCATABLE :: cvfi_glo(:)
-  REAL,ALLOCATABLE :: airefi_glo(:)
-  REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
-  REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
+  ! the distinct part for all planetary physics
+  !------------------------------------------
 
-  ! local arrays, on given MPI/OpenMP domain:
-  REAL,ALLOCATABLE,SAVE :: latfi(:)
-  REAL,ALLOCATABLE,SAVE :: lonfi(:)
-  REAL,ALLOCATABLE,SAVE :: cufi(:)
-  REAL,ALLOCATABLE,SAVE :: cvfi(:)
-  REAL,ALLOCATABLE,SAVE :: airefi(:)
-  REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
-  REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
-!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
-
-  ! Initialize Physics distibution and parameters and interface with dynamics
-  IF (iim*jjm>1) THEN ! general 3D case
-    CALL init_physics_distribution(regular_lonlat,4, &
-                                 nbp,iim,jjm+1,nlayer,communicator)
-  ELSE ! For 1D model
-    CALL init_physics_distribution(regular_lonlat,4, &
-                                 1,1,1,nlayer,communicator)
-  ENDIF
-  CALL init_interface_dyn_phys
-  
-  ! init regular global longitude-latitude grid points and boundaries
-  ALLOCATE(boundslon_reg(iim,2))
-  ALLOCATE(boundslat_reg(jjm+1,2))
-  
-  DO i=1,iim
-   boundslon_reg(i,east)=rlonu(i) 
-   boundslon_reg(i,west)=rlonu(i+1) 
-  ENDDO
-
-  boundslat_reg(1,north)= PI/2 
-  boundslat_reg(1,south)= rlatv(1)
-  DO j=2,jjm
-   boundslat_reg(j,north)=rlatv(j-1) 
-   boundslat_reg(j,south)=rlatv(j) 
-  ENDDO
-  boundslat_reg(jjm+1,north)= rlatv(jjm) 
-  boundslat_reg(jjm+1,south)= -PI/2
-
-  ! Write values in module regular_lonlat_mod
-  CALL init_regular_lonlat(iim,jjm+1, rlonv(1:iim), rlatu, &
-                           boundslon_reg, boundslat_reg)
-
-  ! Generate global arrays on full physics grid
-  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
-  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
-  ALLOCATE(airefi_glo(klon_glo))
-  ALLOCATE(boundslonfi_glo(klon_glo,4))
-  ALLOCATE(boundslatfi_glo(klon_glo,4))
-
-  IF (klon_glo>1) THEN ! general case
-    ! North pole
-    latfi_glo(1)=rlatu(1)
-    lonfi_glo(1)=0.
-    cufi_glo(1) = cu(1)
-    cvfi_glo(1) = cv(1)
-    boundslonfi_glo(1,north_east)=0
-    boundslatfi_glo(1,north_east)=PI/2
-    boundslonfi_glo(1,north_west)=2*PI
-    boundslatfi_glo(1,north_west)=PI/2
-    boundslonfi_glo(1,south_west)=2*PI
-    boundslatfi_glo(1,south_west)=rlatv(1)
-    boundslonfi_glo(1,south_east)=0
-    boundslatfi_glo(1,south_east)=rlatv(1)
-    DO j=2,jjm
-      DO i=1,iim
-        k=(j-2)*iim+1+i
-        latfi_glo(k)= rlatu(j)
-        lonfi_glo(k)= rlonv(i)
-        cufi_glo(k) = cu((j-1)*(iim+1)+i)
-        cvfi_glo(k) = cv((j-1)*(iim+1)+i)
-        boundslonfi_glo(k,north_east)=rlonu(i)
-        boundslatfi_glo(k,north_east)=rlatv(j-1)
-        boundslonfi_glo(k,north_west)=rlonu(i+1)
-        boundslatfi_glo(k,north_west)=rlatv(j-1)
-        boundslonfi_glo(k,south_west)=rlonu(i+1)
-        boundslatfi_glo(k,south_west)=rlatv(j)
-        boundslonfi_glo(k,south_east)=rlonu(i)
-        boundslatfi_glo(k,south_east)=rlatv(j)
-      ENDDO
-    ENDDO
-    ! South pole
-    latfi_glo(klon_glo)= rlatu(jjm+1)
-    lonfi_glo(klon_glo)= 0.
-    cufi_glo(klon_glo) = cu((iim+1)*jjm+1)
-    cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim)
-    boundslonfi_glo(klon_glo,north_east)= 0
-    boundslatfi_glo(klon_glo,north_east)= rlatv(jjm)
-    boundslonfi_glo(klon_glo,north_west)= 2*PI
-    boundslatfi_glo(klon_glo,north_west)= rlatv(jjm)
-    boundslonfi_glo(klon_glo,south_west)= 2*PI
-    boundslatfi_glo(klon_glo,south_west)= -PI/2
-    boundslonfi_glo(klon_glo,south_east)= 0
-    boundslatfi_glo(klon_glo,south_east)= -Pi/2
-
-    ! build airefi(), mesh area on physics grid
-    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo)
-    ! Poles are single points on physics grid
-    airefi_glo(1)=sum(aire(1:iim,1))
-    airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
-
-    ! Sanity check: do total planet area match between physics and dynamics?
-    total_area_dyn=sum(aire(1:iim,1:jjm+1))
-    total_area_phy=sum(airefi_glo(1:klon_glo))
-    IF (total_area_dyn/=total_area_phy) THEN
-      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
-      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
-      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
-      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
-        ! stop here if the relative difference is more than 0.001%
-        abort_message = 'planet total surface discrepancy'
-        CALL abort_gcm(modname, abort_message, 1)
-      ENDIF
-    ENDIF
-  ELSE ! klon_glo==1, running the 1D model
-    ! just copy over input values
-    latfi_glo(1)=rlatu(1)
-    lonfi_glo(1)=rlonv(1)
-    cufi_glo(1)=cu(1)
-    cvfi_glo(1)=cv(1)
-    airefi_glo(1)=aire(1,1)
-    boundslonfi_glo(1,north_east)=rlonu(1)
-    boundslatfi_glo(1,north_east)=PI/2
-    boundslonfi_glo(1,north_west)=rlonu(2)
-    boundslatfi_glo(1,north_west)=PI/2
-    boundslonfi_glo(1,south_west)=rlonu(2)
-    boundslatfi_glo(1,south_west)=rlatv(1)
-    boundslonfi_glo(1,south_east)=rlonu(1)
-    boundslatfi_glo(1,south_east)=rlatv(1)
-  ENDIF ! of IF (klon_glo>1)
-
-!$OMP PARALLEL 
-  ! Now generate local lon/lat/cu/cv/area/bounds arrays
-  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
-  ALLOCATE(airefi(klon_omp))
-  ALLOCATE(boundslonfi(klon_omp,4))
-  ALLOCATE(boundslatfi(klon_omp,4))
-!  CALL initcomgeomphy
-
-  offset = klon_mpi_begin - 1
-  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-
-  ! copy over local grid longitudes and latitudes
-  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
-                     airefi,cufi,cvfi)
+!$OMP PARALLEL
 
   ! Initialize some physical constants
@@ -243,8 +69,6 @@
   CALL init_time(annee_ref,day_ref,day_ini,day_end,nday,ptimestep)
 
-  ! Initialize dimphy module
-  CALL Init_dimphy(klon_omp,nlayer)
+!$OMP END PARALLEL
 
-!$OMP END PARALLEL
 
   ! check that physical constants set in 'suphec' are coherent
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phyvenus/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phyvenus/iniphysiq_mod.F90	(revision 1562)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phyvenus/iniphysiq_mod.F90	(revision 1563)
@@ -6,33 +6,13 @@
 CONTAINS
 
-SUBROUTINE iniphysiq(iim,jjm,nlayer, &
+SUBROUTINE iniphysiq(ii,jj,nlayer, &
                      nbp, communicator, &
                      punjours, pdayref,ptimestep, &
-                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv, &
+                     rlatudyn,rlatvdyn,rlonudyn,rlonvdyn, &
+                     airedyn,cudyn,cvdyn, &
                      prad,pg,pr,pcpp,iflag_phys)
-  USE dimphy, ONLY: init_dimphy
-  USE mod_grid_phy_lmdz, ONLY: klon_glo,  & ! number of atmospheric columns (on full grid)
-                               regular_lonlat, &  ! regular longitude-latitude grid type
-                               nbp_lon, nbp_lat, nbp_lev
-  USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
-                                klon_omp_begin, & ! start index of local omp subgrid
-                                klon_omp_end, & ! end index of local omp subgrid
-                                klon_mpi_begin ! start indes of columns (on local mpi grid)
-  USE geometry_mod, ONLY : init_geometry
-!  USE comgeomphy, ONLY: initcomgeomphy, &
-!                        airephy, & ! physics grid area (m2)
-!                        cuphy, & ! cu coeff. (u_covariant = cu * u)
-!                        cvphy, & ! cv coeff. (v_covariant = cv * v)
-!                        rlond, & ! longitudes
-!                        rlatd ! latitudes
+
   USE temps_mod, ONLY: annee_ref, day_ref, day_ini, day_end
   USE time_phylmdz_mod, ONLY: init_time
-  USE physics_distribution_mod, ONLY : init_physics_distribution
-  USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
-                                 east, west, north, south, &
-                                 north_east, north_west, &
-                                 south_west, south_east
-  USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
-  USE nrtype, ONLY: pi
   IMPLICIT NONE
 
@@ -51,188 +31,35 @@
   REAL, INTENT (IN) :: punjours ! length (in s) of a standard day
   INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
-  INTEGER, INTENT (IN) :: iim ! number of atmospheric columns along longitudes
-  INTEGER, INTENT (IN) :: jjm ! number of atompsheric columns along latitudes
+  INTEGER, INTENT (IN) :: ii ! number of atmospheric columns along longitudes
+  INTEGER, INTENT (IN) :: jj ! number of atompsheric columns along latitudes
   INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
   INTEGER, INTENT(IN) :: communicator ! MPI communicator
-  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
-  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
-  REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid
-  REAL, INTENT (IN) :: rlonu(iim+1) ! longitude boundaries of the physics grid
-  REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2)
-  REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u)
-  REAL, INTENT (IN) :: cv((iim+1)*jjm) ! cv coeff. (v_covariant = cv * v)
+  REAL, INTENT (IN) :: rlatudyn(jj+1) ! latitudes of the physics grid
+  REAL, INTENT (IN) :: rlatvdyn(jj) ! latitude boundaries of the physics grid
+  REAL, INTENT (IN) :: rlonvdyn(ii+1) ! longitudes of the physics grid
+  REAL, INTENT (IN) :: rlonudyn(ii+1) ! longitude boundaries of the physics grid
+  REAL, INTENT (IN) :: airedyn(ii+1,jj+1) ! area of the dynamics grid (m2)
+  REAL, INTENT (IN) :: cudyn((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
+  REAL, INTENT (IN) :: cvdyn((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
   INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation
   REAL, INTENT (IN) :: ptimestep !physics time step (s)
   INTEGER, INTENT (IN) :: iflag_phys ! type of physics to be called
 
-  INTEGER :: ibegin, iend, offset
-  INTEGER :: i,j,k
   CHARACTER (LEN=20) :: modname = 'iniphysiq'
   CHARACTER (LEN=80) :: abort_message
-  REAL :: total_area_phy, total_area_dyn
 
-  ! boundaries, on global grid
-  REAL,ALLOCATABLE :: boundslon_reg(:,:)
-  REAL,ALLOCATABLE :: boundslat_reg(:,:)
+  ! the common part for all planetary physics
+  !------------------------------------------
+  ! --> initialize physics distribution, global fields and geometry
+  CALL inigeom(ii,jj,nlayer, &
+               nbp, communicator, &
+               rlatudyn,rlatvdyn, &
+               rlonudyn,rlonvdyn, &
+               airedyn,cudyn,cvdyn)
 
-  ! global array, on full physics grid:
-  REAL,ALLOCATABLE :: latfi_glo(:)
-  REAL,ALLOCATABLE :: lonfi_glo(:)
-  REAL,ALLOCATABLE :: cufi_glo(:)
-  REAL,ALLOCATABLE :: cvfi_glo(:)
-  REAL,ALLOCATABLE :: airefi_glo(:)
-  REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
-  REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
+  ! the distinct part for all planetary physics
+  !------------------------------------------
 
-  ! local arrays, on given MPI/OpenMP domain:
-  REAL,ALLOCATABLE,SAVE :: latfi(:)
-  REAL,ALLOCATABLE,SAVE :: lonfi(:)
-  REAL,ALLOCATABLE,SAVE :: cufi(:)
-  REAL,ALLOCATABLE,SAVE :: cvfi(:)
-  REAL,ALLOCATABLE,SAVE :: airefi(:)
-  REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
-  REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
-!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
-
-  ! Initialize Physics distibution and parameters and interface with dynamics
-  IF (iim*jjm>1) THEN ! general 3D case
-    CALL init_physics_distribution(regular_lonlat,4, &
-                                 nbp,iim,jjm+1,nlayer,communicator)
-  ELSE ! For 1D model
-    CALL init_physics_distribution(regular_lonlat,4, &
-                                 1,1,1,nlayer,communicator)
-  ENDIF
-  CALL init_interface_dyn_phys
-  
-  ! init regular global longitude-latitude grid points and boundaries
-  ALLOCATE(boundslon_reg(iim,2))
-  ALLOCATE(boundslat_reg(jjm+1,2))
-  
-  DO i=1,iim
-   boundslon_reg(i,east)=rlonu(i) 
-   boundslon_reg(i,west)=rlonu(i+1) 
-  ENDDO
-
-  boundslat_reg(1,north)= PI/2 
-  boundslat_reg(1,south)= rlatv(1)
-  DO j=2,jjm
-   boundslat_reg(j,north)=rlatv(j-1) 
-   boundslat_reg(j,south)=rlatv(j) 
-  ENDDO
-  boundslat_reg(jjm+1,north)= rlatv(jjm) 
-  boundslat_reg(jjm+1,south)= -PI/2
-
-  ! Write values in module regular_lonlat_mod
-  CALL init_regular_lonlat(iim,jjm+1, rlonv(1:iim), rlatu, &
-                           boundslon_reg, boundslat_reg)
-
-  ! Generate global arrays on full physics grid
-  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
-  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
-  ALLOCATE(airefi_glo(klon_glo))
-  ALLOCATE(boundslonfi_glo(klon_glo,4))
-  ALLOCATE(boundslatfi_glo(klon_glo,4))
-
-  IF (klon_glo>1) THEN ! general case
-    ! North pole
-    latfi_glo(1)=rlatu(1)
-    lonfi_glo(1)=0.
-    cufi_glo(1) = cu(1)
-    cvfi_glo(1) = cv(1)
-    boundslonfi_glo(1,north_east)=0
-    boundslatfi_glo(1,north_east)=PI/2
-    boundslonfi_glo(1,north_west)=2*PI
-    boundslatfi_glo(1,north_west)=PI/2
-    boundslonfi_glo(1,south_west)=2*PI
-    boundslatfi_glo(1,south_west)=rlatv(1)
-    boundslonfi_glo(1,south_east)=0
-    boundslatfi_glo(1,south_east)=rlatv(1)
-    DO j=2,jjm
-      DO i=1,iim
-        k=(j-2)*iim+1+i
-        latfi_glo(k)= rlatu(j)
-        lonfi_glo(k)= rlonv(i)
-        cufi_glo(k) = cu((j-1)*(iim+1)+i)
-        cvfi_glo(k) = cv((j-1)*(iim+1)+i)
-        boundslonfi_glo(k,north_east)=rlonu(i)
-        boundslatfi_glo(k,north_east)=rlatv(j-1)
-        boundslonfi_glo(k,north_west)=rlonu(i+1)
-        boundslatfi_glo(k,north_west)=rlatv(j-1)
-        boundslonfi_glo(k,south_west)=rlonu(i+1)
-        boundslatfi_glo(k,south_west)=rlatv(j)
-        boundslonfi_glo(k,south_east)=rlonu(i)
-        boundslatfi_glo(k,south_east)=rlatv(j)
-      ENDDO
-    ENDDO
-    ! South pole
-    latfi_glo(klon_glo)= rlatu(jjm+1)
-    lonfi_glo(klon_glo)= 0.
-    cufi_glo(klon_glo) = cu((iim+1)*jjm+1)
-    cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim)
-    boundslonfi_glo(klon_glo,north_east)= 0
-    boundslatfi_glo(klon_glo,north_east)= rlatv(jjm)
-    boundslonfi_glo(klon_glo,north_west)= 2*PI
-    boundslatfi_glo(klon_glo,north_west)= rlatv(jjm)
-    boundslonfi_glo(klon_glo,south_west)= 2*PI
-    boundslatfi_glo(klon_glo,south_west)= -PI/2
-    boundslonfi_glo(klon_glo,south_east)= 0
-    boundslatfi_glo(klon_glo,south_east)= -Pi/2
-
-    ! build airefi(), mesh area on physics grid
-    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo)
-    ! Poles are single points on physics grid
-    airefi_glo(1)=sum(aire(1:iim,1))
-    airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
-
-    ! Sanity check: do total planet area match between physics and dynamics?
-    total_area_dyn=sum(aire(1:iim,1:jjm+1))
-    total_area_phy=sum(airefi_glo(1:klon_glo))
-    IF (total_area_dyn/=total_area_phy) THEN
-      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
-      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
-      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
-      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
-        ! stop here if the relative difference is more than 0.001%
-        abort_message = 'planet total surface discrepancy'
-        CALL abort_gcm(modname, abort_message, 1)
-      ENDIF
-    ENDIF
-  ELSE ! klon_glo==1, running the 1D model
-    ! just copy over input values
-    latfi_glo(1)=rlatu(1)
-    lonfi_glo(1)=rlonv(1)
-    cufi_glo(1)=cu(1)
-    cvfi_glo(1)=cv(1)
-    airefi_glo(1)=aire(1,1)
-    boundslonfi_glo(1,north_east)=rlonu(1)
-    boundslatfi_glo(1,north_east)=PI/2
-    boundslonfi_glo(1,north_west)=rlonu(2)
-    boundslatfi_glo(1,north_west)=PI/2
-    boundslonfi_glo(1,south_west)=rlonu(2)
-    boundslatfi_glo(1,south_west)=rlatv(1)
-    boundslonfi_glo(1,south_east)=rlonu(1)
-    boundslatfi_glo(1,south_east)=rlatv(1)
-  ENDIF ! of IF (klon_glo>1)
-
-!$OMP PARALLEL 
-  ! Now generate local lon/lat/cu/cv/area/bounds arrays
-  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
-  ALLOCATE(airefi(klon_omp))
-  ALLOCATE(boundslonfi(klon_omp,4))
-  ALLOCATE(boundslatfi(klon_omp,4))
-!  CALL initcomgeomphy
-
-  offset = klon_mpi_begin - 1
-  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-
-  ! copy over local grid longitudes and latitudes
-  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
-                     airefi,cufi,cvfi)
+!$OMP PARALLEL
 
   ! Initialize some physical constants
@@ -242,8 +69,6 @@
   CALL init_time(annee_ref,day_ref,day_ini,day_end,ptimestep)
 
-  ! Initialize dimphy module
-  CALL Init_dimphy(klon_omp,nlayer)
+!$OMP END PARALLEL
 
-!$OMP END PARALLEL
 
   ! check that physical constants set in 'suphec' are coherent
Index: /trunk/LMDZ.GENERIC/libf/dynphy_lonlat/phystd/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/dynphy_lonlat/phystd/iniphysiq_mod.F90	(revision 1562)
+++ /trunk/LMDZ.GENERIC/libf/dynphy_lonlat/phystd/iniphysiq_mod.F90	(revision 1563)
@@ -10,22 +10,5 @@
                      prad,pg,pr,pcpp,iflag_phys)
 
-use dimphy, only : init_dimphy
-use mod_grid_phy_lmdz, only : klon_glo, & ! number of atmospheric columns (on full grid)
-                              regular_lonlat  ! regular longitude-latitude grid type
-use mod_phys_lmdz_para, only : klon_omp, & ! number of columns (on local omp grid)
-                               klon_omp_begin, & ! start index of local omp subgrid
-                               klon_omp_end, & ! end index of local omp subgrid
-                               klon_mpi_begin ! start indes of columns (on local mpi grid)
 use control_mod, only: nday 
-use geometry_mod, only: init_geometry, &
-                        cell_area, & ! physics grid area (m2)
-                        longitude, & ! longitudes (rad)
-                        latitude ! latitudes (rad)
-!use comgeomphy, only : initcomgeomphy, &
-!                       cell_area, & ! physics grid area (m2)
-!                       dx, & ! cu coeff. (u_covariant = cu * u)
-!                       dy, & ! cv coeff. (v_covariant = cv * v)
-!                       longitude, & ! longitudes (rad)
-!                       latitude ! latitudes (rad)
 use surf_heat_transp_mod, only: ini_surf_heat_transp
 use infotrac, only : nqtot ! number of advected tracers
@@ -33,11 +16,12 @@
 USE comvert_mod, ONLY: ap,bp,preff
 use inifis_mod, only: inifis
-use physics_distribution_mod, only: init_physics_distribution
-use regular_lonlat_mod, only: init_regular_lonlat, &
-                              east, west, north, south, &
-                              north_east, north_west, &
-                              south_west, south_east
-use mod_interface_dyn_phys, only: init_interface_dyn_phys
 use ioipsl_getin_p_mod, only: getin_p
+
+
+use geometry_mod, only: cell_area, & ! physics grid area (m2)
+                        longitude, & ! longitudes (rad)
+                        latitude ! latitudes (rad)
+! necessary to get klon_omp
+USE mod_phys_lmdz_para, ONLY: klon_omp ! number of columns (on local omp grid)
 
 implicit none
@@ -52,5 +36,4 @@
 real,intent(in) :: pcpp ! specific heat Cp
 real,intent(in) :: punjours ! length (in s) of a standard day
-!integer,intent(in) :: ngrid ! number of horizontal grid points in the physics (full grid)
 integer,intent(in) :: nlayer ! number of atmospheric layers
 integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes
@@ -69,158 +52,22 @@
 integer,intent(in) :: iflag_phys ! type of physics to be called
 
-integer :: ibegin,iend,offset
-integer :: i,j,k
-character(len=20) :: modname='iniphysiq'
-character(len=80) :: abort_message
-real :: total_area_phy, total_area_dyn
-real :: pi
 logical :: ok_slab_ocean
 
-! boundaries, on global grid
-real,allocatable :: boundslon_reg(:,:)
-real,allocatable :: boundslat_reg(:,:)
+  ! the common part for all planetary physics
+  !------------------------------------------
+  ! --> initialize physics distribution, global fields and geometry
+  CALL inigeom(ii,jj,nlayer, &
+               nbp, communicator, &
+               rlatudyn,rlatvdyn, &
+               rlonudyn,rlonvdyn, &
+               airedyn,cudyn,cvdyn)
 
-! global array, on full physics grid:
-real,allocatable :: latfi_glo(:)
-real,allocatable :: lonfi_glo(:)
-real,allocatable :: cufi_glo(:)
-real,allocatable :: cvfi_glo(:)
-real,allocatable :: airefi_glo(:)
-real,allocatable :: boundslonfi_glo(:,:)
-real,allocatable :: boundslatfi_glo(:,:)
+  ! the distinct part for all planetary physics
+  !------------------------------------------
 
-! local arrays, on given MPI/OpenMP domain:
-real,allocatable,save :: latfi(:)
-real,allocatable,save :: lonfi(:)
-real,allocatable,save :: cufi(:)
-real,allocatable,save :: cvfi(:)
-real,allocatable,save :: airefi(:)
-real,allocatable,save :: boundslonfi(:,:)
-real,allocatable,save :: boundslatfi(:,:)
-!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
+!$OMP PARALLEL
 
-pi=2.*asin(1.0)
-
-! Initialize Physics distibution and parameters and interface with dynamics
-CALL init_physics_distribution(regular_lonlat,4, &
-                                 nbp,ii,jj+1,nlayer,communicator)
-CALL init_interface_dyn_phys
-
-! init regular global longitude-latitude grid points and boundaries
-ALLOCATE(boundslon_reg(ii,2))
-ALLOCATE(boundslat_reg(jj+1,2))
-  
-DO i=1,ii
-   boundslon_reg(i,east)=rlonudyn(i) 
-   boundslon_reg(i,west)=rlonudyn(i+1) 
-ENDDO
-
-boundslat_reg(1,north)= PI/2 
-boundslat_reg(1,south)= rlatvdyn(1)
-DO j=2,jj
-   boundslat_reg(j,north)=rlatvdyn(j-1) 
-   boundslat_reg(j,south)=rlatvdyn(j) 
-ENDDO
-boundslat_reg(jj+1,north)= rlatvdyn(jj) 
-boundslat_reg(jj+1,south)= -PI/2
-
-! Write values in module regular_lonlat_mod
-CALL init_regular_lonlat(ii,jj+1, rlonvdyn(1:ii), rlatudyn, &
-                         boundslon_reg, boundslat_reg)
-
-! Generate global arrays on full physics grid
-allocate(latfi_glo(klon_glo),lonfi_glo(klon_glo))
-allocate(cufi_glo(klon_glo),cvfi_glo(klon_glo))
-allocate(airefi_glo(klon_glo))
-allocate(boundslonfi_glo(klon_glo,4))
-allocate(boundslatfi_glo(klon_glo,4))
-
-! North pole
-latfi_glo(1)=rlatudyn(1)
-lonfi_glo(1)=0.
-cufi_glo(1) = cudyn(1)
-cvfi_glo(1) = cvdyn(1)
-boundslonfi_glo(1,north_east)=0
-boundslatfi_glo(1,north_east)=PI/2
-boundslonfi_glo(1,north_west)=2*PI
-boundslatfi_glo(1,north_west)=PI/2
-boundslonfi_glo(1,south_west)=2*PI
-boundslatfi_glo(1,south_west)=rlatvdyn(1)
-boundslonfi_glo(1,south_east)=0
-boundslatfi_glo(1,south_east)=rlatvdyn(1)
-DO j=2,jj
-  DO i=1,ii
-    k=(j-2)*ii+1+i
-    latfi_glo((j-2)*ii+1+i)= rlatudyn(j)
-    lonfi_glo((j-2)*ii+1+i)= rlonvdyn(i)
-    cufi_glo((j-2)*ii+1+i) = cudyn((j-1)*(ii+1)+i)
-    cvfi_glo((j-2)*ii+1+i) = cvdyn((j-1)*(ii+1)+i)
-    boundslonfi_glo(k,north_east)=rlonudyn(i)
-    boundslatfi_glo(k,north_east)=rlatvdyn(j-1)
-    boundslonfi_glo(k,north_west)=rlonudyn(i+1)
-    boundslatfi_glo(k,north_west)=rlatvdyn(j-1)
-    boundslonfi_glo(k,south_west)=rlonudyn(i+1)
-    boundslatfi_glo(k,south_west)=rlatvdyn(j)
-    boundslonfi_glo(k,south_east)=rlonudyn(i)
-    boundslatfi_glo(k,south_east)=rlatvdyn(j)
-  ENDDO
-ENDDO
-! South pole
-latfi_glo(klon_glo)= rlatudyn(jj+1)
-lonfi_glo(klon_glo)= 0.
-cufi_glo(klon_glo) = cudyn((ii+1)*jj+1)
-cvfi_glo(klon_glo) = cvdyn((ii+1)*jj-ii)
-boundslonfi_glo(klon_glo,north_east)= 0
-boundslatfi_glo(klon_glo,north_east)= rlatvdyn(jj)
-boundslonfi_glo(klon_glo,north_west)= 2*PI
-boundslatfi_glo(klon_glo,north_west)= rlatvdyn(jj)
-boundslonfi_glo(klon_glo,south_west)= 2*PI
-boundslatfi_glo(klon_glo,south_west)= -PI/2
-boundslonfi_glo(klon_glo,south_east)= 0
-boundslatfi_glo(klon_glo,south_east)= -Pi/2
-
-! build airefi(), mesh area on physics grid
-CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,airedyn,airefi_glo)
-! Poles are single points on physics grid
-airefi_glo(1)=sum(airedyn(1:ii,1))
-airefi_glo(klon_glo)=sum(airedyn(1:ii,jj+1))
-
-! Sanity check: do total planet area match between physics and dynamics?
-total_area_dyn=sum(airedyn(1:ii,1:jj+1))
-total_area_phy=sum(airefi_glo(1:klon_glo))
-IF (total_area_dyn/=total_area_phy) THEN
-  WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
-  WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
-  WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
-  IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
-    ! stop here if the relative difference is more than 0.001%
-    abort_message = 'planet total surface discrepancy'
-    CALL abort_gcm(modname, abort_message, 1)
-  ENDIF
-ENDIF
-
-
-!$OMP PARALLEL 
-! Now generate local lon/lat/cu/cv/area arrays
-allocate(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
-allocate(airefi(klon_omp))
-allocate(boundslonfi(klon_omp,4))
-allocate(boundslatfi(klon_omp,4))
-!call initcomgeomphy
-
-offset=klon_mpi_begin-1
-airefi(1:klon_omp)=airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-cufi(1:klon_omp)=cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-cvfi(1:klon_omp)=cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-lonfi(1:klon_omp)=lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-latfi(1:klon_omp)=latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-boundslonfi(1:klon_omp,:)=boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-boundslatfi(1:klon_omp,:)=boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-
-! copy over local grid longitudes and latitudes
-CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
-                   airefi,cufi,cvfi)
-
-call init_dimphy(klon_omp,nlayer) ! Initialize dimphy module
+! copy some fundamental parameters to physics
+! and do some initializations
 
 ! copy over preff , ap() and bp() 
@@ -236,11 +83,9 @@
 endif
 
-! copy some fundamental parameters to physics 
-! and do some initializations 
 call inifis(klon_omp,nlayer,nqtot,pdayref,punjours,nday,ptimestep, &
             latitude,longitude,cell_area,prad,pg,pr,pcpp)
 
+
 !$OMP END PARALLEL
-
 
 end subroutine iniphysiq
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90	(revision 1562)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/iniphysiq_mod.F90	(revision 1563)
@@ -6,31 +6,18 @@
                      nbp, communicator, &
                      punjours, pdayref,ptimestep, &
-                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv, &
+                     rlatudyn,rlatvdyn,rlonudyn,rlonvdyn, &
+                     airedyn,cudyn,cvdyn, &
                      prad,pg,pr,pcpp,iflag_phys)
 
-use dimphy, only : init_dimphy
-use mod_grid_phy_lmdz, only : klon_glo, & ! number of atmospheric columns (on full grid)
-                              regular_lonlat  ! regular longitude-latitude grid type
-use mod_phys_lmdz_para, only : klon_omp, & ! number of columns (on local omp grid)
-                               klon_omp_begin, & ! start index of local omp subgrid
-                               klon_omp_end, & ! end index of local omp subgrid
-                               klon_mpi_begin ! start indes of columns (on local mpi grid)
-use geometry_mod, only: init_geometry
-!use comgeomphy, only : initcomgeomphy, &
-!                       cell_area, & ! physics grid area (m2)
-!                       dx, & ! cu coeff. (u_covariant = cu * u)
-!                       dy, & ! cv coeff. (v_covariant = cv * v)
-!                       longitude, & ! longitudes (rad)
-!                       latitude ! latitudes (rad)
 use infotrac, only : nqtot ! number of advected tracers
 use comgeomfi_h, only: ini_fillgeom
 use temps_mod, only: day_ini, hour_ini
 use phys_state_var_init_mod, only: phys_state_var_init
-use physics_distribution_mod, only: init_physics_distribution
-use regular_lonlat_mod, only: init_regular_lonlat, &
-                              east, west, north, south, &
-                              north_east, north_west, &
-                              south_west, south_east
-use mod_interface_dyn_phys, only: init_interface_dyn_phys
+
+use geometry_mod, only: cell_area, & ! physics grid area (m2)
+                        longitude, & ! longitudes (rad)
+                        latitude ! latitudes (rad)
+! necessary to get klon_omp
+USE mod_phys_lmdz_para, ONLY: klon_omp ! number of columns (on local omp grid)
 
 implicit none
@@ -43,5 +30,4 @@
 real,intent(in) :: pcpp ! specific heat Cp
 real,intent(in) :: punjours ! length (in s) of a standard day
-!integer,intent(in) :: ngrid ! number of horizontal grid points in the physics (full grid)
 integer,intent(in) :: nlayer ! number of atmospheric layers
 integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes
@@ -49,177 +35,38 @@
 integer,intent(in) :: nbp ! number of physics columns for this MPI process
 integer,intent(in) :: communicator ! MPI communicator
-real,intent(in) :: rlatu(jj+1) ! latitudes of the physics grid
-real,intent(in) :: rlatv(jj) ! latitude boundaries of the physics grid
-real,intent(in) :: rlonv(ii+1) ! longitudes of the physics grid
-real,intent(in) :: rlonu(ii+1) ! longitude boundaries of the physics grid
-real,intent(in) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2)
-real,intent(in) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
-real,intent(in) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
+real,intent(in) :: rlatudyn(jj+1) ! latitudes of the physics grid
+real,intent(in) :: rlatvdyn(jj) ! latitude boundaries of the physics grid
+real,intent(in) :: rlonvdyn(ii+1) ! longitudes of the physics grid
+real,intent(in) :: rlonudyn(ii+1) ! longitude boundaries of the physics grid
+real,intent(in) :: airedyn(ii+1,jj+1) ! area of the dynamics grid (m2)
+real,intent(in) :: cudyn((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
+real,intent(in) :: cvdyn((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
 integer,intent(in) :: pdayref ! reference day of for the simulation
 real,intent(in) :: ptimestep !physics time step (s)
 integer,intent(in) :: iflag_phys ! type of physics to be called
 
-integer :: ibegin,iend,offset
-integer :: i,j,k
-character(len=20) :: modname='iniphysiq'
-character(len=80) :: abort_message
-real :: total_area_phy, total_area_dyn
-real :: pi
+  ! the common part for all planetary physics
+  !------------------------------------------
+  ! --> initialize physics distribution, global fields and geometry
+  CALL inigeom(ii,jj,nlayer, &
+               nbp, communicator, &
+               rlatudyn,rlatvdyn, &
+               rlonudyn,rlonvdyn, &
+               airedyn,cudyn,cvdyn)
 
-! boundaries, on global grid
-real,allocatable :: boundslon_reg(:,:)
-real,allocatable :: boundslat_reg(:,:)
+  ! the distinct part for all planetary physics
+  !------------------------------------------
 
-! global array, on full physics grid:
-real,allocatable :: latfi_glo(:)
-real,allocatable :: lonfi_glo(:)
-real,allocatable :: cufi_glo(:)
-real,allocatable :: cvfi_glo(:)
-real,allocatable :: airefi_glo(:)
-real,allocatable :: boundslonfi_glo(:,:)
-real,allocatable :: boundslatfi_glo(:,:)
-
-! local arrays, on given MPI/OpenMP domain:
-real,allocatable,save :: latfi(:)
-real,allocatable,save :: lonfi(:)
-real,allocatable,save :: cufi(:)
-real,allocatable,save :: cvfi(:)
-real,allocatable,save :: airefi(:)
-real,allocatable,save :: boundslonfi(:,:)
-real,allocatable,save :: boundslatfi(:,:)
-!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
-
-
-pi=2.*asin(1.0)
-
-! Initialize Physics distibution and parameters and interface with dynamics
-CALL init_physics_distribution(regular_lonlat,4, &
-                                 nbp,ii,jj+1,nlayer,communicator)
-CALL init_interface_dyn_phys
-
-! init regular global longitude-latitude grid points and boundaries
-ALLOCATE(boundslon_reg(ii,2))
-ALLOCATE(boundslat_reg(jj+1,2))
+!$OMP PARALLEL
   
-DO i=1,ii
-   boundslon_reg(i,east)=rlonu(i) 
-   boundslon_reg(i,west)=rlonu(i+1) 
-ENDDO
-
-boundslat_reg(1,north)= PI/2 
-boundslat_reg(1,south)= rlatv(1)
-DO j=2,jj
-   boundslat_reg(j,north)=rlatv(j-1) 
-   boundslat_reg(j,south)=rlatv(j) 
-ENDDO
-boundslat_reg(jj+1,north)= rlatv(jj) 
-boundslat_reg(jj+1,south)= -PI/2
-
-! Write values in module regular_lonlat_mod
-CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, &
-                         boundslon_reg, boundslat_reg)
-
-! Generate global arrays on full physics grid
-allocate(latfi_glo(klon_glo),lonfi_glo(klon_glo))
-allocate(cufi_glo(klon_glo),cvfi_glo(klon_glo))
-allocate(airefi_glo(klon_glo))
-allocate(boundslonfi_glo(klon_glo,4))
-allocate(boundslatfi_glo(klon_glo,4))
-
-! North pole
-latfi_glo(1)=rlatu(1)
-lonfi_glo(1)=0.
-cufi_glo(1) = cu(1)
-cvfi_glo(1) = cv(1)
-boundslonfi_glo(1,north_east)=0
-boundslatfi_glo(1,north_east)=PI/2
-boundslonfi_glo(1,north_west)=2*PI
-boundslatfi_glo(1,north_west)=PI/2
-boundslonfi_glo(1,south_west)=2*PI
-boundslatfi_glo(1,south_west)=rlatv(1)
-boundslonfi_glo(1,south_east)=0
-boundslatfi_glo(1,south_east)=rlatv(1)
-DO j=2,jj
-  DO i=1,ii
-    k=(j-2)*ii+1+i
-    latfi_glo((j-2)*ii+1+i)= rlatu(j)
-    lonfi_glo((j-2)*ii+1+i)= rlonv(i)
-    cufi_glo((j-2)*ii+1+i) = cu((j-1)*(ii+1)+i)
-    cvfi_glo((j-2)*ii+1+i) = cv((j-1)*(ii+1)+i)
-    boundslonfi_glo(k,north_east)=rlonu(i)
-    boundslatfi_glo(k,north_east)=rlatv(j-1)
-    boundslonfi_glo(k,north_west)=rlonu(i+1)
-    boundslatfi_glo(k,north_west)=rlatv(j-1)
-    boundslonfi_glo(k,south_west)=rlonu(i+1)
-    boundslatfi_glo(k,south_west)=rlatv(j)
-    boundslonfi_glo(k,south_east)=rlonu(i)
-    boundslatfi_glo(k,south_east)=rlatv(j)
-  ENDDO
-ENDDO
-! South pole
-latfi_glo(klon_glo)= rlatu(jj+1)
-lonfi_glo(klon_glo)= 0.
-cufi_glo(klon_glo) = cu((ii+1)*jj+1)
-cvfi_glo(klon_glo) = cv((ii+1)*jj-ii)
-boundslonfi_glo(klon_glo,north_east)= 0
-boundslatfi_glo(klon_glo,north_east)= rlatv(jj)
-boundslonfi_glo(klon_glo,north_west)= 2*PI
-boundslatfi_glo(klon_glo,north_west)= rlatv(jj)
-boundslonfi_glo(klon_glo,south_west)= 2*PI
-boundslatfi_glo(klon_glo,south_west)= -PI/2
-boundslonfi_glo(klon_glo,south_east)= 0
-boundslatfi_glo(klon_glo,south_east)= -Pi/2
-
-! build airefi(), mesh area on physics grid
-CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi_glo)
-! Poles are single points on physics grid
-airefi_glo(1)=sum(aire(1:ii,1))
-airefi_glo(klon_glo)=sum(aire(1:ii,jj+1))
-
-! Sanity check: do total planet area match between physics and dynamics?
-total_area_dyn=sum(aire(1:ii,1:jj+1))
-total_area_phy=sum(airefi_glo(1:klon_glo))
-IF (total_area_dyn/=total_area_phy) THEN
-  WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
-  WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
-  WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
-  IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
-    ! stop here if the relative difference is more than 0.001%
-    abort_message = 'planet total surface discrepancy'
-    CALL abort_gcm(modname, abort_message, 1)
-  ENDIF
-ENDIF
-
-
-
-!$OMP PARALLEL 
-! Now generate local lon/lat/cu/cv/area arrays
-allocate(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
-allocate(airefi(klon_omp))
-allocate(boundslonfi(klon_omp,4))
-allocate(boundslatfi(klon_omp,4))
-!call initcomgeomphy
-      
-offset=klon_mpi_begin-1
-airefi(1:klon_omp)=airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-cufi(1:klon_omp)=cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-cvfi(1:klon_omp)=cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-lonfi(1:klon_omp)=lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-latfi(1:klon_omp)=latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
-boundslonfi(1:klon_omp,:)=boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-boundslatfi(1:klon_omp,:)=boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
-
-! copy over local grid longitudes and latitudes
-CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
-                   airefi,cufi,cvfi)
-
 ! copy some fundamental parameters to physics 
 ! and do some initializations 
 
-call init_dimphy(klon_omp,nlayer) ! Initialize dimphy module
 call phys_state_var_init(klon_omp,nlayer,nqtot, &
                          day_ini,hour_ini,punjours,ptimestep, &
                          prad,pg,pr,pcpp)
-call ini_fillgeom(klon_omp,latfi,lonfi,airefi)
+call ini_fillgeom(klon_omp,latitude,longitude,cell_area)
+! work is needed to put what is in comgeomfi_h in geometry_mod?
+
 call conf_phys(klon_omp,nlayer,nqtot)
 
@@ -229,5 +76,4 @@
 !$OMP END PARALLEL
 
-
 end subroutine iniphysiq
 
