Silverfrost Forums

Welcome to our forums

variable formatting error

19 Nov 2020 10:39 #26618

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

19 Nov 2020 11:43 #26619

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

20 Nov 2020 1:10 #26620

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.

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:

    1
    2
    3
    4
    5
     6
      7
       8
        9
        10
20 Nov 2020 10:52 #26621

I liked this extension at the times of DEC Fortran and always wanted it to be included into this compiler

20 Nov 2020 9:56 #26622

Quoted from wahorger 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

20 Nov 2020 9:59 #26623

Quoted from mecej4 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.

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:

    1
    2
    3
    4
    5
     6
      7
       8
        9
        10

Thanks for the info mecej4. I will check it out. offthechart

20 Nov 2020 10:01 #26624

Quoted from DanRRight 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

Please login to reply.