$cat-n~/GitHub/cmaq_relatives/combine/run_combMM_R_DM.csh1#! /bin/csh -f
23# ====================== COMBINE_v5.3 Run Script ========================
4# Usage: run.combine.uncoupled.csh >&! combine_v53_uncoupled.log &
5#
6# To report problems or request help with this script/program:
7# http://www.epa.gov/cmaq (EPA CMAQ Website)
8# http://www.cmascenter.org (CMAS Website)
9# ===================================================================
1011# ==================================================================
12#> Runtime Environment Options
13# ==================================================================
1415#> Choose compiler and set up CMAQ environment with correct
16#> libraries using config.cmaq. Options: intel | gcc | pgi
基本環境變數設定
編譯器版本gcc
程式碼位置
程式I/O檔案目錄
17setenvcompilergcc1819#> Set location of CMAQ repo. This will be used to point to the correct species definition files.
20setenvREPO_HOME../CMAQ_Project21#> Source the config.cmaq file to set the build environment
22source$REPO_HOME/config_cmaq.cshgcc23setenvCMAQ_HOME$PWD24setenvCMAQ_DATA/nas1/cmaqruns/2018base/data25
31#> Set General Parameters for Configuring the Simulation
32setVRSN=v53#> Code Version
33setPROC=mpi#> serial or mpi
34setMECH=cb6r3_ae7_aq#> Mechanism ID
35setAPPL=18${MO}#> Application Name (e.g. Gridname)
36setSTKCASEE=1137
38#> Define RUNID as any combination of parameters above or others. By default,
39#> this information will be collected into this one string, $RUNID, for easy
40#> referencing in output binaries and log files as well as in other scripts.
41setenvRUNID${VRSN}_${compilerString}_${APPL}4243#> Set the build directory if this was not set above
44#> (this is where the CMAQ executable is located by default).
45#if ( ! $?BINDIR ) then
46setenvBINDIR$REPO_HOME/POST/combine/scripts/BLD_combine_${VRSN}_${compilerString}47#endif
4849#> Set the name of the executable.
50setenvEXECcombine_${VRSN}.exe5152
53#> Set working, input and output directories
54if($DM=='d01')then55setenvGRID_NAMEEAsia_81K56elseif($DM=='d02')then57setenvGRID_NAMEsChina_27k58elseif($DM=='d04')then59setenvGRID_NAMETWN_3X360else61echo"Error input d02/d04"62exit163endif64
輸入/輸出檔案及路徑
65# setenv GRID_NAME TWN_3X3 #> check GRIDDESC file for GRID_NAME options
66setenvCCTMOUTDIR${CMAQ_DATA}/output_CCTM_${RUNID}#> CCTM Output Directory
67setenvPOSTDIR${CCTMOUTDIR}/POST#> Location where combine file will be written
6869if(!-e$POSTDIR)then70mkdir$POSTDIR71endif72737475# =====================================================================
76#> COMBINE Configuration Options
77# =====================================================================
78
日期、日數之計算
79#> Set Start and End Days for looping
80setBEG_DATE=`date -ud "2018-${MO}-15 -1 month" +%Y-%m-%d `81setEND_DATE=`date -ud "2018-${MO}-01 +1 month" +%Y-%m-%d `82# echo ${APPL}|cut -d'n' -f2
83# set MRUN = `echo ${APPL}|cut -d'n' -f2`
84setMRUN=485@NDYS=$MRUN*486setSTART_DATE=`date -ud "${BEG_DATE} +${NDYS}days" +%Y-%m-%d `87setEND_DATE=`date -ud "${START_DATE} +32days" +%Y-%m-%d`88
物質名稱之定義
VOC、PM2.5、PM10之開啟與其詳細計算公式
「輸出檔的層數」也在此檔案內修改
濃度與沉降量2大類
89#> Set location of species definition files for concentration and deposition species.
90setenvSPEC_CONC$REPO_HOME/POST/combine/scripts/spec_def_files/SpecDef_${MECH}.txt91setenvSPEC_DEP$REPO_HOME/POST/combine/scripts/spec_def_files/SpecDef_Dep_${MECH}.txt9293#> Use GENSPEC switch to generate a new specdef file (does not generate output file).
94setenvGENSPECN959697# =====================================================================
98#> Begin Loop Through Simulation Days to Create ACONC File
99# =====================================================================
100101#> Set the species definition file for concentration species.
102setenvSPECIES_DEF$SPEC_CONC103
日數之迴圈
104#> Loop through all days between START_DAY and END_DAY
105setTODAYG=${START_DATE}106setTODAYJ=`date -ud "${START_DATE}" +%Y%j`#> Convert YYYY-MM-DD to YYYYJJJ
107setSTOP_DAY=`date -ud "${END_DATE}" +%Y%j`#> Convert YYYY-MM-DD to YYYYJJJ
108setI=0109while($TODAYJ<=$STOP_DAY)#>Compare dates in terms of YYYYJJJ
110@R=6# $I / 4 + 5
111echo'kuang'$Irun$R112if($R>12)exit0
詳細I/O檔名之定義
113#> Retrieve Calendar day Information
114setYYYY=`date -ud "${TODAYG}" +%Y`115setYY=`date -ud "${TODAYG}" +%y`116setMM=`date -ud "${TODAYG}" +%m`117setDD=`date -ud "${TODAYG}" +%d`118if("${STKCASEE}"!="")then119setenvCTM_APPL${RUNID}_run${R}_$YYYY$MM${DD}_${GRID_NAME}_${STKCASEE}120else121setenvCTM_APPL${RUNID}_$YYYY$MM${DD}_${GRID_NAME}122endif123#> for files that are indexed with Julian day:
124# set YYYYJJJ = `date -ud "${TODAYG}" +%Y%j`
125126#> Define name of combine output file to save hourly average concentration.
127#> A new file will be created for each month/year.
128setenvOUTFILE${POSTDIR}/COMBINE_ACONC_${CTM_APPL}.nc129130#> Define name of input files needed for combine program.
131#> File [1]: CMAQ conc/aconc file
132#> File [2]: MCIP METCRO3D file
133#> File [3]: CMAQ APMDIAG file
134#> File [4]: MCIP METCRO2D file
135setenvMETDIR${CMAQ_DATA}/mcip/${APPL}_run${R}/${GRID_NAME}#> Met Output Directory
136setenvINFILE1$CCTMOUTDIR/CCTM_ACONC_${CTM_APPL}.nc137setenvINFILE2$METDIR/METCRO3D_${APPL}_run${R}.nc138setenvINFILE3$CCTMOUTDIR/CCTM_APMDIAG_${CTM_APPL}.nc139setenvINFILE4$METDIR/METCRO2D_${APPL}_run${R}.nc140
程式之執行
141#> Executable call:
142if($RUN==$R)then143${BINDIR}/${EXEC}144endif145146#> Increment both Gregorian and Julian Days
147setTODAYG=`date -ud "${TODAYG}+1days" +%Y-%m-%d`#> Add a day for tomorrow
148setTODAYJ=`date -ud "${TODAYG}" +%Y%j`#> Convert YYYY-MM-DD to YYYYJJJ
149@I=$I+1150end#Loop to the next Simulation Day
151152
沉降量計算部分
153# =====================================================================
154#> Begin Loop Through Simulation Days to Create DEP File
155# =====================================================================
156157#> Set the species definition file for concentration species.
158setenvSPECIES_DEF$SPEC_DEP159160#> Loop through all days between START_DAY and END_DAY
161setTODAYG=${START_DATE}162setTODAYJ=`date -ud "${START_DATE}" +%Y%j`#> Convert YYYY-MM-DD to YYYYJJJ
163setSTOP_DAY=`date -ud "${END_DATE}" +%Y%j`#> Convert YYYY-MM-DD to YYYYJJJ
164setI=0165while($TODAYJ<=$STOP_DAY)#>Compare dates in terms of YYYYJJJ
166@R=6#$I / 4 + 5
167echo'kuang'$Irun$R168if($R>12)exit0169#> Retrieve Calendar day Information
170setYYYY=`date -ud "${TODAYG}" +%Y`171setYY=`date -ud "${TODAYG}" +%y`172setMM=`date -ud "${TODAYG}" +%m`173setDD=`date -ud "${TODAYG}" +%d`
詳細I/O檔名之定義
174if("${STKCASEE}"!="")then175setenvCTM_APPL${RUNID}_run${R}_$YYYY$MM${DD}_${GRID_NAME}_${STKCASEE}176setenvCTM_APPD${RUNID}_run${R}_$YYYY${MM}_${GRID_NAME}_${STKCASEE}177else178setenvCTM_APPL${RUNID}_$YYYY$MM$DD179setenvCTM_APPD${RUNID}_$YYYY$MM180endif181#> for files that are indexed with Julian day:
182# set YYYYJJJ = `date -ud "${TODAYG}" +%Y%j`
183184#> Define name of combine output file to save hourly total deposition.
185#> A new file will be created for each month/year.
186setenvOUTFILE${POSTDIR}/COMBINE_DEP_${CTM_APPD}187#> Define name of input files needed for combine program.
188#> File [1]: CMAQ DRYDEP file
189#> File [2]: CMAQ WETDEP file
190#> File [3]: MCIP METCRO2D
191#> File [4]: {empty}
192setenvMETDIR${CMAQ_DATA}/mcip/${APPL}_run${R}/${GRID_NAME}#> Met Output Directory
193setenvINFILE1$CCTMOUTDIR/CCTM_DRYDEP_${CTM_APPL}.nc194setenvINFILE2$CCTMOUTDIR/CCTM_WETDEP1_${CTM_APPL}.nc195setenvINFILE3$METDIR/METCRO2D_${APPL}_run${R}.nc196setenvINFILE4197
程式之執行
198#> Executable call:
199if($RUN==$R)then200mpirun-np10${BINDIR}/${EXEC}201endif202203#> Increment both Gregorian and Julian Days
204setTODAYG=`date -ud "${TODAYG}+1days" +%Y-%m-%d`#> Add a day for tomorrow
205setTODAYJ=`date -ud "${TODAYG}" +%Y%j`#> Convert YYYY-MM-DD to YYYYJJJ
206@I=$I+1207end#Loop to the next Simulation Day
208209210exit()