The current implementation uses a simple text file, but future implementation may also be able to switch to shared memory, or whatever the operating system and environment provides, or what the users’ workflow prefers.
export NEMOVAR=/dev/shm/nemovar.$USER
nemovar a 10
to set the value of 10 to a. Then
nemovar a
retrieves the value of a. And finally
nemovar
just shows all variables. Output is always to stdout.
a="10"
b="hello world"
c="3.141592"
to make it compatible with possible future bash(1)
and python(1)
clients.
The data type interpretation is left to the client. This also opens the
option for small lists, e.g.
d="1,2,10:20:2"
First of all, shell variables can be an effective way
to control a script, but sometimes they need to be extracted from a program,
e.g. with some awk/grep/sed, or in this example with txtpar(1NEMO)
ccdstat foo.ccd > foo.log
mean=$(txtpar foo.log p0=Mean,1,5)
disp=$(txtpar foo.log p0=Mean,1,6)
ccdplot foo.ccd $mean-$disp,$mean,$mean+$disp
here we extracted the mean and dispersion from a map, and plotted contours
of the mean, and one dispersion around the mean. Assuming these variables
from the previous example happen to be in a file called nemopars.rc, the
following will work mean=$(nemopars mean)
disp=$(nemopars disp)
Simulations can store results in a keyword=value textual database, something that can be easily read by the shell, or python, or nemopars(1NEMO) .
With
the first version of nemovar you can do the following: export NEMOVAR=nemopars.rc
mean=$(nemovar mean)
disp=$(nemovar disp)
The power of nemovar will come when the user interface shortcuts the
use of the shell,as in this hypothetical example ccdstat foo.ccd nemovar=mean,disp
ccdplot foo.ccd %mean-%disp,%mean,%mean+%disp’
nemovar eps 0.05 eps=0.05
hackcode1 eps=%eps hackcode1 eps=$eps
Note that some table(5NEMO)
programs use %0, %1, %2, .... to refer to column
numbers, so variable names cannot start with a digit. Upper and Lower case
should be allowed.
Recall that the current command line interface already can refer to other keywords, e.g.
foobar a=1 b=’$a’
would assign the same value to both a and b.
2. An option should exist to remove a variable from the database.
3. In case there is true shared memory not associated with a filename, there needs to be a way to save and load true files.
4. When outkeys/savevars are implemented, the following style of IPC is possible:
ccdstat ccd1 outkeys=mean,rms
ccdplot ccd1 %mean
plotting a single contour of the mean value in the image.
redis/valkey https://github.com/valkey-io/valkey
Teuben
7-mar-2024 Created for NEMO2024 PJT 24-jun-2024 0.4: write dummy if NEMOVAR does not exist PJT