[Info-vax] GKS : gopwk problem with VSI's version of GKS
Joukj
joukj at hrem.nano.tudelft.nl
Thu Mar 18 03:12:48 EDT 2021
Arne Vajhøj wrote:
> On 3/17/2021 1:06 PM, Craig A. Berry wrote:
>> My Fortran is awfully rusty, but if the intent is to pass a NULL
>> pointer, wouldn't the second argument need to be %VAL(0) rather than 0?
>
> Yes. Fortran default to BYREF for integers - not BYVAL.
>
> $ type c.c
> #include <stdio.h>
> #include <string.h>
>
> void m(const char *s)
> {
> if(s == NULL)
> {
> printf("s = NULL\n");
> }
> else
> {
> printf("s len = %d\n", strlen(s));
> }
> }
>
> $ cc c
> $ type f.for
> program f
> external m
> call m(%val(0))
> call m(0)
> call m(%ref('ABC'))
> end
> $ for f
> $ link f + c
> $ run f
> s = NULL
> s len = 0
> s len = 3
> $
>
> Arne
>
I got it solved: I realy had to reboot (I thought OpenVMS was not
Windows(#$%^&@)). So simply remove old GKS, install new GKS and rerun
@sys$startup:gkstartup is not enough; in that case you will end-up in a
"mixed version of old/new.
Indeed, Fortran passes all parameters by-reference, except character
strings which are passed by-descriptor. (unless you specify %ref() or
%val()).
In case of gopwk it seems that passing 0, %val(0) and FB_DEF_LUN
(defined in sys$library:gks.f) all work to get the default.
More information about the Info-vax
mailing list