[Info-vax] Technical issues with VMS BASIC port to x86-64 ?

Arne Vajhøj arne at vajhoej.dk
Wed Feb 21 19:15:30 EST 2024


On 2/21/2024 6:55 PM, Arne Vajhøj wrote:
> 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.

Note that VMS Fortran is not unique in accepting that code.

I have not been able to find a Fortran compiler not accepting
it by default.

GFortran:

C:\Work\Fortran>gfortran soso.for -o soso.exe

C:\Work\Fortran>soso
          123         456

C:\Work\Fortran>gfortran bad.for -o bad.exe

C:\Work\Fortran>bad
          123           0

C:\Work\Fortran>gfortran -std=f95 soso.for -o soso.exe
soso.for:2:16:

     2 |       integer*4 a(2)
       |                1
Error: GNU Extension: Nonstandard type declaration INTEGER*4 at (1)
soso.for:5:18:

     5 |       write(*,*) a(1),a(2)
       |                  1
Error: PROCEDURE attribute conflicts with COMMON attribute in 'a' at (1)
soso.for:9:16:

     9 |       integer*4 a(2)
       |                1
Error: GNU Extension: Nonstandard type declaration INTEGER*4 at (1)
soso.for:11:13:

    11 |       data a/123,456/
       |             1
Error: GNU Extension: initialization of common block variable 'a' in 
DATA statement at (1)

C:\Work\Fortran>gfortran -std=f95 bad.for -o bad.exe
bad.for:2:16:

     2 |       integer*4 a(2)
       |                1
Error: GNU Extension: Nonstandard type declaration INTEGER*4 at (1)
bad.for:6:18:

     6 |       write(*,*) a(1),a(2)
       |                  1
Error: PROCEDURE attribute conflicts with COMMON attribute in 'a' at (1)
bad.for:10:16:

    10 |       integer*4 a(2)
       |                1
Error: GNU Extension: Nonstandard type declaration INTEGER*4 at (1)
bad.for:12:13:

    12 |       data a(1)/123/
       |             1
Error: GNU Extension: initialization of common block variable 'a' in 
DATA statement at (1)
bad.for:16:16:

    16 |       integer*4 a(2)
       |                1
Error: GNU Extension: Nonstandard type declaration INTEGER*4 at (1)
bad.for:18:13:

    18 |       data a(2)/456/
       |             1
Error: GNU Extension: initialization of common block variable 'a' in 
DATA statement at (1)

The soso example works fine default.

It is definitely not nice that the compiler and linker silently
drops the initialization of a(2) in the bad example default.

Old G77:

C:\Work\Fortran>g77 soso.for -o soso.exe

C:\Work\Fortran>soso
  123 456

C:\Work\Fortran>g77 bad.for -o bad.exe
bad.for: In subroutine `s2':
bad.for:12:
          data a(1)/123/
                    1
bad.for:18: (continued):
          data a(2)/456/
                    2
Common block `m' initialized at (2) already initialized at (1) -- only 
one program unit may specify initial values for a particular common block

The soso example works fine default.

I think this way to handle the bad example is rather appropriate.

And an even older Watcom compiler for DOS:

C:\Work\Fortran>wfl soso.for
Open Watcom F77/16 Compile and Link Utility Version 1.9
Portions Copyright (c) 1990-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
         wfc soso.for
Open Watcom FORTRAN 77/16 Optimizing Compiler Version 1.9
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
soso.for: 11 statements, 53 bytes, 4 extensions, 0 warnings, 0 errors
         wlink @__wfl__.lnk
Open Watcom Linker Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
loading object files
searching libraries
creating a DOS executable

C:\Work\Fortran>wfl bad.for
Open Watcom F77/16 Compile and Link Utility Version 1.9
Portions Copyright (c) 1990-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
         wfc bad.for
Open Watcom FORTRAN 77/16 Optimizing Compiler Version 1.9
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
bad.for: 17 statements, 59 bytes, 6 extensions, 0 warnings, 0 errors
         wlink @__wfl__.lnk
Open Watcom Linker Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
loading object files
searching libraries
creating a DOS executable

(and it produces correct results too for both - I just can't copy paste
from DOSBOX)

Arne












More information about the Info-vax mailing list