-Dname=value when starting
the program.
gd1 then defines a symbolic variable with name name to have the
value value.
The effect is therefore the same as if in the very first line of its input,
the line sdefine(name, value) would occur.
We write a small shell script that starts gd1 three times with three
different values for the option.
#!/bin/sh
for POS1 in 0e-3 25e-3 50e-3
do
gd1 -Dposition1=$POS1 -Dposition2=0 \
< /usr/local/gd1/Tutorial-SRRC/wPlunger04.gdf | tee out.pos1=$POS1
done
This shell-script can be found as '/usr/local/gd1/Tutorial-SRRC/many-pos1.x'.
The inputfile 'wPlunger04.gdf' now calls the macros as follows:
# # Model the tube and the plunger at phi=17 degrees: # call OuterPlunger( (130.75e-3/2) , 17 ) call InnerPlunger( (OuterRadius-position1), 17 ) # # model the tube and the plunger at phi=-90+22.5 degrees: # call OuterPlunger( (110e-3/2) , (-90+22.5) ) call InnerPlunger( (OuterRadius-position2), (-90+22.5) )The actual positions are output as annotations by specifying in the section
-general:
-general
text()= position1 : Position of the first plunger grep
text()= position2 : Position of the second plunger grep
When gd1 reads this, it will substitute the 'position1' with the value
that was supplied to it via its commandline option -Dposition1=$POS1,
the corresponding happens to the string 'position2'.
The strings 'grep' are supplied so that the outputfiles out.pos1=$POS1
can be 'grep'ed for the string 'grep'.
The full inputfile can be found as
/usr/local/gd1/Tutorial-SRRC/wPlunger04.gdf'.
When we run our shell script, we get three files
out.pos1=0e-3, out.pos1=25e-3, out.pos1=50e-3where the computed frequencies can be found in. The relevant lines can be easily extracted with the UNIX-command 'grep'. To show all lines in the files
out.pos* that contain the string 'grep',
you say
grep grep out.pos*The result is:
out.pos1=0e-3: general> text()= 0e-3 : Position of the first plunger grep out.pos1=0e-3: general> text()= 0 : Position of the second plunger grep Position of the first plunger: 0e-3 grep Position of the second plunger: 0 grep out.pos1=0e-3: 1 52.7470e+06 1.0090174050 0.3438316719 # "grep" for me out.pos1=0e-3: 2 502.5682e+06 0.0000031370 0.0000025505 # "grep" for me out.pos1=0e-3: 3 778.1484e+06 0.0000000660 0.0000000914 # "grep" for me out.pos1=0e-3: 4 779.3503e+06 0.0000000163 0.0000000249 # "grep" for me out.pos1=0e-3: 5 1.0554e+09 0.0000000001 0.0000000002 # "grep" for me out.pos1=0e-3: 6 1.0591e+09 0.0000000003 0.0000000045 # "grep" for me out.pos1=0e-3: 7 1.0971e+09 0.0000000012 0.0000000173 # "grep" for me out.pos1=0e-3: 8 1.0973e+09 0.0000000045 0.0000000428 # "grep" for me out.pos1=0e-3: 9 1.1560e+09 0.0000000521 0.0000005213 # "grep" for me out.pos1=0e-3: 10 1.1976e+09 0.0000001260 0.0000013792 # "grep" for me out.pos1=0e-3: 11 1.2515e+09 0.0004255555 0.0049426207 # "grep" for me out.pos1=0e-3: 12 1.2656e+09 0.0016319888 0.0731105041 # "grep" for me out.pos1=0e-3: 13 1.2668e+09 0.0025985547 1.0000000000 # "grep" for me out.pos1=25e-3: general> text()= 25e-3 : Position of the first plunger grep out.pos1=25e-3: general> text()= 0 : Position of the second plunger grep out.pos1=25e-3: 25e-3 : Position of the first plunger grep out.pos1=25e-3: 0 : Position of the second plunger grep out.pos1=25e-3: 1 503.7682e+06 0.0000024488 0.0000019899 # "grep" for me out.pos1=25e-3: 2 779.4209e+06 0.0000000124 0.0000000171 # "grep" for me out.pos1=25e-3: 3 781.0514e+06 0.0000000431 0.0000000660 # "grep" for me out.pos1=25e-3: 4 1.0575e+09 0.0000000027 0.0000000051 # "grep" for me out.pos1=25e-3: 5 1.0595e+09 0.0000000002 0.0000000024 # "grep" for me out.pos1=25e-3: 6 1.0968e+09 0.0000000062 0.0000000913 # "grep" for me out.pos1=25e-3: 7 1.0975e+09 0.0000000018 0.0000000174 # "grep" for me out.pos1=25e-3: 8 1.1555e+09 0.0000000372 0.0000003780 # "grep" for me out.pos1=25e-3: 9 1.2018e+09 0.0000002208 0.0000025548 # "grep" for me out.pos1=25e-3: 10 1.2529e+09 0.0007020442 0.0086314595 # "grep" for me out.pos1=25e-3: 11 1.2675e+09 0.0009580488 0.0414770393 # "grep" for me out.pos1=25e-3: 12 1.2746e+09 0.0020655866 0.1865897939 # "grep" for me out.pos1=50e-3: general> text()= 50e-3 : Position of the first plunger grep out.pos1=50e-3: general> text()= 0 : Position of the second plunger grep out.pos1=50e-3: 50e-3 : Position of the first plunger grep out.pos1=50e-3: 0 : Position of the second plunger grep out.pos1=50e-3: 1 99.6144e+06 0.9656790469 0.3479304400 # "grep" for me out.pos1=50e-3: 2 505.2467e+06 0.0000031189 0.0000025741 # "grep" for me out.pos1=50e-3: 3 779.6769e+06 0.0000000046 0.0000000065 # "grep" for me out.pos1=50e-3: 4 781.9646e+06 0.0000000537 0.0000000853 # "grep" for me out.pos1=50e-3: 5 1.0479e+09 0.0000000086 0.0000000166 # "grep" for me out.pos1=50e-3: 6 1.0605e+09 0.0000000016 0.0000000236 # "grep" for me out.pos1=50e-3: 7 1.0955e+09 0.0000000193 0.0000003011 # "grep" for me out.pos1=50e-3: 8 1.0983e+09 0.0000000036 0.0000000400 # "grep" for me out.pos1=50e-3: 9 1.1477e+09 0.0000000200 0.0000001945 # "grep" for me out.pos1=50e-3: 10 1.2055e+09 0.0000001903 0.0000020180 # "grep" for me out.pos1=50e-3: 11 1.2473e+09 0.0031135695 0.0463915760 # "grep" for me out.pos1=50e-3: 12 1.2570e+09 0.0168888927 0.6785522929 # "grep" for me out.pos1=50e-3: 13 1.2726e+09 0.0118906521 0.4821503838 # "grep" for meThis usage of gd1 is the reason, why gd1 writes the string
"grep" for mein the table of the frequencies.