Cmaq make BCON files that take more than a day

A few observations:

  1. YYYYJJJ, YYMMDD, YYYYMMDD, and YYYYMM all need to be set inside the “while” loop for this to work as intended, and need to work off of {TODAYG}. In the script you posted, you kept the original script setting of defining these variables prior to the start of the “while” loop, and working off of the static {DATE} variable rather than the {TODAYG} variable incremented in the loop.

  2. the loop needs to encompass the call to the BCON executable.

  3. moreover, in your situation you seem to be working with MCIP files containing three months of hourly data, and CCTM_CONC files just containing a single day. Therefore, you’ll need to define the optional SDATE, STIME, and RUNLEN environment variables to restrict the processing of each day to just the hours present in the CCTM_CONC files.

Something like this might work:

#    set DATE = "2017-01-01"
#    set YYYY = `date -ud "${TODAYG}" +%Y`
#    set YYYYJJJ  = `date -ud "${DATE}" +%Y%j`   #> Convert YYYY-MM-DD to YYYYJJJ

#    set YYMMDD   = `date -ud "${DATE}" +%y%m%d` #> Convert YYYY-MM-DD to YYMMDD

#    set YYYYMMDD = `date -ud "${DATE}" +%Y%m%d` #> Convert YYYY-MM-DD to YYYYMMDD
#   setenv SDATE           ${YYYYJJJ}
#   setenv STIME           000000
#   setenv RUNLEN          240000

    set START_DATE = "2017-01-01"     #> beginning date (July 1, 2016)
    set END_DATE   = "2017-03-31"     #> ending date    (July 1, 2016)
    set TODAYG = ${START_DATE}
    set TODAYJ = `date -ud "${START_DATE}" +%Y%j` #> Convert YYYY-MM-DD to YYYYJJJ
    set START_DAY = ${TODAYJ}
    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 YYYYJJJ  = $TODAYJ
  set YYMMDD   = `date -ud "${TODAYG}" +%y%m%d`   #> Convert YYYY-MM-DD to YYMMDD
  set YYYYMMDD = `date -ud "${TODAYG}" +%Y%m%d` #> Convert YYYY-MM-DD to YYYYMMDD
  set YYYYMM   = `date -ud "${TODAYG}" +%Y%m`     #> Convert YYYY-MM-DD to YYYYMM

  setenv SDATE           ${TODAYJ}
  setenv STIME           000000
  setenv RUNLEN          250000

  if ( $BCON_TYPE == regrid ) then 

    setenv CTM_CONC_1 /home/u220220948411/wrf/cmaq532/data/xie_cr/d01/normal2/output_CCTM_v532_intel_d01_0103_normal/CCTM_CONC_v532_intel_d01_0103_normal_${YYYYMMDD}.nc

    setenv MET_CRO_3D_CRS /home/u220220948411/wrf/cmaq532/data/xie_cr/d01/01_03/METCRO3D_01.nc
    setenv MET_BDY_3D_FIN /home/u220220948411/wrf/cmaq532/data/xie_cr/d02/01_03/METBDY3D_01.nc
    setenv BNDY_CONC_1    "$OUTDIR/BCON_${VRSN}_${APPL}_${BCON_TYPE}_5_${YYYY} -v"

 endif

  if ( $BCON_TYPE == profile ) then
    setenv BC_PROFILE  $BLD/avprofile_cb6r3m_ae7_kmtbr_hemi2016_v53beta2_m3dry_col051_row068.csv
    setenv MET_BDY_3D_FIN /home/u220220948411/wrf/cmaq532/data/xie_cr/d01/01_03/METBDY3D_01.nc    
setenv BNDY_CONC_1    "$OUTDIR/BCON_${VRSN}_${APPL}_${BCON_TYPE}_${YYYYMMDD} -v"
 endif

# =====================================================================
#> Output File
# =====================================================================

#>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 if ( ! -d "$OUTDIR" ) mkdir -p $OUTDIR

 ls -l $BLD/$EXEC; size $BLD/$EXEC
 unlimit
 limit

#> Executable call:
 time $BLD/$EXEC

#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 day