[Info-vax] Technical issues with VMS BASIC port to x86-64 ?
Arne Vajhøj
arne at vajhoej.dk
Wed Feb 21 18:55:41 EST 2024
On 2/20/2024 10:27 PM, Lawrence D'Oliveiro wrote:
> On Tue, 20 Feb 2024 21:09:51 -0500, Arne Vajhøj wrote:
>> I believe the example was somewhat similar to:
>>
>> program bad
>> integer*4 a(2)
>> common /m/a
>> call s1
>> call s2
>> write(*,*) a(1),a(2)
>> end
>> c
>> subroutine s1
>> integer*4 a(2)
>> common /m/a
>> data a(1)/123/
>> end
>> c
>> subroutine s2
>> integer*4 a(2)
>> common /m/a
>> data a(2)/456/
>> end
>
> Looking at the Fortran 2018 spec, section 8.4, it says “A variable, or
> part of a variable, shall not be explicitly initialized more
> than once in a program”.
>
> Also section 8.6.7 says “A variable whose designator appears as a data-
> stmt-object or a data-i-do-object shall not be a dummy argument, accessed
> by use or host association, in a named common block unless the DATA
> statement is in a block data program unit, in blank common, a function
> name, a function result name, an automatic data object, or an allocatable
> variable”.
And?
Instead of reading the specs you should have tried compiling
the code on your VMS system.
It compiles and runs fine!
Yes - it seems to be an extension to the standard. But VMS Fortran
hast lots of extensions to the standard.
But let us take a step back and look at a slightly more
reasonable example.
$ type soso.for
program soso
integer*4 a(2)
common /m/a
call s
write(*,*) a(1),a(2)
end
c
subroutine s
integer*4 a(2)
common /m/a
data a/123,456/
end
$ for soso
$ link soso
$ r soso
123 456
Which may not be good code as it is rather unclear
where the data initialization happens, but not nearly
as bad as the code further above.
And I believe that style is widely used on VMS. BLOCK DATA
are not often used on VMS. I mostly see them used for writeable
shareable images - and that is a very special case.
$ type bad.for
program bad
integer*4 a(2)
common /m/a
call s1
call s2
write(*,*) a(1),a(2)
end
c
subroutine s1
integer*4 a(2)
common /m/a
data a(1)/123/
end
c
subroutine s2
integer*4 a(2)
common /m/a
data a(2)/456/
end
$ for bad
$ link bad
$ r bad
123 456
Is really ugly code. But it worked on VMS VAX 40 years ago,
so the expectation is that it works on VMS x86-64 today.
Backwards compatibility can be a real PITA.
It is possible to ask for stronger standard compliance check.
$ for/stand=f95 soso
program soso
^
%F90-W-WARNING, Fixed form source is an obsolescent feature in Fortran 95.
at line number 1 in file DKA0:[arne]soso.for;1
integer*4 a(2)
..............^
%F90-W-WARNING, Fortran 95 does not allow this length specification. [4]
at line number 2 in file DKA0:[arne]soso.for;1
integer*4 a(2)
..............^
%F90-W-WARNING, Fortran 95 does not allow this length specification. [4]
at line number 9 in file DKA0:[arne]soso.for;1
data a/123,456/
...........^
%F90-W-WARNING, In Fortran 95, this DATA statement object cannot appear
in either a blank COMMON block or a named COMMON block. [A]
at line number 11 in file DKA0:[arne]soso.for;1
$ for/stand=f95 bad
program bad
^
%F90-W-WARNING, Fixed form source is an obsolescent feature in Fortran 95.
at line number 1 in file DKA0:[arne]bad.for;1
integer*4 a(2)
..............^
%F90-W-WARNING, Fortran 95 does not allow this length specification. [4]
at line number 2 in file DKA0:[arne]bad.for;1
integer*4 a(2)
..............^
%F90-W-WARNING, Fortran 95 does not allow this length specification. [4]
at line number 10 in file DKA0:[arne]bad.for;1
data a(1)/123/
...........^
%F90-W-WARNING, In Fortran 95, this DATA statement object cannot appear
in either a blank COMMON block or a named COMMON block. [A]
at line number 12 in file DKA0:[arne]bad.for;1
integer*4 a(2)
..............^
%F90-W-WARNING, Fortran 95 does not allow this length specification. [4]
at line number 16 in file DKA0:[arne]bad.for;1
data a(2)/456/
...........^
%F90-W-WARNING, In Fortran 95, this DATA statement object cannot appear
in either a blank COMMON block or a named COMMON block. [A]
at line number 18 in file DKA0:[arne]bad.for;1
Both the INTEGER*4 declaration and the mix of COMMON and DATA
are not valid per Fortran 95 standard resulting in the warning.
But with old VMS Fortran code that qualifier is pretty rare.
Arne
More information about the Info-vax
mailing list