forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

variable formatting error

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
offthechart



Joined: 04 Dec 2013
Posts: 17

PostPosted: Thu Nov 19, 2020 11:39 pm    Post subject: variable formatting error Reply with quote

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
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Nov 20, 2020 12:43 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Fri Nov 20, 2020 2:10 am    Post subject: Reply with quote

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
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Fri Nov 20, 2020 11:52 am    Post subject: Reply with quote

I liked this extension at the times of DEC Fortran and always wanted it to be included into this compiler
Back to top
View user's profile Send private message
offthechart



Joined: 04 Dec 2013
Posts: 17

PostPosted: Fri Nov 20, 2020 10:56 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
offthechart



Joined: 04 Dec 2013
Posts: 17

PostPosted: Fri Nov 20, 2020 10:59 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
offthechart



Joined: 04 Dec 2013
Posts: 17

PostPosted: Fri Nov 20, 2020 11:01 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group