Index: trunk/LMDZ.MARS/libf/dyn3d/ini_archive.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/ini_archive.F	(revision 1036)
+++ trunk/LMDZ.MARS/libf/dyn3d/ini_archive.F	(revision 1047)
@@ -34,4 +34,5 @@
 c=======================================================================
  
+      use comsoil_h, only: nsoilmx, mlayer
       implicit none
 
@@ -48,5 +49,5 @@
 #include "serre.h"
 #include "control.h"
-#include"comsoil.h"
+!#include"comsoil.h"
 
 #include "netcdf.inc"
Index: trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F	(revision 1036)
+++ trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F	(revision 1047)
@@ -1,3 +1,4 @@
-      SUBROUTINE lect_start_archive(nqtot,date,tsurf,tsoil,emis,q2,
+      SUBROUTINE lect_start_archive(ngrid,nlayer,nqtot,
+     &     date,tsurf,tsoil,emis,q2,
      &     t,ucov,vcov,ps,co2ice,h,phisold_newgrid,
      &     q,qsurf,surfith,nid)
@@ -17,12 +18,13 @@
 c=======================================================================
       use infotrac, only: tnom
+      use comsoil_h, only: nsoilmx, layer, mlayer, volcapa, inertiedat
       implicit none
 
 #include "dimensions.h"
-#include "dimphys.h"
-#include "surfdat.h"
-#include "comsoil.h"
-#include "dimradmars.h"
-#include "yomaer.h"
+!#include "dimphys.h"
+!#include "surfdat.h"
+!#include "comsoil.h"
+!#include "dimradmars.h"
+!#include "yomaer.h"
 #include "planete.h"
 #include "paramet.h"
@@ -49,4 +51,8 @@
 c et autres:
 c----------
+      integer,intent(in) :: ngrid ! number of atmospheric columns
+                                  ! on new physics grid
+      integer,intent(in) :: nlayer ! number of atmospheric layers
+                                   ! on new grid
       integer,intent(in) :: nqtot ! number of advected tracers
 
@@ -98,10 +104,10 @@
 c variable physique
 c------------------
-      REAL tsurf(ngridmx) ! surface temperature
-      REAL tsoil(ngridmx,nsoilmx) ! soil temperature
-      REAL co2ice(ngridmx) ! CO2 ice layer
-      REAL emis(ngridmx)
-      REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqtot)
-c     REAL phisfi(ngridmx)
+      REAL tsurf(ngrid) ! surface temperature
+      REAL tsoil(ngrid,nsoilmx) ! soil temperature
+      REAL co2ice(ngrid) ! CO2 ice layer
+      REAL emis(ngrid)
+      REAL q2(ngrid,nlayer+1),qsurf(ngrid,nqtot)
+c     REAL phisfi(ngrid)
 
       INTEGER i,j,l
@@ -176,5 +182,5 @@
 
       real surfith(iip1,jjp1) ! surface thermal inertia
-!      real surfithfi(ngridmx)
+!      real surfithfi(ngrid)
       ! surface thermal inertia at old horizontal grid resolution
       real, dimension(:,:), allocatable :: surfithold 
@@ -335,5 +341,5 @@
       allocate(varp1 (imold+1,jmold+1,llm+1))
 
-      write(*,*) 'q2',ngridmx,nlayermx+1
+      write(*,*) 'q2',ngrid,nlayer+1
       write(*,*) 'q2S',iip1,jjp1,llm+1
       write(*,*) 'q2old',imold+1,jmold+1,lmold+1
@@ -1000,5 +1006,5 @@
       call interp_horiz (tsurfold,tsurfs,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,tsurfs,tsurf)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsurfs,tsurf)
 c     write(44,*) 'tsurf', tsurf
 
@@ -1007,5 +1013,5 @@
 !     &                  imold,jmold,iim,jjm,nsoilmx,
 !     &                   rlonuold,rlatvold,rlonu,rlatv)
-!      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,tsoils,tsoil)
+!      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoils,tsoil)
 c     write(45,*) 'tsoil',tsoil
 
@@ -1013,5 +1019,5 @@
       call interp_horiz (emisold,emiss,imold,jmold,iim,jjm,1,
      &                   rlonuold,rlatvold,rlonu,rlatv)
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,emiss,emis)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,emiss,emis)
 c     write(46,*) 'emis',emis
 c-----------------------------------------------------------------------
@@ -1130,5 +1136,5 @@
 
       ! Reshape inertiedatS to scalar grid as inertiedat
-      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,
+      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,
      &                  inertiedatS,inertiedat)
       
@@ -1203,5 +1209,5 @@
 
       ! Reshape tsoilS to scalar grid as tsoil
-       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngridmx,tsoilS,tsoil)
+       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoilS,tsoil)
 
 
@@ -1229,5 +1235,5 @@
      &                   rlonuold,rlatvold,rlonu,rlatv)
       write (*,*) 'lect_start_archive: q2s ', q2s (1,2,1)  ! INFO
-      call gr_dyn_fi (llm+1,iim+1,jjm+1,ngridmx,q2s,q2)
+      call gr_dyn_fi (llm+1,iim+1,jjm+1,ngrid,q2s,q2)
       write (*,*) 'lect_start_archive: q2 ', q2 (1,2)  ! INFO
 c     write(47,*) 'q2',q2
@@ -1278,5 +1284,5 @@
       enddo
 
-      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngridmx,qsurfs,qsurf)
+      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngrid,qsurfs,qsurf)
 
 c traceurs 3D
@@ -1329,5 +1335,5 @@
       enddo
       
-      call gr_dyn_fi (1,iim+1,jjm+1,ngridmx,co2ices,co2ice)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,co2ices,co2ice)
 
 c-----------------------------------------------------------------------
Index: trunk/LMDZ.MARS/libf/dyn3d/lectflux.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/lectflux.F	(revision 1036)
+++ 	(revision )
@@ -1,233 +1,0 @@
-      SUBROUTINE lectflux(irec,massem,pbarun,pbarvn,wn,tetan,phin,
-     s     nrec,avant,airefi,
-     s     zmfu, zmfd, zen_u, zde_u,zen_d, zde_d, coefkz,
-     s     yu1,yv1,ftsol,pctsrf,
-     s     frac_impa,frac_nucl,phis)
-
-      IMPLICIT NONE
-
-#include "dimensions.h"
-#include "paramet.h"
-
-#include "comvert.h"
-#include "comconst.h"
-#include "comgeom2.h"
-
-#include "tracstoke.h"
-
-      integer irec,nrec,i,j
-
-      integer ngridmx,ig,l
-      parameter (ngridmx=iim*(jjm-1)+2)
-      INTEGER nbsrf
-      PARAMETER (nbsrf=4) ! nombre de sous-fractions pour une maille
-
-      real zmfd(ngridmx,llm),zde_d(ngridmx,llm),zen_d(ngridmx,llm)
-      real zmfu(ngridmx,llm),zde_u(ngridmx,llm),zen_u(ngridmx,llm)
-      real coefkz(ngridmx,llm)
-      real frac_impa(ngridmx,llm),frac_nucl(ngridmx,llm)
-      real yu1(ngridmx), yv1(ngridmx)
-      real ftsol(ngridmx,nbsrf),pctsrf(ngridmx,nbsrf)
-      integer imfu,imfd,ien_u,ide_u,
-     s      ien_d,ide_d,
-     s      icoefkz,izu1,izv1,
-     s      itsol,ipsf,
-     s      ilei, ilec
-      parameter(imfu=1,imfd=llm+1,ien_u=2*llm+1,ide_u=3*llm+1,
-     s      ien_d=4*llm+1,ide_d=5*llm+1,
-     s      icoefkz=6*llm+1,
-     s      ilei=7*llm+1,ilec=8*llm+1,
-     s      izu1=9*llm+1,izv1=9*llm+2,
-     s      itsol=9*llm+3,ipsf=9*llm+3+nbsrf)
-      logical avant
-
-      real massefi(ngridmx,llm)
-
-      real massem(ip1jmp1,llm),tetan(ip1jmp1,llm)
-      real pbarun(iip1,jjp1,llm),pbarvn(iip1,jjm,llm)
-      real pbarvst(iip1,jjp1,llm)
-      real wn(iip1,jjp1,llm),phin(iip1,jjp1,llm)
-      real phis(iip1,jjp1)
-
-      real airefi(ngridmx)
-
-      real xlecn(ngridmx,9*llm+2+2*nbsrf)
-
-      real zcontrole(ngridmx),zmass,tmpdyn(iip1,jjp1),zflux
-
-      real ziadvtrac,zrec,ziadvtrac2,zrec2
-      real zim,zjm,zlm,zklon,zklev
-
-      real zpi
-
-      zpi=2.*asin(1.)
-
-
-c==================================================================
-c   Si le numero du record est 0 alors: INITIALISATION
-c==================================================================
-c
-      print*,'ENTREE DANS LECTFLUX'
-        print*,'IREC=',IREC
-      if(irec.eq.0) then
-
-        print*,'IREC==',0
-
-C test         call inigeom
-
-c==================================================================
-c   ouverture des fichiers
-c==================================================================
-
-c   Fichier fluxmass
-#ifdef CRAY
-         CALL ASSIGN("assign -N ieee -F null f:fluxmass")
-#endif
-      open(47,file='fluxmass',form='unformatted',
-     s     access='direct'
-     s     ,recl=4*(6*ijp1llm))
-      read(47,rec=1) zrec,dtvr,ziadvtrac,zim,zjm,zlm,
-     s   rlonu,rlonv,rlatu,rlatv,aire
-     s    ,phis
-      print*,'zrec,dtvr,ziadvtrac,zim,zjm,zlm'
-      print*,zrec,dtvr,ziadvtrac,zim,zjm,zlm
-      print*,rlonv
-
-
-
-c  Fichier physique
-c  Fichier lessivage (supprime les donnees utiles sont dans "physique")
-#ifdef CRAY
-         CALL ASSIGN("assign -N ieee -F null f:physique")
-#endif
-      open(49,file='physique',form='unformatted',
-     s     access='direct'
-     s     ,recl=4*ngridmx*(9*llm+2+2*nbsrf))
-      read(49,rec=1) zrec2,ziadvtrac2,zklon,zklev
-      print*,'Entete du fichier physique'
-      print*,zrec2,ziadvtrac2,zklon,zklev
-
-      nrec=zrec
-      print*,'nrec=',nrec
-
-      istdyn=ziadvtrac
-      istphy=ziadvtrac2
-
-c==================================================================
-c   Fin des initialisations
-      else ! irec=0
-c==================================================================
-
-
-c-----------------------------------------------------------------------
-c   Lecture des fichiers fluxmass et  physique:
-c   -----------------------------------------------------
-
-c  Variables dynamiques
-         read(47,rec=irec) massem,pbarun,pbarvst,wn,tetan,phin
-        do l=1,llm
-           do j=1,jjm
-              do i=1,iip1
-                 pbarvn(i,j,l)=pbarvst(i,j,l)
-              enddo
-           enddo
-        enddo
-
-c  Variables physiques
-         read(49,rec=irec) ((xlecn(ig,l),ig=1,ngridmx),
-     s                                    l=1,9*llm+2+2*nbsrf)
-
-       do l=1,llm
-          do ig=1,ngridmx
-             coefkz(ig,l)=xlecn(ig,icoefkz+l-1)
-             frac_impa(ig,l)=xlecn(ig,ilei+l-1)
-             frac_nucl(ig,l)=xlecn(ig,ilec+l-1)
-          enddo
-       enddo
-       do l=1,nbsrf
-          do ig=1,ngridmx
-             ftsol(ig,l)=xlecn(ig,itsol+l-1)
-             pctsrf(ig,l)=xlecn(ig,ipsf+l-1)
-          enddo
-       enddo
-       do ig=1,ngridmx
-          yv1(ig)=xlecn(ig,izv1)
-          yu1(ig)=xlecn(ig,izu1)
-       enddo
-C
-      if(avant) then
-c   Simu directe
-       do l=1,llm
-          do ig=1,ngridmx
-             zmfu(ig,l)=xlecn(ig,imfu+l-1)
-             zmfd(ig,l)=xlecn(ig,imfd+l-1)
-             zde_u(ig,l)=xlecn(ig,ide_u+l-1)
-             zen_u(ig,l)=xlecn(ig,ien_u+l-1)
-             zde_d(ig,l)=xlecn(ig,ide_d+l-1)
-             zen_d(ig,l)=xlecn(ig,ien_d+l-1)
-          enddo
-       enddo
-      else
-c   Simu retro
-       do l=1,llm
-          do ig=1,ngridmx
-             zmfd(ig,l)=-xlecn(ig,imfu+l-1)
-             zmfu(ig,l)=-xlecn(ig,imfd+l-1)
-             zen_d(ig,l)=xlecn(ig,ide_u+l-1)
-             zde_d(ig,l)=xlecn(ig,ien_u+l-1)
-             zen_u(ig,l)=xlecn(ig,ide_d+l-1)
-             zde_u(ig,l)=xlecn(ig,ien_d+l-1)
-          enddo
-       enddo
-      endif
-
-c-----------------------------------------------------------------------
-c   PETIT CONTROLE SUR LES FLUX CONVECTIFS...
-c-----------------------------------------------------------------------
-
-      print*,'Ap redec irec'
-
-         call gr_dyn_fi(llm,iip1,jjp1,ngridmx,massem,massefi)
-
-         do ig=1,ngridmx
-            zcontrole(ig)=1.
-         enddo
-c   zmass=(max(massem(ig,l),massem(ig,l-1))/airefi(ig)
-         do l=2,llm
-            do ig=1,ngridmx
-               zmass=max(massefi(ig,l),massefi(ig,l-1))/airefi(ig)
-               zflux=max(abs(zmfu(ig,l)),abs(zmfd(ig,l)))*dtphys
-               if(zflux.gt.0.9*zmass) then
-                 zcontrole(ig)=min(zcontrole(ig),0.9*zmass/zflux)
-               endif
-            enddo
-         enddo
-
-         do ig=1,ngridmx
-            if(zcontrole(ig).lt.0.99999) then
-               print*,'ATTENTION !!! on reduit les flux de masse '
-               print*,'convectifs au point ig=',ig
-            endif
-         enddo
-
-         call gr_fi_dyn(1,ngridmx,iip1,jjp1,zcontrole,tmpdyn)
-
-         do l=1,llm
-            do ig=1,ngridmx
-               zmfu(ig,l)=zmfu(ig,l)*zcontrole(ig)
-               zmfd(ig,l)=zmfd(ig,l)*zcontrole(ig)
-               zen_u(ig,l)=zen_u(ig,l)*zcontrole(ig)
-               zde_u(ig,l)=zde_u(ig,l)*zcontrole(ig)
-               zen_d(ig,l)=zen_d(ig,l)*zcontrole(ig)
-               zde_d(ig,l)=zde_d(ig,l)*zcontrole(ig)
-            enddo
-         enddo
-
-
-      endif ! irec=0
-
-
-      RETURN
-      END
-
-
Index: trunk/LMDZ.MARS/libf/dyn3d/newstart.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/newstart.F	(revision 1036)
+++ trunk/LMDZ.MARS/libf/dyn3d/newstart.F	(revision 1047)
@@ -19,12 +19,16 @@
       use infotrac, only: iniadvtrac, nqtot, tnom
       use tracer_mod, only: noms, igcm_h2o_vap, igcm_h2o_ice
+      use surfdat_h, only: phisfi, z0, zmea, zstd, zsig, zgam, zthe,
+     &                     albedodat, z0_default
+      use comsoil_h, only: inertiedat, layer, mlayer, nsoilmx
       implicit none
 
 #include "dimensions.h"
+      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) 
 #include "dimphys.h"
-#include "surfdat.h"
-#include "comsoil.h"
-#include "dimradmars.h"
-#include "yomaer.h"
+!#include "surfdat.h"
+!#include "comsoil.h"
+!#include "dimradmars.h"
+!#include "yomaer.h"
 #include "planete.h"
 #include "paramet.h"
@@ -404,6 +408,7 @@
 
         write(*,*) 'Reading file START_ARCHIVE'
-        CALL lect_start_archive(nqtot,date,tsurf,tsoil,emis,q2,
-     .   t,ucov,vcov,ps,co2ice,teta,phisold_newgrid,q,qsurf,
+        CALL lect_start_archive(ngridmx,llm,nqtot,
+     &   date,tsurf,tsoil,emis,q2,
+     &   t,ucov,vcov,ps,co2ice,teta,phisold_newgrid,q,qsurf,
      &   surfith,nid)
         write(*,*) "OK, read start_archive file"
@@ -425,5 +430,5 @@
         write(*,*) 'Reading file STARTFI'
         fichnom = 'startfi.nc'
-        CALL phyetat0 (fichnom,tab0,Lmodif,nsoilmx,nqtot,
+        CALL phyetat0 (fichnom,tab0,Lmodif,nsoilmx,ngridmx,llm,nqtot,
      .        day_ini,time,
      .        tsurf,tsoil,emis,q2,qsurf,co2ice)
@@ -858,5 +863,6 @@
           endif
           
-          call inichim_newstart(nq, q, qsurf, ps, flagh2o, flagthermo)
+          call inichim_newstart(ngridmx, nq, q, qsurf, ps, 
+     &                          flagh2o, flagthermo)
 
          ! We want to have the very same value at lon -180 and lon 180
@@ -1472,8 +1478,8 @@
 C
 
-      call physdem0("restartfi.nc",lonfi,latfi,nsoilmx,nqtot,
-     .              dtphys,real(day_ini),0.0,
+      call physdem0("restartfi.nc",lonfi,latfi,nsoilmx,ngridmx,llm,
+     .              nqtot,dtphys,real(day_ini),0.0,
      .              airefi,albfi,ithfi,zmea,zstd,zsig,zgam,zthe)
-      call physdem1("restartfi.nc",nsoilmx,nqtot,
+      call physdem1("restartfi.nc",nsoilmx,ngridmx,llm,nqtot,
      .              dtphys,hour_ini,
      .              tsurf,tsoil,co2ice,emis,q2,qsurf)
Index: trunk/LMDZ.MARS/libf/dyn3d/start2archive.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/start2archive.F	(revision 1036)
+++ trunk/LMDZ.MARS/libf/dyn3d/start2archive.F	(revision 1047)
@@ -20,7 +20,11 @@
 
       use infotrac, only: iniadvtrac, nqtot, tnom
+      use comsoil_h, only: nsoilmx, inertiedat
+      use surfdat_h, only: ini_surfdat_h
+      use comsoil_h, only: ini_comsoil_h
       implicit none
 
 #include "dimensions.h"
+      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) 
 #include "paramet.h"
 #include "comconst.h"
@@ -34,6 +38,6 @@
 #include "description.h"
 
-#include "dimphys.h"
-#include "comsoil.h"
+!#include "dimphys.h"
+!#include "comsoil.h"
 !#include"advtrac.h"
 #include "netcdf.inc"
@@ -62,5 +66,5 @@
       REAL tsoil(ngridmx,nsoilmx) ! Soil temperature
       REAL co2ice(ngridmx)	! CO2 ice layer
-      REAL q2(ngridmx,nlayermx+1)
+      REAL q2(ngridmx,llm+1)
       REAL,ALLOCATABLE :: qsurf(:,:)
       REAL emis(ngridmx)
@@ -126,4 +130,7 @@
       allocate(qsurf(ngridmx,nqtot))
       allocate(qsurfS(ip1jmp1,nqtot))
+      call ini_surfdat_h(ngridmx)
+      call ini_comsoil_h(ngridmx)
+      
 
       fichnom = 'start.nc'
@@ -135,6 +142,6 @@
       Lmodif=0
 
-      CALL phyetat0 (fichnom,0,Lmodif,nsoilmx,nqtot,day_ini_fi,timefi,
-     .      tsurf,tsoil,emis,q2,qsurf,co2ice)
+      CALL phyetat0 (fichnom,0,Lmodif,nsoilmx,ngridmx,llm,nqtot,
+     &      day_ini_fi,timefi,tsurf,tsoil,emis,q2,qsurf,co2ice)
 
        ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1)
Index: trunk/LMDZ.MARS/libf/dyn3d/write_archive.F
===================================================================
--- trunk/LMDZ.MARS/libf/dyn3d/write_archive.F	(revision 1036)
+++ trunk/LMDZ.MARS/libf/dyn3d/write_archive.F	(revision 1047)
@@ -32,4 +32,5 @@
 c=======================================================================
 
+      use comsoil_h, only: nsoilmx
       implicit none
 
