Home > Archive > Fortran > March 2004 > Is it possible to specify runtime edit descriptors in format statements ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Is it possible to specify runtime edit descriptors in format statements ?
|
|
|
| Hi
I have a problem with Runtime Edit descriptors in FORMAT statements.
PROGRAM MAIN
CHARACTER*7 STR
INTEGER N
DATA STR/'1234567'/
N=3
READ(STR,100)VAL
100 FORMAT(NX,I3);
WRITE(6,101)VAL
101 FORMAT(I3)
END
In the format statement(100) of READ, I have use NX instead of 3X.
The compiler (g77) outputs and error "nrecognized FORMAT specifier"
Is there any way to achive the same result?
Noby Jose.
| |
| jan van oosterwijk 2004-03-27, 12:18 am |
| nobyjos@indiatimes.com (Noby) wrote in message news:<1528aa0c.0403250358.c9568a@posting.google.com>...
> Hi
>
>
> I have a problem with Runtime Edit descriptors in FORMAT statements.
>
> PROGRAM MAIN
> CHARACTER*7 STR
> INTEGER N
> DATA STR/'1234567'/
> N=3
> READ(STR,100)VAL
> 100 FORMAT(NX,I3)
> WRITE(6,101)VAL
> 101 FORMAT(I3)
> END
>
> In the format statement(100) of READ, I have use NX instead of 3X.
> The compiler (g77) outputs and error "nrecognized FORMAT specifier"
>
> Is there any way to achive the same result?
I don't see exactly what your desired sesult is, but the following
program does something similar.
Use a character vriable for the format. You can modify it as needed
in the program.
* modified:
PROGRAM MAIN
CHARACTER*9 STR
INTEGER N, val(3)
CHARACTER*8 format
DATA STR /'123456789'/
DATA format / '(##I3)' /
N = 3
write(format(2:3), '(i2)') N
READ(STR, format) VAL
* 100 FORMAT(NX,I3) ! no longer needed
WRITE(6, 101) VAL
101 FORMAT(I3)
END
Hope this helps you a bit.
Jan van Oosterwijk
jan dot vanoosterwijk at wanadoo dot nl
| |
| jan van oosterwijk 2004-03-27, 12:18 am |
| nobyjos@indiatimes.com (Noby) wrote in message news:<1528aa0c.0403250358.c9568a@posting.google.com>...
> Hi
>
>
> I have a problem with Runtime Edit descriptors in FORMAT statements.
* modifications by [JvO]
> PROGRAM MAIN
>
> CHARACTER*7 STR
> INTEGER N
integer val
character*8 format
>
> DATA STR/'1234567'/
data format / '(#x,I3)' /
> N=3
>
write(format(2:2), I1) n
read (str, format) val
> * READ(STR,100)VAL
> * 100 FORMAT(NX,I3);
> WRITE(6,101)VAL
> 101 FORMAT(I3)
>
> END
>
> In the format statement(100) of READ, I have use NX instead of 3X.
> The compiler (g77) outputs and error "nrecognized FORMAT specifier"
>
> Is there any way to achive the same result?
After second reading a more precise answer to your question.
> Noby Jose.
[JvO]
|
|
|
|
|