PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

error with pgf 12.2 64 bit linux

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
bbernieb



Joined: 21 Jul 2004
Posts: 11

PostPosted: Sun Apr 22, 2012 12:11 pm    Post subject: error with pgf 12.2 64 bit linux Reply with quote

I have a short snipped of code that works fine with older version of pgf95 and does not work correctly with pgf12.2. Here is the reproducer code :

Code:

      integer ,allocatable,dimension(:) :: refimax,refjmax,refkmax
      open(11,file='test.grid.in',status='new',form='unformatted')
      write(11) 2
      write(11) 1,2,3,4,5,6
      close(11)
      open(11,file='test.grid.in',status='old',form='unformatted')
      allocate(refimax(1),refjmax(1),refkmax(1))
      ng=1
      read(11,err=7)refimax(1),refjmax(1),refkmax(1)
      write(*,*) '   single grid format detected'
      goto 8
    7 continue
         write(*,*) '   multiple grid format detected'
         rewind(11)
         deallocate(refimax,refjmax,refkmax)
         read(11)ng
         allocate(refimax(ng),refjmax(ng),refkmax(ng))
         read(11)(refimax(ig),refjmax(ig),refkmax(ig),ig=1,ng)
    8 continue

      stop
      end


This type of code is very common in CFD codes reading grid files.

When I run this code with 12.2 I get :

multiple grid format detected
PGFIO-F-219/unformatted read/unit=11/attempt to read/write past end of record.
File name = test.grid.in unformatted, sequential access record = 1
In source file testit2.f, at line number 17

Thanx,
Bernie
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Tue Apr 24, 2012 11:09 am    Post subject: Reply with quote

Thanks Bernie. I've sent a problem report (TPR#18647) to our compiler engineers for further investigation.

- Mat
Back to top
View user's profile
David Gunter



Joined: 15 Sep 2005
Posts: 25

PostPosted: Tue Apr 24, 2012 11:29 am    Post subject: Reply with quote

I get the same error you do for any Fortran compiler. The reason is the way you are writing and then reading the file.

Remember, Fortran assumes each write to an unformatted file (default access is sequential here) is a record. As such, it appends the record length at the beginning and end of the record, typically this adds 4 bytes on either side of the data written.

So the first write of "2" stores 12 bytes: 4 bytes for the number 2, 4 bytes as the record length field on either side. Then you write out "1,2,3,4,5,6". This creates another 4-byte record length field, then the 24 bytes for the data, and another 4 bytes at the end.

The problem arises when you read back data. You read three integers at once. But the record length fields surrounding that first integer you wrote are telling the system that you should only have one integer in the record.

Basically, for unformatted and sequential access files you must read back the data in the same order it was written.

Here is a version that will always compile and run correctly:

Code:
      program tester
      integer,allocatable,dimension(:) :: refimax,refjmax,refkmax
      integer :: i,j,k
      open(11,file='test.grid.in',status='new',form='unformatted')
      write(11) 2
      write(11) 1,2,3,4,5,6
      close(11)
      open(11,file='test.grid.in',status='old',form='unformatted')
      allocate(refimax(1),refjmax(1),refkmax(1))
      ng=1
      read(11) ng
      read(11,err=7)refimax(1),refjmax(1),refkmax(1),i,j,k
      write(*,*) '   single grid format detected'

      go to 8

7     continue
         write(*,*) '   multiple grid format detected'
         rewind(11)
         deallocate(refimax,refjmax,refkmax)
         read(11)ng
         allocate(refimax(ng),refjmax(ng),refkmax(ng))
         read(11)(refimax(ig),refjmax(ig),refkmax(ig),ig=1,ng)
         close(11)
8     continue

      stop
      end program tester
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Wed Apr 25, 2012 10:48 am    Post subject: Reply with quote

Hi Bernie,

FYI, TPR#18687 has been fix with the fix available in the 12.5 compiler. Thanks again for the report.

- Mat
Back to top
View user's profile
bbernieb



Joined: 21 Jul 2004
Posts: 11

PostPosted: Wed Apr 25, 2012 12:47 pm    Post subject: Reply with quote

thanx mat!!!

Bernie
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group