On Sun, Sep 7, 2014 at 7:35 AM, Jerry DeLisle <jvdeli...@charter.net> wrote: > On 06/09/14 21:08, Janne Blomqvist wrote: >> On Sun, Sep 7, 2014 at 12:51 AM, Jerry DeLisle <jvdeli...@charter.net> wrote: >>> Hi, >>> >>> The attached patch adds a compile time check for negative unit numbers >>> given in >>> an INQUIRE statement. A new test case is provided and one updated. >> >> What about units opened with newunit= ? Those have negative unit >> numbers. It seems strange that one wouldn't be allowed to inquire such >> units? Or if that indeed is the case, I suggest it's a bug in the >> standard (one can imagine such happening by forgetting to update >> inquire constraints after adding newunit= in f2003). >> >> program negunit >> implicit none >> logical :: file_exists >> integer :: u >> open(newunit=u, file="test.dat") >> inquire(unit=u, exist=file_exists) >> write(*,*) u, file_exists >> close(u, status="delete") >> end program negunit >> > > I was thinking of the same issue. The front end patch is correct.
Is it? Is it really the intention that negative units are allowed if the specifier is a variable, but not if it is a constant? Consider the following, admittedly silly, example modified from the previous one: program negunit implicit none logical :: file_exists integer :: u open(newunit=u, file="test.dat") ! By secret magic I know that u=-10 inquire(unit=-10, exist=file_exists) write(*,*) u, file_exists close(u, status="delete") end program negunit Is this not conforming while the previous one is? Sounds a bit strange? > But I need to > work further on the run time side. NEWUNIT presents a particular problem. The > INQUIRE should search the treap for the negative unit and if found, return > true. > Having the negative unit number by itself is not sufficient. Isn't it enough to just remove any checks for the unit number being positive? -- Janne Blomqvist