Index: /trunk/LMDZ.MARS/README
===================================================================
--- /trunk/LMDZ.MARS/README	(revision 2174)
+++ /trunk/LMDZ.MARS/README	(revision 2175)
@@ -2775,2 +2775,10 @@
 Update non orographic GW routine so that key parameter RUWMAX is read in
 from callphys.def
+
+
+== 07/11/2019 == JN 
+File "newstart.F", option "composition". Added the possibility to change atmospheric
+composition when non-co2 gases (ar, n2, co, o2) are implicit. When this case is met,
+we assume the molar mass of non-co2 atmosphere to be the one measured by MSL at Ls~184.
+Atmospheric composition is changed at a selected grid point, and horizontal and vertical
+gradients are preserved.
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 2174)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 2175)
@@ -173,5 +173,5 @@
       real :: latref,lonref,dlatmin,dlonmin
 ! Variable used to change composition
-      real :: Svmr,Smmr,Smmr_old,Smmr_new,Sn
+      real :: Svmr,Smmr,Smmr_old,Smmr_new,n,Sn
       real :: Mair_old,Mair_new,vmr_old,vmr_new
       real,allocatable :: coefvmr(:)  ! Correction coefficient when changing composition
@@ -992,6 +992,12 @@
 
         ! Compute air molar mass at reference site
-          Smmr=0
-          Sn = 0
+          Smmr=0.
+          Sn = 0.
+          write(*,*) 'igcm_co2 = ', igcm_co2
+          write(*,*) 'igcm_n2 = ', igcm_n2
+          write(*,*) 'igcm_ar = ', igcm_ar
+          write(*,*) 'igcm_o2 = ', igcm_o2
+          write(*,*) 'igcm_co = ', igcm_co
+          write(*,*) noms
           do iq=1,nqtot 
              if ((iq.eq.igcm_co2).or.(iq.eq.igcm_n2)
@@ -1002,13 +1008,24 @@
              end if
           end do
-          write(*,*) "At reference site :  "
-          write(*,*) "Sum of mass mix. ratio (should be about 1)=",Smmr
-          Mair_old =Smmr/Sn
-          write(*,*)
-     &     "Air molar mass (g/mol) at reference site= ",Mair_old
+        ! Special case : implicit non-co2 gases ! JN 11/2019
+          if ((igcm_n2.eq.0) .or. (igcm_ar.eq.0)) then 
+           write(*,*) "Warning : non-co2 gases are implicit :  "
+           write(*,*) "At reference site :  "
+       !    write(*,*) "q= ", q(iref, jref, 1,igcm_co2)
+           write(*,*) "Sum of mass mix. ratio (ie MMR(co2))=",Smmr
+           Mair_old = 44.0*Smmr  + 33.87226017157708*(1-Smmr) 
+      
+       !  33.87226017157708 is the 
+       !   molar mass of non-co2 atmosphere measured by MSL at Ls ~184
+       
+           write(*,*)
+     &      "Air molar mass (g/mol) at reference site= ",Mair_old
+          end if
 
         ! Ask for new volume mixing ratio at reference site
           Svmr =0.
           Sn =0.
+          coefvmr(igcm_co2)=1.
+
           do iq=1,nqtot 
            coefvmr(iq) = 1.
@@ -1040,6 +1057,27 @@
            end if
           enddo ! of do iq=1,nqtot 
+
+        ! Special case : implicit non-co2 gases JN 11/2019
+          if ((igcm_n2.eq.0) .or. (igcm_ar.eq.0)) then 
+            write(*,*) "Warning : non-co2 gases are implicit"
+            vmr_old=q(iref,jref,1,igcm_co2)*Mair_old/mmol(igcm_co2)  
+            write(*,*) "Previous vmr(co2)=", vmr_old
+            write(*,*) "New vmr(co2) ? (MSL: 0.956521 at Ls~184)"
+ 666          read(*,*,iostat=ierr) vmr_new
+              if(ierr.ne.0) goto 666
+              coefvmr(igcm_co2) = vmr_new/vmr_old
+              Svmr=Svmr+vmr_new
+              Sn=vmr_new*mmol(igcm_co2) + (1-vmr_new)
+     &         *33.87226017157708 ! Molar mass of non-co2 atm from MSL
+          end if
       !  Estimation of new Air molar mass at reference site (assuming vmr_co2 = 1-Svmr)
           Mair_new = Sn + (1-Svmr)*mmol(igcm_co2) 
+      !  Estimation of new Air molar mass when non-co2 gases are implicit
+          if ((igcm_n2.eq.0) .or. (igcm_ar.eq.0)) then 
+              Mair_new=vmr_new*mmol(igcm_co2) + (1-vmr_new)
+     &         *33.87226017157708 ! Molar mass of non-co2 atm from MSL
+           write(*,*)
+     &     "We consider non-co2 gases vmr measured from Curiosity"
+          end if
           write(*,*)
      &     "NEW Air molar mass (g/mol) at reference site= ",Mair_new
@@ -1047,5 +1085,5 @@
         ! Compute mass mixing ratio changes  
           do iq=1,nqtot  
-            if ((iq.eq.igcm_n2).or.(iq.eq.igcm_ar)
+            if ((iq.eq.igcm_co2).or.(iq.eq.igcm_n2).or.(iq.eq.igcm_ar)
      &          .or. (iq.eq.igcm_o2).or.(iq.eq.igcm_co)) then
              write(*,*) "Everywhere mmr("//trim(tname(iq))//
@@ -1062,6 +1100,7 @@
               Smmr_new = 0.
               do iq=1,nqtot  
-                if ((iq.eq.igcm_n2).or.(iq.eq.igcm_ar)
-     &         .or. (iq.eq.igcm_o2).or.(iq.eq.igcm_co)) then
+                if ((iq.eq.igcm_co2).or.(iq.eq.igcm_n2)
+     &          .or.(iq.eq.igcm_ar)
+     &          .or. (iq.eq.igcm_o2).or.(iq.eq.igcm_co)) then
                    Smmr_old = Smmr_old + q(i,j,l,iq) ! sum of old mmr 
                    q(i,j,l,iq)=q(i,j,l,iq)*coefvmr(iq)*Mair_old/Mair_new
@@ -1075,4 +1114,26 @@
            enddo
           enddo
+
+
+!          do l=1,llm
+!           do j=1,jjp1
+!            do i=1,iip1
+!              Smmr_old = 0.
+!              Smmr_new = 0.
+!              do iq=1,nqtot  
+!                if ((iq.eq.igcm_co2).or.(iq.eq.igcm_n2)
+!     &          .or.(iq.eq.igcm_ar)
+!     &          .or. (iq.eq.igcm_o2).or.(iq.eq.igcm_co)) then
+!                   Smmr_old = Smmr_old + q(i,j,l,iq) ! sum of old mmr 
+!                   q(i,j,l,iq)=q(i,j,l,iq)*coefvmr(iq)*Mair_old/Mair_new
+!                   Smmr_new = Smmr_new + q(i,j,l,iq) ! sum of new mmr
+!                end if 
+!              enddo
+!              iloc = maxloc(q(i,j,l,:))
+!              iqmax = iloc(1)
+!              q(i,j,l,iqmax) = q(i,j,l,iqmax) + Smmr_old - Smmr_new
+!            enddo
+!           enddo
+!          enddo
 
           write(*,*)
