5
|
1 |
#include <stdio.h>
|
|
2 |
#include <stdlib.h>
|
|
3 |
#include <string.h>
|
|
4 |
#include <ctype.h>
|
|
5 |
|
|
6 |
/* The following include file must define a function 'isnan' */
|
|
7 |
/* This function, which returns '1' if the number is NaN and 0*/
|
|
8 |
/* otherwise, could be hand-written if not available. */
|
|
9 |
/* Comment out one of the two following lines, as applicable */
|
|
10 |
#include <math.h> /* for gcc */
|
|
11 |
/* #include <mathimf.h> /\* for Intel icc *\/ */
|
|
12 |
|
|
13 |
#define NaN log(-1.0)
|
|
14 |
|
|
15 |
#define IEXT 0
|
|
16 |
#define FALSE 0
|
|
17 |
#define TRUE 1 /* constants */
|
|
18 |
#define RECL 81
|
|
19 |
|
|
20 |
#define MAXINBUFF RECL+14
|
|
21 |
|
|
22 |
/** Max size of in buffer **/
|
|
23 |
|
|
24 |
#define MAXREAD MAXINBUFF-2
|
|
25 |
/** Max to read 2 less than total size (just to be safe) **/
|
|
26 |
|
|
27 |
#define MAXMOD 30
|
|
28 |
/** Max number of models in a file **/
|
|
29 |
|
|
30 |
#define PATH MAXREAD
|
|
31 |
/** Max path and filename length **/
|
|
32 |
|
|
33 |
#define EXT_COEFF1 (double)0
|
|
34 |
#define EXT_COEFF2 (double)0
|
|
35 |
#define EXT_COEFF3 (double)0
|
|
36 |
|
|
37 |
#define MAXDEG 13
|
|
38 |
#define MAXCOEFF (MAXDEG*(MAXDEG+2)+1)
|
|
39 |
/* index starts with 1!, (from old Fortran) */
|
|
40 |
|
|
41 |
#define RECLEN 80 /* characters excluding line ending(s) */
|
|
42 |
#define MAXMODNAMELENGTH 8
|
|
43 |
/* e.g. IGRF2005 */
|
|
44 |
|
|
45 |
struct model_t{
|
|
46 |
char name[MAXMODNAMELENGTH + 1];
|
|
47 |
double epoch;
|
|
48 |
int max1;
|
|
49 |
int max2;
|
|
50 |
int max3;
|
|
51 |
double yrmin;
|
|
52 |
double yrmax;
|
|
53 |
double altmin;
|
|
54 |
double altmax;
|
|
55 |
double gh[MAXCOEFF]; /* first pair of coeffients */
|
|
56 |
double ghr[MAXCOEFF]; /* second pair; usually 0; rates of change */
|
|
57 |
struct model_t *next;
|
|
58 |
};
|
|
59 |
|
|
60 |
|
|
61 |
/* Subroutines used */
|
|
62 |
|
|
63 |
void print_dashed_line();
|
|
64 |
void print_long_dashed_line(void);
|
|
65 |
void print_header();
|
|
66 |
void print_result(double date, double d, double i, double h, double x, double y, double z, double f);
|
|
67 |
void print_header_sv();
|
|
68 |
void print_result_sv(double date, double ddot, double idot, double hdot, double xdot, double ydot, double zdot, double fdot);
|
|
69 |
void print_result_file(FILE *outf, double d, double i, double h, double x, double y, double z, double f,
|
|
70 |
double ddot, double idot, double hdot, double xdot, double ydot, double zdot, double fdot);
|
|
71 |
double degrees_to_decimal(int degrees,int minutes,int seconds);
|
|
72 |
double julday(int i_month, int i_day, int i_year);
|
|
73 |
int interpsh(double date, double dte1, int nmax1, double dte2, double nmax2,
|
|
74 |
double *gh_Schmidt1, double *gh_Schmidt2, double *gh_model);
|
|
75 |
int extrapsh(double date, double dte1, int nmax1, int nmax2,
|
|
76 |
double *gh_Schmidt1, double *gh_Schmidt2, double *gh_model);
|
|
77 |
void shval3(int igdgc, double flat, double flon, double elev,
|
|
78 |
int nmax, double *gh, int iext,
|
|
79 |
double ext1, double ext2, double ext3,
|
|
80 |
double *x_ptr, double *y_ptr, double *z_ptr);
|
|
81 |
int safegets(char *buffer,int n);
|
|
82 |
int getshc(char *file, int iflag, long strec, int nmax_of_gh,
|
|
83 |
double *gh_Schmidt);
|
|
84 |
|
|
85 |
void dihf(double x, double y, double z,
|
|
86 |
double *d_ptr, double *i_ptr, double *h_ptr, double *f_ptr);
|
|
87 |
|
|
88 |
int models_from_lines(struct model_t ***model_array);
|
|
89 |
int models_from_file(char *filename, struct model_t ***model_array);
|
|
90 |
void free_models(struct model_t **model_array, int nmodels);
|
|
91 |
int dihf_from_models(struct model_t **model_array, int nmodels,
|
|
92 |
double yr, double lon, double lat,
|
|
93 |
double *d_ptr, double *i_ptr, double *h_ptr,
|
|
94 |
double *f_ptr);
|
|
95 |
|
|
96 |
|