J3/13-314 To: J3 From: Malcolm Cohen Subject: Namelist interp Date: 2013 September 0 ---------------------------------------------------------------------- NUMBER: F08/0101 TITLE: NAMELIST and multiple occurrences of a variable KEYWORD: NAMELIST DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Consider Program p1 Real :: x = 3, y = 4 Namelist /n/ x, y Write (*,n) End Program According to 5.6, "The order in which the variables are specified in the NAMELIST statement determines the order in which the values appear on output." However, this stops short of saying that the order is the same, merely that it determines it. Perhaps it might be standard-conforming for a processor to always produce the values in reverse order, for example. 10.11.4 does not seem to address the issue of what the order is. Q1: Is the order meant to be the same? Consider Program p2 Real :: x = 3, y = 4 Namelist /n/ x, y, x Write (*,n) End Program This program did not conform to Fortran 90, but does conform to Fortran 2003 and later. The Fortran 2008 standard says (5.6p2): "The order in which the variables are specified in the NAMELIST statement determines the order in which the values appear on output." However, there are only two variables in the NAMELIST statement, X and Y. Therefore it seems to be ambiguous whether the output should be something like &N X=3 Y=4 / or &N Y=4 X=3 / Some compilers produce &N X=3 Y=4 X=3 / but this is not an ordering of the variables X and Y. Q2. Is this program intended to conform to the standard, and if so, what is the intended output? ANSWER: A1. Yes, the order is meant to be the same. An edit is supplied to clarify this. A2. The program was intended to conform to the standard, and the output was intended to be the third option. An edit is supplied to correct the text in 5.6. ALTERNATIVE ANSWER for A2: A2. The program was intended to conform to the standard, but the output is processor dependent. An edit is supplied to correct the text in 5.6. ALTERNATIVE ALTERNATIVE ANSWER for A2: A2. The program does not conform to the standard, as no interpretation is established for it. An edit is supplied to remove the faulty and useless feature. EDIT: [111:13-14] 5.6p2, replace entire paragraph with "The order in which the values appear on output is the same as the order of the s in the namelist group object list; if a variable appears more than once as a for the same namelist group, its value appears once for each occurrence". EDIT ALTERNATIVE ONE: [111:13-14] 5.6p2, replace entire paragraph with "The order in which the values appear on output is the same as the order of the s in the namelist group object list, except that if a variable appears more than once as a for the same namelist group, it is processor dependent which position its value appears on output, or whether it appears in more than one of those positions." EDIT ALTERNATIVE TWO: [111:12+] 5.6, after constraint C586, Insert new constraint "C586a The same shall not be specified more than once as a for the same namelist group." [111:13-14] 5.6p2, replace sentence with "The order in which the values appear on output is the same as the order of the variables in the namelist group object list." SUBMITTED BY: Malcolm Cohen HISTORY: m202 13-nnn F08/0101 submitted ----------------------------------------------------------------------