Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/inigeomphy_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 3077)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 3078)
@@ -12,5 +12,5 @@
                                 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 geometry_mod, ONLY : init_geometry, init_geometry_cell_area_for_outputs
   USE physics_distribution_mod, ONLY : init_physics_distribution
   USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
@@ -61,4 +61,5 @@
   REAL,ALLOCATABLE :: cvfi_glo(:)
   REAL,ALLOCATABLE :: airefi_glo(:)
+  REAL,ALLOCATABLE :: aire_glo(:)
   REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
   REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
@@ -70,8 +71,10 @@
   REAL,ALLOCATABLE,SAVE :: cvfi(:)
   REAL,ALLOCATABLE,SAVE :: airefi(:)
+  REAL,ALLOCATABLE,SAVE :: airefi_for_outputs(:)
   REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
   REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
   INTEGER,ALLOCATABLE,SAVE :: ind_cell_glo_fi(:)
-!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi,ind_cell_glo_fi)
+!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,airefi_for_outputs)
+!$OMP THREADPRIVATE (boundslonfi,boundslatfi,ind_cell_glo_fi)
 
   ! Initialize Physics distibution and parameters and interface with dynamics
@@ -114,4 +117,5 @@
   ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
   ALLOCATE(airefi_glo(klon_glo))
+  ALLOCATE(aire_glo(klon_glo))
   ALLOCATE(boundslonfi_glo(klon_glo,4))
   ALLOCATE(boundslatfi_glo(klon_glo,4))
@@ -173,4 +177,7 @@
     airefi_glo(1)=sum(aire(1:iim,1))
     airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
+    ! but we also want to store mesh area with poles as on dyn grid
+    ! (for lon-lat outputs)
+    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,aire_glo)
 
     ! Sanity check: do total planet area match between physics and dynamics?
@@ -194,4 +201,5 @@
     cvfi_glo(1)=cv(1)
     airefi_glo(1)=aire(1,1)
+    aire_glo(1)=aire(1,1)
     boundslonfi_glo(1,north_east)=rlonu(1)
     boundslatfi_glo(1,north_east)=PI/2
@@ -208,4 +216,5 @@
   ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
   ALLOCATE(airefi(klon_omp))
+  ALLOCATE(airefi_for_outputs(klon_omp))
   ALLOCATE(boundslonfi(klon_omp,4))
   ALLOCATE(boundslatfi(klon_omp,4))
@@ -215,4 +224,6 @@
   offset = klon_mpi_begin - 1
   airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  airefi_for_outputs(1:klon_omp) = &
+                         aire_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)
@@ -227,4 +238,7 @@
                      airefi,ind_cell_glo_fi,cufi,cvfi)
 
+  ! copy over lon-lat mesh area for outputs (with polar "correction")
+  CALL init_geometry_cell_area_for_outputs(klon_omp,airefi_for_outputs)
+
   ! copy over preff , ap(), bp(), etc 
   CALL init_vertical_layers(nlayer,preff,scaleheight, &
Index: /trunk/LMDZ.COMMON/libf/phy_common/geometry_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/phy_common/geometry_mod.F90	(revision 3077)
+++ /trunk/LMDZ.COMMON/libf/phy_common/geometry_mod.F90	(revision 3078)
@@ -27,6 +27,12 @@
 !$OMP THREADPRIVATE(dy)
 
-  REAL,SAVE,ALLOCATABLE :: cell_area(:)      ! area of the cell
+  REAL,SAVE,ALLOCATABLE :: cell_area(:) ! area of the cell (m2)
 !$OMP THREADPRIVATE(cell_area)
+
+  REAL,SAVE,ALLOCATABLE :: cell_area_for_lonlat_outputs(:) 
+                           ! for lon-lat outputs only: area of the cell
+                           ! but with polar values as in dyn grid
+                           ! (with replicated polar grid point)
+!$OMP THREADPRIVATE(cell_area_for_lonlat_outputs)
 
   INTEGER,SAVE,ALLOCATABLE :: ind_cell_glo(:)      ! global index of a local cell
@@ -76,4 +82,17 @@
 
 
+  SUBROUTINE init_geometry_cell_area_for_outputs(klon, &
+                                                 cell_area_for_lonlat_outputs_)
+  IMPLICIT NONE
+  INTEGER,INTENT(IN) :: klon ! number of columns for this MPI/OpenMP domain
+  REAL,INTENT(IN) :: cell_area_for_lonlat_outputs_(klon) ! tweaked lon-lat mesh
+                     ! cell areas where polar values are as on dyn lon-lat grid
+                     ! for outputs
+  
+  ALLOCATE(cell_area_for_lonlat_outputs(klon))
+  cell_area_for_lonlat_outputs(1:klon)=cell_area_for_lonlat_outputs_(1:klon)
+  
+  END SUBROUTINE init_geometry_cell_area_for_outputs
+
 END MODULE geometry_mod
 
Index: /trunk/LMDZ.MARS/changelog.txt
===================================================================
--- /trunk/LMDZ.MARS/changelog.txt	(revision 3077)
+++ /trunk/LMDZ.MARS/changelog.txt	(revision 3078)
@@ -4252,2 +4252,8 @@
 Improve conctatnc's handling of XIOS output files (handle change in some
 variable names, e.g. "area" or "phisfi").
+
+== 10/10/2023 == EM
+Enable outputing cell area with XIOS and make sure the polar grid point
+is correctly handled (i.e. on lon-lat grid outputs polar mesh area must
+be adjusted to account for the replicated polar meshes).
+ 
Index: /trunk/LMDZ.MARS/libf/phymars/physiq_mod.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 3077)
+++ /trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 3078)
@@ -50,5 +50,5 @@
      &                     mlayer,layer ! soil mid layer depths
       use geometry_mod, only: longitude, latitude, cell_area,
-     &                        longitude_deg 
+     &                        cell_area_for_lonlat_outputs,longitude_deg
       use comgeomfi_h, only: sinlon, coslon, sinlat, coslat
       use surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam,
@@ -110,5 +110,6 @@
       use wxios, only: wxios_context_init, xios_context_finalize
 #endif
-      USE mod_grid_phy_lmdz, ONLY: grid_type, unstructured
+      USE mod_grid_phy_lmdz, ONLY: grid_type, unstructured, 
+     &                             regular_lonlat
       use ioipsl_getin_p_mod, only: getin_p
       use comslope_mod, ONLY: nslope,def_slope,def_slope_mean,
@@ -3172,4 +3173,10 @@
          call write_output("phisfi","Surface geopotential",
      &                    "m2s-2",phisfi(:))
+         if (grid_type == regular_lonlat) then
+           call write_output("area","Mesh area","m2",
+     &                       cell_area_for_lonlat_outputs)
+         else ! unstructured grid (e.g. dynamico)
+           call write_output("area","Mesh area","m2",cell_area)
+         endif
          call write_output("tsurf","Surface temperature","K",
      &                  tsurf(:,iflat))
