- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see in intel fortran and elsewhere that a pointer cannot be specified in a NAMELIST statement; however, when I do so anyway, no compiler errors occur. Furthermore, it seems to work just fine in that reading the namelist file updates the pointer and associated target as expected.
Given that it is not supposed to work, I won't use it, but why does it work at all (or have I misread something)?
cheers,
-joe
where test.data is:
Given that it is not supposed to work, I won't use it, but why does it work at all (or have I misread something)?
cheers,
-joe
[fortran]module glob implicit none integer, parameter:: n = 10 real(8), target:: x(n) real(8), pointer:: ptox1, ptox2 namelist /test/ x, ptox1 contains subroutine initialize () ptox1 => x(1) ptox2 => x(2) return end subroutine initialize end module glob program pointertests use glob implicit none call initialize () open(unit=1,file='test.dat',status='old') read(1,nml=test) close(unit=1) write(6,*) 'x: ', x(1:2) write(6,*) 'ptox1: ', ptox1 write(6,*) 'ptox2: ', ptox2 stop end program pointertests[/fortran]
where test.data is:
[plain]&test x(1:2) = 1.0, 2.0 ptox1 = 10. /[/plain]
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is legal in Fortran 2003. If you ask for F90 or F95 standards checking, it will complain.

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