Stefan Schippers
05/21/2024, 9:11 PM.control / .endc
block you can use environment variables.
Example:
.control
...
...
write $FILENAME
.endc
if environment variable FILENAME
is defined before starting ngspice:
export FILENAME=circuit.raw
the above write command will write into circuit.raw
(@Tim Edwards did you know this?).
Unfortunately environment variables expansion does NOT work outside a .control block, so for example we can not use $PDK_ROOT
in a .lib
statement (sigh).Holger Vogt
05/25/2024, 8:21 AMHolger Vogt
05/25/2024, 8:24 AMHolger Vogt
05/25/2024, 8:27 AMStefan Schippers
05/25/2024, 11:07 AM.lib $PDK_ROOT/$PDK/libs.tech/combined tt
This will make the netlist portable (no absolute pathnames)
But I know the $ has another meaning (as an in-line comment character), so I recognize it is not trivial.Tim Edwards
05/25/2024, 2:09 PM$PDK_ROOT
is a true environment variable, because it describes where the PDK is in the user's environment and makes files portable. $FILENAME
, by contrast, is specific to the simulation. It's basically being used as an end-run around the fact that ngspice's interpreter doesn't accept arguments passed from the command line. But I noticed from the ngspice documentation that variables can be created and passed directly to the program from the command line with the -D
argument. It's a bit oblique (and hard to find in the documentation), but seems reasonable.Holger Vogt
05/25/2024, 8:37 PMHolger Vogt
05/27/2024, 1:47 PMHolger Vogt
05/27/2024, 1:47 PMStefan Schippers
05/27/2024, 4:15 PM