Index: /LMDZ5/branches/IPSLCM5A2.1/DefLists/context_lmdz.xml
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/DefLists/context_lmdz.xml	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/DefLists/context_lmdz.xml	(revision 3629)
@@ -25,4 +25,7 @@
   <domain_definition>
     <domain id="dom_glo" data_dim="2" />
+    <domain id="greordered"  domain_ref="dom_glo">
+      <reorder_domain invert_lat="true" shift_lon_fraction="0.5" min_lon="0" max_lon="360" />
+    </domain> 
   </domain_definition>
   
@@ -33,4 +36,8 @@
 
   <grid_definition>
+
+    <grid id="klev_bnds"> <axis axis_ref="klev" /> <axis axis_ref="bnds" /> </grid>
+    <grid id="klevp1_bnds"> <axis axis_ref="klevp1" /> <axis axis_ref="bnds" /> </grid>
+
      <grid id="grid_glo">
         <domain domain_ref="dom_glo" />
@@ -92,7 +99,22 @@
     <axis id="Bhyb" standard_name="Bhyb comp of Hyb Cord" unit="">
     </axis>
+    <axis id="Ahyb_inter" standard_name="A comp of Hyb Cord at interface" unit="Pa">
+    </axis> 
+    <axis id="Bhyb_inter" standard_name="B comp of Hyb Cord at interface" unit="">
+    </axis>
     <axis id="Alt" standard_name="Height approx for scale heigh of 8km at levels" unit="km">
     </axis>
     <axis id="plev" standard_name="model_level_number" unit="Pa">
+    </axis>
+    <axis id="klev"  prec="8" long_name = "number of layers"
+          standard_name ="number of layers" unit="1">
+    </axis>
+    <axis id="klevp1"  prec="8" long_name = "number of layer interfaces"
+          standard_name ="number of layer interfaces" unit="1">
+    </axis>
+    <axis id="bnds" standard_name="bounds" unit="1" >
+    </axis>
+    <axis id="axis_lat" standard_name="Latitude axis">
+        <reduce_domain operation="average" direction="iDir" />
     </axis>
 
@@ -113,4 +135,5 @@
     </axis> 
 
+
   </axis_definition>
 </context>
Index: /LMDZ5/branches/IPSLCM5A2.1/DefLists/field_def_lmdz.xml
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/DefLists/field_def_lmdz.xml	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/DefLists/field_def_lmdz.xml	(revision 3629)
@@ -7,4 +7,20 @@
 <!--    </field_group>  -->
     
+    <field_group id="coordinates" grid_ref="grid_glo">
+        <field id="io_lon"  />
+        <field id="io_lat"  />
+    </field_group>
+
+    <field_group id="coord_hyb">
+      <field id="Ahyb" long_name="Ahyb at level interface"     axis_ref="klevp1" />
+      <field id="Ahyb_bounds" long_name="" grid_ref="klevp1_bnds" />
+      <field id="Bhyb" long_name="Bhyb at level interface"       axis_ref="klevp1"  />
+      <field id="Bhyb_bounds" long_name=""  grid_ref="klevp1_bnds" />
+      <field id="Ahyb_mid" long_name="Ahyb at the middle of the level"      axis_ref="klev" />
+      <field id="Ahyb_mid_bounds" long_name="" grid_ref="klev_bnds" />
+      <field id="Bhyb_mid" long_name="Bhyb at the middle of the level"       axis_ref="klev"  />
+      <field id="Bhyb_mid_bounds" long_name=""  grid_ref="klev_bnds" />
+    </field_group>
+
     <field_group id="fields_2D" grid_ref="grid_glo">
         <field id="phis"    long_name="Surface geop.height"     unit="m2/s2" />
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/dyn3d_common/disvert.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/dyn3d_common/disvert.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/dyn3d_common/disvert.F90	(revision 3629)
@@ -10,6 +10,6 @@
   use new_unit_m, only: new_unit
   use assert_m, only: assert
-  USE comvert_mod, ONLY: ap, bp, nivsigs, nivsig, dpres, presnivs, &
-                         pa, preff, scaleheight
+  USE comvert_mod, ONLY: ap, bp, aps, bps, nivsigs, nivsig, dpres, presnivs, &
+                         pseudoalt, pa, preff, scaleheight
   USE logic_mod, ONLY: ok_strato
 
@@ -346,7 +346,10 @@
   DO l = 1, llm
      dpres(l) = bp(l) - bp(l+1)
+     aps(l) =  0.5 *( ap(l) +ap(l+1))
+     bps(l) =  0.5 *( bp(l) +bp(l+1))
      presnivs(l) = 0.5 *( ap(l)+bp(l)*preff + ap(l+1)+bp(l+1)*preff )
+     pseudoalt(l) = log(preff/presnivs(l))*scaleheight
      write(lunout, *)'PRESNIVS(', l, ')=', presnivs(l), ' Z ~ ', &
-          log(preff/presnivs(l))*scaleheight &
+          pseudoalt(l) &
           , ' DZ ~ ', scaleheight*log((ap(l)+bp(l)*preff)/ &
           max(ap(l+1)+bp(l+1)*preff, 1.e-10))
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 3629)
@@ -12,5 +12,6 @@
                      prad,pg,pr,pcpp,iflag_phys)
   USE dimphy, ONLY: init_dimphy
-  USE comvert_mod, ONLY: preff, ap, bp, presnivs, scaleheight, pseudoalt
+  USE comvert_mod, ONLY: preff, ap, bp, aps, bps, presnivs, &
+                         scaleheight, pseudoalt
   USE inigeomphy_mod, ONLY: inigeomphy
   USE mod_grid_phy_lmdz, ONLY: nbp_lon,nbp_lat,nbp_lev,klon_glo ! number of atmospheric columns (on full grid)
@@ -103,7 +104,7 @@
 !$OMP COPYIN(annee_ref, day_ini, day_ref, start_time)
 
-  ! copy over preff , ap(), bp(), etc 
+  ! copy over preff , ap(), bp(), etc
   CALL init_vertical_layers(nlayer,preff,scaleheight, &
-                            ap,bp,presnivs,pseudoalt)
+                            ap,bp,aps,bps,presnivs,pseudoalt)
 
   ! Initialize physical constants in physics:
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/misc/wxios.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/misc/wxios.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/misc/wxios.F90	(revision 3629)
@@ -342,4 +342,7 @@
         CALL xios_set_domain_attr_hdl(dom, nj_glo=nj_glo, jbegin=jbegin-1, nj=nj, data_dim=2)
         CALL xios_set_domain_attr_hdl(dom, lonvalue_1d=io_lon(ibegin:iend), latvalue_1d=io_lat(jbegin:jend))
+        IF (xios_is_valid_axis("axis_lat")) THEN
+           CALL xios_set_axis_attr( "axis_lat", n_glo=nj_glo, n=nj, begin=jbegin-1, value=io_lat(jbegin:jend))
+        ENDIF
 #endif
         IF (.NOT.is_sequential) THEN
@@ -372,5 +375,6 @@
     ! Pour déclarer un axe vertical !!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    SUBROUTINE wxios_add_vaxis(axis_id, axis_size, axis_value)
+    SUBROUTINE wxios_add_vaxis(axis_id, axis_size, axis_value,     &
+                               positif, bnds)
         USE print_control_mod, ONLY : prt_level, lunout
         IMPLICIT NONE
@@ -379,4 +383,6 @@
         INTEGER, INTENT(IN) :: axis_size
         REAL, DIMENSION(axis_size), INTENT(IN) :: axis_value
+        CHARACTER (len=*), INTENT(IN), OPTIONAL :: positif
+        REAL, DIMENSION(axis_size, 2), INTENT(IN), OPTIONAL :: bnds
         
 !        TYPE(xios_axisgroup) :: axgroup
@@ -404,5 +410,16 @@
         CALL xios_set_axis_attr(trim(axis_id),size=axis_size,value=axis_value)
 #else
-        CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value)
+        if (PRESENT(positif) .AND. PRESENT(bnds)) then
+          CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, &
+                                  positive=positif, bounds=bnds)
+        else if (PRESENT(positif)) then
+          CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, &
+                                  positive=positif)
+        else if (PRESENT(bnds)) then
+          CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, &
+                                  bounds=bnds)
+        else
+          CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value)
+        endif
 #endif        
         !Vérification:
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/iophy.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/iophy.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/iophy.F90	(revision 3629)
@@ -884,6 +884,6 @@
 ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE
   SUBROUTINE histwrite2d_phy(var,field, STD_iff)
-  USE dimphy, only: klon
-  USE mod_phys_lmdz_para, only: gather_omp, grid1dto2d_mpi, &
+  USE dimphy, ONLY: klon, klev
+  USE mod_phys_lmdz_para, ONLY: gather_omp, grid1dto2d_mpi, &
                                 jj_nb, klon_mpi, klon_mpi_begin, &
                                 klon_mpi_end, is_sequential
@@ -917,7 +917,7 @@
     REAL, ALLOCATABLE, DIMENSION(:) :: fieldok
 
-    IF (prt_level >= 10) THEN
+!    IF (prt_level >= 10) THEN
       WRITE(lunout,*)'Begin histwrite2d_phy for ',trim(var%name)
-    ENDIF
+!    ENDIF
 ! ug RUSTINE POUR LES STD LEVS.....
       IF (PRESENT(STD_iff)) THEN
@@ -948,12 +948,15 @@
 
     !Et sinon on.... écrit
-    IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_phy','Field first DIMENSION not equal to klon',1)
+    IF (SIZE(field)/=klon .AND. SIZE(field)/=klev .AND. SIZE(field)/=klev+1) CALL abort_physic('iophy::histwrite2d_phy','Field first DIMENSION not equal to klon/klev',1)    
+    IF (prt_level >= 10) THEn
+      WRITE (lunout,*)"histwrite2d_phy: .not.vars_defined ; time to gather and write ", trim(var%name)
+    ENDIF
     
-    if (prt_level >= 10) then
-      write(lunout,*)"histwrite2d_phy: .not.vars_defined ; time to gather and write ", &
-                     trim(var%name)
-    endif
     
-    CALL Gather_omp(field,buffer_omp)
+    IF (SIZE(field) == klon) then
+        CALL Gather_omp(field,buffer_omp)
+    ELSE
+        buffer_omp(:)=0.
+    ENDIF
 !$OMP MASTER
     CALL grid1Dto2D_mpi(buffer_omp,Field2d)
@@ -964,13 +967,15 @@
       IF (ok_all_xml) THEN
 #ifdef CPP_XIOS
-          if (prt_level >= 10) then
-             write(lunout,*)'Dans iophy histwrite2D,var%name ',&
-                             trim(var%name)                       
-          endif
-          CALL xios_send_field(var%name, Field2d)
-          if (prt_level >= 10) then
-             write(lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ',&
-                             trim(var%name)                       
-          endif
+          IF (prt_level >= 10) THEN
+             write(lunout,*)'Dans iophy histwrite2D,var%name ', trim(var%name)                       
+          ENDIF
+          IF (SIZE(field) == klon) then
+              CALL xios_send_field(var%name, Field2d)
+          ELSE
+             CALL xios_send_field(var%name, field)
+          ENDIF 
+          IF (prt_level >= 10) THEN
+             WRITE (lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ', trim(var%name)                       
+          ENDIF
 #else
         CALL abort_physic ('iophy','cannot have ok_all_xml = .T. without CPP_XIOS defined' ,1)
@@ -982,10 +987,13 @@
 #ifdef CPP_XIOS
                IF (firstx) THEN
-                  if (prt_level >= 10) then
-                     write(lunout,*)'Dans iophy histwrite2D,iff,var%name ',&
-                                    iff,trim(var%name)                       
-                     write(lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
-                  endif
-                  CALL xios_send_field(var%name, Field2d)
+                  IF (prt_level >= 10) THEN
+                     WRITE (lunout,*)'Dans iophy histwrite2D,iff,var%name ', iff,trim(var%name)                       
+                     WRITE (lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
+                  ENDIF
+                  IF (SIZE(field) == klon) then
+                     CALL xios_send_field(var%name, Field2d)
+                  ELSE
+                     CALL xios_send_field(var%name, field)
+                  ENDIF
                   firstx=.false.
                ENDIF
@@ -1083,5 +1091,5 @@
             iff_beg = 1
             iff_end = nfiles
-      END IF
+      ENDIF
 
   ! On regarde si on est dans la phase de définition ou d'écriture:
@@ -1097,5 +1105,7 @@
   ELSE
     !Et sinon on.... écrit
-    IF (SIZE(field,1)/=klon) CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
+
+    IF (SIZE(field,1)/=klon .AND. SIZE(field,1)/=klev .AND. SIZE(field,1)/=klev+1) CALL abort_physic('iophy::histwrite3d_phy','Field first DIMENSION not equal to klon/klev',1)
+
     nlev=SIZE(field,2)
     if (nlev.eq.klev+1) then
@@ -1105,5 +1115,9 @@
     endif
 
-    CALL Gather_omp(field,buffer_omp)
+    IF (SIZE(field,1) == klon) then
+        CALL Gather_omp(field,buffer_omp)
+    ELSE
+        buffer_omp(:,:)=0.
+    ENDIF
 !$OMP MASTER
     CALL grid1Dto2D_mpi(buffer_omp,field3d)
@@ -1118,6 +1132,10 @@
              write(lunout,*)'Dans iophy histwrite3D,var%name ',&
                              trim(var%name)                       
-          endif
-          CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
+          ENDIF
+          IF (SIZE(field,1) == klon) then
+             CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
+          ELSE
+             CALL xios_send_field(var%name, field)
+          ENDIF
 #else
         CALL abort_physic ('iophy','cannot have ok_all_xml = .T. without CPP_XIOS defined' ,1)
@@ -1136,7 +1154,11 @@
                                   trim(var%name), ' with iim jjm nlevx = ', &
                                   nbp_lon,jj_nb,nlevx
-                endif
-                CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
-                            firstx=.false.
+                ENDIF
+                IF (SIZE(field,1) == klon) then
+                    CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
+                ELSE
+                     CALL xios_send_field(var%name, field)
+                ENDIF
+                firstx=.false.
               ENDIF
 #endif
@@ -1194,6 +1216,6 @@
 #ifdef CPP_XIOS
   SUBROUTINE histwrite2d_xios(field_name,field)
-  USE dimphy, only: klon
-  USE mod_phys_lmdz_para, only: gather_omp, grid1Dto2D_mpi, &
+  USE dimphy, ONLY: klon, klev
+  USE mod_phys_lmdz_para, ONLY: gather_omp, grid1Dto2D_mpi, &
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 jj_nb, klon_mpi
@@ -1217,7 +1239,12 @@
 
     !Et sinon on.... écrit
-    IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
+    IF (SIZE(field)/=klon .AND. SIZE(field)/=klev .AND. SIZE(field)/=klev+1) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon/klev',1)
     
-    CALL Gather_omp(field,buffer_omp)    
+    IF (SIZE(field) == klev .OR. SIZE(field) == klev+1) then
+!$OMP MASTER
+        CALL xios_send_field(field_name,field)
+!$OMP END MASTER   
+    ELSE
+        CALL Gather_omp(field,buffer_omp)    
 !$OMP MASTER
     CALL grid1Dto2D_mpi(buffer_omp,Field2d)
@@ -1257,4 +1284,5 @@
     deallocate(fieldok)
 !$OMP END MASTER   
+    ENDIF
 
   IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite2d_xios ',field_name
@@ -1286,6 +1314,15 @@
 
     !Et on.... écrit
-    IF (SIZE(field,1)/=klon) CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
-    nlev=SIZE(field,2)
+    IF (SIZE(field,1)/=klon .AND. SIZE(field,1)/=klev .AND. SIZE(field,1)/=klev+1) then
+      write(lunout,*)' histrwrite3d_xios ', field_name, SIZE(field)
+      CALL abort_physic('iophy::histwrite3d_xios','Field first DIMENSION not equal to klon/klev',1)
+    ENDIF
+    
+    IF (SIZE(field,1) == klev .OR. SIZE(field,1) == klev+1) then
+!$OMP MASTER
+        CALL xios_send_field(field_name,field)
+!$OMP END MASTER   
+    ELSE
+        nlev=SIZE(field,2)
 
 
@@ -1328,7 +1365,24 @@
     deallocate(fieldok)
 !$OMP END MASTER   
+    ENDIF
 
   IF (prt_level >= 10) write(lunout,*)'End histrwrite3d_xios ',field_name
   END SUBROUTINE histwrite3d_xios
+
+#ifdef CPP_XIOS
+  SUBROUTINE histwrite0d_xios(field_name, field)
+  USE xios, ONLY: xios_send_field
+  IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, INTENT(IN) :: field ! --> scalar
+
+!$OMP MASTER
+   CALL xios_send_field(field_name, field)
+!$OMP END MASTER
+
+  END SUBROUTINE histwrite0d_xios
+#endif
+
 #endif
 end module iophy
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 3629)
@@ -17,11 +17,32 @@
 !  CHARACTER(len=20), dimension(nfiles) :: TEF = type_ecri_files
 
-!!! Comosantes de la coordonnee sigma-hybride
-!!! Ap et Bp
-  TYPE(ctrl_out), SAVE :: o_Ahyb = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11 /), &
-    'Ap', '', '', (/ ('', i=1, 9) /))
-  TYPE(ctrl_out), SAVE :: o_Bhyb = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11 /), &
-    'Bp', '', '', (/ ('', i=1, 9) /))
-  TYPE(ctrl_out), SAVE :: o_Alt = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11 /), &
+!!! saving lon and lat as variables for CMIP6 DataRequest
+  TYPE(ctrl_out), SAVE :: o_longitude = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'io_lon', '', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_latitude = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'io_lat', '', '', (/ ('once', i=1, 9) /))
+
+!!! Composantes de la coordonnee sigma-hybride
+!!! Ap et Bp et interfaces
+  TYPE(ctrl_out), SAVE :: o_Ahyb = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Ahyb', 'Ahyb at level interface', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Bhyb = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Bhyb', 'Bhyb at level interface', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Ahyb_bounds = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Ahyb_bounds', '', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Bhyb_bounds = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Bhyb_bounds', '', '', (/ ('once', i=1, 9) /))
+!!! Composantes de la coordonnee sigma-hybride  au milieu des couches
+!!! Aps et Bps et interfaces
+  TYPE(ctrl_out), SAVE :: o_Ahyb_mid = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Ahyb_mid', 'Ahyb at the middle of the level', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Bhyb_mid = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Bhyb_mid', 'Bhyb at the middle of the level', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Ahyb_mid_bounds = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Ahyb_mid_bounds', '', '', (/ ('once', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Bhyb_mid_bounds = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
+    'Bhyb_mid_bounds', '', '', (/ ('once', i=1, 9) /))
+
+  TYPE(ctrl_out), SAVE :: o_Alt = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11/), &
     'Alt', '', '', (/ ('', i=1, 9) /))
 
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_mod.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_mod.F90	(revision 3629)
@@ -46,5 +46,5 @@
     USE mod_grid_phy_lmdz, only: klon_glo,nbp_lon,nbp_lat
     USE print_control_mod, ONLY: prt_level,lunout
-    USE vertical_layers_mod, ONLY: ap,bp,preff,presnivs, Ahyb, Bhyb
+    USE vertical_layers_mod, ONLY: ap,bp,preff,presnivs, aps, bps, pseudoalt
     USE time_phylmdz_mod, ONLY: day_ini, itau_phy, start_time, annee_ref, day_ref
 #ifdef CPP_XIOS
@@ -130,4 +130,6 @@
     REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/  90.,     90.,     90.,     90., &
                                                                     90., 90., 90., 90., 90. /)                        
+    REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
+    REAL, DIMENSION(klev+1)   :: lev_index
 #ifdef CPP_XIOS
     ! ug Variables utilis\'ees pour r\'ecup\'erer le calendrier pour xios
@@ -140,4 +142,13 @@
     WRITE(lunout,*) 'Debut phys_output_mod.F90'
     ! Initialisations (Valeurs par defaut
+
+    DO ilev=1,klev
+      Ahyb_bounds(ilev,1) = ap(ilev)
+      Ahyb_bounds(ilev,2) = ap(ilev+1)
+      Bhyb_bounds(ilev,1) = bp(ilev)
+      Bhyb_bounds(ilev,2) = bp(ilev+1)
+      lev_index(ilev) = REAL(ilev)
+    END DO
+      lev_index(klev+1) = REAL(klev+1)
 
     IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
@@ -283,15 +294,4 @@
     zdtime_moy = dtime         ! Frequence ou l on moyenne
 
-    ! Calcul des Ahyb, Bhyb et Alt
-    DO k=1,klev
-       Ahyb(k)=(ap(k)+ap(k+1))/2.
-       Bhyb(k)=(bp(k)+bp(k+1))/2.
-       Alt(k)=log(preff/presnivs(k))*8.
-    ENDDO
-    !          if(prt_level.ge.1) then
-    WRITE(lunout,*)'Ap Hybrid = ',Ahyb(1:klev)
-    WRITE(lunout,*)'Bp Hybrid = ',Bhyb(1:klev)
-    WRITE(lunout,*)'Alt approx des couches pour une haut d echelle de 8km = ',Alt(1:klev)
-    !          endif
 
   ecrit_files(7) = ecrit_files(1)
@@ -335,10 +335,19 @@
             levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
     CALL wxios_add_vaxis("Ahyb", &
-            levmax(iff) - levmin(iff) + 1, Ahyb)
+            levmax(iff) - levmin(iff) + 1, aps(levmin(iff):levmax(iff)), positif='down', &
+            bnds=Ahyb_bounds(levmin(iff):levmax(iff),:))
     CALL wxios_add_vaxis("Bhyb", &
-            levmax(iff) - levmin(iff) + 1, Bhyb)
-    CALL wxios_add_vaxis("Alt", &
-            levmax(iff) - levmin(iff) + 1, Alt)
-   else
+            levmax(iff) - levmin(iff) + 1, bps(levmin(iff):levmax(iff)), positif='down', &
+            bnds=Bhyb_bounds(levmin(iff):levmax(iff),:))
+    CALL wxios_add_vaxis("klev", levmax(iff) - levmin(iff) + 1, &
+                          lev_index(levmin(iff):levmax(iff)))
+    CALL wxios_add_vaxis("klevp1", klev+1, &
+                          lev_index(1:klev+1))
+    CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
+
+     CALL wxios_add_vaxis("Alt", &
+            levmax(iff) - levmin(iff) + 1, pseudoalt)
+
+   ELSE
     ! NMC files
     CALL wxios_add_vaxis("plev", &
@@ -403,11 +412,11 @@
 !!!! Composantes de la coordonnee sigma-hybride 
           CALL histvert(nid_files(iff), "Ahyb","Ahyb comp of Hyb Cord ", "Pa", &
-               levmax(iff) - levmin(iff) + 1,Ahyb,nvertap(iff))
+               levmax(iff) - levmin(iff) + 1,aps,nvertap(iff))
 
           CALL histvert(nid_files(iff), "Bhyb","Bhyb comp of Hyb Cord", " ", &
-               levmax(iff) - levmin(iff) + 1,Bhyb,nvertbp(iff))
+               levmax(iff) - levmin(iff) + 1,bps,nvertbp(iff))
 
           CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &                       
-               levmax(iff) - levmin(iff) + 1,Alt,nvertAlt(iff))
+               levmax(iff) - levmin(iff) + 1,pseudoalt,nvertAlt(iff))
 
           else
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_write_mod.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/phys_output_write_mod.F90	(revision 3629)
@@ -27,6 +27,10 @@
     USE mod_phys_lmdz_para, ONLY: is_north_pole_phy,is_south_pole_phy
     USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
-    USE time_phylmdz_mod, only: day_step_phy, start_time, itau_phy
-    USE phys_output_ctrlout_mod, only: o_phis, o_aire, is_ter, is_lic, is_oce, &
+    USE time_phylmdz_mod, ONLY: day_step_phy, start_time, itau_phy
+    USE vertical_layers_mod, ONLY : ap, bp, aps, bps
+    USE phys_output_ctrlout_mod, ONLY: o_phis, o_aire, is_ter, is_lic, is_oce, &
+         o_longitude, o_latitude, &
+         o_Ahyb, o_Bhyb,o_Ahyb_bounds, o_Bhyb_bounds, & 
+         o_Ahyb_mid, o_Bhyb_mid,o_Ahyb_mid_bounds, o_Bhyb_mid_bounds, & 
          is_ave, is_sic, o_contfracATM, o_contfracOR, &
          o_aireTER, o_flat, o_slp, o_ptstar, o_pt0, o_tsol, &
@@ -295,5 +299,5 @@
     USE indice_sol_mod, only: nbsrf
     USE infotrac_phy, only: nqtot, nqo, type_trac
-    USE geometry_mod, only: cell_area
+    USE geometry_mod, only: cell_area, latitude_deg, longitude_deg
     USE surface_data, only: type_ocean, version_ocean, ok_veget, ok_snow
 !    USE aero_mod, only: naero_spc
@@ -351,4 +355,7 @@
     REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
 !   REAL, PARAMETER :: missing_val=nf90_fill_real
+    REAL, DIMENSION(klev+1,2) :: Ahyb_bounds, Bhyb_bounds
+    REAL, DIMENSION(klev,2) :: Ahyb_mid_bounds, Bhyb_mid_bounds
+    INTEGER :: ilev
 #ifndef CPP_XIOS
     REAL :: missing_val
@@ -367,5 +374,27 @@
     ENDIF
 
-    ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
+    Ahyb_bounds(1,1) = 0.
+    Ahyb_bounds(1,2) = aps(1)
+    Bhyb_bounds(1,1) = 1.
+    Bhyb_bounds(1,2) = bps(1)    
+    DO ilev=2,klev
+      Ahyb_bounds(ilev,1) = aps(ilev-1)
+      Ahyb_bounds(ilev,2) = aps(ilev)
+      Bhyb_bounds(ilev,1) = bps(ilev-1)
+      Bhyb_bounds(ilev,2) = bps(ilev)
+    ENDDO
+     Ahyb_bounds(klev+1,1) = aps(klev)
+     Ahyb_bounds(klev+1,2) = 0.
+     Bhyb_bounds(klev+1,1) = bps(klev)
+     Bhyb_bounds(klev+1,2) = 0.
+
+    DO ilev=1, klev
+      Ahyb_mid_bounds(ilev,1) = ap(ilev)
+      Ahyb_mid_bounds(ilev,2) = ap(ilev+1)
+      Bhyb_mid_bounds(ilev,1) = bp(ilev)
+      Bhyb_mid_bounds(ilev,2) = bp(ilev+1)
+    END DO    
+
+! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
     DO iinit=1, iinitend
 #ifdef CPP_XIOS
@@ -403,4 +432,17 @@
        CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
        CALL histwrite_phy(o_aireTER, paire_ter)
+#ifdef CPP_XIOS
+       CALL histwrite_phy(o_Ahyb, ap)
+       CALL histwrite_phy(o_Bhyb, bp)
+       CALL histwrite_phy(o_Ahyb_bounds, Ahyb_bounds)
+       CALL histwrite_phy(o_Bhyb_bounds, Bhyb_bounds)
+       CALL histwrite_phy(o_Ahyb_mid, aps)
+       CALL histwrite_phy(o_Bhyb_mid, bps)
+       CALL histwrite_phy(o_Ahyb_mid_bounds, Ahyb_mid_bounds)
+       CALL histwrite_phy(o_Bhyb_mid_bounds, Bhyb_mid_bounds)
+       CALL histwrite_phy(o_longitude, longitude_deg)
+       CALL histwrite_phy(o_latitude, latitude_deg)
+#endif
+
 !!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! Simulateur AIRS
@@ -1010,5 +1052,4 @@
 !This is warranted by treating INCA aerosols as offline aerosols
        IF (new_aod .and. (.not. aerosol_couple)) THEN
-!       IF (new_aod) THEN
           IF (flag_aerosol.GT.0) THEN
              CALL histwrite_phy(o_od550aer, od550aer)
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/physiq_mod.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/physiq_mod.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/physiq_mod.F90	(revision 3629)
@@ -223,5 +223,7 @@
     use FLOTT_GWD_rando_m, only: FLOTT_GWD_rando
     use ACAMA_GWD_rando_m, only: ACAMA_GWD_rando
-    USE vertical_layers_mod, only : Ahyb, Bhyb
+    USE VERTICAL_LAYERS_MOD, ONLY: aps,bps, ap, bp
+
+
     IMPLICIT none
     !>======================================================================
@@ -4433,5 +4435,5 @@
             pphis, &
             zx_rh, &
-            Ahyb, Bhyb)
+            aps, bps, ap, bp)
 
        CALL VTe(VTinca)
Index: /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/vertical_layers_mod.F90
===================================================================
--- /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/vertical_layers_mod.F90	(revision 3628)
+++ /LMDZ5/branches/IPSLCM5A2.1/libf/phylmd/vertical_layers_mod.F90	(revision 3629)
@@ -9,4 +9,8 @@
    REAL,SAVE,ALLOCATABLE :: bp(:) ! hybrid (sigma contribution) coordinate 
                                   ! at layer interfaces (Pa)
+   REAL,SAVE,ALLOCATABLE :: aps(:) ! hybrid (pressure contribution) coordinate 
+                                   ! at mid-layer (Pa)
+   REAL,SAVE,ALLOCATABLE :: bps(:) ! hybrid (sigma contribution) coordinate 
+                                   ! at mid-layer
    REAL,SAVE,ALLOCATABLE :: presnivs(:) ! reference pressure at mid-layer (Pa),
                                         ! based on preff, ap and bp
@@ -14,12 +18,11 @@
                                          ! based on preff and scaleheight
    
-!$OMP THREADPRIVATE(preff,scaleheight,ap,bp,presnivs,pseudoalt)
-   REAL, SAVE, ALLOCATABLE :: Ahyb(:), Bhyb(:)
-!$OMP THREADPRIVATE(Ahyb, Bhyb) 
+!$OMP THREADPRIVATE(preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt)
+
 
 CONTAINS
 
   SUBROUTINE init_vertical_layers(nlayer,preff_,scaleheight_,ap_,bp_,&
-                                 presnivs_, pseudoalt_)
+                                 aps_,bps_,presnivs_, pseudoalt_)
     IMPLICIT NONE
     INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
@@ -28,4 +31,6 @@
     REAL,INTENT(IN)    :: ap_(nlayer+1) ! hybrid coordinate at interfaces
     REAL,INTENT(IN)    :: bp_(nlayer+1) ! hybrid coordinate at interfaces
+    REAL,INTENT(IN)    :: aps_(nlayer) ! hybrid coordinate at mid-layer
+    REAL,INTENT(IN)    :: bps_(nlayer) ! hybrid coordinate at mid-layer
     REAL,INTENT(IN)    :: presnivs_(nlayer) ! Appproximative pressure of atm. layers (Pa)
     REAL,INTENT(IN)    :: pseudoalt_(nlayer) ! pseudo-altitude of atm. layers (km)
@@ -33,14 +38,15 @@
     ALLOCATE(ap(nlayer+1))
     ALLOCATE(bp(nlayer+1))
+    ALLOCATE(aps(nlayer))
+    ALLOCATE(bps(nlayer))
     ALLOCATE(presnivs(nlayer))
     ALLOCATE(pseudoalt(nlayer))
-    ALLOCATE(Ahyb(nlayer)) 
-    ALLOCATE(Bhyb(nlayer)) 
-
-
+  
     preff = preff_
     scaleheight=scaleheight_
     ap(:) = ap_(:)
     bp(:) = bp_(:)
+    aps(:) = aps_(:)
+    bps(:) = bps_(:)
     presnivs(:) = presnivs_(:)
     pseudoalt(:) = pseudoalt_(:)
