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

random value for ierror from pxfreaddir

Chris_Payne
Beginner
470 Views
Once the end of the directory entries is reachedpxfreaddir returns a random value for the error code. So far I've seen 0, 2, 17, 25, and 128. I'm usingRHEL 5.5, intel64, compiler versions 11.1.72 and 12.0.1.107. No compiler flags.

Edit: The code displayed has apparant syntax errors. They are not present when editing the post - just when displaying it.

[fxfortran]	program rd
	use ifposix
	use ifcore
	implicit none
	
	character*255:: dir
	integer*4    :: dirent
	integer*4    :: dirid
	integer*4    :: ios, i
	
	dir = '.'
	
	! ==================================
	! Allocate an instance of the POSIX directory entry structure
	! ====================================
	call pxfstructcreate('dirent',dirent, ios)
	if (ios /= 0) then
	   call perror('Could not create direct instance')
	   call exit(1)
	end if
	
	! =======================================
	! Open the directory
	! =========================================
	call pxfopendir(dir, len_trim(dir), dirid, ios)
	if (ios /= 0) then
	   call perror('Could not open directory ' // dir)
	   call exit(1)
	end if
	
	write (6,*) 'opendir ios = ', ios
	write (6,*) 'dirid = ', dirid
	write (6,*) 'dirent = ', dirent
	
	! ====================================
	! Read every entry in the directory
	! ====================================
	ios = 0
	i = 0
	do while (ios == 0)
	   ! ===============================
	   ! Get the next directory entry
	   ! =======================================
	   ios = 0
	   call pxfreaddir(dirid, dirent, ios)
	   select case (ios)
	   case (0)
	      i = i + 1
	   case (2)
	      ! end of list, I think...
	   case default
	      write (6,*) 'ios = ', ios
	      call perror('Error reading directory ' // dir(:len_trim(dir)))
	   end select
	end do
	
	! ==========================
	! Close the directory
	! ============================
	call pxfclosedir(dirid, ios)
	
	write (6,*) 'read ', i, ' directory entries'
	
	end
	
[/fxfortran]
0 Kudos
2 Replies
Kevin_D_Intel
Employee
470 Views
I had no success producing any error code other than 128. I ran the same executable repeatedly from within same directory and different directories. The program executes correctly and reports a different number of entries for each unique directory that I tried and the final error code is always 128.

Does anyone else see a random error code?
0 Kudos
mecej4
Honored Contributor III
470 Views
Does anyone else see a random error code?

No, I see only the expected results, and consistently so, on (a) Linux Intel64, 11.1.073 and (b) Linux Itanium using 11.1.072.
0 Kudos
Reply