Index: trunk/LMDZ.COMMON/libf/bibio/pres2lev_mod.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/bibio/pres2lev_mod.F90	(revision 1302)
+++ trunk/LMDZ.COMMON/libf/bibio/pres2lev_mod.F90	(revision 1302)
@@ -0,0 +1,79 @@
+! $Id: pres2lev.F 1179 2009-06-11 14:18:47Z jghattas $
+!
+MODULE pres2lev_mod
+
+CONTAINS 
+
+!******************************************************
+SUBROUTINE pres2lev(varo,varn,lmo,lmn,po,pn,ni,nj,ok_invertp)
+!
+! interpolation lineaire pour passer
+! a une nouvelle discretisation verticale pour
+! les variables de GCM
+! Francois Forget (01/1995)
+! MOdif remy roca 12/97 pour passer de pres2sig
+! Modif F.Codron 07/08 po en 3D
+!**********************************************************
+
+  IMPLICIT NONE
+
+!   Declarations:
+! ==============
+!
+!  ARGUMENTS
+!  """""""""
+  LOGICAL, INTENT(IN) :: ok_invertp
+  INTEGER, INTENT(IN) :: lmo ! dimensions ancienne couches
+  INTEGER, INTENT(IN) :: lmn ! dimensions nouvelle couches
+  
+  INTEGER, INTENT(IN) :: ni,nj ! nombre de point horizontal
+  REAL, INTENT(IN) :: po(ni*nj,lmo) ! niveau de pression ancienne grille
+  REAL, INTENT(IN) :: pn(ni*nj,lmn) ! niveau de pression nouvelle grille
+
+  REAL, INTENT(IN)  :: varo(ni*nj,lmo) ! var dans l'ancienne grille
+  REAL, INTENT(OUT) :: varn(ni*nj,lmn) ! var dans la nouvelle grille
+
+  REAL :: zvaro(ni*nj,lmo),zpo(ni*nj,lmo)
+
+! Autres variables
+! """"""""""""""""
+  INTEGER ::  ln ,lo, k
+  REAL    :: coef
+
+
+! Inversion de l'ordre des niveaux verticaux
+  IF (ok_invertp) THEN
+    DO lo=1,lmo
+      DO k=1,ni*nj
+        zpo(k,lo)=po(k,lmo+1-lo)
+        zvaro(k,lo)=varo(k,lmo+1-lo)
+      ENDDO
+    ENDDO
+  ELSE
+    DO lo=1,lmo
+      DO k=1,ni*nj
+        zpo(k,lo)=po(k,lo)
+        zvaro(k,lo)=varo(k,lo)
+      ENDDO
+    ENDDO
+  ENDIF 
+
+  DO ln=1,lmn
+    DO lo=1,lmo-1
+      DO k=1,ni*nj
+        IF (pn(k,ln) >= zpo(k,1) ) THEN
+          varn(k,ln) = zvaro(k,1)
+        ELSE IF (pn(k,ln) <= zpo(k,lmo)) THEN
+          varn(k,ln) = zvaro(k,lmo)
+        ELSE IF ( pn(k,ln) <= zpo(k,lo) .AND. pn(k,ln) > zpo(k,lo+1) ) THEN
+          coef = (pn(k,ln)-zpo(k,lo)) / (zpo(k,lo+1)-zpo(k,lo))
+          varn(k,ln) = zvaro(k,lo) + coef*(zvaro(k,lo+1)-zvaro(k,lo))
+        ENDIF
+         
+      ENDDO  
+    ENDDO
+  ENDDO                
+
+END SUBROUTINE pres2lev    
+
+END MODULE pres2lev_mod
Index: trunk/LMDZ.COMMON/libf/bibio/wxios.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/bibio/wxios.F90	(revision 1300)
+++ trunk/LMDZ.COMMON/libf/bibio/wxios.F90	(revision 1302)
@@ -26,17 +26,4 @@
     
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    !   str + i   =>   str_i   !!!!!!!!!!!!!!!!!!!!
-    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    
-    SUBROUTINE concat(str, str2, str_str2)
-        CHARACTER(len=*), INTENT(IN) :: str, str2
-        CHARACTER(len=20), INTENT(OUT) :: str_str2
-        
-        
-        str_str2 = TRIM(ADJUSTL(str//"_"//TRIM(ADJUSTL(str2))))
-        !IF (prt_level >= 10) WRITE(lunout,*) "Xios. ",str,"+",str2,"=",str_str2
-    END SUBROUTINE concat
-    
-    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     !   36day => 36d etc     !!!!!!!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -109,5 +96,5 @@
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-    SUBROUTINE wxios_init(xios_ctx_name, locom, outcom)
+    SUBROUTINE wxios_init(xios_ctx_name, locom, outcom, type_ocean)
         IMPLICIT NONE
         INCLUDE 'iniprint.h'
@@ -116,4 +103,5 @@
       INTEGER, INTENT(IN), OPTIONAL :: locom
       INTEGER, INTENT(OUT), OPTIONAL :: outcom
+      CHARACTER(len=6), INTENT(IN), OPTIONAL :: type_ocean
 
     
@@ -142,6 +130,9 @@
         g_ctx_name = xios_ctx_name
         
-        CALL wxios_context_init()
-        
+        ! Si couple alors init fait dans cpl_init
+        IF (.not. PRESENT(type_ocean)) THEN
+            CALL wxios_context_init()
+        ENDIF
+
     END SUBROUTINE wxios_init
 
@@ -158,6 +149,8 @@
         g_ctx = xios_ctx
 
-        IF (prt_level >= 10) WRITE(lunout,*) "wxios_context_init: Current context is ",trim(g_ctx_name)
-
+        IF (prt_level >= 10) THEN
+          WRITE(lunout,*) "wxios_context_init: Current context is ",trim(g_ctx_name)
+          WRITE(lunout,*) "     now call xios_solve_inheritance()"
+        ENDIF
         !Une premiÃ¨re analyse des hÃ©ritages:
         CALL xios_solve_inheritance()
@@ -303,28 +296,34 @@
     ! Pour dÃ©clarer un axe vertical !!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    SUBROUTINE wxios_add_vaxis(axisgroup_id, axis_file, axis_size, axis_value)
-        IMPLICIT NONE
-        INCLUDE 'iniprint.h'
-
-        CHARACTER (len=*), INTENT(IN) :: axisgroup_id, axis_file
+    SUBROUTINE wxios_add_vaxis(axis_id, axis_size, axis_value)
+        IMPLICIT NONE
+        INCLUDE 'iniprint.h'
+
+        CHARACTER (len=*), INTENT(IN) :: axis_id
         INTEGER, INTENT(IN) :: axis_size
         REAL, DIMENSION(axis_size), INTENT(IN) :: axis_value
         
-        TYPE(xios_axisgroup) :: axgroup
-        TYPE(xios_axis) :: ax
-        CHARACTER(len=20) :: axis_id
-        
-        
-        !PrÃ©paration du nom de l'axe:
-        CALL concat(axisgroup_id, axis_file, axis_id)
+!        TYPE(xios_axisgroup) :: axgroup
+!        TYPE(xios_axis) :: ax
+!        CHARACTER(len=50) :: axis_id 
+        
+!        IF (len_trim(axisgroup_id).gt.len(axis_id)) THEN
+!          WRITE(lunout,*) "wxios_add_vaxis: error, size of axis_id too small!!"
+!          WRITE(lunout,*) "     increase it to at least ",len_trim(axisgroup_id)
+!          CALL abort_gcm("wxios_add_vaxis","len(axis_id) too small",1)
+!        ENDIF
+!        axis_id=trim(axisgroup_id)
         
         !On rÃ©cupÃ¨re le groupe d'axes qui va bien:
-        CALL xios_get_axisgroup_handle(axisgroup_id, axgroup)
+        !CALL xios_get_axisgroup_handle(axisgroup_id, axgroup)
         
         !On ajoute l'axe correspondant Ã  ce fichier:
-        CALL xios_add_axis(axgroup, ax, TRIM(ADJUSTL(axis_id)))
+        !CALL xios_add_axis(axgroup, ax, TRIM(ADJUSTL(axis_id)))
         
         !Et on le parametrise:
-        CALL xios_set_axis_attr_hdl(ax, size=axis_size, value=axis_value)
+        !CALL xios_set_axis_attr_hdl(ax, size=axis_size, value=axis_value)
+        
+        ! Ehouarn: New way to declare axis, without axis_group:
+        CALL xios_set_axis_attr(trim(axis_id),size=axis_size,value=axis_value)
         
         !VÃ©rification:
@@ -332,5 +331,5 @@
             IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_vaxis: Axis created: ", TRIM(ADJUSTL(axis_id))
         ELSE
-            WRITE(*,*) "wxios_add_vaxis: Invalid axis: ", TRIM(ADJUSTL(axis_id))
+            WRITE(lunout,*) "wxios_add_vaxis: Invalid axis: ", TRIM(ADJUSTL(axis_id))
         END IF
 
@@ -367,18 +366,23 @@
         
             IF (xios_is_valid_file("X"//fname)) THEN
-                IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_file: New file: ", "X"//fname
-                IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
+                IF (prt_level >= 10) THEN
+                  WRITE(lunout,*) "wxios_add_file: New file: ", "X"//fname
+                  WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
+                ENDIF
             ELSE
-                WRITE(*,*) "wxios_add_file: Error, invalid file: ", "X"//trim(fname)
-                WRITE(*,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
+                WRITE(lunout,*) "wxios_add_file: Error, invalid file: ", "X"//trim(fname)
+                WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
             END IF
         ELSE
-            IF (prt_level >= 10) WRITE(lunout,*) "wxios_add_file: File ",trim(fname), " dÃ©fined using XML."
-                CALL xios_set_file_attr(fname, enabled=.TRUE.)
+            IF (prt_level >= 10) THEN
+              WRITE(lunout,*) "wxios_add_file: File ",trim(fname), " dÃ©fined using XML."
+            ENDIF
+            ! Ehouarn: add an enable=.true. on top of xml definitions... why???
+            CALL xios_set_file_attr(fname, enabled=.TRUE.)
         END IF
     END SUBROUTINE wxios_add_file
     
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    ! Pour crÃ©er un champ      !!!!!!!!!!!!!!!
+    ! Pour crÃ©er un champ      !!!!!!!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     SUBROUTINE wxios_add_field(fieldname, fieldgroup, fieldlongname, fieldunit)
@@ -418,5 +422,5 @@
     
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    ! Pour dÃ©clarer un champ      !!!!!!!!!!!!!!!
+    ! Pour dÃ©clarer un champ      !!!!!!!!!!!!!!!!!
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     SUBROUTINE wxios_add_field_to_file(fieldname, fdim, fid, fname, fieldlongname, fieldunit, field_level, op)
@@ -432,5 +436,5 @@
         CHARACTER(len=*), INTENT(IN) :: op
         
-        CHARACTER(len=20) :: axis_id
+        CHARACTER(len=20) :: axis_id ! Ehouarn: dangerous...
         CHARACTER(len=100) :: operation
         TYPE(xios_file) :: f
@@ -441,6 +445,10 @@
         
         
-        !PrÃ©paration du nom de l'axe:
-        CALL concat("presnivs", fname, axis_id)
+        ! Ajout Abd pour NMC:
+        IF (fid.LE.6) THEN
+          axis_id="presnivs"
+        ELSE
+          axis_id="plev"
+        ENDIF
         
         !on prÃ©pare le nom de l'opÃ©ration:
@@ -448,8 +456,7 @@
         
         
-        
         !On selectionne le bon groupe de champs:
         IF (fdim.EQ.2) THEN
-            CALL xios_get_fieldgroup_handle("fields_2D", fieldgroup)
+          CALL xios_get_fieldgroup_handle("fields_2D", fieldgroup)
         ELSE
           CALL xios_get_fieldgroup_handle("fields_3D", fieldgroup)
@@ -515,26 +522,29 @@
             !Sinon on se contente de l'activer:
             CALL xios_set_field_attr(fieldname, enabled=.TRUE.)
+            !NB: This will override an enable=.false. set by a user in the xml file;
+            !   then the only way to not output the field is by changing its
+            !   output level
         ENDIF       
         
     END SUBROUTINE wxios_add_field_to_file
     
-    SUBROUTINE wxios_update_calendar(ito)
-        INTEGER, INTENT(IN) :: ito
-        CALL xios_update_calendar(ito)
-    END SUBROUTINE wxios_update_calendar
-    
-    SUBROUTINE wxios_write_2D(fieldname, fdata)
-        CHARACTER(len=*), INTENT(IN) :: fieldname
-        REAL, DIMENSION(:,:), INTENT(IN) :: fdata
-        
-        CALL xios_send_field(fieldname, fdata)
-    END SUBROUTINE wxios_write_2D
-    
-    SUBROUTINE wxios_write_3D(fieldname, fdata)
-        CHARACTER(len=*), INTENT(IN) :: fieldname
-        REAL, DIMENSION(:,:,:), INTENT(IN) :: fdata
-        
-        CALL xios_send_field(fieldname, fdata)
-    END SUBROUTINE wxios_write_3D
+!    SUBROUTINE wxios_update_calendar(ito)
+!        INTEGER, INTENT(IN) :: ito
+!        CALL xios_update_calendar(ito)
+!    END SUBROUTINE wxios_update_calendar
+!    
+!    SUBROUTINE wxios_write_2D(fieldname, fdata)
+!        CHARACTER(len=*), INTENT(IN) :: fieldname
+!        REAL, DIMENSION(:,:), INTENT(IN) :: fdata
+!
+!        CALL xios_send_field(fieldname, fdata)
+!    END SUBROUTINE wxios_write_2D
+    
+!    SUBROUTINE wxios_write_3D(fieldname, fdata)
+!        CHARACTER(len=*), INTENT(IN) :: fieldname
+!        REAL, DIMENSION(:,:,:), INTENT(IN) :: fdata
+!        
+!        CALL xios_send_field(fieldname, fdata)
+!    END SUBROUTINE wxios_write_3D
     
     SUBROUTINE wxios_closedef()
