On Fri, 2 Feb 2024, Sven Schreiber wrote:
Am 02.02.2024 um 01:42 schrieb Allin Cottrell:
>
> However, that treatment of the "const" modifier cannot work when
> the series passed is the one named "const" (with ID number 0).
> That series is supposed to be automatically available at all
> levels of function execution,
Well, but only if the dataset context is passed on to the called
function, right?
Right, but that happens automatically within any given gretl
process, regardless of whether any series, or list of series, is
passed to the called function. As a trivial illustration:
<hansl>
function void f (void)
print const
smpl
end function
nulldata 8
setobs 4 2016:1
f()
</hansl>
In the MPI context the dataset (if present) is not automatically
passed between distinct gretl processes, but this is ensured by the
--send-data option for a mpi block. Another trivial illustration:
<hansl>
function void f (void)
printf "process %d\n", $mpirank
print const
smpl
end function
nulldata 8
setobs 4 2016:1
mpi --send-functions --send-data
f()
end mpi --np=2
</hansl>
There's one gotcha to note here. If you don't need to pass the
entire dataset in the MPI context you can use --send-data=L, where L
is a list of series, BUT this won't work if L contains just const.
That's because inter-process transfer of data is done using a gdt or
gdtb file, and "const" is not explicitly represented in such a file.
Trying to save a gdt[b] file containing no series other than const
will fail with the message "No data to save!". It's fine if L
contains just a single series, but it can't be series 0. You could
insert "list L = index" before the mpi block above, and make the
option --send-data=L.
Anyway, the behavior you found with exists() is clearly wrong, and
I'm satisfied that a proper fix can be engineered: we'll give the
called function a copy of const under the parameter name rather then
doing the "shift and rename" thing. That should be in git quite
soon.
Allin