View previous topic :: View next topic |
Author |
Message |
offthechart
Joined: 04 Dec 2013 Posts: 17
|
Posted: Thu Nov 19, 2020 11:39 pm Post subject: variable formatting error |
|
|
I entered this simple code I copied from a Fortran manual and tried compiling, since I have use for this type of formatting tool.
DIMENSION A(5)
DATA A/1.,2.,3.,4.,5./
DO 10 I=1,10
WRITE (6,100) I
100 FORMAT (I<MAX(I,5)>)
10 CONTINUE
The error message was'
0224 DIMENSION A(5)
0225 DATA A/1.,2.,3.,4.,5./
0226 DO 10 I=1,10
0227 WRITE (6,100) I
0228 100 FORMAT (I<MAX(I,5)>)
ERROR C:\users\.....\elect.F 228: Missing width count for 'I' descriptor
ERROR C:\users\...\elect.F 228: Unknown edit descriptor '<', or missing comma
0229 10 CONTINUE
I have W7 64 bit with version 7.00 Silverfrost. Any ideas? There must be a easy answer..?? thanks |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Nov 20, 2020 12:43 am Post subject: |
|
|
Given the error message, it is unlikely to be supported.
What version of FORTRAN did you copy the code from? What is this formatting syntax intended to do?
There are usually ways around, or through, limitations.
Bill |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Nov 20, 2020 2:10 am Post subject: |
|
|
The code snippet uses a nonstandard Fortran extension called "Variable Format Expression" or "VFE". See http://fortranwiki.org/fortran/show/IO+list+references+in+format+strings for more details.
The following code does what seems to be desired. There are many alternative ways of doing the same.
Code: | PROGRAM VFE
IMPLICIT NONE
INTEGER I
CHARACTER(4) :: FMT = '(I5)'
DO I=1, 5
WRITE (*,FMT) I
END DO
DO I = 6, 9
FMT(3:3) = CHAR(ICHAR('0')+I)
WRITE (*,FMT)I
END DO
WRITE(*,'(I10)')I
END |
The output:
Code: | 1
2
3
4
5
6
7
8
9
10 |
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Fri Nov 20, 2020 11:52 am Post subject: |
|
|
I liked this extension at the times of DEC Fortran and always wanted it to be included into this compiler |
|
Back to top |
|
|
offthechart
Joined: 04 Dec 2013 Posts: 17
|
Posted: Fri Nov 20, 2020 10:56 pm Post subject: Re: |
|
|
wahorger wrote: | Given the error message, it is unlikely to be supported.
What version of FORTRAN did you copy the code from? What is this formatting syntax intended to do?
There are usually ways around, or through, limitations.
Bill |
Thanks Bill. I thought this would be useful, but I am trying a work around. The compiler obviously does not like it.
offthechart |
|
Back to top |
|
|
offthechart
Joined: 04 Dec 2013 Posts: 17
|
Posted: Fri Nov 20, 2020 10:59 pm Post subject: Re: |
|
|
mecej4 wrote: | The code snippet uses a nonstandard Fortran extension called "Variable Format Expression" or "VFE". See http://fortranwiki.org/fortran/show/IO+list+references+in+format+strings for more details.
The following code does what seems to be desired. There are many alternative ways of doing the same.
Code: | PROGRAM VFE
IMPLICIT NONE
INTEGER I
CHARACTER(4) :: FMT = '(I5)'
DO I=1, 5
WRITE (*,FMT) I
END DO
DO I = 6, 9
FMT(3:3) = CHAR(ICHAR('0')+I)
WRITE (*,FMT)I
END DO
WRITE(*,'(I10)')I
END |
The output:
Code: | 1
2
3
4
5
6
7
8
9
10 |
|
Thanks for the info mecej4. I will check it out.
offthechart |
|
Back to top |
|
|
offthechart
Joined: 04 Dec 2013 Posts: 17
|
Posted: Fri Nov 20, 2020 11:01 pm Post subject: Re: |
|
|
DanRRight wrote: | I liked this extension at the times of DEC Fortran and always wanted it to be included into this compiler |
It would be useful for sure. Thanks
offthechart |
|
Back to top |
|
|
|