Ignore:
Timestamp:
Jan 25, 2019, 7:51:34 PM (6 years ago)
Author:
oboucher
Message:

Various additions for the interactive CO2 cycle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/tracco2i_mod.F90

    r3435 r3450  
    1111    USE dimphy
    1212    USE infotrac_phy
    13     USE geometry_mod, ONLY : cell_area
    14     USE carbon_cycle_mod, ONLY : nbcf_in, fields_in, cfname_in, fco2_ocn_day, fco2_ff, fco2_bb
     13    USE geometry_mod, ONLY: cell_area
     14    USE carbon_cycle_mod, ONLY: id_CO2, nbcf_in, fields_in, cfname_in, fco2_ocn_day, fco2_ff, fco2_bb
     15    USE carbon_cycle_mod, ONLY: carbon_cycle_tr, carbon_cycle_rad, RCO2_glo, RCO2_tot
    1516    USE mod_grid_phy_lmdz
    16     USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
     17    USE mod_phys_lmdz_mpi_data, ONLY: is_mpi_root
    1718    USE mod_phys_lmdz_para, ONLY: gather, bcast, scatter
    1819    USE phys_cal_mod
     20    USE phys_state_var_mod, ONLY: pctsrf
     21    USE indice_sol_mod, ONLY: nbsrf, is_ter, is_lic, is_oce, is_sic
    1922
    2023    IMPLICIT NONE
     
    4548!----------------
    4649
    47     INTEGER, PARAMETER :: id_CO2=1              !--temporaire OB -- to be changed
    4850    INTEGER                        :: it, k, i, nb
    4951    REAL, DIMENSION(klon,klev)     :: m_air     ! mass of air in every grid box [kg]
     
    5355    REAL, DIMENSION(klon_glo,klev) :: m_air_glo ! variable temporaire sur la grille global
    5456
    55 
    56     INTEGER, SAVE :: mth_pre=0
    57 !$OMP THREADPRIVATE(mth_pre)
    58     REAL, SAVE :: RCO2_glo
    59 !$OMP THREADPRIVATE(RCO2_glo)
     57    INTEGER, SAVE :: mth_pre=0, day_pre=0
     58!$OMP THREADPRIVATE(mth_pre, day_pre)
    6059
    6160    IF (is_mpi_root) THEN
     
    6867    IF (debutphy) THEN
    6968      IF (MAXVAL(tr_seri(:,:,id_CO2)).LT.1.e-15) THEN
    70         tr_seri(:,:,id_CO2)=280.e-6/RMD*RMCO2
     69        !!tr_seri(:,:,id_CO2)=280.e-6/RMD*RMCO2
     70        tr_seri(:,:,id_CO2)=400.e-6/RMD*RMCO2 !--initialised to 400 ppm for a test
    7171      ENDIF
    7272    ENDIF
     
    8585
    8686!--retrieving land and ocean CO2 flux
    87 !--fCO2_nep comes in unit of g CO2 m-2 dt_stomate-1
    88 !--this needs to be changed in ORCHIDEE
    8987    co2land(:)=0.0
    9088    co2ocean(:)=0.0
    9189    DO nb=1, nbcf_in
    92       IF (cfname_in(nb) == "fCO2_nep" )   co2land(:)=fields_in(:,nb)*RMCO2/RMC/86400./1000.
    93       !!IF (cfname_in(nb) == "fCO2_fgco2" ) co2ocean(:)=fco2_ocn_day(:) !--for now
     90!--fCO2_nep comes in unit of kg C m-2 s-1
     91!--converting to kg CO2 m-2 s-1
     92      IF (cfname_in(nb) == "fCO2_nep" )   co2land(:)=fields_in(:,nb)*RMCO2/RMC*pctsrf(:,is_ter)
     93!--fCO2_fgco2 comes in unit of mol C02 m-2 s-1
     94!--converting to kg CO2 m-2 s-1 + change sign
     95      IF (cfname_in(nb) == "fCO2_fgco2" ) co2ocean(:)=-1.*fco2_ocn_day(:)*RMCO2/1.e3*(pctsrf(:,is_oce)+pctsrf(:,is_sic))
    9496    ENDDO
    9597
     
    99101
    100102!--computing global mean CO2 for radiation
    101 !--every timestep for now but enough every month
     103!--every timestep for now but enough every day
    102104!    IF (debutphy.OR.mth_cur.NE.mth_pre) THEN
     105!    IF (debutphy.OR.day_cur.NE.day_pre) THEN
    103106      CALL gather(tr_seri(:,:,id_CO2),co2_glo)
    104107      CALL gather(m_air,m_air_glo)
    105108!$OMP MASTER
    106 !--conversion from kg CO2/kg air into ppm
     109!--compute a global mean CO2 value and print its value in ppm
    107110       IF (is_mpi_root) THEN
    108          RCO2_glo=SUM(co2_glo*m_air_glo)/SUM(m_air_glo)*1.e6*RMD/RMCO2
     111         RCO2_tot=SUM(co2_glo*m_air_glo)  !--unit kg CO2
     112         RCO2_glo=RCO2_tot/SUM(m_air_glo) !--unit kg CO2 / kg air
     113         PRINT *,'tracco2i: global CO2 in ppm =', RCO2_glo*1.e6*RMD/RMCO2
     114         PRINT *,'tracco2i: total CO2 in kg =', RCO2_tot
    109115       ENDIF
    110        PRINT *,'toto in tracco2i: global CO2 in ppm =', RCO2_glo
    111116!$OMP END MASTER
    112117       CALL bcast(RCO2_glo)
    113118       mth_pre=mth_cur
     119       day_pre=day_cur
     120!--if not carbon_cycle_tr, then we reinitialize the CO2 each day to its global mean value
     121       IF (.NOT.carbon_cycle_tr) THEN
     122         tr_seri(:,:,id_CO2)=RCO2_glo
     123       ENDIF
    114124!    ENDIF
    115125
Note: See TracChangeset for help on using the changeset viewer.