Ignore:
Timestamp:
May 26, 2025, 4:21:44 PM (4 weeks ago)
Author:
jbclement
Message:

PEM:
Information about checking of CO2 mass balance.
JBC

Location:
trunk/LMDZ.COMMON/libf/evolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LMDZ.COMMON/libf/evolution/changelog.txt

    r3778 r3779  
    670670- 'deposits' is renamed as 'layerings_map'
    671671- Few cleanings
     672
     673== 26/05/2025 == JBC
     674Information about checking of CO2 mass balance.
  • TabularUnified trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3778 r3779  
    8888    use planete_h,          only: aphelie, periheli, year_day, peri_day, obliquit, iniorbit
    8989    use surfini_mod,        only: surfini
    90     use comconst_mod,       only: pi, rad, g, cpp, kappa
    9190    use comcstfi_h,         only: mugaz
    9291#else
     
    9796    use aerosol_mod,        only: iniaerosol
    9897    use planete_mod,        only: apoastr, periastr, year_day, peri_day, obliquit
    99     use comcstfi_mod,       only: pi, rad, g, mugaz, r
     98    use comcstfi_mod,       only: pi, rad, g, r, cpp, rcp, mugaz
    10099#endif
    101100
    102101#ifndef CPP_1D
    103     use comconst_mod,             only: r
     102    use comconst_mod,             only: pi, rad, g, r, cpp, rcp => kappa
    104103    use iniphysiq_mod,            only: iniphysiq
    105104    use control_mod,              only: iphysiq, day_step, nsplit_phys
    106105#else
    107     use comcstfi_h,               only: r
     106    use comcstfi_h,               only: pi, rad, g, r, cpp, rcp
    108107    use time_phylmdz_mod,         only: iphysiq, steps_per_sol
    109108    use regular_lonlat_mod,       only: init_regular_lonlat
     
    194193real,    dimension(:,:), allocatable :: vmr_co2_PEM_phys       ! Grid points x Times co2 volume mixing ratio used in the PEM
    195194real,    dimension(:,:), allocatable :: q_co2_PEM_phys         ! Grid points x Times co2 mass mixing ratio in the first layer computed in the PEM, first value comes from PCM [kg/kg]
     195real(kind = 16)                      :: totmass_co2ice, totmass_atmco2         ! Current total CO2 masses
     196real(kind = 16)                      :: totmass_co2ice_ini, totmass_atmco2_ini ! Initial total CO2 masses
    196197
    197198! Variables for the evolution of layered layerings_map
     
    207208
    208209! Variables for surface and soil
    209 real, dimension(:,:),     allocatable :: tsurf_avg                        ! Grid points x Slope field: Average surface temperature [K]
    210 real, dimension(:,:),     allocatable :: tsurf_dev                        ! Grid points x Slope field: Surface temperature deviation [K]
    211 real, dimension(:,:),     allocatable :: tsurf_avg_yr1                    ! Grid points x Slope field: Average surface temperature of first call of the PCM [K]
    212 real, dimension(:,:,:),   allocatable :: tsoil_avg                        ! Grid points x Soil x Slope field: Average Soil Temperature [K]
    213 real, dimension(:,:),     allocatable :: tsoil_avg_old                    ! Grid points x Soil field: Average Soil Temperature at the previous time step [K]
    214 real, dimension(:,:,:),   allocatable :: tsoil_dev                        ! Grid points x Soil x Slope field: Soil temperature deviation [K]
    215 real, dimension(:,:,:,:), allocatable :: tsoil_timeseries                 ! Grid points x Soil x Slope x Times field: Soil temperature timeseries [K]
    216 real, dimension(:,:,:,:), allocatable :: tsoil_PEM_timeseries             ! Grid points x Soil x Slope x Times field: Soil temperature timeseries for PEM [K]
    217 real, dimension(:,:,:,:), allocatable :: tsoil_PEM_timeseries_old         ! Grid points x Soil x Slope x Times field: Soil temperature timeseries for PEM at the previous time step [K]
    218 real, dimension(:,:,:,:), allocatable :: watersoil_density_timeseries     ! Grid points x Soil x Slope x Times Water soil density timeseries [kg /m^3]
    219 real, dimension(:,:),     allocatable :: watersurf_density_avg            ! Grid points x Slope: Average water surface density [kg/m^3]
    220 real, dimension(:,:,:,:), allocatable :: watersoil_density_PEM_timeseries ! Grid points x Soil x Slope x Times: Water soil density timeseries for PEM [kg/m^3]
    221 real, dimension(:,:,:),   allocatable :: watersoil_density_PEM_avg        ! Grid points x Soil x Slopes: Average water soil density [kg/m^3]
    222 real, dimension(:),       allocatable :: delta_co2_adsorbed               ! Physics: quantity of CO2 that is exchanged because of adsorption / desorption [kg/m^2]
    223 real, dimension(:),       allocatable :: delta_h2o_adsorbed               ! Physics: quantity of H2O that is exchanged because of adsorption / desorption [kg/m^2]
    224 real                                  :: totmassco2_adsorbed              ! Total mass of CO2 that is exchanged because of adsorption / desoprtion over the planets [kg]
    225 real                                  :: totmassh2o_adsorbed              ! Total mass of H2O that is exchanged because of adsorption / desoprtion over the planets [kg]
    226 logical, dimension(:,:),  allocatable :: co2ice_disappeared               ! logical to check if a co2 ice reservoir already disappeared at a previous timestep
    227 real, dimension(:,:),     allocatable :: icetable_thickness_old           ! ngrid x nslope: Thickness of the ice table at the previous iteration [m]
    228 real, dimension(:,:,:),   allocatable :: ice_porefilling_old              ! ngrid x nslope: Ice pore filling at the previous iteration [m]
    229 real, dimension(:),       allocatable :: delta_h2o_icetablesublim         ! ngrid x Total mass of the H2O that has sublimated / condenses from the ice table [kg]
    230 real, dimension(:),       allocatable :: porefill                         ! Pore filling (output) to compute the dynamic ice table
    231 real                                  :: ssi_depth                        ! Ice table depth (output) to compute the dynamic ice table
    232 real, dimension(:,:),     allocatable :: zshift_surf                      ! Elevation shift for the surface [m]
    233 real, dimension(:,:),     allocatable :: zlag                             ! Newly built lag thickness [m]
    234 real, dimension(:,:),     allocatable :: icetable_depth_old               ! Old depth of the ice table
     210real, dimension(:,:),     allocatable :: tsurf_avg                          ! Grid points x Slope field: Average surface temperature [K]
     211real, dimension(:,:),     allocatable :: tsurf_dev                          ! Grid points x Slope field: Surface temperature deviation [K]
     212real, dimension(:,:),     allocatable :: tsurf_avg_yr1                      ! Grid points x Slope field: Average surface temperature of first call of the PCM [K]
     213real, dimension(:,:,:),   allocatable :: tsoil_avg                          ! Grid points x Soil x Slope field: Average Soil Temperature [K]
     214real, dimension(:,:),     allocatable :: tsoil_avg_old                      ! Grid points x Soil field: Average Soil Temperature at the previous time step [K]
     215real, dimension(:,:,:),   allocatable :: tsoil_dev                          ! Grid points x Soil x Slope field: Soil temperature deviation [K]
     216real, dimension(:,:,:,:), allocatable :: tsoil_timeseries                   ! Grid points x Soil x Slope x Times field: Soil temperature timeseries [K]
     217real, dimension(:,:,:,:), allocatable :: tsoil_PEM_timeseries               ! Grid points x Soil x Slope x Times field: Soil temperature timeseries for PEM [K]
     218real, dimension(:,:,:,:), allocatable :: tsoil_PEM_timeseries_old           ! Grid points x Soil x Slope x Times field: Soil temperature timeseries for PEM at the previous time step [K]
     219real, dimension(:,:,:,:), allocatable :: watersoil_density_timeseries       ! Grid points x Soil x Slope x Times Water soil density timeseries [kg /m^3]
     220real, dimension(:,:),     allocatable :: watersurf_density_avg              ! Grid points x Slope: Average water surface density [kg/m^3]
     221real, dimension(:,:,:,:), allocatable :: watersoil_density_PEM_timeseries   ! Grid points x Soil x Slope x Times: Water soil density timeseries for PEM [kg/m^3]
     222real, dimension(:,:,:),   allocatable :: watersoil_density_PEM_avg          ! Grid points x Soil x Slopes: Average water soil density [kg/m^3]
     223real, dimension(:),       allocatable :: delta_co2_adsorbed                 ! Physics: quantity of CO2 that is exchanged because of adsorption / desorption [kg/m^2]
     224real, dimension(:),       allocatable :: delta_h2o_adsorbed                 ! Physics: quantity of H2O that is exchanged because of adsorption / desorption [kg/m^2]
     225real(kind = 16)                       :: totmass_adsco2, totmass_adsco2_ini ! Total mass of CO2 that is exchanged because of adsorption / desoprtion over the planets [kg]
     226real                                  :: totmass_adsh2o                     ! Total mass of H2O that is exchanged because of adsorption / desoprtion over the planets [kg]
     227logical, dimension(:,:),  allocatable :: co2ice_disappeared                 ! logical to check if a co2 ice reservoir already disappeared at a previous timestep
     228real, dimension(:,:),     allocatable :: icetable_thickness_old             ! ngrid x nslope: Thickness of the ice table at the previous iteration [m]
     229real, dimension(:,:,:),   allocatable :: ice_porefilling_old                ! ngrid x nslope: Ice pore filling at the previous iteration [m]
     230real, dimension(:),       allocatable :: delta_h2o_icetablesublim           ! ngrid x Total mass of the H2O that has sublimated / condenses from the ice table [kg]
     231real, dimension(:),       allocatable :: porefill                           ! Pore filling (output) to compute the dynamic ice table
     232real                                  :: ssi_depth                          ! Ice table depth (output) to compute the dynamic ice table
     233real, dimension(:,:),     allocatable :: zshift_surf                        ! Elevation shift for the surface [m]
     234real, dimension(:,:),     allocatable :: zlag                               ! Newly built lag thickness [m]
     235real, dimension(:,:),     allocatable :: icetable_depth_old                 ! Old depth of the ice table
    235236
    236237! Some variables for the PEM run
     
    664665is_co2ice_ini = .false.
    665666co2ice_disappeared = .false.
     667totmass_co2ice_ini = 0.
     668totmass_atmco2_ini = 0.
    666669if (layering_algo) then
    667670    do ig = 1,ngrid
     
    673676endif
    674677do i = 1,ngrid
     678    totmass_atmco2_ini = totmass_atmco2_ini + cell_area(i)*ps_avg(i)/g
    675679    do islope = 1,nslope
     680        totmass_co2ice_ini = totmass_co2ice_ini + co2_ice(i,islope)*cell_area(i)*subslope_dist(i,islope)/cos(pi*def_slope_mean(islope)/180.)
    676681        if (co2_ice(i,islope) > 0.) is_co2ice_ini(i,islope) = .true.
    677682        if (d_co2ice(i,islope) < 0. .and. co2_ice(i,islope) > 0.) then
     
    693698end where
    694699
     700totmass_adsco2_ini = 0.
     701totmass_adsh2o = 0.
    695702if (adsorption_pem) then
    696     totmassco2_adsorbed = 0.
    697     totmassh2o_adsorbed = 0.
    698703    do ig = 1,ngrid
    699704        do islope = 1,nslope
    700705            do l = 1,nsoilmx_PEM - 1
    701706                if (l == 1) then
    702                    totmassco2_adsorbed = totmassco2_adsorbed + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
     707                   totmass_adsco2_ini = totmass_adsco2_ini + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
    703708                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    704                    totmassh2o_adsorbed = totmassh2o_adsorbed + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
     709                   totmass_adsh2o = totmass_adsh2o + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
    705710                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    706711                else
    707                    totmassco2_adsorbed = totmassco2_adsorbed + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l-1))* &
     712                   totmass_adsco2_ini = totmass_adsco2_ini + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l-1))* &
    708713                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    709                    totmassh2o_adsorbed = totmassh2o_adsorbed + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l-1))* &
     714                   totmass_adsh2o = totmass_adsh2o + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l-1))* &
    710715                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    711716                endif
     
    713718        enddo
    714719    enddo
    715     write(*,*) "Tot mass of CO2 in the regolith =", totmassco2_adsorbed
    716     write(*,*) "Tot mass of H2O in the regolith =", totmassh2o_adsorbed
     720    totmass_adsco2 = totmass_adsco2_ini
     721    write(*,*) "Tot mass of CO2 in the regolith =", totmass_adsco2
     722    write(*,*) "Tot mass of H2O in the regolith =", totmass_adsh2o
    717723endif ! adsorption
    718724
     
    967973
    968974! II_d.6 Update the mass of the regolith adsorbed
     975        totmass_adsco2 = 0.
     976        totmass_adsh2o = 0.
    969977        if (adsorption_pem) then
    970978            call regolith_adsorption(ngrid,nslope,nsoilmx_PEM,timelen,d_h2oice,d_co2ice,h2o_ice,co2_ice, &
    971979                                     tsoil_PEM,TI_PEM,ps_timeseries,q_co2_PEM_phys,q_h2o_PEM_phys,       &
    972980                                     h2o_adsorbed_phys,delta_h2o_adsorbed,co2_adsorbed_phys,delta_co2_adsorbed)
    973 
    974             totmassco2_adsorbed = 0.
    975             totmassh2o_adsorbed = 0.
    976981            do ig = 1,ngrid
    977982                do islope = 1,nslope
    978983                    do l = 1,nsoilmx_PEM
    979984                        if (l == 1) then
    980                             totmassco2_adsorbed = totmassco2_adsorbed + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
     985                            totmass_adsco2 = totmass_adsco2 + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
    981986                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    982                             totmassh2o_adsorbed = totmassh2o_adsorbed + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
     987                            totmass_adsh2o = totmass_adsh2o + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l))* &
    983988                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    984989                        else
    985                             totmassco2_adsorbed = totmassco2_adsorbed + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l - 1))* &
     990                            totmass_adsco2 = totmass_adsco2 + co2_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l - 1))* &
    986991                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    987                             totmassh2o_adsorbed = totmassh2o_adsorbed + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l - 1))* &
     992                            totmass_adsh2o = totmass_adsh2o + h2o_adsorbed_phys(ig,l,islope)*(layer_PEM(l) - layer_PEM(l - 1))* &
    988993                                       subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)*cell_area(ig)
    989994                        endif
     
    991996                enddo
    992997            enddo
    993             write(*,*) "Total mass of CO2 in the regolith =", totmassco2_adsorbed
    994             write(*,*) "Total mass of H2O in the regolith =", totmassh2o_adsorbed
     998            write(*,*) "Total mass of CO2 in the regolith =", totmass_adsco2
     999            write(*,*) "Total mass of H2O in the regolith =", totmass_adsh2o
    9951000        endif
    9961001    endif !soil_pem
     
    10291034    enddo
    10301035    deallocate(flag_co2flow,flag_h2oflow)
     1036
     1037    ! Checking mass balance for CO2
     1038    totmass_co2ice = 0.
     1039    totmass_atmco2 = 0.
     1040    do ig = 1,ngrid
     1041        totmass_atmco2 = totmass_atmco2 + cell_area(ig)*ps_avg(ig)/g
     1042        do islope = 1,nslope
     1043            totmass_co2ice = totmass_co2ice + co2_ice(ig,islope)*cell_area(ig)*subslope_dist(ig,islope)/cos(pi*def_slope_mean(islope)/180.)
     1044        enddo
     1045    enddo
     1046    write(*,'(a,f8.3,a)') " > Relative total CO2 mass balance = ", 100.*(totmass_atmco2 + totmass_co2ice + totmass_adsco2 - totmass_atmco2_ini - totmass_co2ice_ini - totmass_adsco2_ini)/(totmass_atmco2_ini + totmass_co2ice_ini + totmass_adsco2_ini), ' %'
     1047    if ((totmass_atmco2 + totmass_co2ice + totmass_adsco2 - totmass_atmco2_ini - totmass_co2ice_ini - totmass_adsco2_ini)/(totmass_atmco2_ini + totmass_co2ice_ini + totmass_adsco2_ini) > 0.01) then
     1048        write(*,*) '  /!\ Warning: mass balance is not conseved!'
     1049        write(*,'(a,f8.3,a)') '       Atmospheric CO2 mass balance = ', 100.*(totmass_atmco2 - totmass_atmco2_ini)/totmass_atmco2_ini, ' %'
     1050        write(*,'(a,f8.3,a)') '       CO2 ice mass balance         = ', 100.*(totmass_co2ice - totmass_co2ice_ini)/totmass_co2ice_ini, ' %'
     1051        write(*,'(a,f8.3,a)') '       Adsorbed CO2 mass balance    = ', 100.*(totmass_adsco2 - totmass_adsco2_ini)/totmass_adsco2_ini, ' %'
     1052    endif
    10311053
    10321054!------------------------
     
    12671289    call gr_fi_dyn(1,ngrid,iip1,jjp1,ps_start0/ps_start,pdyn)
    12681290    do i = 1,ip1jmp1
    1269         teta(i,:) = teta(i,:)*pdyn(i)**kappa
     1291        teta(i,:) = teta(i,:)*pdyn(i)**rcp
    12701292    enddo
    12711293    ! Correction on atmospheric pressure
Note: See TracChangeset for help on using the changeset viewer.