APPENDIX  D

 Reading and Writing HydroBase 2 station files



To permit each profile to be self-describing in the number and order of its properties, the following C data structures have been implemented .
#define MAXPROP 29
enum property { PR, DE, TE, TH, SA, OX, O2, N2, N3, P4, SI, HT, PE, S0, S1, S2, S3, S4, S_, BF, PV, SV, VA, F1, F2, HE, TU, GN, GE};

#define NBHEAD 76 /* # of bytes in header including LF */
#define NBSEP 3 /* # of bytes separating stations incl LF */
#define NQUAL 4 /* # of bytes for quality control id */

struct HYDRO_HDR {
char country[3], ship[3]; /* 2 char code + end-of-string char */
char origin, instrument; /* 1 char codes */
int cruise, station, year, month, day;
float lat, lon;
int pdr, nobs, nprops, ms10, ms1;
int *prop_id; /* index to observ_prop identifiers */
char qual[NQUAL]; /* quality control bytes */
};

struct HYDRO_DATA {
int nobs, nprops;
double *observ[MAXPROP];
};


The file hydro_utils.c contains the following functions for reading and writing HydroBase station files:
int open_hydro_file(char *, char *, char *, int );
int get_station(int, struct HYDRO_HDR *, struct HYDRO_DATA *);
int read_hydro_hdr(int, struct HYDRO_HDR *);
void report_status(int, FILE *);
int get_data_scan(int, double *, int, int *);
int get_separator(int );
int create_hydro_file(char *, int );
int write_hydro_station(int, struct HYDRO_HDR *, struct HYDRO_DATA *);
int write_hydro_hdr(int, struct HYDRO_HDR *);
int write_hydro_scan(int, double *, int, int *);
int write_separator(int);
int ms10(float, float, int *);
int available(enum property, struct HYDRO_HDR *);
void list_origin(FILE *);
void list_instrument(FILE *);