Index: trunk/LMDZ.COMMON/libf/evolution/changelog.txt
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/changelog.txt	(revision 3983)
+++ trunk/LMDZ.COMMON/libf/evolution/changelog.txt	(revision 3984)
@@ -817,2 +817,5 @@
 - Addition of a module "metamorphism" to compute the PCM frost at the PEM beginning and give it back to the PCM at the PEM end. The frost is considered as the ice given by the PCM "startfi.nc" which is above the yearly minimum. Thereby, metamorphism is performed through this operation.
 - Ice reservoirs representation in the PEM is modernized.
+
+== 08/12/2025 == JBC
+Addition of a module "tracers" to retain properties of atmospheric tracers.
Index: trunk/LMDZ.COMMON/libf/evolution/metamorphism.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/metamorphism.F90	(revision 3984)
+++ trunk/LMDZ.COMMON/libf/evolution/metamorphism.F90	(revision 3984)
@@ -0,0 +1,140 @@
+MODULE metamorphism
+
+implicit none
+
+! Different types of frost
+type :: frost
+    real :: h2o
+    real :: co2
+end type frost
+
+! Frost retained by the PEM to give back to the PCM at the end
+type(frost), dimension(:,:), allocatable :: frost4PCM
+
+! Indices for frost taken from the PCM
+integer :: iPCM_h2ofrost, iPCM_co2frost
+
+!=======================================================================
+contains
+!=======================================================================
+
+SUBROUTINE ini_frost_id(nqtot,noms)
+
+implicit none
+
+! Arguments
+!----------
+integer,                        intent(in) :: nqtot
+character(*), dimension(nqtot), intent(in) :: noms
+
+! Local variables
+!----------------
+integer :: i
+
+! Code
+!-----
+! Initialization
+iPCM_h2ofrost = -1
+iPCM_co2frost = -1
+
+! Getting the index
+do i = 1,nqtot
+    if (trim(noms(i)) == "h2o_ice") iPCM_h2ofrost = i
+    if (trim(noms(i)) == "co2")     iPCM_co2frost = i
+enddo
+
+! Checking if everything has been found
+if (iPCM_h2ofrost < 0) error stop 'ini_frost_id: H2O frost index not found!'
+if (iPCM_co2frost < 0) error stop 'ini_frost_id: CO2 frost index not found!'
+
+END SUBROUTINE ini_frost_id
+!=======================================================================
+
+SUBROUTINE compute_frost(ngrid,nslope,h2ofrost_PCM,min_h2ofrost,co2frost_PCM,min_co2frost)
+
+implicit none
+
+! Arguments
+!----------
+integer,                       intent(in) :: ngrid, nslope
+real, dimension(ngrid,nslope), intent(in) :: h2ofrost_PCM, min_h2ofrost, co2frost_PCM, min_co2frost
+
+! Local variables
+!----------------
+
+! Code
+!-----
+write(*,*) '> Computing frost to give back to the PCM'
+
+! Allocation
+call ini_frost(ngrid,nslope)
+
+! Initialization
+frost4PCM(:,:)%h2o = 0.
+frost4PCM(:,:)%co2 = 0.
+
+! Computation: frost for the PEM is the extra part of the PCM frost above the yearly minimum
+where (h2ofrost_PCM(:,:) > 0.) frost4PCM(:,:)%h2o = h2ofrost_PCM(:,:) - min_h2ofrost(:,:)
+where (co2frost_PCM(:,:) > 0.) frost4PCM(:,:)%co2 = co2frost_PCM(:,:) - min_co2frost(:,:)
+
+END SUBROUTINE compute_frost
+!=======================================================================
+
+SUBROUTINE set_frost4PCM(PCMfrost)
+
+implicit none
+
+! Arguments
+!----------
+real, dimension(:,:,:), intent(inout) :: PCMfrost
+
+! Local variables
+!----------------
+
+! Code
+!-----
+write(*,*) '> Reconstructing frost for the PCM'
+PCMfrost(:,iPCM_h2ofrost,:) = frost4PCM(:,:)%h2o
+PCMfrost(:,iPCM_co2frost,:) = frost4PCM(:,:)%co2
+
+! Deallocation
+call end_frost()
+
+END SUBROUTINE set_frost4PCM
+!=======================================================================
+
+SUBROUTINE ini_frost(ngrid,nslope)
+
+implicit none
+
+! Arguments
+!----------
+integer, intent(in) :: ngrid, nslope
+
+! Local variables
+!----------------
+
+! Code
+!-----
+if (.not. allocated(frost4PCM)) allocate(frost4PCM(ngrid,nslope))
+
+END SUBROUTINE ini_frost
+!=======================================================================
+
+SUBROUTINE end_frost()
+
+implicit none
+
+! Arguments
+!----------
+
+! Local variables
+!----------------
+
+! Code
+!-----
+if (allocated(frost4PCM)) deallocate(frost4PCM)
+
+END SUBROUTINE end_frost
+
+END MODULE metamorphism
Index: trunk/LMDZ.COMMON/libf/evolution/pem.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/pem.F90	(revision 3983)
+++ trunk/LMDZ.COMMON/libf/evolution/pem.F90	(revision 3984)
@@ -82,5 +82,5 @@
 use dimradmars_mod,             only: totcloudfrac, albedo
 use dust_param_mod,             only: tauscaling
-use tracer_mod,                 only: noms, mmol, igcm_h2o_vap ! Tracer names and molar masses
+use tracer_mod,                 only: noms ! Tracer names
 use mod_phys_lmdz_para,         only: is_parallel, is_sequential, is_mpi_root, is_omp_root, is_master
 use planete_h,                  only: year_day
@@ -88,4 +88,5 @@
 use comcstfi_h,                 only: mugaz
 use metamorphism,               only: ini_frost_id, set_frost4PCM, iPCM_h2ofrost, iPCM_co2frost
+use tracers,                    only: mmol
 
 #ifndef CPP_1D
@@ -416,10 +417,5 @@
 call surfini(ngrid,nslope,qsurf)
 call ini_frost_id(nqtot,noms)
-do nnq = 1,nqtot
-    if (noms(nnq) == "h2o_vap") then
-        igcm_h2o_vap = nnq
-        mmol(igcm_h2o_vap) = 18.
-    endif
-enddo
+call ini_tracers_id(nqtot,noms)
 
 !------------------------
@@ -767,5 +763,5 @@
                         tsoil_PEM_timeseries(ig,isoil,islope,t) = tsoil_PEM_timeseries(ig,isoil,islope,t)*tsoil_PEM(ig,isoil,islope)/tsoil_avg_old(ig,isoil)
                         ! Update of watersoil density
-                        watersoil_density_PEM_timeseries(ig,isoil,islope,t) = exp(beta_clap_h2o/tsoil_PEM_timeseries(ig,isoil,islope,t) + alpha_clap_h2o)/tsoil_PEM_timeseries(ig,isoil,islope,t)*mmol(igcm_h2o_vap)/(mugaz*r)
+                        watersoil_density_PEM_timeseries(ig,isoil,islope,t) = exp(beta_clap_h2o/tsoil_PEM_timeseries(ig,isoil,islope,t) + alpha_clap_h2o)/tsoil_PEM_timeseries(ig,isoil,islope,t)*mmol%h2o/(mugaz*r)
                         if (isnan(tsoil_PEM(ig,isoil,islope))) call abort_pem("PEM - Update Tsoil","NaN detected in tsoil_PEM",1)
                     enddo
Index: trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90	(revision 3983)
+++ trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90	(revision 3984)
@@ -18,5 +18,4 @@
 use constants_marspem_mod,      only: alpha_clap_h2o, beta_clap_h2o, TI_breccia, TI_bedrock
 use soil_thermalproperties_mod, only: update_soil_thermalproperties
-use tracer_mod,                 only: mmol, igcm_h2o_vap ! tracer names and molar masses
 use abort_pem_mod,              only: abort_pem
 use compute_soiltemp_mod,       only: ini_tsoil_pem, compute_tsoil_pem
@@ -27,4 +26,5 @@
 use surfdat_h,                  only: watercaptag, perennial_co2ice, qsurf
 use metamorphism,               only: frost4PCM, iPCM_h2ofrost, iPCM_co2frost
+use tracers,                    only: mmol
 
 implicit none
@@ -469,5 +469,5 @@
 
 ! First raw initialization
-            watersoil_avg(:,nsoil_PCM + 1:nsoil_PEM,islope) = exp(beta_clap_h2o/tsoil_PEM(:,nsoil_PCM + 1:nsoil_PEM,islope) + alpha_clap_h2o)/tsoil_PEM(:,nsoil_PCM + 1:nsoil_PEM,islope)*mmol(igcm_h2o_vap)/(mugaz*r)
+            watersoil_avg(:,nsoil_PCM + 1:nsoil_PEM,islope) = exp(beta_clap_h2o/tsoil_PEM(:,nsoil_PCM + 1:nsoil_PEM,islope) + alpha_clap_h2o)/tsoil_PEM(:,nsoil_PCM + 1:nsoil_PEM,islope)*mmol%h2o/(mugaz*r)
         enddo !islope
         write(*,*) 'PEMETAT0: TSOIL done'
Index: trunk/LMDZ.COMMON/libf/evolution/tracers.F90
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/tracers.F90	(revision 3984)
+++ trunk/LMDZ.COMMON/libf/evolution/tracers.F90	(revision 3984)
@@ -0,0 +1,48 @@
+MODULE tracers
+
+implicit none
+
+! Indices for tracers taken from the PCM
+integer :: iPCM_qh2o
+
+! Molar masses of tracers
+type :: mmol
+    real :: h2o
+end type mmol
+
+!=======================================================================
+contains
+!=======================================================================
+
+SUBROUTINE ini_tracers_id(nqtot,noms)
+
+implicit none
+
+! Arguments
+!----------
+integer,                        intent(in) :: nqtot
+character(*), dimension(nqtot), intent(in) :: noms
+
+! Local variables
+!----------------
+integer :: i
+
+! Code
+!-----
+! Initialization
+iPCM_qh2o = -1
+
+! Getting the index
+do i = 1,nqtot
+    if (noms(nnq) == "h2o_vap") then
+        iPCM_qh2o = nnq
+        mmol%h2o = 18.
+    endif
+enddo
+
+! Checking if everything has been found
+if (iPCM_qh2o < 0) error stop 'ini_frost_id: H2O vapour index not found!'
+
+END SUBROUTINE ini_frost_id
+
+END MODULE tracers
