Index: dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/interface_icosa_lmdz.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/interface_icosa_lmdz.f90	(revision 3902)
+++ dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/interface_icosa_lmdz.f90	(revision 3961)
@@ -99,18 +99,18 @@
     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_p,field_t,type_real,llm+1,name="p_in")
     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_p_layer,field_t,type_real,llm,name="p_layer_in")
     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_phi,field_t,type_real,llm,name="phi_in")
+    CALL allocate_field(f_Temp,field_t,type_real,llm,name="Temp_in")
+    CALL allocate_field(f_ulon,field_t,type_real,llm,name="ulon_in")
+    CALL allocate_field(f_ulat,field_t,type_real,llm,name="ulat_in")
+    CALL allocate_field(f_dulon,field_t,type_real,llm,name="dulon_out")
+    CALL allocate_field(f_dulat,field_t,type_real,llm,name="dulat_out")
+    CALL allocate_field(f_dTemp,field_t,type_real,llm,name="dTemp_out")
+    CALL allocate_field(f_dq,field_t,type_real,llm,nqtot,name="dq_out")
+    CALL allocate_field(f_dps,field_t,type_real,name="dps_out")
     CALL allocate_field(f_duc,field_t,type_real,3,llm)    
 
@@ -347,5 +347,5 @@
 
   SUBROUTINE physics
-  USE ICOSA
+  USE icosa
   USE time_mod
   USE disvert_mod
@@ -357,11 +357,14 @@
   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 
+  USE write_field_mod
+  USE checksum_mod
 ! from LMDZ
   USE mod_phys_lmdz_omp_data, ONLY: klon_omp
+  USE geometry_mod, ONLY : cell_area
   IMPLICIT NONE
   
     REAL(rstd),POINTER :: phis(:)
     REAL(rstd),POINTER :: ps(:)
-    REAL(rstd),POINTER :: theta_rhodz(:,:)
+    REAL(rstd),POINTER :: theta_rhodz(:,:,:)
     REAL(rstd),POINTER :: u(:,:)
     REAL(rstd),POINTER :: wflux(:,:)
@@ -384,5 +387,5 @@
 
 
-    INTEGER :: ind
+    INTEGER :: ind,l
     
     REAL(rstd),ALLOCATABLE,SAVE :: ps_phy(:)
@@ -502,4 +505,23 @@
 
 
+!    CALL writeField("p_in",f_p)
+!    CALL writeField("p_layer_in",f_p_layer)
+!    CALL writeField("phi_in",f_phi)
+!    CALL writeField("phis_in",f_phis)
+!    CALL writeField("ulon_in",f_ulon)
+!    CALL writeField("ulat_in",f_ulat)
+!    CALL writeField("Temp_in",f_Temp)
+!    CALL writeField("q_in",f_q)
+!    CALL writeField("wflux_in",f_wflux)
+
+!    CALL checksum(f_p)
+!    CALL checksum(f_p_layer)
+!    CALL checksum(f_phi)
+!    CALL checksum(f_phis)
+!    CALL checksum(f_ulon)
+!    CALL checksum(f_ulat)
+!    CALL checksum(f_Temp)
+!    CALL checksum(f_q)
+!    CALL checksum(f_wflux)
 
     CALL transfer_icosa_to_lmdz(f_p      , p_phy)
@@ -513,4 +535,9 @@
     CALL transfer_icosa_to_lmdz(f_wflux  , wflux_phy)
 
+    DO l=1,llm
+      wflux_phy(:,l)=wflux_phy(:,l)*cell_area(:)
+      phi_phy(:,l)=phi_phy(:,l)-phis_phy(:)
+    ENDDO
+    
     CALL wxios_set_context()
  
@@ -524,4 +551,16 @@
     CALL transfer_lmdz_to_icosa(dq_phy   , f_dq )
     CALL transfer_lmdz_to_icosa(dps_phy  , f_dps )
+ 
+!    CALL writeField("dulon_out",f_dulon)
+!    CALL writeField("dulat_out",f_dulat)
+!    CALL writeField("dTemp_out",f_dTemp)
+!    CALL writeField("dq_out",f_dq)
+!    CALL writeField("dps_out",f_dps)
+
+!    CALL checksum(f_dulon)
+!    CALL checksum(f_dulat)
+!    CALL checksum(f_dTemp)
+!    CALL checksum(f_dq)
+!    CALL checksum(f_dps)
     
     CALL send_message(f_dps,req_dps0)
@@ -631,5 +670,5 @@
         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)
+          theta(ij,l) = theta_rhodz(ij,l,1) / ((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) 
@@ -803,5 +842,5 @@
         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 )
+          theta_rhodz(ij,l,1) = temp(ij,l) * ((p(ij,l)-p(ij,l+1))/g) / (pk(ij,l) / cpp )
         ENDDO
       ENDDO
