VAX FORTRAN read from console

Post Reply

Topic author
meyer_d
Contributor
Posts: 20
Joined: Tue Oct 31, 2023 10:18 pm
Reputation: 0
Status: Offline

VAX FORTRAN read from console

Post by meyer_d » Wed May 08, 2024 3:34 am

I want to read a long series of space-separated integers from the console. I can write a program that compiles, links, and starts to run, but the following line crashes when I enter a line of 134 characters or longer:

...
READ (*,*) (DATUM(I), I=1,DATUM_CNT)
...
(DATUM_CNT is the number of integer values in the input line;
DATUM is an integer array with dimension >= DATUM_CNT;
full source below)

Sample input:

1200 291 495 475 1095 867 28 1105 645 1211 741 559 698 1200 1100 670 1211 299 804 838 880 737 110 1018 132 140 618 504 967 584 835 909 1039 1225 934 456 432 690 181 1061 875

Result is echo of input line up to "... 586 835 90" then the following error message:

%FOR-F-ERRDURREA, error during read
unit -4 file SYS$INPUT:.;
user PC 00000847
-RMS-W-TNS, terminator not seen
%TRACE-F-TRACEBACK, symbolic stack dump follows
module name routine name line rel PC abs PC

0002B292 0002B292
0002B19F 0002B19F
00027D87 00027D87
00027830 00027830
CA002C CA002C 17 00000047 00000847

... Then the remainder of the input line is printed after a command prompt.

Console input less than 134 characters in length is handled normally. The program also works if I divide the series of integers into two input lines. Also, reading the long line of integers from an external file works as expected.

Changing my terminal width setting produces the same error.

Is there anything I can do to get a FORTRAN program to accept a longer line of input from the console?

Full program source:

PROGRAM CA002C

PARAMETER DATUM_CAP=128

INTEGER DATUM_CNT, DATUM(DATUM_CAP), I, ANSWER

WRITE (*,'('' INPUT DATA:'')')
READ (*,*) DATUM_CNT
READ (*,*) (DATUM(I), I=1,DATUM_CNT)
ANSWER = 0
DO I = 1,DATUM_CNT
ANSWER = ANSWER + DATUM(I)
END DO
WRITE (*,'(''0ANSWER:''/I)') ANSWER

END
David Meyer
Takarazuka, Japan
papa@sdf.org


joukj
Master
Posts: 231
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: VAX FORTRAN read from console

Post by joukj » Wed May 08, 2024 4:07 am

Use unit 5 to read and open it with a recl parameter

i.e.
PROGRAM CA002C

PARAMETER DATUM_CAP=128

INTEGER DATUM_CNT, DATUM(DATUM_CAP), I, ANSWER

open( unit=5 , recl=2048)
WRITE (*,'('' INPUT DATA:'')')
READ (5,*) DATUM_CNT
READ (5,*) (DATUM(I), I=1,DATUM_CNT)
ANSWER = 0
DO I = 1,DATUM_CNT
ANSWER = ANSWER + DATUM(I)
END DO
WRITE (*,'(''0ANSWER:''/I)') ANSWER

END
Last edited by joukj on Wed May 08, 2024 4:14 am, edited 1 time in total.


Topic author
meyer_d
Contributor
Posts: 20
Joined: Tue Oct 31, 2023 10:18 pm
Reputation: 0
Status: Offline

Re: VAX FORTRAN read from console

Post by meyer_d » Wed May 08, 2024 9:22 am

Thanks, that works!

So unit 5 is the user's terminal input? What other special unit numbers are defined in VAX FORTRAN? The VAX FORTRAN Language Reference Manual indicates that they're documented in VAX FORTRAN User Manual, but I can't find a copy on-line.
David Meyer
Takarazuka, Japan
papa@sdf.org

User avatar

cct
Master
Posts: 206
Joined: Sat Aug 15, 2020 9:00 am
Reputation: 0
Location: Cambridge, UK
Status: Offline

Re: VAX FORTRAN read from console

Post by cct » Wed May 08, 2024 9:36 am

meyer_d wrote:
Wed May 08, 2024 9:22 am
Thanks, that works!

So unit 5 is the user's terminal input? What other special unit numbers are defined in VAX FORTRAN? The VAX FORTRAN Language Reference Manual indicates that they're documented in VAX FORTRAN User Manual, but I can't find a copy on-line.
See https://docs.vmssoftware.com/vsi-fortra ... ser-manual
--
Chris


Topic author
meyer_d
Contributor
Posts: 20
Joined: Tue Oct 31, 2023 10:18 pm
Reputation: 0
Status: Offline

Re: VAX FORTRAN read from console

Post by meyer_d » Wed May 08, 2024 9:47 am

I found the VSI version of the User Manual, but missed this line:

"...unit number 5 is associated with SYS$INPUT and unit 6 with SYS$OUTPUT."

Are 5 and 6 the only unit numbers with such special associations?
David Meyer
Takarazuka, Japan
papa@sdf.org


joukj
Master
Posts: 231
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: VAX FORTRAN read from console

Post by joukj » Wed May 08, 2024 10:16 am

5 &6 are the ones most used and are also valid for input/output on other platforms (i.e. gfortran on linux etc..)

But as you can see from your error message unit=4 seems to be associated with *
Last edited by joukj on Wed May 08, 2024 10:28 am, edited 2 times in total.

Post Reply