/* inout.h      --      header def's for inout.c        jpb 6/24/95 */


#define NUM_FMT 1       /* 0 IEEE Little Endian (80x86, DEC Risc) */
			/* 1 IEEE Big Endian (SPARC, SGI, Motorola, etc.) */
#define PREC 1          /* storing Matlab file as floats rather than longs */
#define PTYPE float     /* internal representation of float numbers */
#define BYTE unsigned char

			/* Matlab Level 1.0 format data file header */
typedef struct {
	long type;      /* type */
	long mrows;     /* row dimension */
	long ncols;     /* column dimension */
	long imagf;     /* flag indicating imag part */
	long namelen;    /* name length (including NULL) */
} Fmatrix;


extern unsigned int hxsize, hysize;       /* size of height matrix */
extern unsigned int xsize, ysize;       /* size of input matrix */

extern float *hf;                              /* elevation array (height field) */
extern float *ua;                              /* uphill area array */
extern float *bn;                              /* basin accumulation array */

extern BYTE *fl;                               /* array of flow directions */
extern BYTE *flag;                             /* array of checked, peak flags */
extern int xo[9],yo[9];                      /* 8-dir index offset arrays */
extern int x4[4],y4[4];                      /* 4-dir index offset arr */
extern int dhash[9];                         /* 8-direction hash mx */


int hf_read(char *fname);           /* read in heightfield from <fname> */
int hf_read2(char *fname);                /* obsolete */
int hf_write(char *fname);                /* print out hf array to file */
int pgm_write(char *fname, float *array);  /* write out an array to disk */
int pgm_write_hf(char *fname, float *array);  /* write out an array to disk */
int read_mfile(char *fname);
int write_mfile(char *fname, char *pname, PTYPE *hh, 
   unsigned int xsize, unsigned int ysize);
int write_mfile1(char *fname, char *pname, PTYPE *hh, 
   unsigned int xsize, unsigned int ysize);

void edge_fill();                       /* fill in edges of hf array */

void hf_print();                        /* print out hf array to stdout */
void fl_print();                        /* print out fl flow array */
void flag_print();                      /* print flags array */
void fl_p2();                           /* print out fl as graph */
void fl_p3();                           /* print out flag as graph */
void ar_print(float *ar);               /* print an array */


