/* Some needed defined constants                            */
#define PIC_X 101
#define PIC_Y 101
#define NO_VALUE 100.0

/************************************************************
Input full velocities using Burkitt format
*************************************************************/
input_velocities(fname,velocities,pic_x,pic_y)
unsigned char fname[100];
double velocities[PIC_X][PIC_Y][2];
int *pic_x,*pic_y;
{
float x,y;
float temp[PIC_X][PIC_Y][2];
int i,j,k,bytes,fd,OFFSET_X,OFFSET_Y;

for(i=0;i<PIC_X;i++)
for(j=0;j<PIC_Y;j++)
{
temp[i][j][0] = temp[i][j][1] = NO_VALUE; 
velocities[i][j][0] = velocities[i][j][1] = NO_VALUE; 
}

if((fd = open(fname,O_RDONLY))==NULL)
{
printf("Fatal error in opening file %s\n",fname);
exit(1);
}

/* Original size */
read(fd,&x,4);
read(fd,&y,4);
(*pic_y) = x;
(*pic_x) = y;

/* Size of result data */
read(fd,&x,4);
read(fd,&y,4);

/* Offset to start of data */
read(fd,&x,4);
read(fd,&y,4);
OFFSET_Y = x;
OFFSET_X = y;
bytes = 24;

for(i=OFFSET_Y;i<(*pic_y)-OFFSET_Y;i++)
{
bytes += read(fd,&temp[i][OFFSET_X][0],((*pic_x)-(2*OFFSET_X))*8);
}
close(fd);
printf("File %s read - %d bytes - size %d by %d\n",fname,bytes,(*pic_y),(*pic_x));
/* Undo Burkitt format */
for(i=0;i<(*pic_x);i++)
for(j=0;j<(*pic_y);j++)
{
velocities[i][j][0] =  temp[i][j][0];
velocities[i][j][1] = -temp[i][j][1];
}
fflush(stdout);
}


