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 

Namelist problems

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



Joined: 09 May 2008
Posts: 6

PostPosted: Thu Jul 29, 2010 10:07 am    Post subject: Namelist problems Reply with quote

I'm having a real fight with NAMELIST. Not trying to do anything special, just dump the contents of a common block to a file and then read them back in next time the program is run.

It appears to be massively sensitive to the order in which the variables appear in the file. However, the default order in which they get written does _not_ work.

For instance, this file gets read just fine.

Code:

&MENUSLIST
ASSOCIATE = '1                                                                               '
TITLE = '4                                                                               '
ROWHEAD = '3                                                                               '
PROGNAME = '2                                                                               '
LINE = '6                                                                               ' '                                                                                ' '                                                                                ' '                                                                                '
'                                                                                ' '                                                                                ' '                                                                                ' '                                                                                '
'                                                                                ' '                                                                                ' '                                                                                ' '                                                                                '
'                                                                                ' '                                                                                ' '                                                                                ' '                                                                                '
'                                                                                ' '                                                                                ' '                                                                                ' '                                                                                '
/


This one fails with "Error 204, invalid identifier in namelist input group".

[code:1:0edcc70dbb]
&MENUSLIST
ASSOCIATE = '1 '
PROGNAME = '2 '
TITLE = '4 '
ROWHEAD = '3 '
LINE = '6 ' ' ' ' ' ' '
' ' ' ' ' ' ' '
' ' ' ' ' ' ' '
'
Back to top
View user's profile Send private message
Catherine Rees Lay



Joined: 09 May 2008
Posts: 6

PostPosted: Thu Jul 29, 2010 10:11 am    Post subject: Reply with quote

Ack! Post looks fine in preview, is a total mess on the forums.

Summary of rest of post: the order in which FTN95 outputs this NAMELIST is the one which does _not_ work when reading it back in. Any suggestions?
Back to top
View user's profile Send private message
brucebowler
Guest





PostPosted: Thu Jul 29, 2010 1:10 pm    Post subject: Reply with quote

how are the variables defined in the program and does "LINE" really have all those single quotes?
Back to top
Catherine Rees Lay



Joined: 09 May 2008
Posts: 6

PostPosted: Thu Jul 29, 2010 1:40 pm    Post subject: Reply with quote

LINE looks like it does in the first example give or take a bit of wordwrapping - it's an array with 20 elements, each an 80 character string. The quotes are paired correctly on the lines in the file. I don't know why the forum messed up the post for the second CODE segment, but editing it didn't help Sad

Declarations:

INTEGER*4 MAXLINES
PARAMETER(MAXLINES=20)
CHARACTER*80 ASSOCIATE,PROGNAME,TITLE,ROWHEAD,LINE(MAXLINES),

COMMON/MENUS/ ASSOCIATE,PROGNAME,TITLE,ROWHEAD,LINE,

NAMELIST /MENUSLIST/ ASSOCIATE,PROGNAME,TITLE,ROWHEAD,LINE,

All values have been initialised to ' ' in code.

Write statement:
WRITE(99,MENUSLIST)

Read statement:
READ(99,MENUSLIST)

This fails with the file produced by the above WRITE statement, but I can make it pass if I alter the order of the lines in the file by hand.

Really very anodyne Smile

What I don't understand is why the order of the NAMELIST variables matters, and, if it does matter, why the required order is not the order they are written out in, or the order in the declarations, the COMMON block, or the NAMELIST statement.

The only difference between the two files is that in the one which works, I moved the "PROGNAME = " line in its entirety from being the second line in the file to being the fourth.
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Thu Jul 29, 2010 8:13 pm    Post subject: Reply with quote

Hi Catherine

I could not get your code to work either.

I think there's a bug in FTN95 reading NAMELIST character strings which match leading characters of FORTRAN keywords!. At least it seems so to me Very Happy. The bug doesn't seem to effect other data types.

Below is my code, which does work!

All I did was change the name of your PROGNAME variable to XPROGNAME. The order of the data in the files is not supposed to matter.

Perhaps Paul could look at this for you to confirm if its a bug?

David

Code:

PROGRAM MAIN

   INTEGER MAXLINES, I
   PARAMETER(MAXLINES=20)
   CHARACTER*100 ASSOCIATE,XPROGNAME,TITLE,ROWHEAD,LINE(MAXLINES)

   NAMELIST /MENUSLIST/ ASSOCIATE,XPROGNAME,TITLE,ROWHEAD,LINE

   ! Set all character arrays to values
   ASSOCIATE = 'A'
   XPROGNAME = 'B'
   TITLE = 'C'
   ROWHEAD = 'D'
   LINE = 'E'

   OPEN(99,FILE='MENUSFILE')
   WRITE(99,MENUSLIST)
   CLOSE(99)

   ! corrupt variables
   ASSOCIATE = 'X'
   XPROGNAME = 'X'
   TITLE = 'X'
   ROWHEAD = 'X'
   LINE = 'X'
   
   ! Read file back in and print
   OPEN(99,FILE='MENUSFILE')
   READ(99,MENUSLIST)
   CLOSE(99)

   PRINT *,ASSOCIATE
   PRINT *,XPROGNAME
   PRINT *,TITLE
   PRINT *,ROWHEAD
   DO I=1,MAXLINES
      PRINT *,LINE(I)
   END DO
END PROGRAM MAIN
Back to top
View user's profile Send private message
Catherine Rees Lay



Joined: 09 May 2008
Posts: 6

PostPosted: Mon Aug 02, 2010 9:36 pm    Post subject: Reply with quote

Thanks David! I didn't think of that, though one of my first guesses was to wonder if there was something subtle with TITLE because it looked like the sort of thing which might be used for something else.

I'll send the example to Paul - I also think it has to be a bug. There are so few controls on NAMELIST read and writes that there's not much to get wrong.

(goes off to stick Xs on the front of all her common variables...)
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1884

PostPosted: Sat Apr 14, 2018 3:49 pm    Post subject: Reply with quote

I hesitate to refresh this really old thread, but I find that the Namelist problem described here still afflicts FTN95 V 8.1, including the new 64-bit compiler.

Furthermore, when compiled with /64, the program aborts with an access error, instead of simply (if incorrectly) stating that the input data contains an invalid namelist item name, as the 32-bit program does. To receive with /64 the more specific, but still incorrect, message, namely, "*** Error 204, Invalid identifier in namelist input group", one has to compile with a debug option.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2551
Location: Sydney

PostPosted: Sun Apr 15, 2018 7:27 am    Post subject: Reply with quote

mecej4,

I tried (an adaptation of) davidb's example of Fri Jul 30, 2010

It worked for CheckMate x64, but failed with Release x64 or Debug x64
However it worked for CheckMate, Release Win32 and Debug Win32.
A problem with SetMaximumIOBufferSize

NAMELIST has long been problematic with FTN95
Using "WRITE(99,MENUSLIST)" does look to be an easy way to manage data settings, although the way CHARACTER*100 LINE(MAXLINES) is handled doesn't look too friendly. This could be related to the error.

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 16, 2018 11:10 am    Post subject: Reply with quote

I haven't acknowledged this so I must have missed it.
I will look at davidb's code now.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 16, 2018 12:48 pm    Post subject: Reply with quote

It is not something simple.
I have made a note that it needs investigating.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 16, 2018 5:04 pm    Post subject: Reply with quote

This 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 -> 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