Index: trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/newstart.F
===================================================================
--- trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/newstart.F	(revision 1850)
+++ trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/newstart.F	(revision 1871)
@@ -6,8 +6,6 @@
 c   Auteur:   Christophe Hourdin/Francois Forget/Yann Wanherdrick
 c   ------
-c             Derniere modif : 12/03
-c
-c
-c   Objet:  Create or modify the initial state for the LMD Mars GCM
+c
+c   Objet:  Create or modify the initial state for the LMD Titan GCM
 c   -----           (fichiers NetCDF start et startfi)
 c
@@ -568,7 +566,5 @@
       write(*,*) 'flat : no topography ("aquaplanet")'
       write(*,*) 'set_ps_to_preff : used if changing preff with topo'
-      write(*,*) 'nuketharsis : no Tharsis bulge'
       write(*,*) 'bilball : uniform albedo and thermal inertia'
-      write(*,*) 'coldspole : cold subsurface and high albedo at S.pole'
       write(*,*) 'qname : change tracer name'
       write(*,*) 't=profile  : read temperature profile in profile.in'
@@ -582,18 +578,7 @@
 !      write(*,*) 'ini_q-iceH2O : tracers initialisation for chemistry on
 !     $ly '
-      write(*,*) 'noglacier : Remove tropical H2O ice if |lat|<45'
-      write(*,*) 'watercapn : H20 ice on permanent N polar cap '
-      write(*,*) 'watercaps : H20 ice on permanent S polar cap '
-      write(*,*) 'noacglac  : H2O ice across Noachis Terra'
-      write(*,*) 'oborealis : H2O ice across Vastitas Borealis'
-      write(*,*) 'iceball   : Thick ice layer all over surface'
-      write(*,*) 'supercontinent: Create a continent of given Ab and TI'
-      write(*,*) 'wetstart  : start with a wet atmosphere'
       write(*,*) 'isotherm  : Isothermal Temperatures, wind set to zero'
       write(*,*) 'radequi   : Earth-like radiative equilibrium temperature
      $ profile (lat-alt) and winds set to zero'
-      write(*,*) 'coldstart : Start X K above the CO2 frost point and 
-     $set wind to zero (assumes 100% CO2)'
-      write(*,*) 'co2ice=0 : remove CO2 polar cap'
       write(*,*) 'ptot : change total pressure'
       write(*,*) 'emis : change surface emissivity'
@@ -664,30 +649,4 @@
           enddo
 
-c       'nuketharsis : no tharsis bulge for Early Mars'
-c       ---------------------------------------------
-        else if (trim(modif) .eq. 'nuketharsis') then
-
-           DO j=1,jjp1        
-              DO i=1,iim
-                 ig=1+(j-2)*iim +i
-                 if(j.eq.1) ig=1
-                 if(j.eq.jjp1) ig=ngridmx
-
-                 fact1=(((rlonv(i)*180./pi)+100)**2 + 
-     &                (rlatu(j)*180./pi)**2)/65**2 
-                 fact2=exp( -fact1**2.5 )
-
-                 phis(i,j) = phis(i,j) - (phis(i,j)+4000.*g)*fact2
-
-!                 if(phis(i,j).gt.2500.*g)then
-!                    if(rlatu(j)*180./pi.gt.-80.)then ! avoid chopping south polar cap
-!                       phis(i,j)=2500.*g
-!                    endif
-!                 endif
-
-              ENDDO
-           ENDDO
-          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
-
 
 c       bilball : uniform albedo, thermal inertia
@@ -717,55 +676,4 @@
           CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
           CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
-
-c       coldspole : sous-sol de la calotte sud toujours froid
-c       -----------------------------------------------------
-        else if (trim(modif) .eq. 'coldspole') then
-          write(*,*)'new value for the subsurface temperature',
-     &   ' beneath the permanent southern polar cap ? (eg: 141 K)'
- 103      read(*,*,iostat=ierr) tsud
-          if(ierr.ne.0) goto 103
-          write(*,*)
-          write(*,*) ' new value of the subsurface temperature:',tsud
-c         nouvelle temperature sous la calotte permanente
-          do l=2,nsoilmx
-               tsoil(ngridmx,l) =  tsud
-          end do
-
-
-          write(*,*)'new value for the albedo',
-     &   'of the permanent southern polar cap ? (eg: 0.75)'
- 104      read(*,*,iostat=ierr) albsud
-          if(ierr.ne.0) goto 104
-          write(*,*)
-
-c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-c         Option 1:  only the albedo of the pole is modified :    
-          albfi(ngridmx)=albsud
-          write(*,*) 'ig=',ngridmx,'   albedo perennial cap ',
-     &    albfi(ngridmx)
-
-c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-c          Option 2 A haute resolution : coordonnee de la vrai calotte ~    
-c           DO j=1,jjp1
-c             DO i=1,iip1
-c                ig=1+(j-2)*iim +i
-c                if(j.eq.1) ig=1
-c                if(j.eq.jjp1) ig=ngridmx
-c                if ((rlatu(j)*180./pi.lt.-84.).and.
-c     &            (rlatu(j)*180./pi.gt.-91.).and.
-c     &            (rlonv(i)*180./pi.gt.-91.).and.
-c     &            (rlonv(i)*180./pi.lt.0.))         then
-cc    albedo de la calotte permanente fixe a albsud
-c                   alb(i,j)=albsud
-c                   write(*,*) 'lat=',rlatu(j)*180./pi,
-c     &                      ' lon=',rlonv(i)*180./pi
-cc     fin de la condition sur les limites de la calotte permanente
-c                end if
-c             ENDDO
-c          ENDDO
-c      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-c         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
-
 
 c       ptot : Modification of the total pressure: ice + current atmosphere 
@@ -1024,77 +932,4 @@
              
 
-c      wetstart : wet atmosphere with a north to south gradient
-c      --------------------------------------------------------
-       else if (trim(modif) .eq. 'wetstart') then
-        ! check that there is indeed a water vapor tracer
-
-          write(*,*) "No water vapour tracer! Can't use this option"
-          stop
-
-c      noglacier : remove tropical water ice (to initialize high res sim)
-c      --------------------------------------------------
-        else if (trim(modif) .eq. 'noglacier') then
-        
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
-
-
-c      watercapn : H20 ice on permanent northern cap
-c      --------------------------------------------------
-        else if (trim(modif) .eq. 'watercapn') then
-        
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
-c      watercaps : H20 ice on permanent southern cap
-c      -------------------------------------------------
-        else if (trim(modif) .eq. 'watercaps') then
-
-              write(*,*) "No water ice tracer! Can't use this option"
-              stop
-
-c       noacglac : H2O ice across highest terrain
-c       --------------------------------------------
-        else if (trim(modif) .eq. 'noacglac') then
-
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
-c       oborealis : H2O oceans across Vastitas Borealis
-c       -----------------------------------------------
-        else if (trim(modif) .eq. 'oborealis') then
-
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-             
-c       iborealis : H2O ice in Northern plains
-c       --------------------------------------
-        else if (trim(modif) .eq. 'iborealis') then
-
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
-c       oceanball : H2O liquid everywhere
-c       ----------------------------
-        else if (trim(modif) .eq. 'oceanball') then
-
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
-c       iceball : H2O ice everywhere
-c       ----------------------------
-        else if (trim(modif) .eq. 'iceball') then
-
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
-c       supercontinent : H2O ice everywhere
-c       ----------------------------
-        else if (trim(modif) .eq. 'supercontinent') then
- 
-             write(*,*) "No water ice tracer! Can't use this option"
-             stop
-
 c       isotherm : Isothermal temperatures and no winds
 c       -----------------------------------------------
@@ -1153,47 +988,4 @@
           q2(1:ngridmx,1:llm+1)=0
 
-c       coldstart : T set 1K above CO2 frost point and no winds
-c       ------------------------------------------------
-        else if (trim(modif) .eq. 'coldstart') then
-
-          write(*,*)'set temperature of the atmosphere,' 
-     &,'surface and subsurface how many degrees above CO2 frost point?'
- 204      read(*,*,iostat=ierr) Tabove
-          if(ierr.ne.0) goto 204
-
-            DO j=1,jjp1
-             DO i=1,iim
-                ig=1+(j-2)*iim +i
-                if(j.eq.1) ig=1
-                if(j.eq.jjp1) ig=ngridmx
-            tsurf(ig) = (-3167.8)/(log(.01*ps(i,j))-23.23)+Tabove
-             END DO
-            END DO
-          do l=1,nsoilmx
-            do ig=1, ngridmx
-              tsoil(ig,l) = tsurf(ig)
-            end do
-          end do
-          DO j=1,jjp1
-           DO i=1,iim
-            Do l=1,llm
-               pp = aps(l) +bps(l)*ps(i,j) 
-               Tset(i,j,l)=(-3167.8)/(log(.01*pp)-23.23)+Tabove
-            end do
-           end do
-          end do
-
-          flagtset=.true.
-          ucov(1:iip1,1:jjp1,1:llm)=0
-          vcov(1:iip1,1:jjm,1:llm)=0
-          q2(1:ngridmx,1:llm+1)=0
-
-
-c       co2ice=0 : remove CO2 polar ice caps'
-c       ------------------------------------------------
-        else if (trim(modif) .eq. 'co2ice=0') then
-            write(*,*) "Can't remove CO2 ice!! (no co2_ice tracer)"
-        
-        
 !       therm_ini_s: (re)-set soil thermal inertia to reference surface values
 !       ----------------------------------------------------------------------
Index: trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/start2archive.F
===================================================================
--- trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/start2archive.F	(revision 1850)
+++ trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/start2archive.F	(revision 1871)
@@ -21,5 +21,6 @@
       use infotrac, only: infotrac_init, nqtot, tname
       USE comsoil_h
-      
+      USE comchem_h
+
 !      USE comgeomfi_h, ONLY: lati, long, area
 !      use control_mod
@@ -81,6 +82,8 @@
       INTEGER*4 day_ini_fi
 
-!     added by JVO for methane surface tank
-      REAL tankCH4(ngridmx)
+c     Added by JVO for Titan specifities
+      REAL tankCH4(ngridmx) ! Depth of surface methane tank
+      
+      ! + Titan upper atm. chemistry 44 fields in comchem_h
 
 c Variable naturelle / grille scalaire
@@ -94,7 +97,9 @@
       REAL emisS(ip1jmp1)
 
-!     added by JVO for methane surface tank
-      REAL tankCH4S(ip1jmp1)
-
+c     Added by JVO for Titan specifities
+      REAL tankCH4S(ip1jmp1)  ! Depth of surface methane tank
+
+      ! + Titan upper atm. chemistry 44 fields in comchem_h
+ 
 c Variables intermediaires : vent naturel, mais pas coord scalaire
 c----------------------------------------------------------------
@@ -105,4 +110,6 @@
       LOGICAL startdrs
       INTEGER Lmodif
+
+      LOGICAL nokim
 
       REAL ptotal
@@ -192,5 +199,4 @@
        CALL abort
       ENDIF
-      ierr = NF_CLOSE(nid1)
       
       ! allocate arrays of nsoilmx size
@@ -198,4 +204,35 @@
       allocate(tsoilS(ip1jmp1,nsoilmx))
       allocate(ithS(ip1jmp1,nsoilmx))
+
+! Get value of the "upper_chemistry_layers" dimension from physics start file
+
+      ierr = NF_INQ_DIMID(nid1,"upper_chemistry_layers",varid)
+      IF (ierr .NE. NF_NOERR) THEN
+       PRINT*, "start2archive: No upper_chemistry_layers dimension!!"
+       CALL abort
+      ENDIF
+      ierr = NF_INQ_DIMLEN(nid1,varid,nlaykim_up)
+      IF (ierr .NE. NF_NOERR) THEN
+       PRINT*, "start2archive: Failed reading 
+     . upper_chemistry_layers value!!"
+       CALL abort
+      ENDIF
+      
+      ! Allocate arrays of nlaykim_up size, only if they're present
+      ! The test is on HCN but could be on any as we assume we can't do incomplete chemistry
+
+      ierr = NF_INQ_VARID(nid1,'HCN_up',varid)
+      IF (ierr .NE. NF_NOERR) THEN
+        PRINT*, "start2archive: Missing field(s) for upper chemistry ...
+     . I presume they're all absent !"
+        nokim=.TRUE.
+      ELSE
+        PRINT*,"start2archive: I found a field for upper chemistry ...
+     . I presume they're all here as you can't do uncomplete chemistry!"
+        ! Allocates upper chemistry fields in comchem_h on physical and scalar grid
+        CALL allokim_start2archive(ngridmx,ip1jmp1)
+      ENDIF
+
+      ierr = NF_CLOSE(nid1)
 
 c-----------------------------------------------------------------------
@@ -316,4 +353,5 @@
 c qsurf --> qsurfS
 c tankCH4 --> tankCH4S
+c + all 44 chemistry fields
 c
 c-----------------------------------------------------------------------
@@ -327,4 +365,51 @@
       call gr_fi_dyn(nqtot,ngridmx,iip1,jjp1,qsurf,qsurfS)
       call gr_fi_dyn(1,ngridmx,iip1,jjp1,tankCH4,tankCH4S)
+
+      IF (nokim .eqv. .FALSE.) THEN ! NB : fields are in comchem_h
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,H,H_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,H2,H2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH,CH_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH2s,CH2s_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH2,CH2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH3,CH3_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH4,CH4_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2,C2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2H,C2H_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2H2,C2H2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2H3,C2H3_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2H4,C2H4_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2H5,C2H5_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C2H6,C2H6_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3H3,C3H3_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3H5,C3H5_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3H6,C3H6_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3H7,C3H7_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H,C4H_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H3,C4H3_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H4,C4H4_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H2s,C4H2s_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH2CCH2,CH2CCH2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH3CCH,CH3CCH_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3H8,C3H8_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H2,C4H2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H6,C4H6_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H10,C4H10_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,AC6H6,AC6H6_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3H2,C3H2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4H5,C4H5_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,AC6H5,AC6H5_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,N2,N2_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,N4S,N4S_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CN,CN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,HCN,HCN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,H2CN,H2CN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CHCN,CHCN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH2CN,CH2CN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,CH3CN,CH3CN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C3N,C3N_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,HC3N,HC3N_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,NCCN,NCCN_S)
+         call gr_fi_dyn(nlaykim_up,ngridmx,iip1,jjp1,C4N2,C4N2_S)
+      ENDIF
 
 c=======================================================================
@@ -400,5 +485,5 @@
 
 c-----------------------------------------------------------------------
-c Ecriture des champs  (emis,ps,Tsurf,T,u,v,q2,q,qsurf)
+c Ecriture des champs  (emis,ps,Tsurf,T,u,v,q2,q,qsurf,tankCH4)
 c-----------------------------------------------------------------------
 c ATTENTION: q2 a une couche de plus!!!!
@@ -471,4 +556,99 @@
      &         'Depth of surface methane tank','m',2,tankCH4S)
 
+c-----------------------------------------------------------------
+c Ecriture des champs upper_chemistry
+c-----------------------------------------------------------------
+
+      IF (nokim .eqv. .FALSE.) THEN
+         call write_archive(nid,ntime,'H_up',
+     .              'H in upper atmosphere','kg/kg',4,H_S)
+         call write_archive(nid,ntime,'H2_up',
+     .              'H2 in upper atmosphere','kg/kg',4,H2_S)
+         call write_archive(nid,ntime,'CH_up',
+     .              'CH in upper atmosphere','kg/kg',4,CH_S)
+         call write_archive(nid,ntime,'CH2s_up',
+     .              'CH2s in upper atmosphere','kg/kg',4,CH2s_S)
+         call write_archive(nid,ntime,'CH2_up',
+     .              'CH2 in upper atmosphere','kg/kg',4,CH2_S)
+         call write_archive(nid,ntime,'CH3_up',
+     .              'CH3 in upper atmosphere','kg/kg',4,CH3_S)
+         call write_archive(nid,ntime,'CH4_up',
+     .              'CH4 in upper atmosphere','kg/kg',4,CH4_S)
+         call write_archive(nid,ntime,'C2_up',
+     .              'C2 in upper atmosphere','kg/kg',4,C2_S)
+         call write_archive(nid,ntime,'C2H_up',
+     .              'C2H in upper atmosphere','kg/kg',4,C2H_S)
+         call write_archive(nid,ntime,'C2H2_up',
+     .              'C2H2 in upper atmosphere','kg/kg',4,C2H2_S)
+         call write_archive(nid,ntime,'C2H3_up',
+     .              'C2H3 in upper atmosphere','kg/kg',4,C2H3_S)
+         call write_archive(nid,ntime,'C2H4_up',
+     .              'C2H4 in upper atmosphere','kg/kg',4,C2H4_S)
+         call write_archive(nid,ntime,'C2H5_up',
+     .              'C2H5 in upper atmosphere','kg/kg',4,C2H5_S)
+         call write_archive(nid,ntime,'C2H6_up',
+     .              'C2H6 in upper atmosphere','kg/kg',4,C2H6_S)
+         call write_archive(nid,ntime,'C3H3_up',
+     .              'C3H3 in upper atmosphere','kg/kg',4,C3H3_S)
+         call write_archive(nid,ntime,'C3H5_up',
+     .              'C3H5 in upper atmosphere','kg/kg',4,C3H5_S)
+         call write_archive(nid,ntime,'C3H6_up',
+     .              'C3H6 in upper atmosphere','kg/kg',4,C3H6_S)
+         call write_archive(nid,ntime,'C3H7_up',
+     .              'C3H7 in upper atmosphere','kg/kg',4,C3H7_S)
+         call write_archive(nid,ntime,'C4H_up',
+     .              'C4H in upper atmosphere','kg/kg',4,C4H_S)
+         call write_archive(nid,ntime,'C4H3_up',
+     .              'C4H3 in upper atmosphere','kg/kg',4,C4H3_S)
+         call write_archive(nid,ntime,'C4H4_up',
+     .              'C4H4 in upper atmosphere','kg/kg',4,C4H4_S)
+         call write_archive(nid,ntime,'C4H2s_up',
+     .              'C4H2s in upper atmosphere','kg/kg',4,C4H2s_S)
+         call write_archive(nid,ntime,'CH2CCH2_up',
+     .              'CH2CCH2 in upper atmosphere','kg/kg',4,CH2CCH2_S)
+         call write_archive(nid,ntime,'CH3CCH_up',
+     .              'CH3CCH in upper atmosphere','kg/kg',4,CH3CCH_S)
+         call write_archive(nid,ntime,'C3H8_up',
+     .              'C3H8 in upper atmosphere','kg/kg',4,C3H8_S)
+         call write_archive(nid,ntime,'C4H2_up',
+     .              'C4H2 in upper atmosphere','kg/kg',4,C4H2_S)
+         call write_archive(nid,ntime,'C4H6_up',
+     .              'C4H6 in upper atmosphere','kg/kg',4,C4H6_S)
+         call write_archive(nid,ntime,'C4H10_up',
+     .              'C4H10 in upper atmosphere','kg/kg',4,C4H10_S)
+         call write_archive(nid,ntime,'AC6H6_up',
+     .              'AC6H6 in upper atmosphere','kg/kg',4,AC6H6_S)
+         call write_archive(nid,ntime,'C3H2_up',
+     .              'C3H2 in upper atmosphere','kg/kg',4,C3H2_S)
+         call write_archive(nid,ntime,'C4H5_up',
+     .              'C4H5 in upper atmosphere','kg/kg',4,C4H5_S)
+         call write_archive(nid,ntime,'AC6H5_up',
+     .              'AC6H5 in upper atmosphere','kg/kg',4,AC6H5_S)
+         call write_archive(nid,ntime,'N2_up',
+     .              'N2 in upper atmosphere','kg/kg',4,N2_S)
+         call write_archive(nid,ntime,'N4S_up',
+     .              'N4S in upper atmosphere','kg/kg',4,N4S_S)
+         call write_archive(nid,ntime,'CN_up',
+     .              'CN in upper atmosphere','kg/kg',4,CN_S)
+         call write_archive(nid,ntime,'HCN_up',
+     .              'HCN in upper atmosphere','kg/kg',4,HCN_S)
+         call write_archive(nid,ntime,'H2CN_up',
+     .              'H2CN in upper atmosphere','kg/kg',4,H2CN_S)
+         call write_archive(nid,ntime,'CHCN_up',
+     .              'CHCN in upper atmosphere','kg/kg',4,CHCN_S)
+         call write_archive(nid,ntime,'CH2CN_up',
+     .              'CH2CN in upper atmosphere','kg/kg',4,CH2CN_S)
+         call write_archive(nid,ntime,'CH3CN_up',
+     .              'CH3CN in upper atmosphere','kg/kg',4,CH3CN_S)
+         call write_archive(nid,ntime,'C3N_up',
+     .              'C3N in upper atmosphere','kg/kg',4,C3N_S)
+         call write_archive(nid,ntime,'HC3N_up',
+     .              'HC3N in upper atmosphere','kg/kg',4,HC3N_S)
+         call write_archive(nid,ntime,'NCCN_up',
+     .              'NCCN in upper atmosphere','kg/kg',4,NCCN_S)
+         call write_archive(nid,ntime,'C4N2_up',
+     .              'C4N2 in upper atmosphere','kg/kg',4,C4N2_S)
+      ENDIF
+
 c Fin 
 c-----------------------------------------------------------------------
Index: trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/write_archive.F
===================================================================
--- trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/write_archive.F	(revision 1850)
+++ trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/write_archive.F	(revision 1871)
@@ -33,4 +33,5 @@
 
       use comsoil_h, only: nsoilmx
+      use comchem_h, only: nlaykim_up
 
       implicit none
@@ -160,8 +161,9 @@
 #endif
 
-! For a 3D ocean temperature Variable
-!-------------------------------
-
-        else if (dim.eq.-2) then
+
+! For a 3D upper chemistry Variable
+!----------------------------------
+
+        else if (dim.eq.4) then
         ! get variables' ID, if it exists
         ierr=NF_INQ_VARID(nid,nom,varid)
@@ -171,8 +173,8 @@
           ierr=NF_INQ_DIMID(nid,"longitude",id(1))
           ierr=NF_INQ_DIMID(nid,"latitude",id(2))
-          ierr=NF_INQ_DIMID(nid,"ocean_layers",id(3))
+          ierr=NF_INQ_DIMID(nid,"upper_chemistry_layers",id(3))
           if (ierr.ne.NF_NOERR) then
-           write(*,*)"write_archive: dimension <ocean_layers>",
-     &               " is missing !!!"
+           write(*,*)"write_archive: dimension 
+     &                <upper_chemistry_layers> is missing !!!"
            call abort
           endif
@@ -194,5 +196,5 @@
         edges(1)=iip1
         edges(2)=jjp1
-        edges(3)=1 ! JVO2017 : was noceanmx before -> set to 1
+        edges(3)=nlaykim_up
         edges(4)=1
 #ifdef NC_DOUBLE
@@ -201,5 +203,4 @@
            ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
 #endif
-
 
 
