Index: trunk/LMDZ.MARS/libf/phymars/physiq.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/physiq.F	(revision 1463)
+++ trunk/LMDZ.MARS/libf/phymars/physiq.F	(revision 1464)
@@ -37,4 +37,5 @@
      &                      fill_data_thermos, allocate_param_thermos
       use iono_h, only: allocate_param_iono
+      use planetwide_mod
 #ifdef MESOSCALE
       use comsoil_h, only: mlayer,layer
@@ -311,4 +312,5 @@
       real rhopart(ngrid,nlayer) ! number density of a given species
       real colden(ngrid,nq)     ! vertical column of tracers
+      real mass(nq)             ! global mass of tracers (g)
       REAL mtot(ngrid)          ! Total mass of water vapor (kg/m2)
       REAL icetot(ngrid)        ! Total mass of water ice (kg/m2)
@@ -1886,41 +1888,70 @@
              endif ! (scavenging)
           
-          endif ! (dustbin.ne.0)
-
-
-             if (thermochem.or.photochem) then
-                do iq=1,nq
-                  if (noms(iq) .ne. "dust_mass" .and.
-     $                 noms(iq) .ne. "dust_number" .and.
-     $                 noms(iq) .ne. "ccn_mass" .and.
-     $                 noms(iq) .ne. "ccn_number" .and.
-     $                 noms(iq) .ne. "h2o_vap" .and.
-     $                 noms(iq) .ne. "h2o_ice") then
+           endif ! (dustbin.ne.0)
+
+           if (thermochem .or. photochem) then
+              do iq=1,nq
+                 if (noms(iq) .ne. "dust_mass" .and.
+     $               noms(iq) .ne. "dust_number" .and.
+     $               noms(iq) .ne. "ccn_mass" .and.
+     $               noms(iq) .ne. "ccn_number") then
+
+!                   volume mixing ratio
+
                     vmr(1:ngrid,1:nlayer)=zq(1:ngrid,1:nlayer,iq)
-     &                          *mmean(1:ngrid,1:nlayer)/mmol(iq)
+     &                            *mmean(1:ngrid,1:nlayer)/mmol(iq)
+
+                    call wstats(ngrid,"vmr_"//trim(noms(iq)),
+     $                        "Volume mixing ratio","mol/mol",3,vmr)
+                    if ((noms(iq).eq."o")
+     $             .or. (noms(iq).eq."co2")
+     $             .or. (noms(iq).eq."o3")
+     $             .or. (noms(iq).eq."ar")
+     $             .or. (noms(iq).eq."o2")
+     $             .or. (noms(iq).eq."h2o_vap") ) then
+                      call writediagfi(ngrid,"vmr_"//trim(noms(iq)),
+     $                         "Volume mixing ratio","mol/mol",3,vmr)
+                    end if
+
+!                   number density (molecule.cm-3)
+
                     rhopart(1:ngrid,1:nlayer)=zq(1:ngrid,1:nlayer,iq)
      &                          *rho(1:ngrid,1:nlayer)*n_avog/
      &                           (1000*mmol(iq))
-                   call wstats(ngrid,"vmr_"//trim(noms(iq)),
-     $                         "Volume mixing ratio","mol/mol",3,vmr)
+
 !                   call wstats(ngrid,"rho_"//trim(noms(iq)),
-!     $                     "Number density","cm-3",3,rhopart)
+!    $                     "Number density","cm-3",3,rhopart)
 !                   call writediagfi(ngrid,"rho_"//trim(noms(iq)),
-!     $                     "Number density","cm-3",3,rhopart)
-                   do ig = 1,ngrid
-                      colden(ig,iq) = 0.                           
-                   end do
-                   do l=1,nlayer                                    
-                      do ig=1,ngrid                                  
-                         colden(ig,iq) = colden(ig,iq) + zq(ig,l,iq)
-     $                                  *(zplev(ig,l)-zplev(ig,l+1)) 
-     $                                  *6.022e22/(mmol(iq)*g)       
-                      end do                                        
-                   end do                                          
-                   call wstats(ngrid,"c_"//trim(noms(iq)),           
-     $                         "column","mol cm-2",2,colden(1,iq))  
-                  end if ! of if (noms(iq) .ne. "dust_mass" ...)
-                end do ! of do iq=1,nq
-             end if ! of if (thermochem.or.photochem)
+!    $                     "Number density","cm-3",3,rhopart)
+
+!                   vertical column (molecule.cm-2)
+
+                    do ig = 1,ngrid
+                       colden(ig,iq) = 0.                           
+                    end do
+                    do l=1,nlayer                                    
+                       do ig=1,ngrid                                  
+                          colden(ig,iq) = colden(ig,iq) + zq(ig,l,iq)
+     $                                   *(zplev(ig,l)-zplev(ig,l+1)) 
+     $                                   *6.022e22/(mmol(iq)*g)       
+                       end do                                        
+                    end do                                          
+
+                    call wstats(ngrid,"c_"//trim(noms(iq)),           
+     $                          "column","mol cm-2",2,colden(1,iq))  
+                    call writediagfi(ngrid,"c_"//trim(noms(iq)),
+     $                          "column","mol cm-2",2,colden(1,iq))
+
+!                   global mass (g)
+               
+                    call planetwide_sumval(colden(:,iq)/6.022e23
+     $                            *mmol(iq)*1.e4*area(:),mass(iq))
+
+                    call writediagfi(ngrid,"mass_"//trim(noms(iq)),
+     $                              "global mass","g",0,mass(iq))
+
+                 end if ! of if (noms(iq) .ne. "dust_mass" ...)
+              end do ! of do iq=1,nq
+           end if ! of if (thermochem .or. photochem)
 
            end if ! of if (tracer)
@@ -2290,42 +2321,4 @@
      $           3,zdtnirco2)
 
-
-             if (thermochem.or.photochem) then
-                do iq=1,nq
-                  if (noms(iq) .ne. "dust_mass" .and.
-     $                 noms(iq) .ne. "dust_number" .and.
-     $                 noms(iq) .ne. "ccn_mass" .and.
-     $                 noms(iq) .ne. "ccn_number" .and.
-     $                 noms(iq) .ne. "h2o_vap" .and.
-     $                 noms(iq) .ne. "h2o_ice") then
-                    vmr(1:ngrid,1:nlayer)=zq(1:ngrid,1:nlayer,iq)
-     &                          *mmean(1:ngrid,1:nlayer)/mmol(iq)
-                    rhopart(1:ngrid,1:nlayer)=zq(1:ngrid,1:nlayer,iq)
-     &                          *rho(1:ngrid,1:nlayer)*n_avog/
-     &                           (1000*mmol(iq))
-                   call writediagfi(ngrid,"rho_"//trim(noms(iq)),
-     $                     "Number density","cm-3",3,rhopart)
-                   if ((noms(iq).eq."o") .or. (noms(iq).eq."co2").or.
-     $                 (noms(iq).eq."o3")) then
-                      call writediagfi(ngrid,"vmr_"//trim(noms(iq)),
-     $                         "Volume mixing ratio","mol/mol",3,vmr)
-                   end if
-                   do ig = 1,ngrid
-                      colden(ig,iq) = 0.
-                   end do
-                   do l=1,nlayer
-                      do ig=1,ngrid
-                         colden(ig,iq) = colden(ig,iq) + zq(ig,l,iq)
-     $                                  *(zplev(ig,l)-zplev(ig,l+1))
-     $                                  *6.022e22/(mmol(iq)*g)
-                      end do
-                   end do
-                   call writediagfi(ngrid,"c_"//trim(noms(iq)),
-     $                             "column","mol cm-2",2,colden(1,iq))
-                  end if ! of if (noms(iq) .ne. "dust_mass" ...)
-                end do ! of do iq=1,nq
-             end if ! of if (thermochem.or.photochem)
-
-
          endif  !(callthermos)
 
