?? chemistry.f90
字號:
#include <misc.h>#include <params.h>module chemistry!---------------------------------------------------------------------------------! Module to parameterized greenhouse gas chemical loss frequencies from ! Portmann and Solomon!--------------------------------------------------------------------------------- use precision use pmgrid, only: plat, plev, plevp, plond, masterproc use ppgrid, only: pcols, pver use physconst, only: mwdry, mwch4, mwn2o, mwf11, mwf12, mwh2o use constituents,only: ppcnst, cnst_add, cnst_name, advected, ch4vmr, n2ovmr, f11vmr, f12vmr implicit none private ! Make default type private to the module save!! Public interfaces! public chem_register_cnst ! register consituents public chem_initialize ! initialize (history) variables public chem_init_mix ! initialize mixing ratios if not read from initial file public chem_time_interp ! time interpolate chemical loss frequencies public chem_driver ! interface to tendency computation integer, parameter :: ptrlon=01 ! number of longitudes in input dataset integer, parameter :: ptrlat=36 ! number of latitudes in input dataset integer, parameter :: ptrlev=56 ! number of levels in input dataset integer, parameter :: ptrtim=12 ! number of times(months) in input dataset! Ratios of molecular weights real(r8), parameter :: rmwn2o = mwn2o/mwdry ! ratio of molecular weight n2o to dry air real(r8), parameter :: rmwch4 = mwch4/mwdry ! ratio of molecular weight ch4 to dry air real(r8), parameter :: rmwf11 = mwf11/mwdry ! ratio of molecular weight cfc11 to dry air real(r8), parameter :: rmwf12 = mwf12/mwdry ! ratio of molecular weight cfc12 to dry air real(r8), parameter :: rh2och4= mwh2o/mwch4 ! ratio of molecular weight h2o to ch4! Time/space interpolation of loss frequencies real(r8) :: tch4i (plat,plev,ptrtim) ! input data ch4 loss rate interp. in lat and lev real(r8) :: tn2oi (plat,plev,ptrtim) ! input data n2o loss rate interp. in lat and lev real(r8) :: tcfc11i(plat,plev,ptrtim) ! input data cfc11 loss rate interp. in lat and lev real(r8) :: tcfc12i(plat,plev,ptrtim) ! input data cfc12 loss rate interp. in lat and lev real(r8) :: tch4m (plat,plev,2) ! input data ch4 loss rate interp. in lat and lev real(r8) :: tn2om (plat,plev,2) ! input data n2o loss rate interp. in lat and lev real(r8) :: tcfc11m(plat,plev,2) ! input data cfc11 loss rate interp. in lat and lev real(r8) :: tcfc12m(plat,plev,2) ! input data cfc12 loss rate interp. in lat and lev real(r8) :: tch4 (plat,plev) ! instantaneous ch4 loss rate real(r8) :: tn2o (plat,plev) ! instantaneous ch4 loss rate real(r8) :: tcfc11 (plat,plev) ! instantaneous ch4 loss rate real(r8) :: tcfc12 (plat,plev) ! instantaneous ch4 loss rate real(r8) :: cdaytrm ! calendar day for previous month data real(r8) :: cdaytrp ! calendar day for next month data integer :: np ! array index for previous month tracer data integer :: nm ! array index for next month tracer data integer :: np1 ! current forward time index of tracer dataset integer :: date_tr(ptrtim) ! date on tracer dataset (YYYYMMDD) integer :: sec_tr(ptrtim) ! seconds of date on tracer dataset (0-86399)! dummy values for specific heats at constant pressure real(r8), parameter:: cpch4 = 666. real(r8), parameter:: cpn2o = 666. real(r8), parameter:: cpf11 = 666. real(r8), parameter:: cpf12 = 666. character(len=8) :: srcnam (4) ! names of source/sink tendencies integer :: ixghg ! index of 1st constituent (N2O)contains!=============================================================================== subroutine chem_register_cnst!----------------------------------------------------------------------- ! ! Purpose: register advected constituents for parameterized greenhouse gas chemistry! ! Method: ! <Describe the algorithm(s) used in the routine.> ! <Also include any applicable external references.> ! ! Author: B.A. Boville! !-----------------------------------------------------------------------!---------------------------Local workspace----------------------------- integer :: m ! tracer index!-----------------------------------------------------------------------! Set names of diffused variable tendencies and declare them as history variables call cnst_add('N2O' , advected, mwn2o, cpn2o, 0., ixghg, longname='Nitrous Oxide') call cnst_add('CH4' , advected, mwch4, cpch4, 0., m, longname='Methane') call cnst_add('CFC11', advected, mwf11, cpf11, 0., m) call cnst_add('CFC12', advected, mwf12, cpf12, 0., m) return end subroutine chem_register_cnst!=============================================================================== subroutine chem_initialize!----------------------------------------------------------------------- ! ! Purpose: initialize parameterized greenhouse gas chemistry! (declare history variables)! ! Method: ! <Describe the algorithm(s) used in the routine.> ! <Also include any applicable external references.> ! ! Author: NCAR CMS! !----------------------------------------------------------------------- use history, only: addfld, add_default, phys_decomp!---------------------------Local workspace----------------------------- integer :: m ! tracer index!-----------------------------------------------------------------------! Set names of diffused variable tendencies and declare them as history variables do m = 1, 4 srcnam(m) = trim(cnst_name(ixghg-1+m)) // 'SRC' call addfld (srcnam(m),'kg/kg/s ',pver, 'A',trim(cnst_name(ixghg-1+m))//' source/sink',phys_decomp) call add_default (srcnam(m), 1, ' ') end do call chem_init_loss return end subroutine chem_initialize!=============================================================================== subroutine chem_driver (state, ptend, cflx, dt)!----------------------------------------------------------------------- ! ! Purpose: ! Interface to parameterized greenhouse gas chemisty (source/sink).! ! Method: ! <Describe the algorithm(s) used in the routine.> ! <Also include any applicable external references.> ! ! Author: B.A. Boville! !----------------------------------------------------------------------- use history, only: outfld use physics_types, only: physics_state, physics_ptend use phys_grid, only: get_lat_all_p!----------------------------------------------------------------------- implicit none!-----------------------------------------------------------------------!! Arguments:! real(r8), intent(in) :: dt ! time step type(physics_state), intent(in ) :: state ! Physics state variables type(physics_ptend), intent(inout) :: ptend ! indivdual parameterization tendencies real(r8), intent(inout) :: cflx(pcols,ppcnst) ! Surface constituent flux (kg/m^2/s)!! Local variables! integer :: m ! tracer index integer :: ioff ! offset for ghg indices integer :: lchnk ! chunk identifier integer :: ncol ! number of atmospheric columns integer :: lat(pcols) ! latitude index for S->N storage!!----------------------------------------------------------------------- ioff = ixghg - 1 lchnk = state%lchnk ncol = state%ncol! get latitude indices call get_lat_all_p(lchnk, ncol, lat)! compute tendencies and surface fluxes call ghg_chem ( lchnk, ncol, lat, & state%q(:,:,1), state%q(:,:,ixghg:ixghg+3), & ptend%q(:,:,1), ptend%q(:,:,ixghg:ixghg+3), cflx(:,ixghg:ixghg+3), dt)! set flags for tracer tendencies (water and 4 ghg's) ptend%lq(1) = .TRUE. ptend%lq(ioff+1:ioff+4) = .TRUE.!! record tendencies on history files do m = 1, 4 call outfld (srcnam(m),ptend%q(:,:,ioff+m),pcols,lchnk) end do return end subroutine chem_driver!=============================================================================== subroutine ghg_chem (lchnk, ncol, lat, qh2o, qghg, dqh2o, dqghg, fghg, dt)!----------------------------------------------------------------------- ! ! Purpose: ! Apply the interpolated chemical loss rates from the input data to! N2O, CH4, CFC11 and CFC12. Set the surface values to a constant.! ! Method: ! <Describe the algorithm(s) used in the routine.> ! <Also include any applicable external references.> ! ! Author: NCAR CMS! !----------------------------------------------------------------------- implicit none!-----------------------------------------------------------------------!! Arguments:! integer, intent(in) :: lchnk ! chunk identifier integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: lat(pcols) ! latitude index for S->N storage real(r8), intent(in) :: dt ! time step real(r8), intent(in) :: qh2o(pcols,pver) ! mass mixing ratios of water vapor real(r8), intent(in) :: qghg(pcols,pver,4) ! mass mixing ratios of greenhouse gases real(r8), intent(out) :: dqh2o(pcols,pver) ! tendency of mass mixing ratios (water) real(r8), intent(out) :: dqghg(pcols,pver,4) ! tendency of mass mixing ratios (ghg's) real(r8), intent(out) :: fghg(pcols,4) ! Surface constituent flux (kg/m^2/s)!! Local variables! integer i,k ! loop indexes real(r8) xch4 ! new methane mass mixing ratio real(r8) xn2o ! new nitrous oxide mass mixing ratio real(r8) xcfc11 ! new cfc11 mass mixing ratio real(r8) xcfc12 ! new cfc12 mass mixing ratio!!-----------------------------------------------------------------------!! Apply chemical rate coefficient using time split implicit method. The! turn the new value back into a tendency. NOTE that water tendency is! twice methane tendency. Water is specific humidity which is in mass! mixing ratio units. Note that! o 1 => indx of n2o! o 2 => indx of ch4! o 3 => indx of cfc11! o 4 => indx of cfc12! do k=1,pver-2 do i=1,ncol xn2o = qghg(i,k,1) / (1. + tn2o (lat(i),k) * dt) xch4 = qghg(i,k,2) / (1. + tch4 (lat(i),k) * dt) xcfc11 = qghg(i,k,3) / (1. + tcfc11(lat(i),k) * dt) xcfc12 = qghg(i,k,4) / (1. + tcfc12(lat(i),k) * dt) dqghg(i,k,1) =(xn2o - qghg(i,k,1)) / dt dqghg(i,k,2) =(xch4 - qghg(i,k,2)) / dt dqghg(i,k,3) =(xcfc11 - qghg(i,k,3)) / dt dqghg(i,k,4) =(xcfc12 - qghg(i,k,4)) / dt dqh2o(i,k) = -2. * rh2och4 * dqghg(i,k,2) end do end do!! Set the "surface" tendencies (bottom 2 levels) to maintain specified! tropospheric concentrations.! do k = pver-1, pver do i=1,ncol dqghg(i,k,1) =((rmwn2o*n2ovmr) - qghg(i,k,1)) / dt dqghg(i,k,2) =((rmwch4*ch4vmr) - qghg(i,k,2)) / dt dqghg(i,k,3) =((rmwf11*f11vmr) - qghg(i,k,3)) / dt dqghg(i,k,4) =((rmwf12*f12vmr) - qghg(i,k,4)) / dt dqh2o(i,k) = 0. end do end do!! For now set all tracer fluxes to 0! do i=1,ncol fghg(i,1) = 0. fghg(i,2) = 0. fghg(i,3) = 0. fghg(i,4) = 0. end do return end subroutine ghg_chem!=============================================================================== subroutine chem_init_loss!----------------------------------------------------------------------- ! ! Purpose: ! Do initial read of time-variant chemical loss rate frequency dataset, containing! loss rates as a function of latitude and pressure. Determine the two! consecutive months between which the current date lies.! ! Method: ! <Describe the algorithm(s) used in the routine.> ! <Also include any applicable external references.> ! ! Author: NCAR CMS!----------------------------------------------------------------------- use ioFileMod use commap use time_manager, only: get_curr_date, get_perp_date, get_curr_calday, & is_perpetual use filenames, only: bndtvg implicit none
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -