#! /bin/csh -f #SBATCH --job-name=2NS_asens_combine_jobs #SBATCH --constraint=amd #SBATCH --partition=bigmem #SBATCH --time=7-00:00:00 #SBATCH --nodes=2 #SBATCH --ntasks=120 #SBATCH --mem=100G #SBATCH --mail-user=mrasel@gmu.edu #Email account #SBATCH --mail-type=FAIL,BEGIN,END #When to email #SBATCH --output=/scratch/%u/slurm_scipts/2NS_asens_combine_cmaqv54_dep_conc_cb6r3_ae7_aq_batch_%j.out #SBATCH --error=/scratch/%u/slurm_scipts/2NS_asens_combine_cmaqv54_dep_conc_cb6r3_ae7_aq_batch_%j.err #SBATCH --nodelist=amd[081-082] # ====================== COMBINE_v5.4.X Run Script =================== # Usage: run.combine.uncoupled.csh >&! combine.log & # # To report problems or request help with this script/program: # http://www.epa.gov/cmaq (EPA CMAQ Website) # http://www.cmascenter.org (CMAS Website) # =================================================================== # ================================================================== #> Runtime Environment Options # ================================================================== #> Choose compiler and set up CMAQ environment with correct #> libraries using config.cmaq. Options: intel | gcc | pgi setenv compiler gcc #> Source the config.cmaq file to set the build environment cd /scratch/mrasel/cmaq-5.4/cmaq_hdf1.10.0/CMAQ_REPO source ./config_cmaq.csh #> Set General Parameters for Configuring the Simulation set VRSN = v54_DDM3D #> Code Version set PROC = mpi #> serial or mpi set MECH = cb6r3_ae7_aq #> Mechanism ID set APPL = AQF5X #> Application Name (e.g. Gridname) set SEN = 2NS #Sensitivity name #> Define RUNID as any combination of parameters above or others. By default, #> this information will be collected into this one string, $RUNID, for easy #> referencing in output binaries and log files as well as in other scripts. set RUNID = ${VRSN}_${compilerString}_${APPL} #> Set the build directory if this was not set above #> (this is where the CMAQ executable is located by default). if ( ! $?BINDIR ) then set BINDIR = $CMAQ_HOME/POST/combine/scripts/BLD_combine_v54_${compilerString} endif #> Set the name of the executable. set EXEC = combine_v54.exe #> Set location of CMAQ repo. This will be used to point to the correct species definition files. set REPO_HOME = ${CMAQ_REPO} #> Set working, input and output directories # set METDIR = ${CMAQ_DATA}/$APPL/met/mcip #> Met Output Directory # set CCTMOUTDIR = ${CMAQ_DATA}/output_CCTM_${RUNID} #> CCTM Output Directory # set POSTDIR = ${CMAQ_DATA}/POST #> Location where combine file will be written set INPDIR = /scratch/mrasel/cmaq-5.4/data_input set METpath = $INPDIR/mcip set OUTDIR = /scratch/mrasel/cmaq-5.4/data_output/cctm_out set POSTDIR = ${OUTDIR}/POSTDIR #> MCIP meteorology files setenv GRID_BDY_2D $METpath/GRIDBDY2D_AQF5X.nc setenv GRID_CRO_2D $METpath/GRIDCRO2D_AQF5X.nc setenv GRID_CRO_3D $METpath/GRIDCRO3D_AQF5X.nc setenv GRID_DOT_2D $METpath/GRIDDOT2D_AQF5X.nc setenv MET_CRO_2D $METpath/METCRO2D_AQF5X.nc setenv MET_CRO_3D $METpath/METCRO3D_AQF5X.nc setenv MET_DOT_3D $METpath/METDOT3D_AQF5X.nc setenv MET_BDY_3D $METpath/METBDY3D_AQF5X.nc setenv LUFRAC_CRO $METpath/LUFRAC_CRO_AQF5X.nc if ( ! -e $POSTDIR ) then mkdir $POSTDIR endif # ===================================================================== #> COMBINE Configuration Options # ===================================================================== #> Set Start and End Days for looping set START_DATE = "2019-12-20" #> beginning date from the calling run script set END_DATE = "2020-03-20" #> ending date from the calling run script setenv START_DATE_H $START_DATE setenv END_DATE_H $END_DATE #> Set location of species definition files for concentration and deposition species. set EQPOSTSCR = /home/mrasel/scripts/cmaq/v5.4/post setenv SPEC_CONC $EQPOSTSCR/SpecDef_asens_egus_${SEN}_cmaqv54_cb6r3_ae7_aq.txt setenv SPEC_PHOT $EQPOSTSCR/SpecDef_photdiag_cmaqv53_ts_cb6r3_ae7_aq.txt setenv SPEC_DEP $EQPOSTSCR/SpecDef_sens_egus_${SEN}_dep_cmaqv54_ts_cb6r3_ae7_aq.txt setenv SPEC_EMIS $EQPOSTSCR/SpecDef_inline_emis_equates_12us1.txt setenv SPEC_CONC_3D $EQPOSTSCR/SpecDef_conc3d_cmaqv53_ts_cb6r3_ae7_aq.txt # setenv SPEC_CONC $CMAQ_HOME/POST/combine/scripts/spec_def_files/SpecDef_${MECH}.txt # setenv SPEC_DEP $CMAQ_HOME/POST/combine/scripts/spec_def_files/SpecDef_Dep_${MECH}.txt #> Use GENSPEC switch to generate a new specdef file (does not generate output file). setenv GENSPEC N # ===================================================================== #> Begin Loop Through Simulation Days to Create ACONC File # ===================================================================== #> Set the species definition file for concentration species. setenv SPECIES_DEF $SPEC_CONC #> Loop through all days between START_DAY and END_DAY set TODAYG = ${START_DATE} set TODAYJ = `date -ud "${START_DATE}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ set STOP_DAY = `date -ud "${END_DATE}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ while ($TODAYJ <= $STOP_DAY ) #>Compare dates in terms of YYYYJJJ #> Retrieve Calendar day Information set YYYY = `date -ud "${TODAYG}" +%Y` set YY = `date -ud "${TODAYG}" +%y` set MM = `date -ud "${TODAYG}" +%m` set DD = `date -ud "${TODAYG}" +%d` #> for files that are indexed with Julian day: # set YYYYJJJ = `date -ud "${TODAYG}" +%Y%j` #> Calculate the month for tomorrow. set tomorrow_date = `date -ud "${TODAYG}+1days" +%Y-%m-%d` set MMtomorrow = `date -ud "${tomorrow_date}" +%m` #> Define name of combine output file to save hourly average concentration. #> A new file will be created for each month/year. setenv OUTFILE ${POSTDIR}/COMBINE_${SEN}_ASENS_${RUNID}_$YYYY$MM.nc #> Define name of input files needed for combine program. #> File [1]: CMAQ conc/aconc file #> File [2]: MCIP METCRO3D file #> File [3]: CMAQ AELMO file #> File [4]: MCIP METCRO2D file setenv INFILE1 $OUTDIR/CCTM_ASENS_${RUNID}_$YYYY$MM$DD.nc setenv INFILE2 ${MET_CRO_3D} setenv INFILE3 $OUTDIR/CCTM_AELMO_${RUNID}_$YYYY$MM$DD.nc setenv INFILE4 ${MET_CRO_2D} setenv INFILE5 # setenv INFILE1 $CCTMOUTDIR/CCTM_ACONC_${RUNID}_$YYYY$MM$DD.nc # setenv INFILE2 $METDIR/METCRO3D_$YY$MM$DD.nc # setenv INFILE3 $CCTMOUTDIR/CCTM_AELMO_${RUNID}_$YYYY$MM$DD.nc # setenv INFILE4 $METDIR/METCRO2D_$YY$MM$DD.nc #> Executable call: ${BINDIR}/${EXEC} # if this is the last day of the month run calc_tmetric for monthly averages if ( ${MMtomorrow} != ${MM} ) then setenv INFILE ${POSTDIR}/COMBINE_${SEN}_ASENS_${RUNID}_${YYYY}${MM}.nc setenv OUTFILE ${POSTDIR}/COMBINE_${SEN}_ASENS_${RUNID}_${YYYY}${MM}_av.nc sbatch --export=ALL $EQPOSTSCR/calc_tmetric_avg_monthly_combine_batch.csh endif # if this is the last day of the month run hr2day for daily averages if ( ${MMtomorrow} != ${MM} ) then setenv INFILE ${POSTDIR}/COMBINE_${SEN}_ASENS_${RUNID}_${YYYY}${MM}.nc setenv OUTFILE ${POSTDIR}/HR2DAY_${SEN}_ASENS_${RUNID}_${YYYY}${MM}.nc sbatch --export=ALL $EQPOSTSCR/hr2day_daily_averages_batch.csh endif #> Increment both Gregorian and Julian Days set TODAYG = `date -ud "${TODAYG}+1days" +%Y-%m-%d` #> Add a day for tomorrow set TODAYJ = `date -ud "${TODAYG}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ end #Loop to the next Simulation Day # ===================================================================== #> Begin Loop Through Simulation Days to Create DEP File # ===================================================================== #> Set the species definition file for concentration species. setenv SPECIES_DEF $SPEC_DEP #> Loop through all days between START_DAY and END_DAY set TODAYG = ${START_DATE} set TODAYJ = `date -ud "${START_DATE}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ set STOP_DAY = `date -ud "${END_DATE}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ while ($TODAYJ <= $STOP_DAY ) #>Compare dates in terms of YYYYJJJ #> Retrieve Calendar day Information set YYYY = `date -ud "${TODAYG}" +%Y` set YY = `date -ud "${TODAYG}" +%y` set MM = `date -ud "${TODAYG}" +%m` set DD = `date -ud "${TODAYG}" +%d` #> for files that are indexed with Julian day: # set YYYYJJJ = `date -ud "${TODAYG}" +%Y%j` #> Calculate the month for tomorrow. set tomorrow_date = `date -ud "${TODAYG}+1days" +%Y-%m-%d` set MMtomorrow = `date -ud "${tomorrow_date}" +%m` #> Define name of combine output file to save hourly total deposition. #> A new file will be created for each month/year. setenv OUTFILE ${POSTDIR}/COMBINE_${SEN}_SENS_DEP_${RUNID}_$YYYY$MM #> Define name of input files needed for combine program. #> File [1]: CMAQ DRYDEP file #> File [2]: CMAQ WETDEP file #> File [3]: MCIP METCRO2D #> File [4]: {empty} setenv INFILE1 $OUTDIR/CCTM_SENDDEP_${RUNID}_$YYYY$MM$DD.nc setenv INFILE2 $OUTDIR/CCTM_SENWDEP_${RUNID}_$YYYY$MM$DD.nc setenv INFILE3 ${MET_CRO_2D} setenv INFILE4 #> Executable call: ${BINDIR}/${EXEC} # if this is the last day of the month run calc_tmetric to compute monthly sum if ( ${MMtomorrow} != ${MM} ) then setenv INFILE ${POSTDIR}/COMBINE_${SEN}_SENS_DEP_${RUNID}_${YYYY}${MM}.nc setenv OUTFILE ${POSTDIR}/COMBINE_${SEN}_SENS_DEP_${RUNID}_${YYYY}${MM}_sum.nc sbatch --export=ALL $EQPOSTSCR/calc_tmetric_sum_monthly_combine_batch.csh endif set progstat = ${status} if ( ${progstat} ) then echo "ERROR ${progstat} in $BINDIR/$EXEC" exit( ${progstat} ) endif #> Increment both Gregorian and Julian Days set TODAYG = `date -ud "${TODAYG}+1days" +%Y-%m-%d` #> Add a day for tomorrow set TODAYJ = `date -ud "${TODAYG}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ end #Loop to the next Simulation Day exit()