forked from ObbeTuinenburg/UTrack-atmospheric-moisture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recycling.h
144 lines (127 loc) · 4.26 KB
/
recycling.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
struct meteoday {
float* ef;
double* efadd;
double* efscale;
float* nf;
double* nfadd;
double* nfscale;
float* pw;
double* pwadd;
double* pwscale;
float* q;
double* qadd;
double* qscale;
float* t;
double* tadd;
double* tscale;
float* u;
double* uadd;
double* uscale;
float* v;
double* vadd;
double* vscale;
float* w;
double* wadd;
double* wscale;
float* E;
double* Eadd;
double* Escale;
float* P;
double* Padd;
double* Pscale;
float* lat;
float* lon;
float* lev;
int day;
int month;
int year;
};
struct simmeteo {
struct meteoday* meteo[2];
};
struct state {
float u;
float v;
float w;
float E;
float P;
float PW;
float nf;
float ef;
};
struct loc {
float lat;
float lon;
float lev;
float theta;
float time;
int day;
int curlevidx;
int curlevidx2;
};
struct simulation_settings {
int simulation_number;
float mixing;
int interpolation;
int daynum;
int nday;
int* parcels_in_system;
int num_release;
int release_days;
int release_parcel;
int hour;
float runtime;
// Allocated memory for parcels during tracking
float* particle_lat;
float* particle_lon;
float* particle_lev;
float* particle_theta;
float* particle_original;
float* particle_present;
float* particle_curtime;
// Grid cell size
float* grid_size_NW;
float* grid_size_EW;
// Input
int* release_input;
char inputfile[100];
// Output
char outputfile[100];
double* emitted_out;
double* budget;
double* insystem_out;
double* insystem;
double* allocated_out;
struct simulation_settings *next;
};
int readdata(float* array, char* s, const char *path, double* add, double* offset, float* lats, float* lons, float* levs, float* time);
int read2d(float* array, char* s, const char *path, double* add, double* scale, float* lats, float* lons, float* time);
int readgldas(float* array, char* s, const char *path, float* lats, float* lons, double* time);
int readcellnum(int* array, char* s, const char *path, float* lats, float* lons);
int readisogsm(float* array, char* s, const char *path, float* lats, float* lons, float* time);
int readirrigation(double* array, char* s, const char *path, float* lats, float* lons);
int readforest(float* array, char* s, const char *path, float* lats, float* lons);
int readcat(float* array, char* s, const char *path, float* lats, float* lons);
int readbasins(double* array, char* s, const char *path, float* lats, float* lons);
int readisomean(float* arraye, float* arrayp, const char *path);
struct state interpolate(struct loc curloc,struct meteoday* meteo, struct simulation_settings s);
int get_lsm(short*array,double*add,double*scale);
int get_era5_hour(int year,int month,int day,int hour,struct meteoday meteo);
int get_era5_3d(int year,int month,int day,int hour,struct meteoday meteo);
int get_era5_3dt(int year,int month,int day,int hour,struct meteoday meteo);
int get_era5_3dq(int year,int month,int day,int hour,struct meteoday meteo);
int get_era5_3dw(int year,int month,int day,int hour,struct meteoday meteo);
int get_era5_3duv(int year,int month,int day,int hour,struct meteoday meteo);
int get_input(int *array,char* path);
int write_output(double *released,double *insystem,double *allocated,float *lats,float *lons,int ndays,char* outfile, float runtime);
int free_meteo_hour(struct meteoday* meteo);
int load_meteo_hour(int curyear,int curmonth,int curday,int curhour,struct meteoday* meteo);
int lagrangian_simulation(struct meteoday* meteo,struct simulation_settings simulation);
int trajectory(struct meteoday* meteo, struct simulation_settings s,int particle_number);
int eulerian_simulation(struct meteoday* meteo,struct simulation_settings simulation);
float get_starting_height(struct meteoday* meteo,struct simulation_settings simulation,int lat_idx,int lon_idx);
float get_potential_temp(struct meteoday* meteo,int i,int j,float lev);
int get_3d_interpolation(struct state* outstate,struct meteoday* meteo,int curlatidx,int curlonidx,int curlevidx,float latfrac,float lonfrac,float levfrac,float timefrac);
int get_2d_interpolation(struct state* outstate,struct meteoday* meteo,int curlatidx,int curlonidx,float latfrac,float lonfrac,float timefrac);
struct state gridcell_state(struct loc curloc,struct meteoday* meteo, struct simulation_settings s);
int eul2layers(struct meteoday* meteo,struct simulation_settings simulation);