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 

Hollerith stings again

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



Joined: 31 Oct 2006
Posts: 1430

PostPosted: Wed Jul 08, 2020 5:09 am    Post subject: Hollerith stings again Reply with quote

Hollerith fields in Format statements are "deleted" in Fortran 95, but Fortran compilers continue it to support it. While working with an old Fortran program with copious instances of Format statements with Hollerith edit descriptors, I discovered a perplexing bug in FTN95 8.63. Here is a bug demonstrator, in fixed form source:

Code:
C
      PROGRAM HOLLERITH_BUG
*        1         2         3         4         5         6         7
*23456789 123456789 123456789 123456789 123456789 123456789 123456789 12XXXXXXXX
      WRITE (*,10)
   10 FORMAT (//,2X,39HWARNING: 1) Hollerith fields in Format ,
     + 29Hspecifications can cause bugs,/,22X,23Has you will see in this
     + ,9H example.)
      WRITE (*,20)
   20 FORMAT (9X,49H2) Especially problematic are circumstances such
     2 ,37Has this example with two such formats)
      WRITE (*,*)
      END


The compiler says:

Code:
[FTN95/Win32 Ver. 8.63.0 Copyright (c) Silverfrost Ltd 1993-2020]
0009)       WRITE (*,20)
*** Continuation of Hollerith strings is not supported

    1 ERROR [hbug.F] - Compilation failed.

The wording of the error message suggests that the compiler objects to one of the two FORMAT statements rather than the WRITE statement. After trying several changes to the two FORMAT statements, I found that what may be happening is as follows.

Line 10 contains a Hollerith descriptor of stated length 49. That implies that the line should contain a space character at the end of the line before EOL. However, most text editors remove trailing spaces from program source lines, and Fortran compilers pad fixed form source line ends with blanks. FTN95 does not appear to do so, and in most circumstances it would not matter, but not here. It probably finds only 48 characters before EOL, and issues the error message. To test this, I placed a character in column 73 of that line, and that made the error message go away.


Last edited by mecej4 on Wed Jul 08, 2020 10:33 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6593
Location: Salford, UK

PostPosted: Wed Jul 08, 2020 8:15 am    Post subject: Reply with quote

mecej4

Thank you for the bug report. I have logged as needing attention.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2187
Location: Yateley, Hants, UK

PostPosted: Wed Jul 08, 2020 9:36 am    Post subject: Reply with quote

That looks like a hard one to catch - although interesting to see how you set out the demonstrator, as in most old Fortran FORMATs with Holleriths they were written in capitals only. Seeing that in someone else's old code might alert me to an issue with line length (maybe, if I was having a good day).

As a matter of style, I always avoided Holleriths that ran over into a continuation line because I found them difficult to read, and doubly difficult to edit the FORMAT without causing errors. Once, in a moment of forgetfulness, I tried to concatenate two strings in a FORMAT using // as you might somewhere other than there. It doesn't work - for obvious reasons, as // means something else in a FORMAT. I put it down to tiredness.

Incidentally, in helping someone with old code I found that their original compiler had been less fussy about commas in FORMAT statements than FTN95, or probably the Standard (or even than I am).

Good catch.

Eddie

And yes, sometimes these things do sting - again and again.


Last edited by LitusSaxonicum on Wed Jul 08, 2020 10:48 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6593
Location: Salford, UK

PostPosted: Wed Jul 08, 2020 10:38 am    Post subject: Reply with quote

This bug has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support 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