This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re Namelist IOSTAT behaviour


hi!

Man, this took me some time to track down.

> I think that we need to see the rest of your code before agreeing that there is a bug.

It seems to be related to me having put the namelist definition in a
module. The following code (where input.dat is a file that does not
contain a debugging namelist entry) goes wrong:

MODULE debug
  LOGICAL debug_area
  NAMELIST/debugging/debug_area
END MODULE debug

PROGRAM ding
  USE debug
  IMPLICIT NONE
  INTEGER :: ios
  OPEN(unit=10, status='unknown', file='input.dat')
  READ(unit=10, nml=debugging,  iostat=ios)
  PRINT*, 'nml=debugging',ios
END PROGRAM ding

$ gfortran -o namelistding namelistding.f90 && ./namelistding
 nml=debugging          2

The following works properly:

PROGRAM ding
  IMPLICIT NONE
  LOGICAL debug_area
  NAMELIST/debugging/debug_area
  INTEGER :: ios
  OPEN(unit=10, status='unknown', file='input.dat')
  READ(unit=10, nml=debugging,  iostat=ios)
  PRINT*, 'nml=debugging',ios
END PROGRAM ding

$ gfortran -o namelistding namelistding.f90 && ./namelistding
 nml=debugging          -1

More interesting, the following also works:

MODULE debug
  LOGICAL debug_area
  NAMELIST/debugging/debug_area
END MODULE debug

PROGRAM ding
  USE debug
  IMPLICIT NONE
  NAMELIST/debugging/debug_area
  INTEGER :: ios
  OPEN(unit=10, status='unknown', file='input.dat')
  READ(unit=10, nml=debugging,  iostat=ios)
  PRINT*, 'nml=debugging',ios
END PROGRAM ding

$ gfortran -o namelistding namelistding.f90 && ./namelistding
 nml=debugging          -1

whereas ifort, correctly AFAIK, complains about the redefinition of the
namelist.

Thanks
Neilen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]