Variable array overwriting 1st array.

Variable array overwriting 1st array.

Needing an array expert for review. I have converted an old program from f77 to f90. Everything compiles and links but there is an array problem.

PROBLEM WHEN X1 READS IT ALSO PUSHES DATA IN Y1
SAMES ISSUE WITH X2. IT WRITES TO NEXT AVAILABLE ENTRIES FOR Y1. UPON READ OF Y1, DATA ALSO OVERWRITES X1.

I will attach the files so someone can maybe take a look, compile or link.

Thanks for any help.

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Note table.txt needs to be renamed table.inp.

The upload would not accept a .inp file.

Thanks

In the main program is a major error:
the statement CALL READ1(0,0) is in error, because the constant 0 will be overwritten as 1 by the statement IPAS1 = 1.
You should call READ1 in the main program as:
IPAS1 = 0
IERR = 0
CALL READ1(IPAS1, IERR)

But when this is corrected, X1 is indeed overwritten by Y1 in subroutine READ3. This happens when READ3 is called for the second time in subroutine READ2.
It appears that the ITAB indices are not correct: ITAB(2,2) = 548 and ITAB(4,2 ) = 549.
Via the call of READ3 in subroutine READ2: TAB(548) represents X1 and TABS(549) represents Y1. So, Y1(1...) overwrites X1(2... ).
I assume the computation of the ITAB indices is incorrect somewhere.

Thanks nijhuis.

I see the error in the itabs. It should be as below.

ITAB (NT, 2) = ITAB (NT, 1) + NX
ITAB (NT, 3) = ITAB (NT, 2) + NY
ITAB (NT, 4) = ITAB (NT, 3) + NZ

Those other errors were a result of skinying down the code to post it.

After correcting the ITAB statements the program crashes because a string is read where a number is expected.
This happens, because the input file is not correct. The values NX, NY, NZ and NTAB as read in the file are not conform the amount of data following that line.

Guus

Thanks. I caught that.

Leave a Comment

Please sign in to add a comment. Not a member? Join today