- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HelloI
I use the namelist to save the data to a file. If some variables in the namelist change places or if a new variable is added to the namelist, there is no problem when data are reading from the file. But if even one variable is deleted from the namelist, so other variables in the namelist can not be read from the file any more.
How can i read the data from the file if one variable is deleted from the namelist?
Thank you in advance!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A namelist input list should not contain a name-value pair where the name is not in the declaration of the namelist. See this quotation from the Fortran 2008 Standard, 10.11.2-2: Each object designator shall begin with a name from the namelist-group-object-list (5.6) and shall follow the syntax of ...
Instead of deleting items from the namelist, you could leave the items in the declaration, and simply not use the (conceptually) deleted items in the rest of your code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe there is an option to ignore the unknown parameters, when reading namelist ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Believe it or not, over 40 years ago we solved this problem by adding compiler-dependent code to re-process the input when the namelist read throws an error. I don't know that standardizing this was ever considered, nor even whether the recovery possibilities are documented for current compilers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4 wrote:
Instead of deleting items from the namelist, you could leave the items in the declaration, and simply not use the (conceptually) deleted items in the rest of your code.
Thank you, it seems to be the only way

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page