Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Namelist problem

Averkov__Igor
Beginner
774 Views

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!

0 Kudos
4 Replies
mecej4
Honored Contributor III
774 Views

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.

0 Kudos
Averkov__Igor
Beginner
774 Views

Maybe there is an option to ignore the unknown parameters, when reading namelist ?

0 Kudos
TimP
Honored Contributor III
774 Views

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.

0 Kudos
Averkov__Igor
Beginner
774 Views

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

0 Kudos
Reply