|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Catherine Rees Lay
Joined: 09 May 2008 Posts: 6
|
Posted: Thu Jul 29, 2010 10:07 am Post subject: Namelist problems |
|
|
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 |
|
|
Catherine Rees Lay
Joined: 09 May 2008 Posts: 6
|
Posted: Thu Jul 29, 2010 10:11 am Post subject: |
|
|
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 |
|
|
brucebowler Guest
|
Posted: Thu Jul 29, 2010 1:10 pm Post subject: |
|
|
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
|
Posted: Thu Jul 29, 2010 1:40 pm Post subject: |
|
|
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
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
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 |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Jul 29, 2010 8:13 pm Post subject: |
|
|
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 . 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 |
|
|
Catherine Rees Lay
Joined: 09 May 2008 Posts: 6
|
Posted: Mon Aug 02, 2010 9:36 pm Post subject: |
|
|
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 |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1895
|
Posted: Sat Apr 14, 2018 3:49 pm Post subject: |
|
|
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 |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2560 Location: Sydney
|
Posted: Sun Apr 15, 2018 7:27 am Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7938 Location: Salford, UK
|
Posted: Mon Apr 16, 2018 11:10 am Post subject: |
|
|
I haven't acknowledged this so I must have missed it.
I will look at davidb's code now. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7938 Location: Salford, UK
|
Posted: Mon Apr 16, 2018 12:48 pm Post subject: |
|
|
It is not something simple.
I have made a note that it needs investigating. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7938 Location: Salford, UK
|
Posted: Mon Apr 16, 2018 5:04 pm Post subject: |
|
|
This has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
|
|
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
|