subroutine write_composition_file(composition_file, & planet_descriptor,Nlev,Nmol,mol_name, & zlev,Plev,Tlev,xlev) implicit none include 'max.inc' include 'formats.inc' c c Purpose: to generate a composition file compatible with kspectrum c c Input: c + composition_file: name of the file to generate c + planet_descriptor: short descriptor of the atmosphere c + Nlev: number of atmospheric levels c + Nmol: number of molecules c + mol_name: description of each molecule c + zlev: altitude of each level (m) c + Plev: pressure at each level (Pa) c + Tlev: temperature at each level (K) c + xlev: molar fraction of each molecule, for each level (mole of [x] / mole of gas mixture) c c Output: c + the composition file c c I/O character*(Nchar_mx) composition_file character*(Nchar_mx) planet_descriptor integer Nlev integer Nmol character*10 mol_name(1:Nmol_max) double precision zlev(1:Nmax) double precision Plev(1:Nmax) double precision Tlev(1:Nmax) double precision xlev(1:Nmax,1:Nmol_max) c temp integer imol,ilev character*10 molname character*1 spch character*20 s character*(Nchar_mx) string integer na,nb,ne c label integer strlen character*(Nchar_mx) label label='subroutine write_composition_file' spch=' ' open(12,file=composition_file(1:strlen(composition_file))) string='Atmospheric composition input ' string=string(1:strlen(string))//'data file for planet:' string=string(1:strlen(string))//' '// & planet_descriptor(1:strlen(planet_descriptor)) write(12,'(a)') string(1:strlen(string)) write(12,10) 'Number of atmospheric levels:' write(12,*) Nlev write(12,10) 'Number of molecules:' write(12,*) Nmol write(12,*) string=' z (km) / P (atm) / T (K) *' do imol=1,Nmol molname=mol_name(imol) nb=5 if (strlen(molname).eq.1) then na=7 else if (strlen(molname).eq.2) then na=6 else if (strlen(molname).eq.3) then na=5 endif s='*' do ne=1,nb s=s(1:strlen(s)-1)//spch//'*' enddo s=s(1:strlen(s)-1)//'/*' do ne=1,na s=s(1:strlen(s)-1)//spch//'*' enddo string=string(1:strlen(string)-1) & //s(1:strlen(s)-1) & //'x[' & //molname(1:strlen(molname)) & //']*' enddo write(12,10) string(1:strlen(string)-1) do ilev=1,Nlev write(12,50) zlev(ilev)/1.0D+3 ! km & ,Plev(ilev)/1.013D+5 ! atm & ,Tlev(ilev) ! K & ,(xlev(ilev,imol),imol=1,Nmol) ! mol/mol enddo write(12,*) close(12) write(*,*) 'Output file successfully generated:' write(*,*) composition_file(1:strlen(composition_file)) return end subroutine write_isotopic_composition_file(iso_comp_file, & Nlev,Nmol,mol_name,mol_index,mol_niso,iso_index, & iso_abundance,iso_Qref,iso_g,iso_mass) implicit none include 'max.inc' include 'formats.inc' c c Purpose: to generate an isotopic composition file compatible with kspectrum c c Input: c + iso_comp_file: name of the file to generate c + Nlev: number of atmospheric levels c + Nmol: number of molecules c + mol_name: description of each molecule c + mol_index: index of each molecule c + mol_niso: number of isotopes for each molecule c + iso_index: index of each isotope, for each molecule c + iso_abundance: abundance of each isotope, for each molecule c + iso_Qref: reference partition function of each isotope, for each molecule c + iso_g: parameter g of each isotope, for each molecule c + iso_mass: molar mass of each isotope, for each molecule (g/mol) c c Output: c + the isotopic composition file c c I/O character*(Nchar_mx) iso_comp_file integer Nlev integer Nmol character*10 mol_name(1:Nmol_max) integer mol_index(1:Nmol_max) integer mol_niso(1:Nmol_max) integer iso_index(1:Nmol_max,1:Niso_max) double precision iso_abundance(1:Nmax,1:Nmol_max,1:Niso_max) double precision iso_Qref(1:Nmol_max,1:Niso_max) integer iso_g(1:Nmol_max,1:Niso_max) double precision iso_mass(1:Nmol_max,1:Niso_max) c temp integer imol,iso,ilev character*(Nchar_mx) string character*(Nchar_mx) index_str integer conv_err c label integer strlen character*(Nchar_mx) label label='subroutine write_isotopic_composition_file' open(12,file=iso_comp_file(1:strlen(iso_comp_file))) write(12,'(a)') 'Number of levels:' write(12,*) Nlev string='Molecule / Q(296K) / gj / Molar Mass(g) ' & //'/ isotopic abundance (one per level)' write(12,'(a)') string(1:strlen(string)) do imol=1,Nmol string=' '//mol_name(imol)(1:strlen(mol_name(imol))) call num2str(mol_index(imol),index_str,conv_err) if (conv_err.eq.1) then call error(label) write(*,*) 'Could not convert to character string:' write(*,*) 'mol_index(',imol,')=',mol_index(imol) stop endif string=string(1:strlen(string)) & //' (' & //index_str(1:strlen(index_str)) & //')' write(12,'(a)') string(1:strlen(string)) do iso=1,mol_niso(imol) write(12,64) iso_index(imol,iso) & ,iso_Qref(imol,iso),iso_g(imol,iso),iso_mass(imol,iso) & ,(iso_abundance(ilev,imol,iso),ilev=1,Nlev) enddo ! i enddo ! mol close(12) write(*,*) 'Output file successfully generated:' write(*,*) iso_comp_file(1:strlen(iso_comp_file)) return end subroutine write_narrowbands_file(nu_file, & Nband,nu_lo,nu_hi) implicit none include 'max.inc' include 'formats.inc' c c Purpose: to generate a narrowbands file compatible with kspectrum c c Input: c + nu_file: name of the narrowbands file to generate c + Nband: number of narrowbands c + nu_lo: lower wavenumber for each band (inv. cm) c + nu_hi: upper wavenumber for each band (inv. cm) c c Output: c + the narrowbands file c c I/O character*(Nchar_mx) nu_file integer Nband double precision nu_lo(1:Nbmx) double precision nu_hi(1:Nbmx) c temp integer iband c label integer strlen character*(Nchar_mx) label label='subroutine write_narrowbands_file' open(12,file=nu_file(1:strlen(nu_file))) write(12,*) Nband do iband=1,Nband write(12,*) nu_lo(iband),nu_hi(iband) enddo ! band close(12) write(*,*) 'Output file successfully generated:' write(*,*) nu_file(1:strlen(nu_file)) return end