Batch script for M3WNDW or BCWNDW

I am looking for a sample batch script I can use to execute m3wndw and bcwndw. I am not sure what is the structure to use to provide the input file, output file and the grid domain bounds. I can run the program using the command prompt, but it’s tedious for regridding files for an entire year.

Copy down what all the responses were for m3wndw (for example), and then use them to construct
an command-file to use with it: Something like:

    set cmd = /tmp/m3wndw.$$
    echo "Yes continue with program " >& $cmd
    echo "INFILE"                     >> $cmd
    echo "$SDATE"                     >> $cmd
    echo "$STIME"                     >> $cmd
    echo "           "                     >> $cmd    #  default RUNLEN
   ...etc ...
    m3wndw < $cmd

Can you please explain what the first line mean? specifically the double dollar sign?
This is mu run script
#!/bin/csh -f
#This script window out the southwest US data from 12US1 domain
#12US1 domain : 459 col by 299 row and origin of -2556 and -1728
#ADEQ_12PHX : 154 col by 110 row and origin of -2256 and -996

setenv infile /CAMData/CMAQ/2016_12US1/emis/cmaq_ready/emis_mole_all_20160603_12US1_nobeis_2016ff_16j.ncf
setenv outfile /CAMData/CMAQ/2016_12US1/emis/cmaq_ready/emis_mole_all_20160603_ADEQ_12PHX_nobeis_2016ff_16j.ncf
set cmd = /CAMData/CMAQ/Libraries/ioapi-3.2/ioapi/lib/m3wndw.$$
echo “$infile” >&$cmd
echo “$outfile” >>$cmd
echo “2016155” >>$cmd
echo “000000” >>$cmd
echo “240000” >>$cmd
echo “ADEQ_12PHX” >>$cmd
echo “26” >>$cmd
echo “179” >>$cmd
echo “62” >>$cmd
echo “171” >>$cmd

/CAMData/CMAQ/Libraries/ioapi-3.2/ioapi/lib/m3wndw < $cmd

When I run it I get:
/CAMData/CMAQ/Libraries/ioapi-3.2/ioapi/lib/m3wndw.17550: Permission denied.

Normally that should be /tmp/m3wndw.$$ (or similarly).

This is the standard UNIX/Linux way of safely creating a scratch-file: $$ is the built-in shell-variable for the current-shell process-ID (which is unique on the entire system you’re running on), so that (short of malice), no other file on the system should have that name, and so no-one should accidentally corrupt or clobber that scratch-file.

FWIW, lots of people who should know better fail to do this and create brittle systems as a result. Cisco’s anyconnect VPN-client is an example of such a failure. So you should not feel bad about not having been taught this…