Index: LMDZ5/trunk/libf/phylmd/physiq.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/physiq.F90	(revision 2343)
+++ LMDZ5/trunk/libf/phylmd/physiq.F90	(revision 2344)
@@ -3,5 +3,5 @@
 
 SUBROUTINE physiq (nlon,nlev, &
-     debut,lafin,jD_cur, jH_cur,pdtphys, &
+     debut,lafin,jD_cur_,jH_cur_,pdtphys_, &
      paprs,pplay,pphi,pphis,presnivs, &
      u,v,rot,t,qx, &
@@ -14,9 +14,9 @@
   USE comgeomphy
   USE phys_cal_mod, only: year_len, mth_len, days_elapsed, jh_1jan, year_cur, &
-       mth_cur, phys_cal_update
+       mth_cur,jD_cur, jH_cur, jD_ref, phys_cal_update
   USE write_field_phy
   USE dimphy
   USE infotrac_phy, ONLY: nqtot, nbtr, nqo, type_trac
-  USE mod_grid_phy_lmdz
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo
   USE mod_phys_lmdz_para
   USE iophy
@@ -48,4 +48,6 @@
   use radlwsw_m, only: radlwsw
   use phyaqua_mod, only: zenang_an
+  USE time_phylmdz_mod, only: day_step_phy, annee_ref, day_ref, itau_phy, &
+                              start_time, pdtphys
   USE control_mod, ONLY: config_inca
 #ifdef CPP_XIOS
@@ -114,14 +116,12 @@
   !! d_ps----output-R-tendance physique de la pression au sol
   !!======================================================================
-  include "dimensions.h"
   integer jjmp1
-  parameter (jjmp1=jjm+1-1/jjm)
-  integer iip1
-  parameter (iip1=iim+1)
+!  parameter (jjmp1=jjm+1-1/jjm) ! => (jjmp1=nbp_lat-1/(nbp_lat-1))
+!  integer iip1
+!  parameter (iip1=iim+1)
 
   include "regdim.h"
   include "dimsoil.h"
   include "clesphys.h"
-  include "temps.h"
   include "thermcell.h"
   !======================================================================
@@ -219,7 +219,8 @@
   INTEGER nlon
   INTEGER nlev
-  REAL, intent(in):: jD_cur, jH_cur
-
-  REAL pdtphys
+  REAL, intent(in):: jD_cur_, jH_cur_ 
+! JD_cur and JH_cur to be used in physics are in phys_cal_mod
+  REAL,INTENT(IN) :: pdtphys_
+! NB: pdtphys to be used in physics is in time_phylmdz_mod
   LOGICAL debut, lafin
   REAL paprs(klon,klev+1)
@@ -509,5 +510,5 @@
   SAVE lmt_pas                ! frequence de mise a jour
   !$OMP THREADPRIVATE(lmt_pas) 
-  real zmasse(klon, llm),exner(klon, llm) 
+  real zmasse(klon, nbp_lev),exner(klon, nbp_lev) 
   !     (column-density of mass of air in a cell, in kg m-2)
   real, parameter:: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
@@ -694,5 +695,5 @@
   REAL tabcntr0( length       )
   !
-  INTEGER ndex2d(iim*jjmp1)
+  INTEGER ndex2d(nbp_lon*nbp_lat)
   !IM
   !
@@ -706,11 +707,13 @@
   !IM 141004 END
   !IM 190504 BEG
-  INTEGER ij, imp1jmp1
-  PARAMETER(imp1jmp1=(iim+1)*jjmp1)
+  INTEGER ij
+!  INTEGER imp1jmp1
+!  PARAMETER(imp1jmp1=(iim+1)*jjmp1)
   !ym A voir plus tard
-  REAL zx_tmp(imp1jmp1), airedyn(iim+1,jjmp1)
-  REAL padyn(iim+1,jjmp1,klev+1)
-  REAL dudyn(iim+1,jjmp1,klev)
-  REAL rlatdyn(iim+1,jjmp1)
+  REAL zx_tmp((nbp_lon+1)*nbp_lat)
+  REAL airedyn(nbp_lon+1,nbp_lat)
+  REAL padyn(nbp_lon+1,nbp_lat,klev+1)
+  REAL dudyn(nbp_lon+1,nbp_lat,klev)
+  REAL rlatdyn(nbp_lon+1,nbp_lat)
   !IM 190504 END
   LOGICAL ok_msk
@@ -724,6 +727,7 @@
   REAL zx_tmp_fi2d(klon)      ! variable temporaire grille physique
   REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D 
-  REAL zx_tmp_2d(iim,jjmp1)
-  REAL zx_lon(iim,jjmp1), zx_lat(iim,jjmp1)
+  REAL zx_tmp_2d(nbp_lon,nbp_lat)
+  REAL zx_lon(nbp_lon,nbp_lat)
+  REAL zx_lat(nbp_lon,nbp_lat)
   !
   INTEGER nid_day_seri, nid_ctesGCM
@@ -900,7 +904,13 @@
 !albedo SB <<<
 
+  ! Ehouarn: set value of jjmp1 since it is no longer a "fixed parameter"
+  jjmp1=nbp_lat
+
   !======================================================================
   ! Gestion calendrier : mise a jour du module phys_cal_mod
   !
+  JD_cur=JD_cur_
+  JH_cur=JH_cur_
+  pdtphys=pdtphys_
   CALL phys_cal_update(jD_cur,jH_cur)
 
@@ -992,5 +1002,5 @@
 
   torsfc=0.
-  forall (k=1: llm) zmasse(:, k) = (paprs(:, k)-paprs(:, k+1)) / rg
+  forall (k=1: nbp_lev) zmasse(:, k) = (paprs(:, k)-paprs(:, k+1)) / rg
 
 
@@ -1832,8 +1842,8 @@
 
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
@@ -1978,8 +1988,8 @@
 
      if (mydebug) then
-        call writefield_phy('u_seri',u_seri,llm)
-        call writefield_phy('v_seri',v_seri,llm)
-        call writefield_phy('t_seri',t_seri,llm)
-        call writefield_phy('q_seri',q_seri,llm)
+        call writefield_phy('u_seri',u_seri,nbp_lev)
+        call writefield_phy('v_seri',v_seri,nbp_lev)
+        call writefield_phy('t_seri',t_seri,nbp_lev)
+        call writefield_phy('q_seri',q_seri,nbp_lev)
      endif
 
@@ -2469,8 +2479,8 @@
 
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
@@ -3039,8 +3049,8 @@
 
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
@@ -3397,6 +3407,6 @@
           ibas_con, &
           cldfra, &
-          iim, &
-          jjm, &
+          nbp_lon, &
+          nbp_lat-1, &
           tr_seri, &
           ftsol, &
@@ -3525,8 +3535,8 @@
 
      if (mydebug) then
-        call writefield_phy('u_seri',u_seri,llm)
-        call writefield_phy('v_seri',v_seri,llm)
-        call writefield_phy('t_seri',t_seri,llm)
-        call writefield_phy('q_seri',q_seri,llm)
+        call writefield_phy('u_seri',u_seri,nbp_lev)
+        call writefield_phy('v_seri',v_seri,nbp_lev)
+        call writefield_phy('t_seri',t_seri,nbp_lev)
+        call writefield_phy('q_seri',q_seri,nbp_lev)
      endif
 
@@ -3716,8 +3726,8 @@
   !
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
@@ -3801,8 +3811,8 @@
   !
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
@@ -3909,8 +3919,8 @@
 
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
@@ -4082,5 +4092,5 @@
 
   d_t_ec(:,:)=0.
-  forall (k=1: llm) exner(:, k) = (pplay(:, k)/paprs(:,1))**RKAPPA
+  forall (k=1: nbp_lev) exner(:, k) = (pplay(:, k)/paprs(:,1))**RKAPPA
   CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx(:,:,ivap), &
        u_seri,v_seri,t_seri,q_seri,pbl_tke(:,:,is_ave)-tke0(:,:), &
@@ -4178,8 +4188,8 @@
   !
   if (mydebug) then
-     call writefield_phy('u_seri',u_seri,llm)
-     call writefield_phy('v_seri',v_seri,llm)
-     call writefield_phy('t_seri',t_seri,llm)
-     call writefield_phy('q_seri',q_seri,llm)
+     call writefield_phy('u_seri',u_seri,nbp_lev)
+     call writefield_phy('v_seri',v_seri,nbp_lev)
+     call writefield_phy('t_seri',t_seri,nbp_lev)
+     call writefield_phy('q_seri',q_seri,nbp_lev)
   endif
 
