module photolysis_mod !*********************************************************************** ! ! subject: ! -------- ! ! module for photolysis online ! ! VERSION: Extracted from LMDZ.MARS work of Franck Lefevre (Yassin Jaziri) ! April 2019 - Yassin Jaziri add updates generic input (Yassin Jaziri) ! !*********************************************************************** use types_asis implicit none ! photolysis integer, save :: nabs ! number of absorbing gases ! spectral grid integer, save :: nw ! number of spectral intervals (low-res) integer, save :: mopt ! high-res/low-res switch real, allocatable, save :: wl(:) ! lower wavelength for each interval (nm) real, allocatable, save :: wc(:) ! center wavelength for each interval (nm) real, allocatable, save :: wu(:) ! upper wavelength for each interval (nm) real, save :: photoheat_lmax ! maximum wavelength until photochemical heating is calculated ! solar flux real, allocatable, save :: fstar1AU(:) ! stellar flux (photon.s-1.nm-1.cm-2) at 1 au ! cross-sections and quantum yields real, allocatable, save :: qy(:,:) ! photodissociation yield real, allocatable, save :: xs(:,:,:) ! absorption cross-section (cm2) real, allocatable, save :: sj(:,:,:) ! general cross-section array by photodissociation yield (cm2) real, allocatable, save :: xs_temp(:,:) ! absorption cross-section temperature (K) integer, allocatable, save :: tdim(:) ! absorption cross-section temperature dimension logical, allocatable, save :: jlabelbis(:) ! check in jlabel if the species is included in more than 1 photolysis contains subroutine init_photolysis(nlayer,nreact) use types_asis, only: reactions use tracer_h use chimiedata_h, only: indexchim use ioipsl_getin_p_mod, only: getin_p integer, intent(in) :: nlayer ! number of atmospheric layers integer, intent(in) :: nreact ! number of reactions in reactions files integer :: iphot,tdim_max,i3prod,ij,iw,ilay,ireact integer :: specheck(nesp) ! initialise on-line photolysis ! mopt = 1 high-resolution ! mopt = 2 low-resolution (recommended for gcm use) ! mopt = 3 input file reading grid mopt = 3 ! set wavelength grid call gridw(nw,wl,wc,wu,mopt) allocate(fstar1AU(nw)) ! read and grid solar flux data call rdsolarflux(nw,wl,wc,fstar1AU) ! read maximum wavelength until photochemical heating is calculated write(*,*) "Maximum wavelength until photochemical heating is calculated" photoheat_lmax=wc(nw-1) ! default value last point of wavelength grid call getin_p("photoheat_lmax",photoheat_lmax) write(*,*) "photoheat_lmax = ",photoheat_lmax ! calculate nabs number of absorbing gases allocate(jlabelbis(nb_phot_hv_max)) nabs = 0 specheck(:) = 0 jlabelbis(:) = .true. do iphot=1,nb_phot_hv_max if (specheck(indexchim(trim(jlabel(iphot,2)))) .eq. 0) then specheck(indexchim(trim(jlabel(iphot,2)))) = 1 nabs = nabs + 1 else jlabelbis(iphot) = .false. endif end do ! Get temperature dimension and allocate allocate(tdim(nb_hv_max)) tdim(:) = 1 tdim_max = 1 do iphot=1,nb_hv_max read(jparamline(iphot),*) tdim(iphot) if (tdim(iphot) > tdim_max) tdim_max = tdim(iphot) end do ! allocation allocate(qy(nw,nb_hv_max)) allocate(xs(tdim_max,nw,nb_hv_max)) allocate(sj(nlayer,nw,nb_phot_hv_max)) allocate(xs_temp(tdim_max,nb_hv_max)) xs(:,:,:) = 0. xs_temp(:,:) = 0. print*, 'WARNING: for all branching photolysis of one specie' print*, ' the cross section files should be the same' print*, ' they are used for optical depths calculation' print*, ' only the quantum yield should be different' i3prod = 0 ireact = 0 ! read and grid cross-sections do iphot=1,nb_hv_max ireact = ireact + 1 call rdxsi(nw,wl,xs(:tdim(iphot),:,iphot),jparamline(iphot),xs_temp(:tdim(iphot),iphot),qy(:,iphot),tdim(iphot),jlabel(iphot+i3prod,2)) do while(reactions(ireact)%rtype/=0) ireact = ireact + 1 end do if (reactions(ireact)%three_prod) i3prod = i3prod + 1 end do ! init sj for no temperature dependent cross sections (tdim.eq.1) iphot = 0 ij = 0 ireact = 0 do while(iphot