Index: dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/phylmd/interface_icosa_lmdz.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/phylmd/interface_icosa_lmdz.f90	(revision 4028)
+++ dynamico_lmdz/aquaplanet/ICOSA_LMDZ/src/phylmd/interface_icosa_lmdz.f90	(revision 4047)
@@ -30,6 +30,5 @@
   INTEGER :: count_clock=0
   
-  REAL :: day_length
-
+!  REAL,SAVE :: day_length ! length of a day (s)
   
   INTEGER,SAVE :: nbp_phys
@@ -54,12 +53,6 @@
   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 
    
   
@@ -74,24 +67,6 @@
   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    
+!  REAL(rstd) :: pseudoalt(llm)
+
   INTEGER :: nbp_phys, nbp_phys_glo
   
@@ -190,5 +165,5 @@
   USE infotrac_phy, ONLY : init_infotrac_phy
   USE inifis_mod, ONLY : inifis 
-  USE phyaqua_mod, ONLY : iniaqua 
+!  USE phyaqua_mod, ONLY : iniaqua 
    
   
@@ -197,5 +172,5 @@
 
 
-  INTEGER  :: ind,i,j,ij,pos
+  INTEGER  :: ind,i,j,k,ij,pos
   REAL(rstd),POINTER :: bounds_lon(:,:)
   REAL(rstd),POINTER :: bounds_lat(:,:)
@@ -214,14 +189,16 @@
 
   INTEGER :: run_length  
-  INTEGER :: annee_ref  
-  INTEGER :: day_ref    
+  REAL,SAVE :: day_length ! length of a day (s) ! SAVEd to be OpenMP shared
+  INTEGER,SAVE :: annee_ref  
+  INTEGER,SAVE :: 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
+  ! Tracer stuff (SAVEd when needed to be OpenMP shared)
+  INTEGER :: nq
+  INTEGER,SAVE                  :: nqo, nbtr
+  CHARACTER(len=4),SAVE         :: type_trac
+  CHARACTER(len=20),ALLOCATABLE,SAVE :: tname(:)    ! tracer short name for restart and diagnostics
   CHARACTER(len=23),ALLOCATABLE :: ttext(:)     ! tracer long name for diagnostics
   INTEGER,ALLOCATABLE           :: niadv(:)    ! equivalent dyn / physique
@@ -303,5 +280,5 @@
 
     ! Initialize tracer names, numbers, etc. for physics
-
+!$OMP MASTER
     !Config  Key  = type_trac
     !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
@@ -313,11 +290,37 @@
      type_trac = 'lmdz'
      CALL getin('type_trac',type_trac)
-
-! init model for standard lmdz case
-    nqo=2
-    nbtr=2
+!$OMP END MASTER
+!$OMP BARRIER
+
+! allocate some of the tracer arrays
     ALLOCATE(tname(nqtot))
     ALLOCATE(ttext(nqtot))
     ALLOCATE(niadv(nqtot))
+
+! read "traceur.def" file to know tracer names (and figure out nqo and nbtr)
+!$OMP MASTER
+    OPEN(unit=42,file="traceur.def",form="formatted",status="old",iostat=ierr)
+    IF (ierr==0) THEN
+      READ(42,*) nq ! should be the same as nqtot
+      IF (nq /= nqtot) THEN
+        WRITE(*,*) "Error: number of tracers in tracer.def should match nqtot!"
+        WRITE(*,*) "       will just use nqtot=",nqtot," tracers"
+      ENDIF
+      DO i=1,nqtot
+        READ(42,*) j,k,tname(i)
+      ENDDO
+      CLOSE(42)
+    ENDIF
+    ! figure out how many water tracers are present
+    nqo=0
+    DO i=1,nqtot
+      IF (INDEX(tname(i),"H2O")==1) THEN
+        nqo=nqo+1
+      ENDIF
+    ENDDO
+    nbtr=nqtot-nqo
+!$OMP END MASTER
+!$OMP BARRIER
+
     ALLOCATE(conv_flg(nbtr))
     ALLOCATE(pbl_flg(nbtr))
@@ -326,17 +329,13 @@
     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
+    ! tracer long names:
+    ttext(1)=trim(tname(1))//"VLH" !'H2OvVLH'
+    DO i=2,nqtot
+      ttext(i)=trim(tname(1))//"VL1"
+    ENDDO
+    solsym(1:nbtr)=tname(nqo+1:nqtot)
+    DO i=1,nqtot
+      niadv(i)=i
+    ENDDO
     ! isotopes
     ALLOCATE(nqfils(nqtot)) ; nqfils(:)=0
@@ -375,4 +374,5 @@
 
    ! Initialize physical constant
+!$OMP MASTER
     day_length=86400
     CALL getin('day_length',day_length)
@@ -387,4 +387,6 @@
     day_ref=1
     CALL getin("dayref",day_ref)
+!$OMP END MASTER
+!$OMP BARRIER
     
     physics_timestep=dt*itau_physics
