×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Write line delimiter question

Write line delimiter question

Write line delimiter question

(OP)
I'm trying to help someone else at work by writing a program for them. They use a Fortran program to analyse certain datasets. They need the data in a certain format though. The data being processed are raster images. The format the data needs to be in starts with 7 numbers, these are the X min and max, the Y max and min, the width of each cell, the height of each cell and the number value for "no data" cells. After this, the actual data is written. It as stored in a series of rows. The data file is all in binary format rather than ASCII format.

If you don't follow, don't worry. The point is, the code writes each line of data with the following commands:

do i=1,m
write (30) (a(i,j),j=1,n)
enddo

where n is the width of the array and m is the height. This writes a series of numbers into the file, in this case they are 4 byte real numbers. However, each row of numbers has a 4 byte delimiter at the start and end of each line. The delimiter isn't a constant though. It is the same throughout each output file, but if I give it different input data the delimiter is different. I assume it has some relationship to the data being outputted like the number of columns but the exact line escapes me.

I am using the Force 2.0.7 compiler for this. To help me, I've been given a program that converts and equivalent file in ASCII format into the binary format. The ASCII format version has the first 7 numbers comma delimited then each row of numbers comma delimited and written on a different line. The full source code for this program is as follows:

c program erm_read.for
c Written by Zhiqun Shi, 23rd July 1994
c Revised 2nd August 1994, 31st August 1994, 2nd September
c The function of this program is to read a head of ermapper data file,
c then to determine the coordinate origin of the set of data, spacing
c interval and cell numbers of easting and northing.


character infile*40,outfile*40
Real a(3000000)

print *,' Input file name of grid data ='
read (5,100) infile
print *,' Input the output file name of grid data ='
read (5,100) outfile
100 format(a40)
open(unit=20,file=infile,status='old',form='formatted')
open(unit=30,file=outfile,status='new',form='unformatted')
print *,'Start Reading'
read(20,*) xmin,xmax,ymin,ymax,dx,dy,spec
m=nint((ymax-ymin)/dy)
n=nint((xmax-xmin)/dx)
print *,' xmin=',xmin
print *,' xmax=',xmax
print *,' ymin=',ymin
print *,' ymax=',ymax
print *,' dx=',dx
print *,' dy=',dy
print *,' spec=',spec
print *,' The total number of rows, m=',m
print *,' The total number of columns, n=',n



write (30) xmin,xmax,ymin,ymax,dx,dy,spec
Call data_input(a,m,n)
print *, 'Finish output data'
Stop
End

subroutine data_input(a,m,n)
real a(m,n)
do i=1,m
read (20,*) (a(i,j),j=1,n)
enddo
rewind 20
close (unit=20)

do i=1,m
write (30) (a(i,j),j=1,n)
enddo
rewind 30

close (unit=30)
return
end

RE: Write line delimiter question

(OP)
Don't worry. I got it. It's the number of bytes each line uses.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close