#!/bin/bash # # This script allows to prepare a simulation case in terms of species used, # specified chemical schemes, number of aerosol bins, bin sizes, boundary conditions. echo -e "\033[1;47m Preparation of CHEMISTRY files \033[0m" #------------------------------------------------------------------------------------------------------- # cut1 and cut2 forced the size distribution to have these values in the middle of the size distribution cut1=2.5 cut2=10. # dmin and dmax (micrometers) are used as tuner parameter to adjust the aerosol # distribution (they are not the min and max cut off diameter !!) dmin=0.01 dmax=40. # create families at the end of REACTIONS and separate GASP / AERO models if [ ${mecachim} = "0" ] ; then mecaj=melchior2 else mecaj=${meca} fi if [[ ${seasalt} = "2" && "${meca}" == "saprc" ]] ; then mecaj=${meca}.nacl fi #================================================ echo "Make non-chemistry dependent files" \cp -f DEPO_SPEC.${meca} DEPO_SPEC \cp -f SEASALT.univ SEASALT \cp -f VEGETATION.univ VEGETATION \cp -f SEA.univ SEA \cp -f DEPO_PARS.univ DEPO_PARS \cp -f SEMIVOL.univ SEMIVOL \cp -f SOIL.univ SOIL # Data for the wet deposition \cp -f WETD_SPEC.univ WETD_SPEC #--------------------------------------------------- # Prepare ascii data files for mineral dust if [ ${iusedust} -gt 0 ] ; then touch MAKEPRI.dust MINERAL.dust FastJ.dust REACTIONS.dust touch WETD_SPEC.dust AEROSOL.dust OUTPUT_SPECIES.dust input-fastj_1.txt \rm MAKEPRI.dust MINERAL.dust FastJ.dust REACTIONS.dust \rm WETD_SPEC.dust AEROSOL.dust OUTPUT_SPECIES.dust input-fastj_1.txt if [ $iusedust == "1" ] ; then inputdustfile=DATA_MINERAL.onlyDUST fi if [ $iusedust == "2" ] ; then inputdustfile=DATA_MINERAL.elements fi if [ $iusedust == "3" ] ; then inputdustfile=DATA_MINERAL.species fi gawk -v iusedust=$iusedust -f chemprep-prepDUSTmineralo.awk -v file=${inputdustfile} ${inputdustfile} \cp -f MINERAL.dust MINERAL cat WETD_SPEC.dust >> WETD_SPEC cat -s ${chemprepdir}/data_fastj/input-fastj.txt FastJ.dust >> input-fastj_1.txt fi touch input-fastj_1.txt #--------------------------------------------------- # Prepare files in case of use of tracers if [ ${trc} -eq 1 ] ; then . chemprep-prep-tracer.sh fi if [ ${trc} -eq 1 ] ; then cat DEPO_SPEC.trc >> DEPO_SPEC cat WETD_SPEC.trc >> WETD_SPEC cat FastJ.trc >> input-fastj_1.txt fi #================================================ echo "Make FAMILIES and AEROSOL" touch ANTHROPIC if [ ${mecachim} -gt 0 ] ; then cat ${chemprepdir}/data/ANTHROPIC.${meca} >> ANTHROPIC fi if [ ${aero} -eq 1 ] ; then cat ANTHROPIC.aero >> ANTHROPIC if [ ${carb} = "0" ] ; then cat ANTHROPIC.tppm >> ANTHROPIC fi fi if [ ${soatyp} -gt 0 ] ; then cat ANTHROPIC.med >> ANTHROPIC fi if [ ${carb} = "1" ] ; then cat ANTHROPIC.carb >> ANTHROPIC fi if [ ${trc} -eq 1 ] ; then cat ANTHROPIC.trc >> ANTHROPIC fi \cp ANTHROPIC FIRES echo "Make REACTIONS unique file" touch AEROSOL MAKEPRI REACTIONS \rm -r AEROSOL MAKEPRI REACTIONS touch AEROSOL MAKEPRI REACTIONS if [ ${mecachim} -gt 0 ] ; then cat REACTIONS.univ.${meca} >> REACTIONS if [ ${aero} = "0" ] ; then cat REACTIONS.univ.other.${meca} >> REACTIONS fi fi if [ ${aero} = "1" ] ; then cat AEROSOL.aero.${soa} >> AEROSOL cat MAKEPRI.aero >> MAKEPRI cat REACTIONS.univ.aero >> REACTIONS cat REACTIONS.univ.${meca}.soa-${soa} >> REACTIONS fi if [ ${seasalt} = "1" ] ; then cat REACTIONS.univ.isal >> REACTIONS cat AEROSOL.isal >> AEROSOL cat MAKEPRI.isal >> MAKEPRI fi if [ ${seasalt} = "2" ] ; then if [ "${meca}" == "saprc" ] ; then cat REACTIONS.univ.${meca}.nacl >> REACTIONS fi cat REACTIONS.univ.nacl >> REACTIONS cat AEROSOL.nacl >> AEROSOL cat MAKEPRI.nacl >> MAKEPRI fi if [ ${iusedust} -gt 0 ] ; then cat REACTIONS.dust >> REACTIONS cat AEROSOL.dust >> AEROSOL cat MAKEPRI.dust >> MAKEPRI fi if [ ${carb} = "1" ] ; then cat REACTIONS.univ.carb >> REACTIONS cat AEROSOL.carb >> AEROSOL cat MAKEPRI.carb >> MAKEPRI fi if [[ ${carb} = "0" && ${aero} = "1" ]] ; then cat MAKEPRI.tppm >> MAKEPRI fi if [ ${trc} = "1" ] ; then cat REACTIONS.trc >> REACTIONS cat AEROSOL.trc >> AEROSOL cat MAKEPRI.trc >> MAKEPRI fi # Delete empty lines sed '/^$/d' MAKEPRI > tmp mv tmp MAKEPRI #================================================ echo "Make active species list" echo " - gaseous or non-reactive species species" gawk -f chemprep.awk REACTIONS # last line for fastJ echo "9999" >> "FJX_j2j.dat" sort .species | uniq | gawk '{print $0}' > ACTIVE_SPECIES.gas cat ACTIVE_SPECIES.gas > tmp sort tmp | uniq | gawk '{print NR,$0}' > ACTIVE_SPECIES.gas ngasspec=`wc -l ACTIVE_SPECIES.gas | gawk '{print $1}'` if [ ${bins} = "1" ] ; then echo " - aerosols species" echo " Building aerosols size distributions: chemprep-distrib program" echo ${nbins} ${cut1} ${cut2} ${dmin} ${dmax} > tmpdistrib ./chemprep-distrib.e || exit 1 sort -g -k 2,2 AEROSOL -o tmp echo "# Number of sections D(2.5) D(10.0)" > aerobin.univ cat .fambound >> aerobin.univ \rm .fambound echo "# Name of aerosol components, properties (no blank line a the end!)" >> aerobin.univ echo "# NAME TYPE Molar mass Origin [0=bio,1=anth,2=mineral]" >> aerobin.univ cat aerobin.univ tmp > AEROSOL \rm aerobin.univ echo "=====================================" echo "AEROSOL file for this simulation:" echo "-------------------------------------" cat AEROSOL echo " - Prepare families list" ./chemprep-families.e || exit 1 # full active species file # ACTIVE_SPECIES.aero previously created by chemprep-families.e # contains list of aerosols species as bins: p01PPM ... cat ACTIVE_SPECIES.aero > tmp rm -f OUTPUT_SPECIES.aero-bins for spec in `awk '{print $1}' ACTIVE_SPECIES.aero` ; do mass=`grep -w ${spec:3} AEROSOL | awk '{print $3}'` echo "${spec} ${mass}" >>OUTPUT_SPECIES.aero-bins done gawk '{print NR+"'${ngasspec}'",$0}' tmp > ACTIVE_SPECIES.aero \rm tmp else \rm -f PRIMARY AEROSOL MAKEPRI fi #================================================ # finalize ACTIVE_SPECIES file if [ -e ACTIVE_SPECIES.gas ] ; then cat ACTIVE_SPECIES.gas > tmp-gas fi if [ -e ACTIVE_SPECIES.aero ] ; then cat ACTIVE_SPECIES.aero > tmp-aero fi touch tmp-gas tmp-aero tmp-cplt ACTIVE_SPECIES cat tmp-gas tmp-aero > tmp-cplt # Put value for transport scheme gawk '{print $0,'$iadv,$iadvv'}' tmp-cplt > ACTIVE_SPECIES \rm tmp-* #================================================ # FAMILIES.auto prepared by chemprep-families.e in case of aerosols echo "Make families list" touch .tmp .tmp1 .tmp2 \rm .tmp .tmp1 .tmp2 touch FAMILIES1 FAMILIES2 FAMILIES \rm FAMILIES1 FAMILIES2 FAMILIES touch OUTPUT_SPECIES.families touch tmp_families if [ ${mecachim} -gt 0 ] ; then cat FAMILIES.gasp.${meca} > tmp_families sed -e s/=/" "/g tmp_families > .tmp sed -e s/+/" "/g .tmp > .tmp1 gawk '{print NF-1,$0}' .tmp1 >> FAMILIES1 cat FAMILIES1 | gawk '{print $2,"0."}' >> OUTPUT_SPECIES.families cat FAMILIES1 >>FAMILIES fi if [ -e FAMILIES.auto ] ; then cat FAMILIES.auto > tmp_families sed -e s/=/" "/g tmp_families > .tmp sed -e s/+/" "/g .tmp > .tmp1 gawk '{print NF-1,$0}' .tmp1 >> FAMILIES2 cat FAMILIES2 | gawk '{print $2,"100."}' >> OUTPUT_SPECIES.families cat FAMILIES2 >>FAMILIES fi if [ ${trc} = 1 ] ; then cat FAMILIES.trcgas >> FAMILIES fi # Families when several mineral dust species if [ ${iusedust} -ge 2 ] ; then \rm tmp1 tmp2 gawk -v nbins=${nbins} '{ if(FNR==1){printf "pDUST=" > "tmp1"} for(i=1;i<=nbins;i++){ spec=$1 printf("%-s%.2i%-s%-s","p",i,spec,"+") >> "tmp1" } }' AEROSOL.dust gawk '{ long=length($1)-1 val=substr($1,1,long) printf("%-s",val) >> "tmp2" }' tmp1 cat tmp2 >> tmp-dust sed -e s/=/" "/g tmp-dust > tmp-dust2 sed -e s/+/" "/g tmp-dust2 > tmp-dust3 gawk '{print NF-1,$0}' tmp-dust3 > tmp-dust4 sed -e s/=/" "/ tmp-dust4 | gawk '{print $2,"100."}' >> OUTPUT_SPECIES.families cat tmp-dust4 >> FAMILIES \rm tmp1 tmp2 \rm tmp-dust tmp-dust2 tmp-dust3 tmp-dust4 fi echo "Building output species list" touch OUTPUT_SPECIES.full OUTPUT_SPECIES.low if [ ${mecachim} != "0" ] ; then cat OUTPUT_SPECIES_${meca}.gas.full >> OUTPUT_SPECIES.full cat OUTPUT_SPECIES.gas.low >> OUTPUT_SPECIES.low fi if [ ${aero} = "1" ] ; then cat OUTPUT_SPECIES.aero.${soa} >> OUTPUT_SPECIES.full fi if [ ${seasalt} = "1" ] ; then cat OUTPUT_SPECIES.isal >> OUTPUT_SPECIES.full fi if [ ${seasalt} = "2" ] ; then cat OUTPUT_SPECIES.nacl >> OUTPUT_SPECIES.full if [ "${meca}" == "saprc" ] ; then cat OUTPUT_SPECIES_saprc.nacl >> OUTPUT_SPECIES.full fi fi if [ ${iusedust} -gt 0 ] ; then cat OUTPUT_SPECIES.dust >> OUTPUT_SPECIES.full fi if [ ${carb} = "1" ] ; then cat OUTPUT_SPECIES.carb >> OUTPUT_SPECIES.full fi if [ ${trc} = "1" ] ; then cat OUTPUT_SPECIES.trc >> OUTPUT_SPECIES.low cat OUTPUT_SPECIES.trc >> OUTPUT_SPECIES.full fi if [ ${bins} = "1" ] ; then cat OUTPUT_SPECIES.aero-bins >> OUTPUT_SPECIES.full fi # Add families: always included in the output species file cat OUTPUT_SPECIES.families >> OUTPUT_SPECIES.full cat OUTPUT_SPECIES.families >> OUTPUT_SPECIES.low #--------------------------------------------------------------------- # Copy fastJX input data files \cp input-fastj_1.txt ${chemprepfic}/input-fastj.txt \cp ${chemprepdir}/data_fastj/FJX_spec_${mecaj}.dat ${chemprepfic}/FJX_spec.dat \cp ${chemprepdir}/data_fastj/FJX_scat-cld.dat ${chemprepfic} \cp ${chemprepdir}/data_fastj/FJX_scat-UMa.dat ${chemprepfic} \cp ${chemprepdir}/data_fastj/atmos_std.dat ${chemprepfic} \rm tmp* .tmp* \rm input-fastj_1.txt