On 13/06/2022 01:46, Lynn McGuire wrote:
So, is there a better way to code this ?
Better no, maybe more compact. If performance is an
issue one can declare ie the string as a parameter.
...
Does anybody know why there is such a restriction?
----------------------------------------------
$ gfc --version 2>&1 | head -n1
GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
(Red Hat Linux 3.2.2-5)
Ev. Drikos <drikosev@gmail.com> schrieb:
Does anybody know why there is such a restriction?
----------------------------------------------
$ gfc --version 2>&1 | head -n1
GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
(Red Hat Linux 3.2.2-5)
Without looking at the code: g77 has not been maintained for a really
long time, and it only implements f77 + some extensions. I would not
be surprised by any restrictions of anything f90-like or later.
...
$ gfortran8 -ffixed-form icep.f
icep.f:20:11:
read(goes(icep:icep),*) nn
1
Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable
On 19/06/2022 13:12, Thomas Koenig wrote:
Ev. Drikos <drikosev@gmail.com> schrieb:
Does anybody know why there is such a restriction?
----------------------------------------------
$ gfc --version 2>&1 | head -n1
GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
(Red Hat Linux 3.2.2-5)
Without looking at the code: g77 has not been maintained for a really
long time, and it only implements f77 + some extensions. I would not
be surprised by any restrictions of anything f90-like or later.
Thanks for the feedback, the OP discussed F77. In this case version 8
issues a similar error as well:
$ gfortran8 -ffixed-form icep.f
icep.f:20:11:
read(goes(icep:icep),*) nn
1
Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable
On 19/06/2022 13:21, Ev. Drikos wrote:
...
$ gfortran8 -ffixed-form icep.f
icep.f:20:11:
read(goes(icep:icep),*) nn
1
Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable
Ok, an extra assignment to a variable could solve this issue, ie:
ch = go(icep:icep) !an extra assignment to a variable
read(ch, *) nn
goto(10,11) nn
Due to the fixed form format, the example is readable in my gists: https://gist.github.com/drikosev/7f24acb6435f441d5d6f7be220efdbe9
Yet, the question remains open. Is it perhaps a compiler specific bug
or a standard restriction?
It is a standard restriction in f77. I remember similar situations many
times in the 1980s.
The I/O list of READ and WRITE statements contains variables (and arrays)
but not constants or expressions. That is obvious for READ, but not
for WRITE.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:32:34 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,579 |