- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I try to read this:
read(26,1012)(m2x(i),i=1,21) I got this:
error #6358: Constants and expressions are invalid in read-only I/O lists
When I change to:
do i=1,21
read(26,1012)m2x
end do
It reads and later writes only the last value from my array.
12 21.45000 1
14 21.45000 1
16 21.45000 1
19 21.45000 1
21 21.45000 1
24 21.45000 1
26 21.45000 1
27 21.45000 1
28 21.45000 1
32 21.45000 1
34 21.45000 1
41 21.45000 1
45 21.45000 1
47 21.45000 1
48 21.45000 1
49 21.45000 1
50 21.45000 1
51 21.45000 1
52 21.45000 1
55 21.45000 1
58 21.45000 1
I am attaching the code.
read(26,1012)(m2x(i),i=1,21) I got this:
error #6358: Constants and expressions are invalid in read-only I/O lists
When I change to:
do i=1,21
read(26,1012)m2x
end do
It reads and later writes only the last value from my array.
12 21.45000 1
14 21.45000 1
16 21.45000 1
19 21.45000 1
21 21.45000 1
24 21.45000 1
26 21.45000 1
27 21.45000 1
28 21.45000 1
32 21.45000 1
34 21.45000 1
41 21.45000 1
45 21.45000 1
47 21.45000 1
48 21.45000 1
49 21.45000 1
50 21.45000 1
51 21.45000 1
52 21.45000 1
55 21.45000 1
58 21.45000 1
I am attaching the code.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is because you did not declare m2x as an array, and the compiler, thinking that m2x(i) must therefore a real function of an integer argument, told you that you cannot read values into a function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot mecej.
But it is not still working.What I really want is that my program takes 21 values from newmodel.dat and writes them into new file.I have declared m2x as an array real,dimension(21,1).
I got this:
12 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 1
There should be one numerical value not 21 zeros.
But it is not still working.What I really want is that my program takes 21 values from newmodel.dat and writes them into new file.I have declared m2x as an array real,dimension(21,1).
I got this:
12 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 1
There should be one numerical value not 21 zeros.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I cannot help you much since your program needs several input data files, of which you gave only one. Simply stating that the program result does not look correct does not give one much of a basis for diagnosing problems.
Why should you expect to be able to change the declaration of m2x from a scalar to an array without changing the instances of m2x in I/O statements and other places where the variable occurs. In particular, do you really want to read your array m2x 21 times?
If you were more meticulous with describing your work and documenting changes to your code, and strove for completeness in your problem descriptions, you would make faster progress.
Why should you expect to be able to change the declaration of m2x from a scalar to an array without changing the instances of m2x in I/O statements and other places where the variable occurs. In particular, do you really want to read your array m2x 21 times?
If you were more meticulous with describing your work and documenting changes to your code, and strove for completeness in your problem descriptions, you would make faster progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks again.I will try to explain.From newmodel.dat I want to extract 21 numerical values,actually I want to rewrite a column with new resistivity values.Two other columns do not change.New file would be input file for other program.I am adding all other input files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page