[gradsusr] Reading 3d variable in FORTRAN after using fwrite

Thomas Robinson ter at hawaii.edu
Fri Apr 27 20:56:52 EDT 2012


Aloha,

I used fwrite to write out a 2d variable that varies in time, so it has
dimensions of x,y,t.

nt=763
'set fwrite -le -sq -cl CHI.2000.summer.dat'
'set gxout fwrite'
day = 360
while (day <= nt)
 'set t ' day
 'd chi'
  day=day+1
endwhile
'disable fwrite'

This seems to work fine.  When I go to try to open it using FORTRAN, I get
an error.

       real chi (nx,ny,nt)
       open (29, file="CHI.2000.summer.dat", status="OLD",
     &      access="sequential",form="unformatted")
        read(29)chi

If I have my chi variable as (nx,ny) there is no problem.  If I just set
nt=2, then there is a problem when I run the program:
PGFIO-F-219/unformatted read/unit=29/attempt to read/write past end of
record.
 File name = CHI.2000.summer.dat    unformatted, sequential access   record
= 1
 In source file avg_chi.f, at line number 25


I was feeling saucey and tried to change the code up adding
      real chi_temp(nx,ny)
and I tried this:
      do 50 it=1,nt
        write (6,*)it
        read (29)chi_temp
           do 51 ix=1,nx
           do 52 iy=1,ny
              chi(ix,iy,it)=chi_temp(ix,iy)
52        continue
51        continue
50    continue

And this is what happened:
            1
            2
            3
            4
PGFIO-F-217/unformatted read/unit=29/attempt to read past end of file.
 File name = CHI.2000.summer.dat    unformatted, sequential access   record
= 4
 In source file avg_chi.f, at line number 29

I should have about 300 time steps.  Is there a limit or something?  Any
help you could provide would be very much appreciated!

-- 
Tom Robinson
At-Large Graduate Student Organization Representative
Student Caucus Representative for the Graduate Student Organization
Graduate Student - Department of Meteorology
732-718-2323
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20120427/16f46108/attachment-0003.html 


More information about the gradsusr mailing list