Index: dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/distrib_icosa_lmdz.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/distrib_icosa_lmdz.f90	(revision 3841)
+++ dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/distrib_icosa_lmdz.f90	(revision 3841)
@@ -0,0 +1,231 @@
+MODULE distrib_icosa_lmdz_mod
+  
+  TYPE t_distrib_physic
+    INTEGER,POINTER :: index(:)    ! list of index used for thread entering in lmdz physic
+    INTEGER         :: nindex      ! number of index used
+    INTEGER         :: domain_ind  ! index of the related domain
+  END TYPE t_distrib_physic
+  
+  INTEGER, SAVE :: ndomain_distrib    ! number of domain needed for thread data
+!$OMP THREADPRIVATE(ndomain_distrib)
+
+  TYPE(t_distrib_physic),ALLOCATABLE, SAVE :: distrib_physic(:) 
+!$OMP THREADPRIVATE(distrib_physic)  
+
+
+  INTERFACE transfer_icosa_to_lmdz
+    MODULE PROCEDURE transfer_icosa_to_lmdz1d,transfer_icosa_to_lmdz2d,transfer_icosa_to_lmdz3d
+  END INTERFACE transfer_icosa_to_lmdz
+
+  INTERFACE transfer_lmdz_to_icosa
+    MODULE PROCEDURE transfer_lmdz1d_to_icosa,transfer_lmdz2d_to_icosa,transfer_lmdz3d_to_icosa
+  END INTERFACE transfer_lmdz_to_icosa
+      
+CONTAINS
+
+
+  SUBROUTINE init_distrib_icosa_lmdz
+  USE mod_phys_lmdz_omp_data, ONLY: klon_omp_begin, klon_omp_end
+  USE domain_mod
+  USE dimensions
+  IMPLICIT NONE
+    INTEGER :: pos,pos_tmp,nindex
+    INTEGER :: ind, i,j,ij
+    
+    ALLOCATE(distrib_physic(ndomain))
+   
+    ndomain_distrib=0 
+    pos=0
+    DO ind=1,ndomain
+      CALL swap_dimensions(ind)
+
+! first guess to determine number of indices for this domain
+      pos_tmp=pos
+      nindex=0
+      DO j=jj_begin,jj_end
+        DO i=ii_begin,ii_end
+          ij=(j-1)*iim+i
+          pos_tmp=pos_tmp+1
+          IF (pos_tmp >= klon_omp_begin .AND. pos_tmp <= klon_omp_end) nindex=nindex+1
+        ENDDO
+      ENDDO
+
+! fill the index array
+
+      IF (nindex>0) THEN
+        ndomain_distrib=ndomain_distrib+1
+        ALLOCATE(distrib_physic(ndomain_distrib)%index(nindex))
+        distrib_physic(ndomain_distrib)%nindex=nindex
+        distrib_physic(ndomain_distrib)%domain_ind=ind
+        
+        nindex=0
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            pos=pos+1
+            IF (pos >= klon_omp_begin .AND. pos <= klon_omp_end) THEN
+              nindex=nindex+1
+              distrib_physic(ndomain_distrib)%index(nindex)=ij
+            ENDIF
+          ENDDO
+        ENDDO
+      ELSE
+        pos=pos_tmp
+      ENDIF
+    
+    ENDDO
+       
+  END SUBROUTINE init_distrib_icosa_lmdz
+                  
+  SUBROUTINE transfer_icosa_to_lmdz1d(f_field_icosa, field_lmdz)
+  USE field_mod
+  IMPLICIT NONE
+    TYPE(t_field),POINTER :: f_field_icosa(:)
+    REAL(rstd)         :: field_lmdz(:)
+    REAL(rstd),POINTER :: field_icosa(:)
+    INTEGER         :: pos, nindex,ind,i
+    INTEGER,POINTER :: index(:)
+    
+    pos=0
+    DO ind=1,ndomain_distrib
+      field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind)
+      index=>distrib_physic(ind)%index
+      nindex=distrib_physic(ind)%nindex
+      DO i=1,nindex
+        pos=pos+1
+        field_lmdz(pos)=field_icosa(index(i))
+      ENDDO
+    ENDDO
+    
+  END SUBROUTINE  transfer_icosa_to_lmdz1d
+  
+  SUBROUTINE transfer_icosa_to_lmdz2d(f_field_icosa, field_lmdz)
+  USE field_mod
+  IMPLICIT NONE
+    TYPE(t_field),POINTER :: f_field_icosa(:)
+    REAL(rstd)         :: field_lmdz(:,:)
+
+    REAL(rstd),POINTER :: field_icosa(:,:)
+    INTEGER         :: pos, nindex,ind,i
+    INTEGER,POINTER :: index(:)
+    INTEGER :: l
+    
+    DO l=1,size(field_lmdz,2)  
+      pos=0
+      DO ind=1,ndomain_distrib
+        field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind)
+        index=>distrib_physic(ind)%index
+        nindex=distrib_physic(ind)%nindex
+        DO i=1,nindex
+          pos=pos+1
+          field_lmdz(pos,l)=field_icosa(index(i),l)
+        ENDDO
+      ENDDO
+    ENDDO
+    
+  END SUBROUTINE  transfer_icosa_to_lmdz2d
+
+
+    
+  SUBROUTINE transfer_icosa_to_lmdz3d(f_field_icosa, field_lmdz)
+  USE field_mod
+  IMPLICIT NONE
+    TYPE(t_field),POINTER :: f_field_icosa(:)
+    REAL(rstd)         :: field_lmdz(:,:,:)
+    REAL(rstd),POINTER :: field_icosa(:,:,:)
+    INTEGER         :: pos, nindex,ind,i
+    INTEGER,POINTER :: index(:)
+    INTEGER :: l,q
+
+    DO q=1,size(field_lmdz,3)  
+      DO l=1,size(field_lmdz,2)  
+        pos=0
+        DO ind=1,ndomain_distrib
+          field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind)
+          index=>distrib_physic(ind)%index
+          nindex=distrib_physic(ind)%nindex
+          DO i=1,nindex
+            pos=pos+1
+            field_lmdz(pos,l,q)=field_icosa(index(i),l,q)
+          ENDDO
+        ENDDO
+      ENDDO
+    ENDDO
+    
+  END SUBROUTINE  transfer_icosa_to_lmdz3d
+      
+  SUBROUTINE transfer_lmdz1d_to_icosa(field_lmdz,f_field_icosa)
+  USE field_mod
+  IMPLICIT NONE
+    REAL(rstd)         :: field_lmdz(:)
+    TYPE(t_field),POINTER :: f_field_icosa(:)
+    REAL(rstd),POINTER :: field_icosa(:)
+    INTEGER         :: pos, nindex,ind,i
+    INTEGER,POINTER :: index(:)
+    
+    pos=0
+    DO ind=1,ndomain_distrib
+      field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind)
+      index=>distrib_physic(ind)%index
+      nindex=distrib_physic(ind)%nindex
+      DO i=1,nindex
+        pos=pos+1
+        field_icosa(index(i))=field_lmdz(pos)
+      ENDDO
+    ENDDO
+  END SUBROUTINE  transfer_lmdz1d_to_icosa
+
+  SUBROUTINE transfer_lmdz2d_to_icosa(field_lmdz,f_field_icosa)
+  USE field_mod
+  IMPLICIT NONE
+    REAL(rstd)         :: field_lmdz(:,:)
+    TYPE(t_field),POINTER :: f_field_icosa(:)
+    REAL(rstd),POINTER :: field_icosa(:,:)
+    INTEGER         :: pos, nindex,ind,i
+    INTEGER,POINTER :: index(:)
+    INTEGER :: l
+    
+    DO l=1,size(field_lmdz,2)  
+      pos=0
+      DO ind=1,ndomain_distrib
+        field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind)
+        index=>distrib_physic(ind)%index
+        nindex=distrib_physic(ind)%nindex
+        DO i=1,nindex
+          pos=pos+1
+          field_icosa(index(i),l)=field_lmdz(pos,l)
+        ENDDO
+      ENDDO
+    ENDDO
+  
+  END SUBROUTINE transfer_lmdz2d_to_icosa    
+
+
+  SUBROUTINE transfer_lmdz3d_to_icosa(field_lmdz,f_field_icosa)
+  USE field_mod
+  IMPLICIT NONE
+    REAL(rstd)         :: field_lmdz(:,:,:)
+    TYPE(t_field),POINTER :: f_field_icosa(:)
+    REAL(rstd),POINTER :: field_icosa(:,:,:)
+    INTEGER         :: pos, nindex,ind,i
+    INTEGER,POINTER :: index(:)
+    INTEGER :: l,q
+    
+    DO q=1,size(field_lmdz,3)  
+      DO l=1,size(field_lmdz,2)  
+        pos=0
+        DO ind=1,ndomain_distrib
+          field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind)
+          index=>distrib_physic(ind)%index
+          nindex=distrib_physic(ind)%nindex
+          DO i=1,nindex
+            pos=pos+1
+            field_icosa(index(i),l,q)=field_lmdz(pos,l,q)
+          ENDDO
+        ENDDO
+      ENDDO
+    ENDDO
+  
+  END SUBROUTINE transfer_lmdz3d_to_icosa    
+
+END MODULE distrib_icosa_lmdz_mod
Index: dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/initialize_physic.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/initialize_physic.f90	(revision 3840)
+++ 	(revision )
@@ -1,36 +1,0 @@
-  SUBROUTINE initialize_physic(nbp,nlayer, communicator,                        &
-                               day_length,start_day,timestep,                   &
-                               nvertex,latfi,lonfi,airefi,bounds_lonfi,bounds_latfi,  &
-                               radius,g, R, cpp,                        &
-                               preff, ap, bp)                   
-    USE mod_grid_phy_lmdz
-    INTEGER :: nbp_glo
-    REAL    :: pseudoalt(nlayer)
-    
-    pseudoalt(:)=0 
-    
-    CALL MPI_ALLREDUCE(nbp,nbp_glo,1,MPI_INTEGER,MPI_SUM,communicator,ierr)
-    
-    CALL init_physics_distribution(unstructured, 6, nbp, 1, nbp_glo, llm, communicator)
-    CALL init_geometry(lonfi, latfi, boundslonfi, boundslatfi, airefi)
-    CALL init_vertical_layers(nlayer,preff,ap,bp,presnivs,pseudoalt)
-  
-    CALL init_infotrac_phy(nqtot,nqo,nbtr,tname,ttext,type_trac,&
-                         niadv,conv_flg,pbl_flg,solsym)
-  
-    
-    punjour=day_length
-    prad=radius
-    pg=g
-    pr=R
-    pcpp=cpp
-    ptimestep=timestep
-    day_step=day_length/timestep
-    
-    CALL inifis(punjours,prad,pg,pr,pcpp,ptimestep,&
-              day_step,dayref,anneeref,nday,&
-              annee_ref,day_ini,day_end,&
-              itau_phy,itaufin,&
-              start_time,day_ref,jD_ref, &
-              offline,raz_date,config_inca, &
-              lunout,prt_level,debug)
Index: dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/interface_icosa_lmdz.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/interface_icosa_lmdz.f90	(revision 3841)
+++ dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/interface_icosa_lmdz.f90	(revision 3841)
@@ -0,0 +1,771 @@
+MODULE interface_icosa_lmdz_mod
+
+  USE field_mod, ONLY: t_field
+  USE transfert_mod, ONLY: t_message
+  
+ 
+  TYPE(t_message) :: req_u
+
+  TYPE(t_field),POINTER,SAVE :: f_p(:) 
+  TYPE(t_field),POINTER,SAVE :: f_pks(:)  
+  TYPE(t_field),POINTER,SAVE :: f_pk(:)  
+  TYPE(t_field),POINTER,SAVE :: f_p_layer(:)    
+  TYPE(t_field),POINTER,SAVE :: f_theta(:)   
+  TYPE(t_field),POINTER,SAVE :: f_phi(:)   
+  TYPE(t_field),POINTER,SAVE :: f_Temp(:)    
+  TYPE(t_field),POINTER,SAVE :: f_ulon(:)    
+  TYPE(t_field),POINTER,SAVE :: f_ulat(:)   
+  TYPE(t_field),POINTER,SAVE :: f_dulon(:)
+  TYPE(t_field),POINTER,SAVE :: f_dulat(:)
+  TYPE(t_field),POINTER,SAVE :: f_dTemp(:)
+  TYPE(t_field),POINTER,SAVE :: f_dq(:)
+  TYPE(t_field),POINTER,SAVE :: f_dps(:)
+  TYPE(t_field),POINTER,SAVE :: f_duc(:)
+  TYPE(t_field),POINTER,SAVE :: f_bounds_lon(:)
+  TYPE(t_field),POINTER,SAVE :: f_bounds_lat(:)
+
+  INTEGER :: start_clock
+  INTEGER :: stop_clock
+  INTEGER :: count_clock=0
+  
+  REAL :: day_length
+
+  
+  INTEGER,SAVE :: nbp_phys
+  INTEGER,SAVE :: nbp_phys_glo
+
+
+CONTAINS
+
+  SUBROUTINE initialize_physics
+  USE distrib_icosa_lmdz_mod, ONLY : init_distrib_icosa_lmdz, transfer_icosa_to_lmdz
+! from dynamico
+  USE domain_mod
+  USE dimensions
+  USE mpi_mod
+  USE mpipara
+  USE disvert_mod
+  USE xios_mod
+  USE time_mod , init_time_icosa=> init_time 
+
+! from LMDZ
+  USE mod_grid_phy_lmdz, ONLY : unstructured
+  USE mod_phys_lmdz_omp_data, ONLY: klon_omp
+  USE time_phylmdz_mod, ONLY: init_time_lmdz => init_time
+  USE transfert_mod
+  USE physics_distribution_mod, ONLY : init_physics_distribution
+  USE geometry_mod, ONLY : init_geometry
+  USE vertical_layers_mod, ONLY : init_vertical_layers
+  USE infotrac_phy, ONLY : init_infotrac_phy
+  USE inifis_mod, ONLY : inifis 
+  USE phyaqua_mod, ONLY : iniaqua 
+   
+  
+  IMPLICIT NONE
+  INTEGER  :: ind,i,j,ij,pos
+  REAL(rstd),POINTER :: bounds_lon(:,:)
+  REAL(rstd),POINTER :: bounds_lat(:,:)
+  
+  REAL(rstd),ALLOCATABLE :: latfi(:)
+  REAL(rstd),ALLOCATABLE :: lonfi(:)
+  REAL(rstd),ALLOCATABLE :: airefi(:)
+  REAL(rstd),ALLOCATABLE :: bounds_latfi(:,:)
+  REAL(rstd),ALLOCATABLE :: bounds_lonfi(:,:)
+  REAL(rstd) :: pseudoalt(llm)
+
+  INTEGER :: run_length  
+  INTEGER :: annee_ref  
+  INTEGER :: day_ref    
+  INTEGER :: day_ini    
+  REAL    :: start_time 
+  REAL    :: physics_timestep    
+
+
+  INTEGER                       :: nqo, nbtr
+  CHARACTER(len=4)              :: type_trac
+  CHARACTER(len=20),ALLOCATABLE :: tname(:)    ! tracer short name for restart and diagnostics
+  CHARACTER(len=23),ALLOCATABLE :: ttext(:)     ! tracer long name for diagnostics
+  INTEGER,ALLOCATABLE           :: niadv(:)    ! equivalent dyn / physique
+  INTEGER,ALLOCATABLE           :: conv_flg(:) ! conv_flg(it)=0 : convection desactivated for tracer number it 
+  INTEGER,ALLOCATABLE           :: pbl_flg(:)  ! pbl_flg(it)=0  : boundary layer diffusion desactivaded for tracer number it 
+  CHARACTER(len=8),ALLOCATABLE :: solsym(:)  ! tracer name from inca
+
+  INTEGER :: iflag_phys    
+  INTEGER :: nbp_phys, nbp_phys_glo
+  
+!$OMP PARALLEL
+    CALL allocate_field(f_bounds_lon,field_t,type_real,6)
+    CALL allocate_field(f_bounds_lat,field_t,type_real,6)
+    CALL allocate_field(f_p,field_t,type_real,llm+1)
+    CALL allocate_field(f_pks,field_t,type_real)
+    CALL allocate_field(f_pk,field_t,type_real,llm)
+    CALL allocate_field(f_p_layer,field_t,type_real,llm)
+    CALL allocate_field(f_theta,field_t,type_real,llm)
+    CALL allocate_field(f_phi,field_t,type_real,llm)
+    CALL allocate_field(f_Temp,field_t,type_real,llm)
+    CALL allocate_field(f_ulon,field_t,type_real,llm)
+    CALL allocate_field(f_ulat,field_t,type_real,llm)
+    CALL allocate_field(f_dulon,field_t,type_real,llm)
+    CALL allocate_field(f_dulat,field_t,type_real,llm)
+    CALL allocate_field(f_dTemp,field_t,type_real,llm)
+    CALL allocate_field(f_dq,field_t,type_real,llm,nqtot)
+    CALL allocate_field(f_dps,field_t,type_real)
+    CALL allocate_field(f_duc,field_t,type_real,3,llm)    
+!$OMP END PARALLEL    
+
+    nbp_phys=0
+    DO ind=1,ndomain
+      CALL swap_dimensions(ind)
+      nbp_phys=nbp_phys+ii_nb*jj_nb
+    ENDDO
+    
+
+!initialize LMDZ5 physic mpi decomposition
+    CALL MPI_ALLREDUCE(nbp_phys,nbp_phys_glo,1,MPI_INTEGER,MPI_SUM,comm_icosa,ierr)
+    CALL init_physics_distribution(unstructured, 6, nbp_phys, 1, nbp_phys_glo, llm, comm_icosa)
+    
+    DO ind=1,ndomain
+        CALL swap_dimensions(ind)
+        CALL swap_geometry(ind)
+        bounds_lon=f_bounds_lon(ind)
+        bounds_lat=f_bounds_lat(ind)
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            CALL xyz2lonlat(xyz_v(ij+z_rup,:), bounds_lon(ij,1), bounds_lat(ij,1))
+            CALL xyz2lonlat(xyz_v(ij+z_up,:), bounds_lon(ij,2), bounds_lat(ij,2))
+            CALL xyz2lonlat(xyz_v(ij+z_lup,:), bounds_lon(ij,3), bounds_lat(ij,3))
+            CALL xyz2lonlat(xyz_v(ij+z_ldown,:), bounds_lon(ij,4), bounds_lat(ij,4))
+            CALL xyz2lonlat(xyz_v(ij+z_down,:), bounds_lon(ij,5), bounds_lat(ij,5))
+            CALL xyz2lonlat(xyz_v(ij+z_rdown,:), bounds_lon(ij,6), bounds_lat(ij,6))
+         ENDDO
+       ENDDO            
+    ENDDO
+          
+!$OMP PARALLEL
+    CALL initialize_physics_omp
+!$OMP END PARALLEL            
+
+    CALL xios_set_context    
+
+
+     
+
+  END SUBROUTINE initialize_physics
+
+
+  SUBROUTINE initialize_physics_omp
+  USE distrib_icosa_lmdz_mod, ONLY : init_distrib_icosa_lmdz, transfer_icosa_to_lmdz
+! from dynamico
+  USE domain_mod
+  USE dimensions
+  USE mpi_mod
+  USE mpipara
+  USE disvert_mod
+  USE xios_mod
+  USE time_mod , init_time_icosa=> init_time 
+
+! from LMDZ
+  USE mod_grid_phy_lmdz, ONLY : unstructured
+  USE mod_phys_lmdz_omp_data, ONLY: klon_omp
+  USE time_phylmdz_mod, ONLY: init_time_lmdz => init_time
+  USE transfert_mod
+  USE physics_distribution_mod, ONLY : init_physics_distribution
+  USE geometry_mod, ONLY : init_geometry
+  USE vertical_layers_mod, ONLY : init_vertical_layers
+  USE infotrac_phy, ONLY : init_infotrac_phy
+  USE inifis_mod, ONLY : inifis 
+  USE phyaqua_mod, ONLY : iniaqua 
+   
+  
+  IMPLICIT NONE
+
+
+
+  INTEGER  :: ind,i,j,ij,pos
+  REAL(rstd),POINTER :: bounds_lon(:,:)
+  REAL(rstd),POINTER :: bounds_lat(:,:)
+  
+  REAL(rstd),ALLOCATABLE :: latfi(:)
+  REAL(rstd),ALLOCATABLE :: lonfi(:)
+  REAL(rstd),ALLOCATABLE :: airefi(:)
+  REAL(rstd),ALLOCATABLE :: bounds_latfi(:,:)
+  REAL(rstd),ALLOCATABLE :: bounds_lonfi(:,:)
+  REAL(rstd) :: pseudoalt(llm)
+
+  INTEGER :: run_length  
+  INTEGER :: annee_ref  
+  INTEGER :: day_ref    
+  INTEGER :: day_ini    
+  REAL    :: start_time 
+  REAL    :: physics_timestep    
+
+
+  INTEGER                       :: nqo, nbtr
+  CHARACTER(len=4)              :: type_trac
+  CHARACTER(len=20),ALLOCATABLE :: tname(:)    ! tracer short name for restart and diagnostics
+  CHARACTER(len=23),ALLOCATABLE :: ttext(:)     ! tracer long name for diagnostics
+  INTEGER,ALLOCATABLE           :: niadv(:)    ! equivalent dyn / physique
+  INTEGER,ALLOCATABLE           :: conv_flg(:) ! conv_flg(it)=0 : convection desactivated for tracer number it 
+  INTEGER,ALLOCATABLE           :: pbl_flg(:)  ! pbl_flg(it)=0  : boundary layer diffusion desactivaded for tracer number it 
+  CHARACTER(len=8),ALLOCATABLE :: solsym(:)  ! tracer name from inca
+
+  INTEGER :: iflag_phys    
+
+
+    CALL init_distrib_icosa_lmdz
+    
+    ALLOCATE(latfi(klon_omp))
+    ALLOCATE(lonfi(klon_omp))
+    ALLOCATE(airefi(klon_omp))
+    ALLOCATE(bounds_latfi(klon_omp,6))
+    ALLOCATE(bounds_lonfi(klon_omp,6))
+
+    CALL transfer_icosa_to_lmdz(geom%lat_i,latfi)
+    CALL transfer_icosa_to_lmdz(geom%lon_i,lonfi)
+    CALL transfer_icosa_to_lmdz(f_bounds_lat,bounds_latfi)
+    CALL transfer_icosa_to_lmdz(f_bounds_lon,bounds_lonfi)
+    CALL transfer_icosa_to_lmdz(geom%Ai,airefi)
+
+    CALL init_geometry(lonfi, latfi, bounds_lonfi, bounds_latfi, airefi)
+
+    pseudoalt(:)=0
+    CALL init_vertical_layers(llm,preff,ap,bp,presnivs,pseudoalt)
+
+
+    ! Initialize tracer names, numbers, etc. for physics
+
+    !Config  Key  = type_trac
+    !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
+    !Config  Def  = lmdz
+    !Config  Help = 
+    !Config         'lmdz' = pas de couplage, pur LMDZ
+    !Config         'inca' = model de chime INCA 
+    !Config         'repr' = model de chime REPROBUS
+     type_trac = 'lmdz'
+     CALL getin('type_trac',type_trac)
+
+! init model for standard lmdz case
+    nqo=2
+    nbtr=2
+    ALLOCATE(tname(nqtot))
+    ALLOCATE(ttext(nqtot))
+    ALLOCATE(niadv(nqtot))
+    ALLOCATE(conv_flg(nbtr))
+    ALLOCATE(pbl_flg(nbtr))
+    ALLOCATE(solsym(nbtr))
+    
+    conv_flg(:) = 1 ! convection activated for all tracers
+    pbl_flg(:)  = 1 ! boundary layer activated for all tracers
+    tname(1)='H2Ov'    
+    tname(2)='H2Ol'    
+    tname(3)='RN'    
+    tname(4)='PB'
+    ttext(1)='H2OvVLH'    
+    ttext(2)='H2OlVL1'    
+    ttext(3)='RNVL1'    
+    ttext(4)='PBVL1'
+    solsym(1:2)=tname(3:4)
+    niadv(1)=1
+    niadv(2)=2
+    niadv(3)=3
+    niadv(4)=4
+        
+    CALL init_infotrac_phy(nqtot,nqo,nbtr,tname,ttext,type_trac,&
+                           niadv,conv_flg,pbl_flg,solsym)
+
+   ! Initialize physical constant
+    day_length=86400
+    CALL getin('day_length',day_length)
+    CALL inifis(day_length,radius,g,kappa*cpp,cpp)
+ 
+
+    
+  ! init time
+    annee_ref=2015
+    CALL getin("anneeref",annee_ref)
+    
+    day_ref=1
+    CALL getin("dayref",day_ref)
+    
+    physics_timestep=dt*itau_physics
+    run_length=itaumax*dt
+    ndays=NINT(run_length/day_length)
+    
+    day_ini=INT(itau0*dt/day_length)+day_ref
+    start_time= itau0*dt/day_length-INT(itau0*dt/day_length)
+
+    CALL init_time_lmdz(annee_ref, day_ref, day_ini, start_time, ndays, physics_timestep)
+
+  ! Additional initializations for aquaplanets
+    CALL getin("iflag_phys",iflag_phys)
+    IF (iflag_phys>=100) THEN
+      CALL iniaqua(klon_omp, iflag_phys)
+    END IF
+
+  
+  END SUBROUTINE  initialize_physics_omp 
+  
+  
+
+
+  SUBROUTINE physics
+  USE ICOSA
+  USE time_mod
+  USE disvert_mod
+  USE transfert_mod
+  USE mpipara
+  USE xios_mod
+  USE trace
+  USE distrib_icosa_lmdz_mod, ONLY : transfer_icosa_to_lmdz, transfer_lmdz_to_icosa
+  USE physics_external_mod, ONLY : it, f_phis, f_ps, f_theta_rhodz, f_u, f_wflux, f_q 
+! from LMDZ
+  USE mod_phys_lmdz_omp_data, ONLY: klon_omp
+  IMPLICIT NONE
+  
+    REAL(rstd),POINTER :: phis(:)
+    REAL(rstd),POINTER :: ps(:)
+    REAL(rstd),POINTER :: theta_rhodz(:,:)
+    REAL(rstd),POINTER :: u(:,:)
+    REAL(rstd),POINTER :: wflux(:,:)
+    REAL(rstd),POINTER :: q(:,:,:)
+    REAL(rstd),POINTER :: p(:,:)
+    REAL(rstd),POINTER :: pks(:)
+    REAL(rstd),POINTER :: pk(:,:)
+    REAL(rstd),POINTER :: p_layer(:,:)
+    REAL(rstd),POINTER :: theta(:,:)
+    REAL(rstd),POINTER :: phi(:,:)
+    REAL(rstd),POINTER :: Temp(:,:)
+    REAL(rstd),POINTER :: ulon(:,:)
+    REAL(rstd),POINTER :: ulat(:,:)
+    REAL(rstd),POINTER :: dulon(:,:)
+    REAL(rstd),POINTER :: dulat(:,:)
+    REAL(rstd),POINTER :: dTemp(:,:)
+    REAL(rstd),POINTER :: dq(:,:,:)
+    REAL(rstd),POINTER :: dps(:)
+    REAL(rstd),POINTER :: duc(:,:,:)
+
+
+    INTEGER :: ind
+    
+    REAL(rstd),ALLOCATABLE,SAVE :: ps_phy(:)
+!$OMP THREADPRIVATE(ps_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: p_phy(:,:)
+!$OMP THREADPRIVATE(p_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: p_layer_phy(:,:)
+!$OMP THREADPRIVATE(p_layer_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: Temp_phy(:,:)
+!$OMP THREADPRIVATE(Temp_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: phis_phy(:)
+!$OMP THREADPRIVATE(phis_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: phi_phy(:,:)
+!$OMP THREADPRIVATE(phi_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: ulon_phy(:,:)
+!$OMP THREADPRIVATE(ulon_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: ulat_phy(:,:)
+!$OMP THREADPRIVATE(ulat_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: q_phy(:,:,:)
+!$OMP THREADPRIVATE(q_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: wflux_phy(:,:)
+!$OMP THREADPRIVATE(wflux_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: dulon_phy(:,:)
+!$OMP THREADPRIVATE(dulon_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: dulat_phy(:,:)
+!$OMP THREADPRIVATE(dulat_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: dTemp_phy(:,:)
+!$OMP THREADPRIVATE(dTemp_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: dq_phy(:,:,:)
+!$OMP THREADPRIVATE(dq_phy)
+    REAL(rstd),ALLOCATABLE,SAVE :: dps_phy(:)
+!$OMP THREADPRIVATE(dps_phy)
+    REAL(rstd)   :: dtphy 
+    LOGICAL      :: debut
+    LOGICAL      :: lafin
+    LOGICAL,SAVE :: first=.TRUE.
+!$OMP THREADPRIVATE(first)
+
+    
+    IF(first) THEN 
+      debut=.TRUE.
+    ELSE 
+      debut=.FALSE.
+    ENDIF
+
+    IF(it==itaumax) THEN 
+      lafin=.TRUE.
+    ELSE 
+      lafin=.FALSE.
+    ENDIF
+
+    IF (first) THEN
+      first=.FALSE.
+      CALL init_message(f_u,req_e1_vect,req_u)
+      ALLOCATE(ps_phy(klon_omp))
+      ALLOCATE(p_phy(klon_omp,llm+1))
+      ALLOCATE(p_layer_phy(klon_omp,llm))
+      ALLOCATE(Temp_phy(klon_omp,llm))
+      ALLOCATE(phis_phy(klon_omp))
+      ALLOCATE(phi_phy(klon_omp,llm))
+      ALLOCATE(ulon_phy(klon_omp,llm))
+      ALLOCATE(ulat_phy(klon_omp,llm))
+      ALLOCATE(q_phy(klon_omp,llm,nqtot))
+      ALLOCATE(wflux_phy(klon_omp,llm))
+      ALLOCATE(dulon_phy(klon_omp,llm))
+      ALLOCATE(dulat_phy(klon_omp,llm))
+      ALLOCATE(dTemp_phy(klon_omp,llm))
+      ALLOCATE(dq_phy(klon_omp,llm,nqtot))
+      ALLOCATE(dps_phy(klon_omp))
+!$OMP BARRIER
+    ENDIF
+
+
+!$OMP MASTER        
+!    CALL update_calendar(it)
+!$OMP END MASTER
+!$OMP BARRIER
+    dtphy=itau_physics*dt
+    
+    
+    
+    CALL transfert_message(f_u,req_u)
+    
+    DO ind=1,ndomain
+      CALL swap_dimensions(ind)
+      IF (assigned_domain(ind)) THEN
+        CALL swap_geometry(ind)
+      
+        phis=f_phis(ind)
+        ps=f_ps(ind)
+        theta_rhodz=f_theta_rhodz(ind)
+        u=f_u(ind)
+        q=f_q(ind)
+        wflux=f_wflux(ind)
+        p=f_p(ind)
+        pks=f_pks(ind)
+        pk=f_pk(ind)
+        p_layer=f_p_layer(ind)
+        theta=f_theta(ind)
+        phi=f_phi(ind)
+        Temp=f_Temp(ind)
+        ulon=f_ulon(ind)
+        ulat=f_ulat(ind)
+            
+        CALL grid_icosa_to_physics
+
+      ENDIF
+    ENDDO
+   
+!$OMP BARRIER
+!$OMP MASTER
+    CALL SYSTEM_CLOCK(start_clock)
+!$OMP END MASTER
+    CALL trace_start("physic")
+!    CALL trace_off()
+
+
+
+    CALL transfer_icosa_to_lmdz(f_p      , p_phy)
+    CALL transfer_icosa_to_lmdz(f_p_layer, p_layer_phy)
+    CALL transfer_icosa_to_lmdz(f_phi    , phi_phy)
+    CALL transfer_icosa_to_lmdz(f_phis   , phis_phy )
+    CALL transfer_icosa_to_lmdz(f_ulon   , ulon_phy )
+    CALL transfer_icosa_to_lmdz(f_ulat   , ulat_phy)
+    CALL transfer_icosa_to_lmdz(f_Temp   , Temp_phy)
+    CALL transfer_icosa_to_lmdz(f_q      , q_phy)
+    CALL transfer_icosa_to_lmdz(f_wflux  , wflux_phy)
+
+ 
+    CALL physiq(klon_omp, llm, debut, lafin, dtphy, &
+                p_phy, p_layer_phy, phi_phy, phis_phy, presnivs, ulon_phy, ulat_phy, Temp_phy, q_phy, wflux_phy, &
+                dulon_phy, dulat_phy, dTemp_phy, dq_phy, dps_phy)
+    
+    CALL transfer_lmdz_to_icosa(dulon_phy, f_dulon )
+    CALL transfer_lmdz_to_icosa(dulat_phy, f_dulat )
+    CALL transfer_lmdz_to_icosa(dTemp_phy, f_dTemp )
+    CALL transfer_lmdz_to_icosa(dq_phy   , f_dq )
+    CALL transfer_lmdz_to_icosa(dps_phy  , f_dps )
+
+
+
+
+!    CALL trace_on()
+    CALL trace_end("physic")
+!$OMP MASTER
+    CALL SYSTEM_CLOCK(stop_clock)
+    count_clock=count_clock+stop_clock-start_clock
+!$OMP END MASTER
+
+!$OMP BARRIER                       
+
+    DO ind=1,ndomain
+      CALL swap_dimensions(ind)
+      IF (assigned_domain(ind)) THEN
+        CALL swap_geometry(ind)
+
+        theta_rhodz=f_theta_rhodz(ind)
+        u=f_u(ind)
+        q=f_q(ind)
+        ps=f_ps(ind)
+        dulon=f_dulon(ind)
+        dulat=f_dulat(ind)
+        Temp=f_temp(ind)
+        dTemp=f_dTemp(ind)
+        dq=f_dq(ind)
+        dps=f_dps(ind)
+        duc=f_duc(ind)
+        p=f_p(ind)
+        pks=f_pks(ind)
+        pk=f_pk(ind)
+      
+        CALL grid_physics_to_icosa
+      ENDIF
+    ENDDO
+
+!$OMP BARRIER
+    CALL xios_set_context    
+   
+ 
+  CONTAINS
+
+    SUBROUTINE grid_icosa_to_physics
+    USE pression_mod
+    USE exner_mod
+    USE theta2theta_rhodz_mod
+    USE geopotential_mod
+    USE wind_mod
+    USE omp_para
+    IMPLICIT NONE
+    
+    REAL(rstd) :: uc(3)
+    INTEGER :: i,j,ij,l
+    
+
+! compute pression
+
+      DO    l    = ll_begin,ll_endp1
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            p(ij,l) = ap(l) + bp(l) * ps(ij)
+          ENDDO
+        ENDDO
+      ENDDO
+
+!$OMP BARRIER
+
+! compute exner
+       
+       IF (is_omp_first_level) THEN
+         DO j=jj_begin,jj_end
+            DO i=ii_begin,ii_end
+               ij=(j-1)*iim+i
+               pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+            ENDDO
+         ENDDO
+       ENDIF
+
+       ! 3D : pk
+       DO l = ll_begin,ll_end
+          DO j=jj_begin,jj_end
+             DO i=ii_begin,ii_end
+                ij=(j-1)*iim+i
+                pk(ij,l) = cpp * ((.5/preff)*(p(ij,l)+p(ij,l+1))) ** kappa
+             ENDDO
+          ENDDO
+       ENDDO
+
+!$OMP BARRIER
+
+!   compute theta, temperature and pression at layer
+    DO    l    = ll_begin, ll_end
+      DO j=jj_begin,jj_end
+        DO i=ii_begin,ii_end
+          ij=(j-1)*iim+i
+          theta(ij,l) = theta_rhodz(ij,l) / ((p(ij,l)-p(ij,l+1))/g)
+          Temp(ij,l) = theta(ij,l) * pk(ij,l) / cpp
+          p_layer(ij,l)=preff*(pk(ij,l)/cpp)**(1./kappa) 
+        ENDDO
+      ENDDO
+    ENDDO
+
+
+!!! Compute geopotential
+       
+  ! for first layer
+  IF (is_omp_first_level) THEN
+    DO j=jj_begin,jj_end
+      DO i=ii_begin,ii_end
+        ij=(j-1)*iim+i
+        phi( ij,1 ) = phis( ij ) + theta(ij,1) * ( pks(ij) - pk(ij,1) )
+      ENDDO
+    ENDDO
+  ENDIF
+!!-> implicit flush on phi(:,1)
+          
+  ! for other layers
+  DO l = ll_beginp1, ll_end
+    DO j=jj_begin,jj_end
+      DO i=ii_begin,ii_end
+        ij=(j-1)*iim+i
+        phi(ij,l) =  0.5 * ( theta(ij,l)  + theta(ij,l-1) )  & 
+                         * (  pk(ij,l-1) -  pk(ij,l)    )
+      ENDDO
+    ENDDO
+  ENDDO       
+
+!$OMP BARRIER
+
+
+  IF (is_omp_first_level) THEN
+    DO l = 2, llm
+      DO j=jj_begin,jj_end
+! ---> Bug compilo intel ici en openmp
+! ---> Couper la boucle
+       IF (j==jj_end+1) PRINT*,"this message must not be printed"
+        DO i=ii_begin,ii_end
+          ij=(j-1)*iim+i
+          phi(ij,l) = phi(ij,l)+ phi(ij,l-1)
+        ENDDO
+      ENDDO
+    ENDDO
+! --> IMPLICIT FLUSH on phi --> non 
+  ENDIF 
+
+! compute wind centered lon lat compound
+    DO l=ll_begin,ll_end
+      DO j=jj_begin,jj_end
+        DO i=ii_begin,ii_end
+          ij=(j-1)*iim+i
+          uc(:)=1/Ai(ij)*                                                                                                &
+                        ( ne(ij,right)*u(ij+u_right,l)*le(ij+u_right)*((xyz_v(ij+z_rdown,:)+xyz_v(ij+z_rup,:))/2-centroid(ij,:))  &
+                         + ne(ij,rup)*u(ij+u_rup,l)*le(ij+u_rup)*((xyz_v(ij+z_rup,:)+xyz_v(ij+z_up,:))/2-centroid(ij,:))          &
+                         + ne(ij,lup)*u(ij+u_lup,l)*le(ij+u_lup)*((xyz_v(ij+z_up,:)+xyz_v(ij+z_lup,:))/2-centroid(ij,:))          &
+                         + ne(ij,left)*u(ij+u_left,l)*le(ij+u_left)*((xyz_v(ij+z_lup,:)+xyz_v(ij+z_ldown,:))/2-centroid(ij,:))    &
+                         + ne(ij,ldown)*u(ij+u_ldown,l)*le(ij+u_ldown)*((xyz_v(ij+z_ldown,:)+xyz_v(ij+z_down,:))/2-centroid(ij,:))&
+                         + ne(ij,rdown)*u(ij+u_rdown,l)*le(ij+u_rdown)*((xyz_v(ij+z_down,:)+xyz_v(ij+z_rdown,:))/2-centroid(ij,:)))
+          ulon(ij,l)=sum(uc(:)*elon_i(ij,:))
+          ulat(ij,l)=sum(uc(:)*elat_i(ij,:)) 
+        ENDDO
+      ENDDO
+    ENDDO
+
+!$OMP BARRIER
+    END SUBROUTINE grid_icosa_to_physics
+
+
+    SUBROUTINE grid_physics_to_icosa
+    USE theta2theta_rhodz_mod
+    USE omp_para
+    IMPLICIT NONE
+      INTEGER :: i,j,ij,l,iq
+          
+      DO l=ll_begin,ll_end
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            duc(ij,:,l)=dulon(ij,l)*elon_i(ij,:)+dulat(ij,l)*elat_i(ij,:)
+          ENDDO
+        ENDDO
+      ENDDO
+
+      DO l=ll_begin,ll_end
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            u(ij+u_right,l) = u(ij+u_right,l) + dtphy * sum( 0.5*(duc(ij,:,l) + duc(ij+t_right,:,l))*ep_e(ij+u_right,:) )
+            u(ij+u_lup,l) = u(ij+u_lup,l) + dtphy * sum( 0.5*(duc(ij,:,l) + duc(ij+t_lup,:,l))*ep_e(ij+u_lup,:) )
+            u(ij+u_ldown,l) = u(ij+u_ldown,l) + dtphy*sum( 0.5*(duc(ij,:,l) + duc(ij+t_ldown,:,l))*ep_e(ij+u_ldown,:) )
+          ENDDO
+        ENDDO
+      ENDDO          
+
+      DO l=ll_begin,ll_end
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            Temp(ij,l)=Temp(ij,l)+ dtphy * dTemp(ij,l)
+          ENDDO
+        ENDDO
+      ENDDO          
+      
+      DO iq=1,nqtot
+        DO l=ll_begin,ll_end
+          DO j=jj_begin,jj_end
+            DO i=ii_begin,ii_end
+              ij=(j-1)*iim+i
+              q(ij,l,iq)=q(ij,l,iq)+ dtphy * dq(ij,l,iq)
+            ENDDO
+          ENDDO
+        ENDDO 
+      ENDDO
+
+!$OMP BARRIER
+      
+     IF (is_omp_first_level) THEN
+       DO j=jj_begin,jj_end
+         DO i=ii_begin,ii_end
+           ij=(j-1)*iim+i
+           ps(ij)=ps(ij)+ dtphy * dps(ij)
+          ENDDO
+       ENDDO
+     ENDIF
+
+!     CALL compute_temperature2theta_rhodz(ps,Temp,theta_rhodz,0)
+
+! compute pression
+!$OMP BARRIER
+      DO    l    = ll_begin,ll_endp1
+        DO j=jj_begin,jj_end
+          DO i=ii_begin,ii_end
+            ij=(j-1)*iim+i
+            p(ij,l) = ap(l) + bp(l) * ps(ij)
+          ENDDO
+        ENDDO
+      ENDDO
+
+!$OMP BARRIER
+
+! compute exner
+       
+       IF (is_omp_first_level) THEN
+         DO j=jj_begin,jj_end
+            DO i=ii_begin,ii_end
+               ij=(j-1)*iim+i
+               pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+            ENDDO
+         ENDDO
+       ENDIF
+
+       ! 3D : pk
+       DO l = ll_begin,ll_end
+          DO j=jj_begin,jj_end
+             DO i=ii_begin,ii_end
+                ij=(j-1)*iim+i
+                pk(ij,l) = cpp * ((.5/preff)*(p(ij,l)+p(ij,l+1))) ** kappa
+             ENDDO
+          ENDDO
+       ENDDO
+
+!$OMP BARRIER
+
+!   compute theta, temperature and pression at layer
+    DO    l    = ll_begin, ll_end
+      DO j=jj_begin,jj_end
+        DO i=ii_begin,ii_end
+          ij=(j-1)*iim+i
+          theta_rhodz(ij,l) = temp(ij,l) * ((p(ij,l)-p(ij,l+1))/g) / (pk(ij,l) / cpp )
+        ENDDO
+      ENDDO
+    ENDDO
+    
+    END SUBROUTINE grid_physics_to_icosa
+
+
+
+  END SUBROUTINE physics
+
+
+
+
+
+END MODULE interface_icosa_lmdz_mod
Index: dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/wrapper.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/wrapper.f90	(revision 3841)
+++ dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/wrapper.f90	(revision 3841)
@@ -0,0 +1,16 @@
+SUBROUTINE initialize_external_physics
+  USE interface_icosa_lmdz_mod, ONLY: initialize_physics
+  IMPLICIT NONE
+  
+    CALL initialize_physics  
+
+END SUBROUTINE initialize_external_physics
+
+
+SUBROUTINE external_physics
+  USE interface_icosa_lmdz_mod, ONLY: physics
+  IMPLICIT NONE
+  
+  CALL physics
+
+END SUBROUTINE external_physics
