ROPO
Loading...
Searching...
No Matches
fmi_util.h
1
25#ifndef _FMI_UTIL_
26#define _FMI_UTIL_
27#include <string.h>
28
29#define MAX(x,y) ((x)>(y)?(x):(y))
30#define MIN(x,y) ((x)<(y)?(x):(y))
31#define SGN(x) ((x)<0?-1:((x)>0?1:0))
32#define ABS(x) ((x)<0?-(x):(x))
33#define SQRT2 1.41421356
34
35#ifndef PI
36#define PI 3.14159
37#endif
38
39#ifndef YES
40#define YES 1
41#endif
42
43#ifndef NO
44#define NO 0
45#endif
46
47#define EPSILON 0.0000001
48#define BIGNUMBER 32768
49
50#define EARTH_RADIUS 6372000 /* metres, = 6372 KM */
51
52#define TRUNC(x) ((int)(100*(x))/100.0)
53/*#define SIGMOID(x,a) ((x)>0 ? (a)*(x)/(1+(a)*(x)) : (a)*(x)/(1-(a)*(x)) ) */
54#define GAUSS(a,x) (1/((x*x)/(a*a+0.000001)+1))
55
56float pseudo_gauss(float a,float x);
57int pseudo_gauss_int(int a,int x);
58
59float pseudo_sigmoid(float a,float x); /* between -128 and 128 */
60int pseudo_sigmoid_int(int a,int x); /* between -128 and 128 */
61/*#define pseudo_sigmoid(a,x) ((x)>0 ? 255*(x)/(a+(x)) : 255*(x)/(a-(x))) */
62/*#define pseudo_gauss(a,x) (255*(a)*(a)/((a)*(a)+(x)*(x))) */
63
64char *argument(int argc, char **argv, char *target);
65int file_count(int argc, char **argv);
66
67int param(int argc, char **argv,int index, char *key);
68int paramn(int argc, char **argv,int index, char *key);
69
70#define FMI_UTIL_COMMAND_LINE_LEN 1024
71extern char fmi_util_command_line[FMI_UTIL_COMMAND_LINE_LEN];
72extern char *fmi_util_comment;
73char *extract_command_line(int argc, char **argv);
74
75
76#define FMI_FILENAME_LEN 1024
77
78
79/*#define BASENAME(s) (strrchr(s,'/')==NULL?s:(strrchr(s,'/'))+1) */
80char *file_path(char *filename);
81char *file_basename(char *filename); /* without path and 1 extension */
82char *file_extension(char *filename);
83char *file_name(char *filename); /* without path */
84
85#define FMI_ARG(i) (argv[i])
86#define FMI_IARG(i) (atoi(argv[i]))
87
88#define FMI_PARAM(s) (argument(argc,argv,s))
89#define FMI_FLAG(s) (argument(argc,argv,s)!=NULL)
90#define FMI_FILES() (file_count(argc,argv))
91#define FMI_HELP(n) ((argc<n)||(argument(argc,argv,"-h"))||(argument(argc,argv,"-help")))
92
93/* DEBUG LEVELS */
94/* 0 silent */
95/* 1 light processing information */
96/* 2 light processing information, write aux files */
97/* 3 heavy processing information, write aux files */
98extern int fmi_debug_level;
99#define FMI_DEBUG(n) (n<=fmi_debug_level)
100void fmi_debug(int n,char *s);
101void fmi_error(char *s);
102
103void trchr(char *string,char from,char to);
104
105
106/* METEOROLOGICAL STUFF */
107
108
109#endif
110