Yuan Mei
07/18/2021, 10:57 AMngspice
interactive session
compose Ws values 1u 2u
compose Ls values 0.1u 0.2u
foreach WW $&Ws
foreach LL $&Ls
echo W/L = $WW / $LL
end
end
The printing of W/L works as expected. But if it is put into the .control
... .endc
block in a file and use ngspice
to load it from commandline, it complains that Error: WW: no such variable. Error: LL: no such variable. I am puzzled by this behavior. Any suggestions?Satya Mishra
07/18/2021, 5:32 PMecho
it appears that whole thing is evaluated in a shell script? If I change the echo ...
to print $WW / $LL
I get meaningful resultsVern
07/19/2021, 1:51 AMecho
is a nutmeg command (nutmeg is the name of the interactive interpreter). IIRC, nutmeg is essentially a modified csh, so that's what's running commands specific to the interpreter. The print
command, however, is an internal SPICE command, so it works like you'd expect in batch mode.
I'm afraid the ngpsice manual doesn't do a good job pointing out what commands are specific to nutmeg. The interactive interpreter section has asterisks to indicate "only available in ngspice, not in ngnutmeg," which I think indicates the given command only makes sense inside a .control
block, not on the nutmeg command line. There's no marker to indicate what makes sense on the command line, but not in a .control
block, however.Yuan Mei
07/19/2021, 3:25 AM.control
let a = 1
set b = 1
echo $&a, $b
.endc
which run as expected in batch mode. echo clearly has access to both vector and variable. The only trouble seems to be with the foreach
generated variable, which somehow is not accessible by echo
.