@echo off

rem  With the above '@echo off' stmt, this bat file will close automatically unless there
rem  is an error of some kind.  If so, click on the GoNec window to see what happened.
rem
rem  This version of NEC expects to have input and output files both named in a file
rem  which is itself named 'Infile.dat'.  Contains names '$Multi$.nec' and '$Temp$.out'.
rem
rem  The output file is renamed on termination to signal the caller that NEC is done.
rem  (Assumes caller has deleted '$Multi$.out' and is waiting for it to re-appear.)
rem  '$Multi$.out' also deleted here, if found, so this bat file can be run stand-alone.
rem
rem  The Nec2d960.exe and SomNec2d.exe modules both require that the Nec2d.exe and
rem  F77L3.eer files be present in the same folder.  Keep these files together.
rem
rem  The single parm passed to this bat file will be either "Som" or "NoSom".  If "Som",
rem  generate a Sommerfeld ground file named Som2d.nec for use by Nec2d.  This file is
rem  built based on parms in the $Som2d$.dat file.  If not "Som", either a gound file
rem  is not needed or it is already available and has been renamed for use by Nec2dxxx.
rem  Both SomNec2d and Nec2d/Nec2d960 produce log files in addition to the wanted data
rem  output files.  These log files may usually be ignored.
rem
rem  NOTE:  On computers with limited memory you may wish to replace the use of
rem  'Nec2d960.exe' with 'Nec2d.exe' below.  Nec2d960 can handle 960 segments, Nec2d
rem  is limited to 256 segments.  Nec2dxxx modules to handle up to 11000 segments are
rem  available in the nec-pc-x.zip file from Jos Bergervoet.  See the Unofficial NEC
rem  Archives site at www.qsl.net/wb6tpu/swindex.html.

if not "%1" == "Som" goto NoSom
	SomNec2d.exe  <$Som2d$.dat  >SomNec2d.log
:NoSom 
	Nec2d960.exe  <Infile.dat   >Nec2d.log
	if exist $Multi$.out del $Multi$.out
	rename $Temp$.out $Multi$.out
