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: can't read /proc/cpuinfo


jvdelisle@verizon.net wrote:
Timothy C Prince wrote:
with gfortran 4.3 20070615, on x86-64 linux
open(11,file='/proc/cpuinfo',action='READ',iostat=ios)

apparently succeeds (ios == 0)

but then

read(11,'(a)',iostat=ios)txtline

immediately gives ios == -1

Did I miss something obvious?

I suppose it is possible to do
system("cat /proc/cpuinfo > txtfile")
and open that file, similar to what I do to capture uname data, but I preferred the scheme of reading directly, as ifort can do.
Tim Prince


This seems to be closer. Each read gets a lines worth:

   character(256) :: astring
   astring = ""
   open(11,file='/proc/cpuinfo', form="formatted" , access="stream")
   do i= 1, 10
   read(11,'(a)') astring
   print '(a)', astring
   end do
   end

I do want to look into why your approach does not work.

OK, my source works with just the pre-processor conditional switch between the different OPEN parameters required by the two compilers. Maybe ifort will work with the same OPEN as gfortran, once the stream keyword is accepted.


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