MPTRAC
mptrac.h
Go to the documentation of this file.
1/*
2 This file is part of MPTRAC.
3
4 MPTRAC is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 MPTRAC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2013-2025 Forschungszentrum Juelich GmbH
18*/
19
116#ifndef LIBTRAC_H
117#define LIBTRAC_H
118
119/* ------------------------------------------------------------
120 Includes...
121 ------------------------------------------------------------ */
122
123#include <ctype.h>
124#include <gsl/gsl_fft_complex.h>
125#include <gsl/gsl_math.h>
126#include <gsl/gsl_randist.h>
127#include <gsl/gsl_rng.h>
128#include <gsl/gsl_sort.h>
129#include <gsl/gsl_spline.h>
130#include <gsl/gsl_statistics.h>
131#include <math.h>
132#include <netcdf.h>
133#include <omp.h>
134#include <stdint.h>
135#include <stdio.h>
136#include <stdlib.h>
137#include <string.h>
138#include <time.h>
139#include <sys/time.h>
140
141#ifdef MPI
142#include "mpi.h"
143#else
145#define MPI_Datatype void*
146#endif
147
148#ifdef DD
149#include <netcdf_par.h>
150#endif
151
152#ifdef _OPENACC
153#include "openacc.h"
154#endif
155
156#ifdef CURAND
157#include "curand.h"
158#endif
159
160#ifdef THRUST
161#include "thrustsort.h"
162#endif
163
164#ifdef ZFP
165#include "zfp.h"
166#endif
167
168#ifdef ZSTD
169#include "zstd.h"
170#endif
171
172#ifdef SZ3
173#include "SZ3c/sz3c.h"
174#endif
175
176#ifdef CMS
177#include "cmultiscale.h"
178#endif
179
180#ifdef KPP
181#include "chem_Parameters.h"
182#include "chem_Global.h"
183#include "chem_Sparse.h"
184#endif
185
186#ifdef ECCODES
187#include "eccodes.h"
188#else
190#define codes_handle void*
191#endif
192
193/* ------------------------------------------------------------
194 Constants...
195 ------------------------------------------------------------ */
196
198#ifndef AVO
199#define AVO 6.02214076e23
200#endif
201
203#ifndef CPD
204#define CPD 1003.5
205#endif
206
208#ifndef EPS
209#define EPS (MH2O / MA)
210#endif
211
213#ifndef G0
214#define G0 9.80665
215#endif
216
218#ifndef H0
219#define H0 7.0
220#endif
221
223#ifndef LV
224#define LV 2501000.
225#endif
226
228#ifndef KARMAN
229#define KARMAN 0.40
230#endif
231
233#ifndef KB
234#define KB 1.3806504e-23
235#endif
236
238#ifndef MA
239#define MA 28.9644
240#endif
241
243#ifndef MH2O
244#define MH2O 18.01528
245#endif
246
248#ifndef MO3
249#define MO3 48.00
250#endif
251
253#ifndef P0
254#define P0 1013.25
255#endif
256
258#ifndef RA
259#define RA (1e3 * RI / MA)
260#endif
261
263#ifndef RE
264#define RE 6367.421
265#endif
266
268#ifndef RI
269#define RI 8.3144598
270#endif
271
273#ifndef T0
274#define T0 273.15
275#endif
276
277/* ------------------------------------------------------------
278 Dimensions...
279 ------------------------------------------------------------ */
280
282#ifndef EP
283#define EP 140
284#endif
285
287#ifndef EX
288#define EX 1444
289#endif
290
292#ifndef EY
293#define EY 724
294#endif
295
297#ifndef LEN
298#define LEN 5000
299#endif
300
302#ifndef METVAR
303#define METVAR 13
304#endif
305
307#ifndef NP
308#define NP 10000000
309#endif
310
312#ifndef NQ
313#define NQ 15
314#endif
315
317#ifndef NCSI
318#define NCSI 1000000
319#endif
320
322#ifndef NENS
323#define NENS 2000
324#endif
325
327#ifndef NOBS
328#define NOBS 10000000
329#endif
330
332#ifndef NTHREADS
333#define NTHREADS 512
334#endif
335
337#ifndef CY
338#define CY 250
339#endif
340
342#ifndef CO3
343#define CO3 30
344#endif
345
347#ifndef CP
348#define CP 70
349#endif
350
352#ifndef CSZA
353#define CSZA 50
354#endif
355
357#ifndef CT
358#define CT 12
359#endif
360
362#ifndef CTS
363#define CTS 1000
364#endif
365
367#ifndef DD_NPART
368#define DD_NPART 100000
369#endif
370
372#ifndef DD_NNMAX
373#define DD_NNMAX 26
374#endif
375
377#ifndef DD_NPOLE
378#define DD_NPOLE -2
379#endif
380
382#ifndef DD_SPOLE
383#define DD_SPOLE -3
384#endif
385
386/* ------------------------------------------------------------
387 Macros...
388 ------------------------------------------------------------ */
389
409#ifdef _OPENACC
410#define ALLOC(ptr, type, n) \
411 if(acc_get_num_devices(acc_device_nvidia) <= 0) \
412 ERRMSG("Not running on a GPU device!"); \
413 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
414 ERRMSG("Out of memory!");
415#else
416#define ALLOC(ptr, type, n) \
417 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
418 ERRMSG("Out of memory!");
419#endif
420
439#define ARRAY_2D(ix, iy, ny) \
440 ((ix) * (ny) + (iy))
441
458#define ARRAY_3D(ix, iy, ny, iz, nz) \
459 (((ix)*(ny) + (iy)) * (nz) + (iz))
460
483#define ARRHENIUS(a, b, t) \
484 ((a) * exp( -(b) / (t)))
485
505#define CLAMP(v, lo, hi) \
506 (((v) < (lo)) ? (lo) : (((v) > (hi)) ? (hi) : (v)))
507
529#define DEG2DX(dlon, lat) \
530 (RE * DEG2RAD(dlon) * cos(DEG2RAD(lat)))
531
550#define DEG2DY(dlat) \
551 (RE * DEG2RAD(dlat))
552
567#define DEG2RAD(deg) \
568 ((deg) * (M_PI / 180.0))
569
592#define DP2DZ(dp, p) \
593 (- (dp) * H0 / (p))
594
614#define DX2DEG(dx, lat) \
615 (((lat) < -89.999 || (lat) > 89.999) ? 0 \
616 : (dx) * 180. / (M_PI * RE * cos(DEG2RAD(lat))))
617
632#define DY2DEG(dy) \
633 ((dy) * 180. / (M_PI * RE))
634
651#define DZ2DP(dz, p) \
652 (-(dz) * (p) / H0)
653
667#define DIST(a, b) \
668 sqrt(DIST2(a, b))
669
683#define DIST2(a, b) \
684 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
685
699#define DOTP(a, b) \
700 (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
701
713#define ECC(cmd) { \
714 int ecc_result=(cmd); \
715 if(ecc_result!=0) \
716 ERRMSG("ECCODES error: %s", codes_get_error_message(ecc_result)); \
717 }
718
732#define ECC_READ_2D(variable, target, scaling_factor, found_flag) { \
733 if(strcmp(short_name, variable) == 0) { \
734 for (int ix = 0; ix < met->nx; ix++) \
735 for (int iy = 0; iy < met->ny; iy++) \
736 target[ix][iy] = (float)(values[iy * met->nx + ix] * scaling_factor); \
737 found_flag = 1; \
738 } \
739 }
740
755#define ECC_READ_3D(variable, level, target, scaling_factor, found_flag) { \
756 if(strcmp(short_name, variable) == 0) { \
757 for (int ix = 0; ix < met->nx; ix++) \
758 for (int iy = 0; iy < met->ny; iy++) \
759 target[ix][iy][level] = (float) (values[iy * met->nx + ix] * scaling_factor); \
760 found_flag += 1; \
761 } \
762 }
763
780#define FMOD(x, y) \
781 ((x) - (int) ((x) / (y)) * (y))
782
798#define FREAD(ptr, type, size, in) { \
799 if(fread(ptr, sizeof(type), size, in)!=size) \
800 ERRMSG("Error while reading!"); \
801 }
802
818#define FWRITE(ptr, type, size, out) { \
819 if(fwrite(ptr, sizeof(type), size, out)!=size) \
820 ERRMSG("Error while writing!"); \
821 }
822
833#define INTPOL_INIT \
834 double cw[4] = {0.0, 0.0, 0.0, 0.0}; int ci[3] = {0, 0, 0};
835
847#define INTPOL_2D(var, init) \
848 intpol_met_time_2d(met0, met0->var, met1, met1->var, \
849 atm->time[ip], atm->lon[ip], atm->lat[ip], \
850 &var, ci, cw, init);
851
864#define INTPOL_3D(var, init) \
865 intpol_met_time_3d(met0, met0->var, met1, met1->var, \
866 atm->time[ip], atm->p[ip], \
867 atm->lon[ip], atm->lat[ip], \
868 &var, ci, cw, init);
869
883#define INTPOL_SPACE_ALL(p, lon, lat) { \
884 intpol_met_space_3d(met, met->z, p, lon, lat, &z, ci, cw, 1); \
885 intpol_met_space_3d(met, met->t, p, lon, lat, &t, ci, cw, 0); \
886 intpol_met_space_3d(met, met->u, p, lon, lat, &u, ci, cw, 0); \
887 intpol_met_space_3d(met, met->v, p, lon, lat, &v, ci, cw, 0); \
888 intpol_met_space_3d(met, met->w, p, lon, lat, &w, ci, cw, 0); \
889 intpol_met_space_3d(met, met->pv, p, lon, lat, &pv, ci, cw, 0); \
890 intpol_met_space_3d(met, met->h2o, p, lon, lat, &h2o, ci, cw, 0); \
891 intpol_met_space_3d(met, met->o3, p, lon, lat, &o3, ci, cw, 0); \
892 intpol_met_space_3d(met, met->lwc, p, lon, lat, &lwc, ci, cw, 0); \
893 intpol_met_space_3d(met, met->rwc, p, lon, lat, &rwc, ci, cw, 0); \
894 intpol_met_space_3d(met, met->iwc, p, lon, lat, &iwc, ci, cw, 0); \
895 intpol_met_space_3d(met, met->swc, p, lon, lat, &swc, ci, cw, 0); \
896 intpol_met_space_3d(met, met->cc, p, lon, lat, &cc, ci, cw, 0); \
897 intpol_met_space_2d(met, met->ps, lon, lat, &ps, ci, cw, 0); \
898 intpol_met_space_2d(met, met->ts, lon, lat, &ts, ci, cw, 0); \
899 intpol_met_space_2d(met, met->zs, lon, lat, &zs, ci, cw, 0); \
900 intpol_met_space_2d(met, met->us, lon, lat, &us, ci, cw, 0); \
901 intpol_met_space_2d(met, met->vs, lon, lat, &vs, ci, cw, 0); \
902 intpol_met_space_2d(met, met->ess, ess, lat, &ess, ci, cw, 0); \
903 intpol_met_space_2d(met, met->nss, nss, lat, &nss, ci, cw, 0); \
904 intpol_met_space_2d(met, met->shf, shf, lat, &shf, ci, cw, 0); \
905 intpol_met_space_2d(met, met->lsm, lon, lat, &lsm, ci, cw, 0); \
906 intpol_met_space_2d(met, met->sst, lon, lat, &sst, ci, cw, 0); \
907 intpol_met_space_2d(met, met->pbl, lon, lat, &pbl, ci, cw, 0); \
908 intpol_met_space_2d(met, met->pt, lon, lat, &pt, ci, cw, 0); \
909 intpol_met_space_2d(met, met->tt, lon, lat, &tt, ci, cw, 0); \
910 intpol_met_space_2d(met, met->zt, lon, lat, &zt, ci, cw, 0); \
911 intpol_met_space_2d(met, met->h2ot, lon, lat, &h2ot, ci, cw, 0); \
912 intpol_met_space_2d(met, met->pct, lon, lat, &pct, ci, cw, 0); \
913 intpol_met_space_2d(met, met->pcb, lon, lat, &pcb, ci, cw, 0); \
914 intpol_met_space_2d(met, met->cl, lon, lat, &cl, ci, cw, 0); \
915 intpol_met_space_2d(met, met->plcl, lon, lat, &plcl, ci, cw, 0); \
916 intpol_met_space_2d(met, met->plfc, lon, lat, &plfc, ci, cw, 0); \
917 intpol_met_space_2d(met, met->pel, lon, lat, &pel, ci, cw, 0); \
918 intpol_met_space_2d(met, met->cape, lon, lat, &cape, ci, cw, 0); \
919 intpol_met_space_2d(met, met->cin, lon, lat, &cin, ci, cw, 0); \
920 intpol_met_space_2d(met, met->o3c, lon, lat, &o3c, ci, cw, 0); \
921 }
922
937#define INTPOL_TIME_ALL(time, p, lon, lat) { \
938 intpol_met_time_3d(met0, met0->z, met1, met1->z, time, p, lon, lat, &z, ci, cw, 1); \
939 intpol_met_time_3d(met0, met0->t, met1, met1->t, time, p, lon, lat, &t, ci, cw, 0); \
940 intpol_met_time_3d(met0, met0->u, met1, met1->u, time, p, lon, lat, &u, ci, cw, 0); \
941 intpol_met_time_3d(met0, met0->v, met1, met1->v, time, p, lon, lat, &v, ci, cw, 0); \
942 intpol_met_time_3d(met0, met0->w, met1, met1->w, time, p, lon, lat, &w, ci, cw, 0); \
943 intpol_met_time_3d(met0, met0->pv, met1, met1->pv, time, p, lon, lat, &pv, ci, cw, 0); \
944 intpol_met_time_3d(met0, met0->h2o, met1, met1->h2o, time, p, lon, lat, &h2o, ci, cw, 0); \
945 intpol_met_time_3d(met0, met0->o3, met1, met1->o3, time, p, lon, lat, &o3, ci, cw, 0); \
946 intpol_met_time_3d(met0, met0->lwc, met1, met1->lwc, time, p, lon, lat, &lwc, ci, cw, 0); \
947 intpol_met_time_3d(met0, met0->rwc, met1, met1->rwc, time, p, lon, lat, &rwc, ci, cw, 0); \
948 intpol_met_time_3d(met0, met0->iwc, met1, met1->iwc, time, p, lon, lat, &iwc, ci, cw, 0); \
949 intpol_met_time_3d(met0, met0->swc, met1, met1->swc, time, p, lon, lat, &swc, ci, cw, 0); \
950 intpol_met_time_3d(met0, met0->cc, met1, met1->cc, time, p, lon, lat, &cc, ci, cw, 0); \
951 intpol_met_time_2d(met0, met0->ps, met1, met1->ps, time, lon, lat, &ps, ci, cw, 0); \
952 intpol_met_time_2d(met0, met0->ts, met1, met1->ts, time, lon, lat, &ts, ci, cw, 0); \
953 intpol_met_time_2d(met0, met0->zs, met1, met1->zs, time, lon, lat, &zs, ci, cw, 0); \
954 intpol_met_time_2d(met0, met0->us, met1, met1->us, time, lon, lat, &us, ci, cw, 0); \
955 intpol_met_time_2d(met0, met0->vs, met1, met1->vs, time, lon, lat, &vs, ci, cw, 0); \
956 intpol_met_time_2d(met0, met0->ess, met1, met1->ess, time, lon, lat, &ess, ci, cw, 0); \
957 intpol_met_time_2d(met0, met0->nss, met1, met1->nss, time, lon, lat, &nss, ci, cw, 0); \
958 intpol_met_time_2d(met0, met0->shf, met1, met1->shf, time, lon, lat, &shf, ci, cw, 0); \
959 intpol_met_time_2d(met0, met0->lsm, met1, met1->lsm, time, lon, lat, &lsm, ci, cw, 0); \
960 intpol_met_time_2d(met0, met0->sst, met1, met1->sst, time, lon, lat, &sst, ci, cw, 0); \
961 intpol_met_time_2d(met0, met0->pbl, met1, met1->pbl, time, lon, lat, &pbl, ci, cw, 0); \
962 intpol_met_time_2d(met0, met0->pt, met1, met1->pt, time, lon, lat, &pt, ci, cw, 0); \
963 intpol_met_time_2d(met0, met0->tt, met1, met1->tt, time, lon, lat, &tt, ci, cw, 0); \
964 intpol_met_time_2d(met0, met0->zt, met1, met1->zt, time, lon, lat, &zt, ci, cw, 0); \
965 intpol_met_time_2d(met0, met0->h2ot, met1, met1->h2ot, time, lon, lat, &h2ot, ci, cw, 0); \
966 intpol_met_time_2d(met0, met0->pct, met1, met1->pct, time, lon, lat, &pct, ci, cw, 0); \
967 intpol_met_time_2d(met0, met0->pcb, met1, met1->pcb, time, lon, lat, &pcb, ci, cw, 0); \
968 intpol_met_time_2d(met0, met0->cl, met1, met1->cl, time, lon, lat, &cl, ci, cw, 0); \
969 intpol_met_time_2d(met0, met0->plcl, met1, met1->plcl, time, lon, lat, &plcl, ci, cw, 0); \
970 intpol_met_time_2d(met0, met0->plfc, met1, met1->plfc, time, lon, lat, &plfc, ci, cw, 0); \
971 intpol_met_time_2d(met0, met0->pel, met1, met1->pel, time, lon, lat, &pel, ci, cw, 0); \
972 intpol_met_time_2d(met0, met0->cape, met1, met1->cape, time, lon, lat, &cape, ci, cw, 0); \
973 intpol_met_time_2d(met0, met0->cin, met1, met1->cin, time, lon, lat, &cin, ci, cw, 0); \
974 intpol_met_time_2d(met0, met0->o3c, met1, met1->o3c, time, lon, lat, &o3c, ci, cw, 0); \
975 }
976
991#define LAPSE(p1, t1, p2, t2) \
992 (1e3 * G0 / RA * ((t2) - (t1)) / ((t2) + (t1)) \
993 * ((p2) + (p1)) / ((p2) - (p1)))
994
1010#define LIN(x0, y0, x1, y1, x) \
1011 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
1012
1037#define MAX(a,b) \
1038 (((a)>(b))?(a):(b))
1039
1051#define MET_HEADER \
1052 fprintf(out, \
1053 "# $1 = time [s]\n" \
1054 "# $2 = altitude [km]\n" \
1055 "# $3 = longitude [deg]\n" \
1056 "# $4 = latitude [deg]\n" \
1057 "# $5 = pressure [hPa]\n" \
1058 "# $6 = temperature [K]\n" \
1059 "# $7 = zonal wind [m/s]\n" \
1060 "# $8 = meridional wind [m/s]\n" \
1061 "# $9 = vertical velocity [hPa/s]\n" \
1062 "# $10 = H2O volume mixing ratio [ppv]\n"); \
1063 fprintf(out, \
1064 "# $11 = O3 volume mixing ratio [ppv]\n" \
1065 "# $12 = geopotential height [km]\n" \
1066 "# $13 = potential vorticity [PVU]\n" \
1067 "# $14 = surface pressure [hPa]\n" \
1068 "# $15 = surface temperature [K]\n" \
1069 "# $16 = surface geopotential height [km]\n" \
1070 "# $17 = surface zonal wind [m/s]\n" \
1071 "# $18 = surface meridional wind [m/s]\n" \
1072 "# $19 = eastward turbulent surface stress [N/m^2]\n" \
1073 "# $20 = northward turbulent surface stress [N/m^2]\n"); \
1074 fprintf(out, \
1075 "# $21 = surface sensible heat flux [W/m^2]\n" \
1076 "# $22 = land-sea mask [1]\n" \
1077 "# $23 = sea surface temperature [K]\n" \
1078 "# $24 = tropopause pressure [hPa]\n" \
1079 "# $25 = tropopause geopotential height [km]\n" \
1080 "# $26 = tropopause temperature [K]\n" \
1081 "# $27 = tropopause water vapor [ppv]\n" \
1082 "# $28 = cloud liquid water content [kg/kg]\n" \
1083 "# $29 = cloud rain water content [kg/kg]\n" \
1084 "# $30 = cloud ice water content [kg/kg]\n"); \
1085 fprintf(out, \
1086 "# $31 = cloud snow water content [kg/kg]\n" \
1087 "# $32 = cloud cover [1]\n" \
1088 "# $33 = total column cloud water [kg/m^2]\n" \
1089 "# $34 = cloud top pressure [hPa]\n" \
1090 "# $35 = cloud bottom pressure [hPa]\n" \
1091 "# $36 = pressure at lifted condensation level (LCL) [hPa]\n" \
1092 "# $37 = pressure at level of free convection (LFC) [hPa]\n" \
1093 "# $38 = pressure at equilibrium level (EL) [hPa]\n" \
1094 "# $39 = convective available potential energy (CAPE) [J/kg]\n" \
1095 "# $40 = convective inhibition (CIN) [J/kg]\n"); \
1096 fprintf(out, \
1097 "# $41 = relative humidity over water [%%]\n" \
1098 "# $42 = relative humidity over ice [%%]\n" \
1099 "# $43 = dew point temperature [K]\n" \
1100 "# $44 = frost point temperature [K]\n" \
1101 "# $45 = NAT temperature [K]\n" \
1102 "# $46 = HNO3 volume mixing ratio [ppv]\n" \
1103 "# $47 = OH volume mixing ratio [ppv]\n" \
1104 "# $48 = H2O2 volume mixing ratio [ppv]\n" \
1105 "# $49 = HO2 volume mixing ratio [ppv]\n" \
1106 "# $50 = O(1D) volume mixing ratio [ppv]\n"); \
1107 fprintf(out, \
1108 "# $51 = boundary layer pressure [hPa]\n" \
1109 "# $52 = total column ozone [DU]\n" \
1110 "# $53 = number of data points\n" \
1111 "# $54 = number of tropopause data points\n" \
1112 "# $55 = number of CAPE data points\n");
1113
1138#define MIN(a,b) \
1139 (((a)<(b))?(a):(b))
1140
1153#define MOLEC_DENS(p,t) \
1154 (AVO * 1e-6 * ((p) * 100) / (RI * (t)))
1155
1167#define NC(cmd) { \
1168 int nc_result=(cmd); \
1169 if(nc_result!=NC_NOERR) \
1170 ERRMSG("%s", nc_strerror(nc_result)); \
1171 }
1172
1196#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units, level, quant) { \
1197 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
1198 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
1199 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
1200 if((quant) > 0) \
1201 NC(nc_def_var_quantize(ncid, varid, NC_QUANTIZE_GRANULARBR, quant)); \
1202 if((level) != 0) { \
1203 NC(nc_def_var_deflate(ncid, varid, 1, 1, level)); \
1204 /* unsigned int ulevel = (unsigned int)level; */ \
1205 /* NC(nc_def_var_filter(ncid, varid, 32015, 1, (unsigned int[]){ulevel})); */ \
1206 } \
1207 }
1208
1226#define NC_GET_DOUBLE(varname, ptr, force) { \
1227 if(force) { \
1228 NC(nc_inq_varid(ncid, varname, &varid)); \
1229 NC(nc_get_var_double(ncid, varid, ptr)); \
1230 } else { \
1231 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
1232 NC(nc_get_var_double(ncid, varid, ptr)); \
1233 } else \
1234 WARN("netCDF variable %s is missing!", varname); \
1235 } \
1236 }
1237
1256#define NC_INQ_DIM(dimname, ptr, min, max, check) { \
1257 int dimid; size_t naux; \
1258 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
1259 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
1260 *ptr = (int)naux; \
1261 if (check) \
1262 if ((*ptr) < (min) || (*ptr) > (max)) \
1263 ERRMSG("Dimension %s is out of range!", dimname); \
1264 }
1265
1280#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
1281 NC(nc_inq_varid(ncid, varname, &varid)); \
1282 if(hyperslab) { \
1283 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
1284 } else { \
1285 NC(nc_put_var_double(ncid, varid, ptr)); \
1286 } \
1287 }
1288
1304#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
1305 NC(nc_inq_varid(ncid, varname, &varid)); \
1306 if(hyperslab) { \
1307 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
1308 } else { \
1309 NC(nc_put_var_float(ncid, varid, ptr)); \
1310 } \
1311 }
1312
1327#define NC_PUT_INT(varname, ptr, hyperslab) { \
1328 NC(nc_inq_varid(ncid, varname, &varid)); \
1329 if(hyperslab) { \
1330 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
1331 } else { \
1332 NC(nc_put_var_int(ncid, varid, ptr)); \
1333 } \
1334 }
1335
1349#define NC_PUT_ATT(varname, attname, text) { \
1350 NC(nc_inq_varid(ncid, varname, &varid)); \
1351 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
1352 }
1353
1366#define NC_PUT_ATT_GLOBAL(attname, text) \
1367 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
1368
1386#define NN(x0, y0, x1, y1, x) \
1387 (fabs((x) - (x0)) <= fabs((x) - (x1)) ? (y0) : (y1))
1388
1404#ifdef _OPENACC
1405#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1406 const int ip0_const = ip0; \
1407 const int ip1_const = ip1; \
1408 _Pragma(__VA_ARGS__) \
1409 _Pragma("acc parallel loop independent gang vector") \
1410 for (int ip = ip0_const; ip < ip1_const; ip++) \
1411 if (!check_dt || cache->dt[ip] != 0)
1412#else
1413#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1414 const int ip0_const = ip0; \
1415 const int ip1_const = ip1; \
1416 _Pragma("omp parallel for default(shared)") \
1417 for (int ip = ip0_const; ip < ip1_const; ip++) \
1418 if (!check_dt || cache->dt[ip] != 0)
1419#endif
1420
1443#define P(z) \
1444 (P0 * exp(-(z) / H0))
1445
1467#define PSAT(t) \
1468 (6.112 * exp(17.62 * ((t) - T0) / (243.12 + (t) - T0)))
1469
1491#define PSICE(t) \
1492 (6.112 * exp(22.46 * ((t) - T0) / (272.62 + (t) - T0)))
1493
1518#define PW(p, h2o) \
1519 ((p) * MAX((h2o), 0.1e-6) / (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1520
1535#define RAD2DEG(rad) \
1536 ((rad) * (180.0 / M_PI))
1537
1565#define RH(p, t, h2o) \
1566 (PW(p, h2o) / PSAT(t) * 100.)
1567
1595#define RHICE(p, t, h2o) \
1596 (PW(p, h2o) / PSICE(t) * 100.)
1597
1620#define RHO(p, t) \
1621 (100. * (p) / (RA * (t)))
1622
1639#define SET_ATM(qnt, val) \
1640 if (ctl->qnt >= 0) \
1641 atm->q[ctl->qnt][ip] = val;
1642
1662#define SET_QNT(qnt, name, longname, unit) \
1663 if (strcasecmp(ctl->qnt_name[iq], name) == 0) { \
1664 ctl->qnt = iq; \
1665 sprintf(ctl->qnt_longname[iq], longname); \
1666 sprintf(ctl->qnt_unit[iq], unit); \
1667 } else
1668
1683#define SH(h2o) \
1684 (EPS * MAX((h2o), 0.1e-6))
1685
1696#define SQR(x) \
1697 ((x)*(x))
1698
1710#define SWAP(x, y, type) \
1711 do {type tmp = x; x = y; y = tmp;} while(0);
1712
1734#define TDEW(p, h2o) \
1735 (T0 + 243.12 * log(PW((p), (h2o)) / 6.112) \
1736 / (17.62 - log(PW((p), (h2o)) / 6.112)))
1737
1759#define TICE(p, h2o) \
1760 (T0 + 272.62 * log(PW((p), (h2o)) / 6.112) \
1761 / (22.46 - log(PW((p), (h2o)) / 6.112)))
1762
1783#define THETA(p, t) \
1784 ((t) * pow(1000. / (p), 0.286))
1785
1812#define THETAVIRT(p, t, h2o) \
1813 (TVIRT(THETA((p), (t)), MAX((h2o), 0.1e-6)))
1814
1833#define TOK(line, tok, format, var) { \
1834 if(((tok)=strtok((line), " \t"))) { \
1835 if(sscanf(tok, format, &(var))!=1) continue; \
1836 } else ERRMSG("Error while reading!"); \
1837 }
1838
1858#define TVIRT(t, h2o) \
1859 ((t) * (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1860
1880#define Z(p) \
1881 (H0 * log(P0 / (p)))
1882
1911#define ZDIFF(lnp0, t0, h2o0, lnp1, t1, h2o1) \
1912 (RI / MA / G0 * 0.5 * (TVIRT((t0), (h2o0)) + TVIRT((t1), (h2o1))) \
1913 * ((lnp0) - (lnp1)))
1914
1930#define ZETA(ps, p, t) \
1931 (((p) / (ps) <= 0.3 ? 1. : \
1932 sin(M_PI / 2. * (1. - (p) / (ps)) / (1. - 0.3))) \
1933 * THETA((p), (t)))
1934
1935/* ------------------------------------------------------------
1936 Log messages...
1937 ------------------------------------------------------------ */
1938
1940#ifndef LOGLEV
1941#define LOGLEV 2
1942#endif
1943
1973#define LOG(level, ...) { \
1974 if(level >= 2) \
1975 printf(" "); \
1976 if(level <= LOGLEV) { \
1977 printf(__VA_ARGS__); \
1978 printf("\n"); \
1979 } \
1980 }
1981
2010#define WARN(...) { \
2011 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2012 LOG(0, __VA_ARGS__); \
2013 }
2014
2043#define ERRMSG(...) { \
2044 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2045 LOG(0, __VA_ARGS__); \
2046 exit(EXIT_FAILURE); \
2047 }
2048
2078#define PRINT(format, var) \
2079 printf("Print (%s, %s, l%d): %s= "format"\n", \
2080 __FILE__, __func__, __LINE__, #var, var);
2081
2082/* ------------------------------------------------------------
2083 Timers...
2084 ------------------------------------------------------------ */
2085
2087#define NTIMER 100
2088
2102#define PRINT_TIMERS \
2103 timer("END", "END", 1);
2104
2117#define SELECT_TIMER(id, group) \
2118 timer(id, group, 0);
2119
2120/* ------------------------------------------------------------
2121 Structs...
2122 ------------------------------------------------------------ */
2123
2131typedef struct {
2132
2133 /* ------------------------------------------------------------
2134 Quantity parameters...
2135 ------------------------------------------------------------ */
2136
2138 int nq;
2139
2141 char qnt_name[NQ][LEN];
2142
2144 char qnt_longname[NQ][LEN];
2145
2147 char qnt_unit[NQ][LEN];
2148
2150 char qnt_format[NQ][LEN];
2151
2154
2157
2160
2163
2166
2169
2172
2175
2178
2181
2184
2187
2190
2193
2196
2199
2202
2205
2208
2211
2214
2217
2220
2223
2226
2229
2232
2235
2238
2241
2244
2247
2250
2253
2256
2259
2262
2265
2268
2271
2274
2277
2280
2283
2286
2289
2292
2295
2298
2301
2304
2307
2310
2313
2316
2319
2322
2325
2328
2331
2334
2337
2340
2343
2346
2349
2352
2355
2358
2361
2364
2367
2370
2373
2376
2379
2382
2385
2388
2391
2394
2397
2400
2403
2406
2409
2412
2415
2418
2421
2424
2427
2430
2433
2436
2439
2442
2444 double t_start;
2445
2447 double t_stop;
2448
2450 double dt_mod;
2451
2452 /* ------------------------------------------------------------
2453 Meteo data parameters...
2454 ------------------------------------------------------------ */
2455
2457 char metbase[LEN];
2458
2460 double dt_met;
2461
2464
2468
2472
2475
2478
2481
2484
2487
2489 int met_comp_prec[METVAR];
2490
2492 double met_comp_tol[METVAR];
2493
2496
2499
2502
2505
2508
2511
2514
2517
2520
2523
2526
2529
2532
2535
2538
2541
2544
2547
2550
2553
2556
2559
2562
2565
2568
2571
2573 double met_p[EP];
2574
2577
2580
2582 double met_lev_hyam[EP];
2583
2585 double met_lev_hybm[EP];
2586
2589
2592
2595
2598
2601
2604
2607
2611
2614
2617
2620
2623
2626
2629
2630 /* ------------------------------------------------------------
2631 Geophysical module parameters...
2632 ------------------------------------------------------------ */
2633
2635 double sort_dt;
2636
2640
2642 char balloon[LEN];
2643
2646
2650
2653
2656
2659
2662
2665
2668
2671
2674
2677
2680
2683
2686
2689
2691 double conv_cin;
2692
2694 double conv_dt;
2695
2698
2701
2704
2707
2710
2713
2715 double bound_p0;
2716
2718 double bound_p1;
2719
2722
2725
2728
2731
2733 char species[LEN];
2734
2736 double molmass;
2737
2740
2743
2746
2748 char clim_hno3_filename[LEN];
2749
2751 char clim_oh_filename[LEN];
2752
2754 char clim_h2o2_filename[LEN];
2755
2757 char clim_ho2_filename[LEN];
2758
2760 char clim_o1d_filename[LEN];
2761
2763 char clim_o3_filename[LEN];
2764
2766 char clim_ccl4_timeseries[LEN];
2767
2769 char clim_ccl3f_timeseries[LEN];
2770
2772 char clim_ccl2f2_timeseries[LEN];
2773
2775 char clim_n2o_timeseries[LEN];
2776
2778 char clim_sf6_timeseries[LEN];
2779
2782
2785
2788
2791
2794
2797
2800
2803
2806
2809
2812
2815
2818
2821
2824
2827
2830
2833
2836
2839
2842
2845
2847 double oh_chem[4];
2848
2851
2854
2857
2859 double dt_kpp;
2860
2863
2865 double wet_depo_pre[2];
2866
2869
2872
2875
2878
2880 double wet_depo_ic_h[2];
2881
2883 double wet_depo_bc_h[2];
2884
2887
2890
2893
2896
2899
2901 double psc_h2o;
2902
2904 double psc_hno3;
2905
2906 /* ------------------------------------------------------------
2907 Output parameters...
2908 ------------------------------------------------------------ */
2909
2911 char atm_basename[LEN];
2912
2914 char atm_gpfile[LEN];
2915
2918
2921
2924
2928
2933
2936
2938 int atm_nc_quant[NQ];
2939
2942
2944 char csi_basename[LEN];
2945
2947 char csi_kernel[LEN];
2948
2951
2953 char csi_obsfile[LEN];
2954
2957
2960
2963
2965 double csi_z0;
2966
2968 double csi_z1;
2969
2972
2974 double csi_lon0;
2975
2977 double csi_lon1;
2978
2981
2983 double csi_lat0;
2984
2986 double csi_lat1;
2987
2989 int nens;
2990
2992 char ens_basename[LEN];
2993
2996
2998 char grid_basename[LEN];
2999
3001 char grid_kernel[LEN];
3002
3004 char grid_gpfile[LEN];
3005
3008
3011
3014
3016 int grid_nc_quant[NQ];
3017
3020
3023
3025 double grid_z0;
3026
3028 double grid_z1;
3029
3032
3035
3038
3041
3044
3047
3050
3052 char prof_basename[LEN];
3053
3055 char prof_obsfile[LEN];
3056
3059
3061 double prof_z0;
3062
3064 double prof_z1;
3065
3068
3071
3074
3077
3080
3083
3085 char sample_basename[LEN];
3086
3088 char sample_kernel[LEN];
3089
3091 char sample_obsfile[LEN];
3092
3095
3098
3100 char stat_basename[LEN];
3101
3103 double stat_lon;
3104
3106 double stat_lat;
3107
3109 double stat_r;
3110
3112 double stat_t0;
3113
3115 double stat_t1;
3116
3118 char vtk_basename[LEN];
3119
3122
3125
3128
3131
3134
3135 /* ------------------------------------------------------------
3136 Domain decomposition...
3137 ------------------------------------------------------------ */
3138
3140 int dd;
3141
3144
3147
3150
3153
3154} ctl_t;
3155
3164typedef struct {
3165
3167 int np;
3168
3170 double time[NP];
3171
3173 double p[NP];
3174
3176 double lon[NP];
3177
3179 double lat[NP];
3180
3182 double q[NQ][NP];
3183
3184} atm_t;
3185
3193typedef struct {
3194
3196 double time;
3197
3199 double p;
3200
3202 double lon;
3203
3205 double lat;
3206
3208 double q[NQ];
3209
3210} particle_t;
3211
3212
3219typedef struct {
3220
3222 double iso_var[NP];
3223
3225 double iso_ps[NP];
3226
3228 double iso_ts[NP];
3229
3232
3234 float uvwp[NP][3];
3235
3237 double rs[3 * NP + 1];
3238
3240 double dt[NP];
3241
3242} cache_t;
3243
3251typedef struct {
3252
3254 int np;
3255
3257 int nsza;
3258
3260 int no3c;
3261
3263 double p[CP];
3264
3266 double sza[CSZA];
3267
3269 double o3c[CO3];
3270
3272 double n2o[CP][CSZA][CO3];
3273
3275 double ccl4[CP][CSZA][CO3];
3276
3278 double ccl3f[CP][CSZA][CO3];
3279
3281 double ccl2f2[CP][CSZA][CO3];
3282
3284 double o2[CP][CSZA][CO3];
3285
3287 double o3_1[CP][CSZA][CO3];
3288
3290 double o3_2[CP][CSZA][CO3];
3291
3293 double h2o2[CP][CSZA][CO3];
3294
3296 double h2o[CP][CSZA][CO3];
3297
3298} clim_photo_t;
3299
3307typedef struct {
3308
3311
3313 double time[CTS];
3314
3316 double vmr[CTS];
3317
3318} clim_ts_t;
3319
3327typedef struct {
3328
3331
3333 int nlat;
3334
3336 int np;
3337
3339 double time[CT];
3340
3342 double lat[CY];
3343
3345 double p[CP];
3346
3348 double vmr[CT][CP][CY];
3349
3350} clim_zm_t;
3351
3359typedef struct {
3360
3363
3366
3368 double tropo_time[12];
3369
3371 double tropo_lat[73];
3372
3374 double tropo[12][73];
3375
3378
3381
3384
3387
3390
3393
3396
3399
3402
3405
3408
3409} clim_t;
3410
3418typedef struct {
3419
3421 double time;
3422
3424 int nx;
3425
3427 int ny;
3428
3430 int np;
3431
3433 int npl;
3434
3436 double lon[EX];
3437
3439 double lat[EY];
3440
3442 double p[EP];
3443
3445 double hybrid[EP];
3446
3448 double hyam[EP];
3449
3451 double hybm[EP];
3452
3454 double eta[EP];
3455
3457 float ps[EX][EY];
3458
3460 float ts[EX][EY];
3461
3463 float zs[EX][EY];
3464
3466 float us[EX][EY];
3467
3469 float vs[EX][EY];
3470
3472 float ess[EX][EY];
3473
3475 float nss[EX][EY];
3476
3478 float shf[EX][EY];
3479
3481 float lsm[EX][EY];
3482
3484 float sst[EX][EY];
3485
3487 float pbl[EX][EY];
3488
3490 float pt[EX][EY];
3491
3493 float tt[EX][EY];
3494
3496 float zt[EX][EY];
3497
3499 float h2ot[EX][EY];
3500
3502 float pct[EX][EY];
3503
3505 float pcb[EX][EY];
3506
3508 float cl[EX][EY];
3509
3511 float plcl[EX][EY];
3512
3514 float plfc[EX][EY];
3515
3517 float pel[EX][EY];
3518
3520 float cape[EX][EY];
3521
3523 float cin[EX][EY];
3524
3526 float o3c[EX][EY];
3527
3529 float z[EX][EY][EP];
3530
3532 float t[EX][EY][EP];
3533
3535 float u[EX][EY][EP];
3536
3538 float v[EX][EY][EP];
3539
3541 float w[EX][EY][EP];
3542
3544 float pv[EX][EY][EP];
3545
3547 float h2o[EX][EY][EP];
3548
3550 float o3[EX][EY][EP];
3551
3553 float lwc[EX][EY][EP];
3554
3556 float rwc[EX][EY][EP];
3557
3559 float iwc[EX][EY][EP];
3560
3562 float swc[EX][EY][EP];
3563
3565 float cc[EX][EY][EP];
3566
3568 float pl[EX][EY][EP];
3569
3571 float ul[EX][EY][EP];
3572
3574 float vl[EX][EY][EP];
3575
3577 float wl[EX][EY][EP];
3578
3580 float zetal[EX][EY][EP];
3581
3583 float zeta_dotl[EX][EY][EP];
3584
3585} met_t;
3586
3592typedef struct {
3593
3594 /* ------------------------------------------------------------
3595 MPI Information
3596 ------------------------------------------------------------ */
3597
3599 int rank;
3600
3602 int size;
3603
3605 int neighbours[DD_NNMAX];
3606
3607#ifdef DD
3609 MPI_Datatype MPI_Particle;
3610#endif
3611
3612 /* ------------------------------------------------------------
3613 Properties of subdomains
3614 ------------------------------------------------------------ */
3615
3618
3621
3624
3627
3629 size_t subdomain_start[4];
3630
3632 size_t subdomain_count[4];
3633
3635 size_t halo_bnd_start[4];
3636
3638 size_t halo_bnd_count[4];
3639
3642
3645
3646 /* ------------------------------------------------------------
3647 Caches
3648 ------------------------------------------------------------ */
3649
3651 int init;
3652
3653#ifdef DD
3654
3656 double a[NP];
3657
3659 int p[NP];
3660
3662 double help[NP];
3663
3664#endif
3665
3666} dd_t;
3667
3668/* ------------------------------------------------------------
3669 OpenACC routines...
3670 ------------------------------------------------------------ */
3671
3672#ifdef _OPENACC
3673#pragma acc routine (clim_oh)
3674#pragma acc routine (clim_photo)
3675#pragma acc routine (clim_tropo)
3676#pragma acc routine (clim_ts)
3677#pragma acc routine (clim_zm)
3678#pragma acc routine (cos_sza)
3679#pragma acc routine (intpol_check_lon_lat)
3680#pragma acc routine (intpol_met_4d_zeta)
3681#pragma acc routine (intpol_met_space_3d)
3682#pragma acc routine (intpol_met_space_2d)
3683#pragma acc routine (intpol_met_time_3d)
3684#pragma acc routine (intpol_met_time_2d)
3685#pragma acc routine (kernel_weight)
3686#pragma acc routine (lapse_rate)
3687#pragma acc routine (locate_irr)
3688#pragma acc routine (locate_irr_float)
3689#pragma acc routine (locate_reg)
3690#pragma acc routine (locate_vert)
3691#pragma acc routine (nat_temperature)
3692#pragma acc routine (pbl_weight)
3693#pragma acc routine (sedi)
3694#pragma acc routine (stddev)
3695#pragma acc routine (tropo_weight)
3696#endif
3697
3698/* ------------------------------------------------------------
3699 Functions...
3700 ------------------------------------------------------------ */
3701
3724 void *data,
3725 size_t N);
3726
3741void cart2geo(
3742 const double *x,
3743 double *z,
3744 double *lon,
3745 double *lat);
3746
3769double clim_oh(
3770 const ctl_t * ctl,
3771 const clim_t * clim,
3772 const double t,
3773 const double lon,
3774 const double lat,
3775 const double p);
3776
3796 const ctl_t * ctl,
3797 clim_t * clim);
3798
3828double clim_photo(
3829 const double rate[CP][CSZA][CO3],
3830 const clim_photo_t * photo,
3831 const double p,
3832 const double sza,
3833 const double o3c);
3834
3860double clim_tropo(
3861 const clim_t * clim,
3862 const double t,
3863 const double lat);
3864
3883void clim_tropo_init(
3884 clim_t * clim);
3885
3902double clim_ts(
3903 const clim_ts_t * ts,
3904 const double t);
3905
3927double clim_zm(
3928 const clim_zm_t * zm,
3929 const double t,
3930 const double lat,
3931 const double p);
3932
3977 const ctl_t * ctl,
3978 const char *varname,
3979 float *array,
3980 const size_t nx,
3981 const size_t ny,
3982 const size_t np,
3983 const double *plev,
3984 const int decompress,
3985 FILE * inout);
3986
4019void compress_pck(
4020 const char *varname,
4021 float *array,
4022 const size_t nxy,
4023 const size_t nz,
4024 const int decompress,
4025 FILE * inout);
4026
4057 const char *varname,
4058 float *array,
4059 const int nx,
4060 const int ny,
4061 const int nz,
4062 const int precision,
4063 const double tolerance,
4064 const int decompress,
4065 FILE * inout);
4066
4106 const char *varname,
4107 float *array,
4108 const int nx,
4109 const int ny,
4110 const int nz,
4111 const int precision,
4112 const double tolerance,
4113 const int decompress,
4114 FILE * inout);
4115
4138 const char *varname,
4139 float *array,
4140 const size_t n,
4141 const int decompress,
4142 const int level,
4143 FILE * inout);
4144
4169double cos_sza(
4170 const double sec,
4171 const double lon,
4172 const double lat);
4173
4196void day2doy(
4197 const int year,
4198 const int mon,
4199 const int day,
4200 int *doy);
4201
4249 atm_t * atm,
4250 ctl_t * ctl,
4251 dd_t * dd,
4252 int init);
4253
4319 atm_t * atm,
4320 particle_t * particles,
4321 ctl_t * ctl,
4322 int *nparticles,
4323 cache_t * cache,
4324 int rank);
4325
4390 double lon,
4391 double lat,
4392 met_t * met,
4393 ctl_t * ctl,
4394 int mpi_size,
4395 int nx_glob,
4396 int ny_glob);
4397
4428 particle_t * particles,
4429 int *nparticles,
4430 MPI_Datatype MPI_Particle,
4431 int *neighbours,
4432 int nneighbours,
4433 ctl_t ctl);
4434
4458 const ctl_t ctl,
4459 dd_t * dd);
4460
4486 ctl_t * ctl,
4487 dd_t * dd,
4488 atm_t * atm);
4489
4514 met_t * met,
4515 int nx_glob);
4516
4542 atm_t * atm,
4543 particle_t * particles,
4544 ctl_t * ctl,
4545 int *nparticles,
4546 cache_t * cache);
4547
4570 MPI_Datatype * MPI_Particle);
4571
4607 const ctl_t * ctl,
4608 met_t * met0,
4609 atm_t * atm,
4610 dd_t * dd,
4611 int *nparticles,
4612 int *rank);
4613
4642 double *a,
4643 dd_t * dd,
4644 const int np);
4645
4667void doy2day(
4668 const int year,
4669 const int doy,
4670 int *mon,
4671 int *day);
4672
4699void fft_help(
4700 double *fcReal,
4701 double *fcImag,
4702 const int n);
4703
4730void geo2cart(
4731 const double z,
4732 const double lon,
4733 const double lat,
4734 double *x);
4735
4760void get_met_help(
4761 const ctl_t * ctl,
4762 const double t,
4763 const int direct,
4764 const char *metbase,
4765 const double dt_met,
4766 char *filename);
4767
4791void get_met_replace(
4792 char *orig,
4793 char *search,
4794 char *repl);
4795
4832void get_tropo(
4833 const int met_tropo,
4834 ctl_t * ctl,
4835 clim_t * clim,
4836 met_t * met,
4837 const double *lons,
4838 const int nx,
4839 const double *lats,
4840 const int ny,
4841 double *pt,
4842 double *zt,
4843 double *tt,
4844 double *qt,
4845 double *o3t,
4846 double *ps,
4847 double *zs);
4848
4870 const double *lons,
4871 const int nlon,
4872 const double *lats,
4873 const int nlat,
4874 const double lon,
4875 const double lat,
4876 double *lon2,
4877 double *lat2);
4878
4921 const met_t * met0,
4922 float height0[EX][EY][EP],
4923 float array0[EX][EY][EP],
4924 const met_t * met1,
4925 float height1[EX][EY][EP],
4926 float array1[EX][EY][EP],
4927 const double ts,
4928 const double height,
4929 const double lon,
4930 const double lat,
4931 double *var,
4932 int *ci,
4933 double *cw,
4934 const int init);
4935
4971 const met_t * met,
4972 float array[EX][EY][EP],
4973 const double p,
4974 const double lon,
4975 const double lat,
4976 double *var,
4977 int *ci,
4978 double *cw,
4979 const int init);
4980
5016 const met_t * met,
5017 float array[EX][EY],
5018 const double lon,
5019 const double lat,
5020 double *var,
5021 int *ci,
5022 double *cw,
5023 const int init);
5024
5059 const met_t * met0,
5060 float array0[EX][EY][EP],
5061 const met_t * met1,
5062 float array1[EX][EY][EP],
5063 const double ts,
5064 const double p,
5065 const double lon,
5066 const double lat,
5067 double *var,
5068 int *ci,
5069 double *cw,
5070 const int init);
5071
5107 const met_t * met0,
5108 float array0[EX][EY],
5109 const met_t * met1,
5110 float array1[EX][EY],
5111 const double ts,
5112 const double lon,
5113 const double lat,
5114 double *var,
5115 int *ci,
5116 double *cw,
5117 const int init);
5118
5156void intpol_tropo_3d(
5157 const double time0,
5158 float array0[EX][EY],
5159 const double time1,
5160 float array1[EX][EY],
5161 const double lons[EX],
5162 const double lats[EY],
5163 const int nlon,
5164 const int nlat,
5165 const double time,
5166 const double lon,
5167 const double lat,
5168 const int method,
5169 double *var,
5170 double *sigma);
5171
5198void jsec2time(
5199 const double jsec,
5200 int *year,
5201 int *mon,
5202 int *day,
5203 int *hour,
5204 int *min,
5205 int *sec,
5206 double *remain);
5207
5234double kernel_weight(
5235 const double kz[EP],
5236 const double kw[EP],
5237 const int nk,
5238 const double p);
5239
5278double lapse_rate(
5279 const double t,
5280 const double h2o);
5281
5311 ctl_t * ctl);
5312
5332int locate_irr(
5333 const double *xx,
5334 const int n,
5335 const double x);
5336
5363 const float *xx,
5364 const int n,
5365 const double x,
5366 const int ig);
5367
5388int locate_reg(
5389 const double *xx,
5390 const int n,
5391 const double x);
5392
5414void locate_vert(
5415 float profiles[EX][EY][EP],
5416 const int np,
5417 const int lon_ap_ind,
5418 const int lat_ap_ind,
5419 const double alt_ap,
5420 int *ind);
5421
5447void module_advect(
5448 const ctl_t * ctl,
5449 const cache_t * cache,
5450 met_t * met0,
5451 met_t * met1,
5452 atm_t * atm);
5453
5477 const ctl_t * ctl,
5478 const cache_t * cache,
5479 met_t * met0,
5480 met_t * met1,
5481 atm_t * atm);
5482
5520 const ctl_t * ctl,
5521 const cache_t * cache,
5522 const clim_t * clim,
5523 met_t * met0,
5524 met_t * met1,
5525 atm_t * atm);
5526
5568void module_chem_grid(
5569 const ctl_t * ctl,
5570 met_t * met0,
5571 met_t * met1,
5572 atm_t * atm,
5573 const double t);
5574
5602void module_chem_init(
5603 const ctl_t * ctl,
5604 const cache_t * cache,
5605 const clim_t * clim,
5606 met_t * met0,
5607 met_t * met1,
5608 atm_t * atm);
5609
5634 const ctl_t * ctl,
5635 cache_t * cache,
5636 met_t * met0,
5637 met_t * met1,
5638 atm_t * atm);
5639
5668 ctl_t * ctl,
5669 atm_t * atm,
5670 cache_t * cache,
5671 dd_t * dd,
5672 met_t ** met);
5673
5700void module_decay(
5701 const ctl_t * ctl,
5702 const cache_t * cache,
5703 const clim_t * clim,
5704 atm_t * atm);
5705
5742void module_diff_meso(
5743 const ctl_t * ctl,
5744 cache_t * cache,
5745 met_t * met0,
5746 met_t * met1,
5747 atm_t * atm);
5748
5782void module_diff_pbl(
5783 const ctl_t * ctl,
5784 cache_t * cache,
5785 met_t * met0,
5786 met_t * met1,
5787 atm_t * atm);
5788
5843void module_diff_turb(
5844 const ctl_t * ctl,
5845 cache_t * cache,
5846 const clim_t * clim,
5847 met_t * met0,
5848 met_t * met1,
5849 atm_t * atm);
5850
5870void module_dry_depo(
5871 const ctl_t * ctl,
5872 const cache_t * cache,
5873 met_t * met0,
5874 met_t * met1,
5875 atm_t * atm);
5876
5909void module_h2o2_chem(
5910 const ctl_t * ctl,
5911 const cache_t * cache,
5912 const clim_t * clim,
5913 met_t * met0,
5914 met_t * met1,
5915 atm_t * atm);
5916
5937 const ctl_t * ctl,
5938 cache_t * cache,
5939 met_t * met0,
5940 met_t * met1,
5941 atm_t * atm);
5942
5960void module_isosurf(
5961 const ctl_t * ctl,
5962 const cache_t * cache,
5963 met_t * met0,
5964 met_t * met1,
5965 atm_t * atm);
5966
5999 ctl_t * ctl,
6000 cache_t * cache,
6001 clim_t * clim,
6002 met_t * met0,
6003 met_t * met1,
6004 atm_t * atm);
6005
6024void module_meteo(
6025 const ctl_t * ctl,
6026 const cache_t * cache,
6027 const clim_t * clim,
6028 met_t * met0,
6029 met_t * met1,
6030 atm_t * atm);
6031
6049void module_mixing(
6050 const ctl_t * ctl,
6051 const clim_t * clim,
6052 atm_t * atm,
6053 const double t);
6054
6083 const ctl_t * ctl,
6084 const clim_t * clim,
6085 atm_t * atm,
6086 const int *ixs,
6087 const int *iys,
6088 const int *izs,
6089 const int qnt_idx,
6090 const int use_ensemble);
6091
6124void module_oh_chem(
6125 const ctl_t * ctl,
6126 const cache_t * cache,
6127 const clim_t * clim,
6128 met_t * met0,
6129 met_t * met1,
6130 atm_t * atm);
6131
6159void module_position(
6160 const cache_t * cache,
6161 met_t * met0,
6162 met_t * met1,
6163 atm_t * atm);
6164
6189void module_rng_init(
6190 const int ntask);
6191
6217void module_rng(
6218 const ctl_t * ctl,
6219 double *rs,
6220 const size_t n,
6221 const int method);
6222
6245void module_sedi(
6246 const ctl_t * ctl,
6247 const cache_t * cache,
6248 met_t * met0,
6249 met_t * met1,
6250 atm_t * atm);
6251
6275void module_sort(
6276 const ctl_t * ctl,
6277 met_t * met0,
6278 atm_t * atm);
6279
6299void module_sort_help(
6300 double *a,
6301 const int *p,
6302 const int np);
6303
6327void module_timesteps(
6328 const ctl_t * ctl,
6329 cache_t * cache,
6330 met_t * met0,
6331 atm_t * atm,
6332 const double t);
6333
6355 ctl_t * ctl,
6356 const atm_t * atm);
6357
6391 const ctl_t * ctl,
6392 const cache_t * cache,
6393 const clim_t * clim,
6394 met_t * met0,
6395 met_t * met1,
6396 atm_t * atm);
6397
6427void module_wet_depo(
6428 const ctl_t * ctl,
6429 const cache_t * cache,
6430 met_t * met0,
6431 met_t * met1,
6432 atm_t * atm);
6433
6465void mptrac_alloc(
6466 ctl_t ** ctl,
6467 cache_t ** cache,
6468 clim_t ** clim,
6469 met_t ** met0,
6470 met_t ** met1,
6471 atm_t ** atm,
6472 dd_t ** dd);
6473
6504void mptrac_free(
6505 ctl_t * ctl,
6506 cache_t * cache,
6507 clim_t * clim,
6508 met_t * met0,
6509 met_t * met1,
6510 atm_t * atm,
6511 dd_t * dd);
6512
6548void mptrac_get_met(
6549 ctl_t * ctl,
6550 clim_t * clim,
6551 const double t,
6552 met_t ** met0,
6553 met_t ** met1,
6554 dd_t * dd);
6555
6575void mptrac_init(
6576 ctl_t * ctl,
6577 cache_t * cache,
6578 clim_t * clim,
6579 atm_t * atm,
6580 const int ntask);
6581
6617int mptrac_read_atm(
6618 const char *filename,
6619 const ctl_t * ctl,
6620 atm_t * atm);
6621
6653void mptrac_read_clim(
6654 const ctl_t * ctl,
6655 clim_t * clim);
6656
6686void mptrac_read_ctl(
6687 const char *filename,
6688 int argc,
6689 char *argv[],
6690 ctl_t * ctl);
6691
6722int mptrac_read_met(
6723 const char *filename,
6724 const ctl_t * ctl,
6725 const clim_t * clim,
6726 met_t * met,
6727 dd_t * dd);
6728
6750 ctl_t * ctl,
6751 cache_t * cache,
6752 clim_t * clim,
6753 met_t ** met0,
6754 met_t ** met1,
6755 atm_t * atm,
6756 double t,
6757 dd_t * dd);
6758
6788void mptrac_write_atm(
6789 const char *filename,
6790 const ctl_t * ctl,
6791 const atm_t * atm,
6792 const double t);
6793
6831void mptrac_write_met(
6832 const char *filename,
6833 const ctl_t * ctl,
6834 met_t * met);
6835
6870 const char *dirname,
6871 const ctl_t * ctl,
6872 met_t * met0,
6873 met_t * met1,
6874 atm_t * atm,
6875 const double t);
6876
6908 const ctl_t * ctl,
6909 const cache_t * cache,
6910 const clim_t * clim,
6911 met_t ** met0,
6912 met_t ** met1,
6913 const atm_t * atm);
6914
6945 const ctl_t * ctl,
6946 const cache_t * cache,
6947 const clim_t * clim,
6948 met_t ** met0,
6949 met_t ** met1,
6950 const atm_t * atm);
6951
6979double nat_temperature(
6980 const double p,
6981 const double h2o,
6982 const double hno3);
6983
7004double pbl_weight(
7005 const ctl_t * ctl,
7006 const atm_t * atm,
7007 const int ip,
7008 const double pbl,
7009 const double ps);
7010
7043int read_atm_asc(
7044 const char *filename,
7045 const ctl_t * ctl,
7046 atm_t * atm);
7047
7078int read_atm_bin(
7079 const char *filename,
7080 const ctl_t * ctl,
7081 atm_t * atm);
7082
7107int read_atm_clams(
7108 const char *filename,
7109 const ctl_t * ctl,
7110 atm_t * atm);
7111
7141int read_atm_nc(
7142 const char *filename,
7143 const ctl_t * ctl,
7144 atm_t * atm);
7145
7174void read_clim_photo(
7175 const char *filename,
7176 clim_photo_t * photo);
7177
7195 const int ncid,
7196 const char *varname,
7197 const clim_photo_t * photo,
7198 double var[CP][CSZA][CO3]);
7199
7223int read_clim_ts(
7224 const char *filename,
7225 clim_ts_t * ts);
7226
7253void read_clim_zm(
7254 const char *filename,
7255 const char *varname,
7256 clim_zm_t * zm);
7257
7285void read_kernel(
7286 const char *filename,
7287 double kz[EP],
7288 double kw[EP],
7289 int *nk);
7290
7322int read_met_bin(
7323 const char *filename,
7324 const ctl_t * ctl,
7325 met_t * met);
7326
7352void read_met_bin_2d(
7353 FILE * in,
7354 const met_t * met,
7355 float var[EX][EY],
7356 const char *varname);
7357
7395void read_met_bin_3d(
7396 FILE * in,
7397 const ctl_t * ctl,
7398 const met_t * met,
7399 float var[EX][EY][EP],
7400 const char *varname,
7401 const float bound_min,
7402 const float bound_max);
7403
7431void read_met_cape(
7432 const ctl_t * ctl,
7433 const clim_t * clim,
7434 met_t * met);
7435
7458void read_met_cloud(
7459 met_t * met);
7460
7486void read_met_detrend(
7487 const ctl_t * ctl,
7488 met_t * met);
7489
7513 met_t * met);
7514
7541void read_met_geopot(
7542 const ctl_t * ctl,
7543 met_t * met);
7544
7572 const char *filename,
7573 const ctl_t * ctl,
7574 met_t * met);
7575
7597 codes_handle ** handles,
7598 int count_handles,
7599 met_t * met);
7600
7621 codes_handle ** handles,
7622 const int num_messages,
7623 const ctl_t * ctl,
7624 met_t * met);
7625
7656 codes_handle ** handles,
7657 const int num_messages,
7658 const ctl_t * ctl,
7659 met_t * met);
7660
7689void read_met_ml2pl(
7690 const ctl_t * ctl,
7691 const met_t * met,
7692 float var[EX][EY][EP],
7693 const char *varname);
7694
7717 const ctl_t * ctl,
7718 met_t * met);
7719
7750int read_met_nc(
7751 const char *filename,
7752 const ctl_t * ctl,
7753 met_t * met,
7754 dd_t * dd);
7755
7790void read_met_nc_grid(
7791 const char *filename,
7792 const int ncid,
7793 const ctl_t * ctl,
7794 met_t * met,
7795 dd_t * dd);
7796
7842 dd_t * dd,
7843 const ctl_t * ctl,
7844 met_t * met,
7845 const int ncid);
7846
7879 const int ncid,
7880 const ctl_t * ctl,
7881 met_t * met,
7882 dd_t * dd);
7883
7914 const int ncid,
7915 const ctl_t * ctl,
7916 met_t * met,
7917 dd_t * dd);
7918
7951int read_met_nc_2d(
7952 const int ncid,
7953 const char *varname,
7954 const char *varname2,
7955 const char *varname3,
7956 const char *varname4,
7957 const char *varname5,
7958 const char *varname6,
7959 const ctl_t * ctl,
7960 const met_t * met,
7961 dd_t * dd,
7962 float dest[EX][EY],
7963 const float scl,
7964 const int init);
7965
7995int read_met_nc_3d(
7996 const int ncid,
7997 const char *varname,
7998 const char *varname2,
7999 const char *varname3,
8000 const char *varname4,
8001 const ctl_t * ctl,
8002 const met_t * met,
8003 dd_t * dd,
8004 float dest[EX][EY][EP],
8005 const float scl);
8006
8052void read_met_pbl(
8053 const ctl_t * ctl,
8054 met_t * met);
8055
8088 met_t * met);
8089
8120 met_t * met);
8121
8152void read_met_pv(
8153 met_t * met);
8154
8177void read_met_ozone(
8178 met_t * met);
8179
8208void read_met_sample(
8209 const ctl_t * ctl,
8210 met_t * met);
8211
8240void read_met_tropo(
8241 const ctl_t * ctl,
8242 const clim_t * clim,
8243 met_t * met);
8244
8276void read_obs(
8277 const char *filename,
8278 const ctl_t * ctl,
8279 double *rt,
8280 double *rz,
8281 double *rlon,
8282 double *rlat,
8283 double *robs,
8284 int *nobs);
8285
8313void read_obs_asc(
8314 const char *filename,
8315 double *rt,
8316 double *rz,
8317 double *rlon,
8318 double *rlat,
8319 double *robs,
8320 int *nobs);
8321
8348void read_obs_nc(
8349 const char *filename,
8350 double *rt,
8351 double *rz,
8352 double *rlon,
8353 double *rlat,
8354 double *robs,
8355 int *nobs);
8356
8390double scan_ctl(
8391 const char *filename,
8392 int argc,
8393 char *argv[],
8394 const char *varname,
8395 const int arridx,
8396 const char *defvalue,
8397 char *value);
8398
8425double sedi(
8426 const double p,
8427 const double T,
8428 const double rp,
8429 const double rhop);
8430
8460void spline(
8461 const double *x,
8462 const double *y,
8463 const int n,
8464 const double *x2,
8465 double *y2,
8466 const int n2,
8467 const int method);
8468
8491float stddev(
8492 const float *data,
8493 const int n);
8494
8519void time2jsec(
8520 const int year,
8521 const int mon,
8522 const int day,
8523 const int hour,
8524 const int min,
8525 const int sec,
8526 const double remain,
8527 double *jsec);
8528
8557void timer(
8558 const char *name,
8559 const char *group,
8560 const int output);
8561
8587double time_from_filename(
8588 const char *filename,
8589 const int offset);
8590
8608double tropo_weight(
8609 const clim_t * clim,
8610 const atm_t * atm,
8611 const int ip);
8612
8635void write_atm_asc(
8636 const char *filename,
8637 const ctl_t * ctl,
8638 const atm_t * atm,
8639 const double t);
8640
8664void write_atm_bin(
8665 const char *filename,
8666 const ctl_t * ctl,
8667 const atm_t * atm);
8668
8692void write_atm_clams(
8693 const char *filename,
8694 const ctl_t * ctl,
8695 const atm_t * atm);
8696
8722 const char *dirname,
8723 const ctl_t * ctl,
8724 const atm_t * atm,
8725 const double t);
8726
8750void write_atm_nc(
8751 const char *filename,
8752 const ctl_t * ctl,
8753 const atm_t * atm);
8754
8783void write_csi(
8784 const char *filename,
8785 const ctl_t * ctl,
8786 const atm_t * atm,
8787 const double t);
8788
8830 const char *filename,
8831 const ctl_t * ctl,
8832 const atm_t * atm,
8833 const double t);
8834
8862void write_ens(
8863 const char *filename,
8864 const ctl_t * ctl,
8865 const atm_t * atm,
8866 const double t);
8867
8906void write_grid(
8907 const char *filename,
8908 const ctl_t * ctl,
8909 met_t * met0,
8910 met_t * met1,
8911 const atm_t * atm,
8912 const double t);
8913
8959void write_grid_asc(
8960 const char *filename,
8961 const ctl_t * ctl,
8962 const double *cd,
8963 double *mean[NQ],
8964 double *sigma[NQ],
8965 const double *vmr_impl,
8966 const double t,
8967 const double *z,
8968 const double *lon,
8969 const double *lat,
8970 const double *area,
8971 const double dz,
8972 const int *np);
8973
9016void write_grid_nc(
9017 const char *filename,
9018 const ctl_t * ctl,
9019 const double *cd,
9020 double *mean[NQ],
9021 double *sigma[NQ],
9022 const double *vmr_impl,
9023 const double t,
9024 const double *z,
9025 const double *lon,
9026 const double *lat,
9027 const double *area,
9028 const double dz,
9029 const int *np);
9030
9060void write_met_bin(
9061 const char *filename,
9062 const ctl_t * ctl,
9063 met_t * met);
9064
9092void write_met_bin_2d(
9093 FILE * out,
9094 met_t * met,
9095 float var[EX][EY],
9096 const char *varname);
9097
9135void write_met_bin_3d(
9136 FILE * out,
9137 const ctl_t * ctl,
9138 met_t * met,
9139 float var[EX][EY][EP],
9140 const char *varname,
9141 const int precision,
9142 const double tolerance);
9143
9171void write_met_nc(
9172 const char *filename,
9173 const ctl_t * ctl,
9174 met_t * met);
9175
9198void write_met_nc_2d(
9199 const int ncid,
9200 const char *varname,
9201 met_t * met,
9202 float var[EX][EY],
9203 const float scl);
9204
9228void write_met_nc_3d(
9229 const int ncid,
9230 const char *varname,
9231 met_t * met,
9232 float var[EX][EY][EP],
9233 const float scl);
9234
9265void write_prof(
9266 const char *filename,
9267 const ctl_t * ctl,
9268 met_t * met0,
9269 met_t * met1,
9270 const atm_t * atm,
9271 const double t);
9272
9304void write_sample(
9305 const char *filename,
9306 const ctl_t * ctl,
9307 met_t * met0,
9308 met_t * met1,
9309 const atm_t * atm,
9310 const double t);
9311
9338void write_station(
9339 const char *filename,
9340 const ctl_t * ctl,
9341 atm_t * atm,
9342 const double t);
9343
9372void write_vtk(
9373 const char *filename,
9374 const ctl_t * ctl,
9375 const atm_t * atm,
9376 const double t);
9377
9378#endif /* LIBTRAC_H */
void read_met_geopot(const ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:8122
int dd_init(ctl_t *ctl, dd_t *dd, atm_t *atm)
Initializes domain decomposition for parallel processing.
void compress_zstd(const char *varname, float *array, const size_t n, const int decompress, const int level, FILE *inout)
Compresses or decompresses a float array using Zstandard (ZSTD).
#define LEN
Maximum length of ASCII data lines.
Definition: mptrac.h:298
void mptrac_alloc(ctl_t **ctl, cache_t **cache, clim_t **clim, met_t **met0, met_t **met1, atm_t **atm, dd_t **dd)
Allocates and initializes memory resources for MPTRAC.
Definition: mptrac.c:5156
void mptrac_write_atm(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes air parcel data to a file in various formats.
Definition: mptrac.c:6778
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:1052
void read_met_grib_surface(codes_handle **handles, const int num_messages, const ctl_t *ctl, met_t *met)
Reads surface meteorological data from a grib file and stores it in the meteorological data structure...
void read_met_extrapolate(met_t *met)
Extrapolates meteorological data.
Definition: mptrac.c:8082
void write_atm_clams_traj(const char *dirname, const ctl_t *ctl, const atm_t *atm, const double t)
Writes CLaMS trajectory data to a NetCDF file.
Definition: mptrac.c:11466
int read_met_nc_2d(const int ncid, const char *varname, const char *varname2, const char *varname3, const char *varname4, const char *varname5, const char *varname6, const ctl_t *ctl, const met_t *met, dd_t *dd, float dest[EX][EY], const float scl, const int init)
Reads a 2-dimensional meteorological variable from a NetCDF file.
Definition: mptrac.c:8752
void write_met_nc_2d(const int ncid, const char *varname, met_t *met, float var[EX][EY], const float scl)
Writes a 2D meteorological variable to a NetCDF file.
Definition: mptrac.c:12865
void read_met_sample(const ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:10505
void write_met_bin_3d(FILE *out, const ctl_t *ctl, met_t *met, float var[EX][EY][EP], const char *varname, const int precision, const double tolerance)
Writes a 3-dimensional meteorological variable to a binary file.
Definition: mptrac.c:12611
void read_obs(const char *filename, const ctl_t *ctl, double *rt, double *rz, double *rlon, double *rlat, double *robs, int *nobs)
Reads observation data from a file and stores it in arrays.
Definition: mptrac.c:10850
void module_advect(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Advances particle positions using different advection schemes.
Definition: mptrac.c:2972
void module_timesteps(const ctl_t *ctl, cache_t *cache, met_t *met0, atm_t *atm, const double t)
Calculate time steps for air parcels based on specified conditions.
Definition: mptrac.c:4872
void module_meteo(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Update atmospheric properties using meteorological data.
Definition: mptrac.c:4189
void read_clim_photo(const char *filename, clim_photo_t *photo)
Reads photolysis rates from a NetCDF file and populates the given photolysis structure.
Definition: mptrac.c:7210
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:7921
void module_decay(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, atm_t *atm)
Simulate exponential decay processes for atmospheric particles.
Definition: mptrac.c:3575
double sedi(const double p, const double T, const double rp, const double rhop)
Calculates the sedimentation velocity of a particle in air.
Definition: mptrac.c:11023
double cos_sza(const double sec, const double lon, const double lat)
Calculates the cosine of the solar zenith angle.
Definition: mptrac.c:1011
#define METVAR
Number of 3-D meteorological variables.
Definition: mptrac.h:303
void intpol_met_space_2d(const met_t *met, float array[EX][EY], const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological variables in 2D space.
Definition: mptrac.c:2371
int read_met_nc_3d(const int ncid, const char *varname, const char *varname2, const char *varname3, const char *varname4, const ctl_t *ctl, const met_t *met, dd_t *dd, float dest[EX][EY][EP], const float scl)
Reads a 3-dimensional meteorological variable from a NetCDF file.
Definition: mptrac.c:9014
void dd_sort(const ctl_t *ctl, met_t *met0, atm_t *atm, dd_t *dd, int *nparticles, int *rank)
Sort particles according to box index and target rank for neighbours.
int read_atm_nc(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a generic netCDF file and populates the given atmospheric structure.
Definition: mptrac.c:7177
void write_csi_ens(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes ensemble-based Critical Success Index (CSI) and other verification statistics to an output fil...
void read_met_pbl(const ctl_t *ctl, met_t *met)
Computes the planetary boundary layer (PBL) pressure based on meteorological data.
Definition: mptrac.c:10113
void read_met_detrend(const ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:7978
void read_met_tropo(const ctl_t *ctl, const clim_t *clim, met_t *met)
Calculates the tropopause and related meteorological variables based on various methods and stores th...
Definition: mptrac.c:10678
void read_obs_asc(const char *filename, double *rt, double *rz, double *rlon, double *rlat, double *robs, int *nobs)
Reads observation data from an ASCII file.
Definition: mptrac.c:10894
void module_chem_init(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Initializes the chemistry modules by setting atmospheric composition.
Definition: mptrac.c:3420
int locate_reg(const double *xx, const int n, const double x)
Locate the index of the interval containing a given value in a regular grid.
Definition: mptrac.c:2933
void get_tropo(const int met_tropo, ctl_t *ctl, clim_t *clim, met_t *met, const double *lons, const int nx, const double *lats, const int ny, double *pt, double *zt, double *tt, double *qt, double *o3t, double *ps, double *zs)
Calculate tropopause data.
Definition: mptrac.c:2071
void locate_vert(float profiles[EX][EY][EP], const int np, const int lon_ap_ind, const int lat_ap_ind, const double alt_ap, int *ind)
Locate the four vertical indizes of a box for a given height value.
Definition: mptrac.c:2952
void compress_cms(const ctl_t *ctl, const char *varname, float *array, const size_t nx, const size_t ny, const size_t np, const double *plev, const int decompress, FILE *inout)
Compresses or decompresses a 3-D meteorological field using cmultiscale.
void read_met_nc_levels(const int ncid, const ctl_t *ctl, met_t *met, dd_t *dd)
Reads and processes meteorological level data from NetCDF files with domain decomposition.
Definition: mptrac.c:8555
void read_met_monotonize(const ctl_t *ctl, met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:9748
int read_clim_ts(const char *filename, clim_ts_t *ts)
Reads a climatological time series from a file and populates the given time series structure.
Definition: mptrac.c:7329
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:10250
void mptrac_run_timestep(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t **met0, met_t **met1, atm_t *atm, double t, dd_t *dd)
Executes a single timestep of the MPTRAC model simulation.
Definition: mptrac.c:6518
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:4919
void write_ens(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes ensemble data to a file.
Definition: mptrac.c:11948
void module_mixing(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const double t)
Update atmospheric properties through interparcel mixing.
Definition: mptrac.c:4296
void compress_zfp(const char *varname, float *array, const int nx, const int ny, const int nz, const int precision, const double tolerance, const int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats using the ZFP library.
double clim_zm(const clim_zm_t *zm, const double t, const double lat, const double p)
Interpolates monthly mean zonal mean climatological variables.
Definition: mptrac.c:405
#define EY
Maximum number of latitudes for meteo data.
Definition: mptrac.h:293
void module_mixing_help(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const int *ixs, const int *iys, const int *izs, const int qnt_idx, const int use_ensemble)
Perform subgrid-scale interparcel mixing of a given quantity.
Definition: mptrac.c:4367
void read_clim_photo_help(const int ncid, const char *varname, const clim_photo_t *photo, double var[CP][CSZA][CO3])
Reads a 3D climatological photochemistry variable from a NetCDF file.
Definition: mptrac.c:7301
void read_met_ml2pl(const ctl_t *ctl, const met_t *met, float var[EX][EY][EP], const char *varname)
Interpolates meteorological data to specified pressure levels.
Definition: mptrac.c:9706
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:204
void read_obs_nc(const char *filename, double *rt, double *rz, double *rlon, double *rlat, double *robs, int *nobs)
Reads observation data from a NetCDF file.
Definition: mptrac.c:10922
void dd_particles2atm(atm_t *atm, particle_t *particles, ctl_t *ctl, int *nparticles, cache_t *cache)
Converts particle data to atmospheric data.
void read_met_bin_2d(FILE *in, const met_t *met, float var[EX][EY], const char *varname)
Reads a 2-dimensional meteorological variable from a binary file and stores it in the provided array.
Definition: mptrac.c:7671
int locate_irr(const double *xx, const int n, const double x)
Locate the index of the interval containing a given value in a sorted array.
Definition: mptrac.c:2869
void module_isosurf_init(const ctl_t *ctl, cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Initialize the isosurface module based on atmospheric data.
Definition: mptrac.c:4013
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:2659
void intpol_met_4d_zeta(const met_t *met0, float height0[EX][EY][EP], float array0[EX][EY][EP], const met_t *met1, float height1[EX][EY][EP], float array1[EX][EY][EP], const double ts, const double height, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological variables to a given position and time.
Definition: mptrac.c:2141
void write_grid_asc(const char *filename, const ctl_t *ctl, const double *cd, double *mean[NQ], double *sigma[NQ], const double *vmr_impl, const double t, const double *z, const double *lon, const double *lat, const double *area, const double dz, const int *np)
Writes grid data to an ASCII file.
Definition: mptrac.c:12236
void mptrac_update_device(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t **met0, met_t **met1, const atm_t *atm)
Updates device memory for specified data structures.
Definition: mptrac.c:6666
void time2jsec(const int year, const int mon, const int day, const int hour, const int min, const int sec, const double remain, double *jsec)
Converts time components to seconds since January 1, 2000, 12:00:00 UTC.
Definition: mptrac.c:11124
void mptrac_init(ctl_t *ctl, cache_t *cache, clim_t *clim, atm_t *atm, const int ntask)
Initializes the MPTRAC model and its associated components.
Definition: mptrac.c:5364
void intpol_met_time_3d(const met_t *met0, float array0[EX][EY][EP], const met_t *met1, float array1[EX][EY][EP], const double ts, const double p, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological data in 3D space and time.
Definition: mptrac.c:2429
#define codes_handle
Placeholder when ECCODES is not available.
Definition: mptrac.h:190
void fft_help(double *fcReal, double *fcImag, const int n)
Computes the Fast Fourier Transform (FFT) of a complex sequence.
Definition: mptrac.c:1923
void module_wet_depo(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Perform wet deposition calculations for air parcels.
Definition: mptrac.c:5021
void compress_pck(const char *varname, float *array, const size_t nxy, const size_t nz, const int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats.
Definition: mptrac.c:680
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:6973
void spline(const double *x, const double *y, const int n, const double *x2, double *y2, const int n2, const int method)
Performs spline interpolation or linear interpolation.
Definition: mptrac.c:11056
#define CP
Maximum number of pressure levels for climatological data.
Definition: mptrac.h:348
#define NQ
Maximum number of quantities per data point.
Definition: mptrac.h:313
double clim_photo(const double rate[CP][CSZA][CO3], const clim_photo_t *photo, const double p, const double sza, const double o3c)
Calculates the photolysis rate for a given set of atmospheric conditions.
Definition: mptrac.c:147
void read_clim_zm(const char *filename, const char *varname, clim_zm_t *zm)
Reads zonally averaged climatological data from a netCDF file and populates the given structure.
Definition: mptrac.c:7383
#define EX
Maximum number of longitudes for meteo data.
Definition: mptrac.h:288
void read_met_nc_grid_dd_naive(dd_t *dd, const ctl_t *ctl, met_t *met, const int ncid)
Read meteorological grid data from a NetCDF file and set up subdomain decomposition with halos.
Definition: mptrac.c:9873
void module_sedi(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Simulate sedimentation of particles in the atmosphere.
Definition: mptrac.c:4740
int read_met_nc(const char *filename, const ctl_t *ctl, met_t *met, dd_t *dd)
Reads meteorological data from a NetCDF file and processes it.
Definition: mptrac.c:9833
void timer(const char *name, const char *group, const int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:11155
void write_atm_asc(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes air parcel data to an ASCII file or gnuplot.
Definition: mptrac.c:11281
void intpol_met_space_3d(const met_t *met, float array[EX][EY][EP], const double p, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological variables in 3D space.
Definition: mptrac.c:2313
void module_convection(const ctl_t *ctl, cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Performs convective mixing of atmospheric particles.
Definition: mptrac.c:3462
void read_kernel(const char *filename, double kz[EP], double kw[EP], int *nk)
Reads kernel function data from a file and populates the provided arrays.
Definition: mptrac.c:7482
void module_bound_cond(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Apply boundary conditions to particles based on meteorological and climatological data.
Definition: mptrac.c:3162
double scan_ctl(const char *filename, int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scans a control file or command-line arguments for a specified variable.
Definition: mptrac.c:10951
#define CT
Maximum number of time steps for climatological data.
Definition: mptrac.h:358
void module_advect_init(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Initializes the advection module by setting up pressure fields.
Definition: mptrac.c:3135
int dd_is_periodic_longitude(met_t *met, int nx_glob)
Check whether the longitude grid is periodic (global coverage).
int read_met_grib(const char *filename, const ctl_t *ctl, met_t *met)
Reads meteorological data from a grib file and processes it.
void mptrac_get_met(ctl_t *ctl, clim_t *clim, const double t, met_t **met0, met_t **met1, dd_t *dd)
Retrieves meteorological data for the specified time.
Definition: mptrac.c:5242
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:4834
float stddev(const float *data, const int n)
Calculates the standard deviation of a set of data.
Definition: mptrac.c:11103
void intpol_tropo_3d(const double time0, float array0[EX][EY], const double time1, float array1[EX][EY], const double lons[EX], const double lats[EY], const int nlon, const int nlat, const double time, const double lon, const double lat, const int method, double *var, double *sigma)
Interpolates tropopause data in 3D (latitude, longitude, and time).
Definition: mptrac.c:2491
void read_met_bin_3d(FILE *in, const ctl_t *ctl, const met_t *met, float var[EX][EY][EP], const char *varname, const float bound_min, const float bound_max)
Reads 3D meteorological data from a binary file, potentially using different compression methods.
Definition: mptrac.c:7700
int locate_irr_float(const float *xx, const int n, const double x, const int ig)
Locate the index of the interval containing a given value in an irregularly spaced array.
Definition: mptrac.c:2899
void dd_get_rect_neighbour(const ctl_t ctl, dd_t *dd)
Determines rectangular neighbouring ranks for MPI processes.
double time_from_filename(const char *filename, const int offset)
Extracts and converts a timestamp from a filename to Julian seconds.
Definition: mptrac.c:11223
void write_prof(const char *filename, const ctl_t *ctl, met_t *met0, met_t *met1, const atm_t *atm, const double t)
Writes profile data to a specified file.
Definition: mptrac.c:12924
void dd_atm2particles(atm_t *atm, particle_t *particles, ctl_t *ctl, int *nparticles, cache_t *cache, int rank)
Extracts particles from an atmospheric state and prepares them for inter-domain transfer.
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:5454
void module_chem_grid(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double t)
Computes gridded chemical tracer concentrations (volume mixing ratio) from individual air parcel mass...
Definition: mptrac.c:3258
double tropo_weight(const clim_t *clim, const atm_t *atm, const int ip)
Computes a weighting factor based on tropopause pressure.
Definition: mptrac.c:11258
void write_met_nc(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a NetCDF file.
Definition: mptrac.c:12701
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:4604
int mptrac_read_atm(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a specified file into the given atmospheric structure.
Definition: mptrac.c:5383
void mptrac_update_host(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t **met0, met_t **met1, const atm_t *atm)
Updates host memory for specified data structures.
Definition: mptrac.c:6722
void mptrac_write_output(const char *dirname, const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double t)
Writes various types of output data to files in a specified directory.
Definition: mptrac.c:6882
double clim_oh(const ctl_t *ctl, const clim_t *clim, const double t, const double lon, const double lat, const double p)
Calculates the hydroxyl radical (OH) concentration from climatology data, with an optional diurnal co...
Definition: mptrac.c:89
void read_met_grib_levels(codes_handle **handles, const int num_messages, const ctl_t *ctl, met_t *met)
Reads meteorological variables at different vertical levels from a grib file.
#define CTS
Maximum number of data points of climatological time series.
Definition: mptrac.h:363
void read_met_ozone(met_t *met)
Calculates the total column ozone from meteorological ozone data.
Definition: mptrac.c:10476
int dd_calc_subdomain_from_coords(double lon, double lat, met_t *met, ctl_t *ctl, int mpi_size, int nx_glob, int ny_glob)
Computes the destination subdomain (MPI rank) for a particle based on its geographic coordinates.
void broadcast_large_data(void *data, size_t N)
Broadcasts large data across all processes in an MPI communicator.
void read_met_nc_surface(const int ncid, const ctl_t *ctl, met_t *met, dd_t *dd)
Reads and processes surface meteorological data from NetCDF files with domain decomposition.
Definition: mptrac.c:8417
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:232
void module_rng(const ctl_t *ctl, double *rs, const size_t n, const int method)
Generate random numbers using various methods and distributions.
Definition: mptrac.c:4635
void get_met_help(const ctl_t *ctl, const double t, const int direct, const char *metbase, const double dt_met, char *filename)
Generates a formatted filename for meteorological data files based on the input parameters.
Definition: mptrac.c:1980
void write_station(const char *filename, const ctl_t *ctl, atm_t *atm, const double t)
Writes station data to a specified file.
Definition: mptrac.c:13313
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: mptrac.c:74
#define NP
Maximum number of atmospheric data points.
Definition: mptrac.h:308
void doy2day(const int year, const int doy, int *mon, int *day)
Converts a given day of the year (DOY) to a date (month and day).
Definition: mptrac.c:1893
void dd_communicate_particles(particle_t *particles, int *nparticles, MPI_Datatype MPI_Particle, int *neighbours, int nneighbours, ctl_t ctl)
Communicates particles between MPI processes.
void intpol_met_time_2d(const met_t *met0, float array0[EX][EY], const met_t *met1, float array1[EX][EY], const double ts, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological data in 2D space and time.
Definition: mptrac.c:2458
void module_position(const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Update the positions and pressure levels of atmospheric particles.
Definition: mptrac.c:4553
void clim_oh_diurnal_correction(const ctl_t *ctl, clim_t *clim)
Applies a diurnal correction to the hydroxyl radical (OH) concentration in climatology data.
Definition: mptrac.c:115
void write_met_bin_2d(FILE *out, met_t *met, float var[EX][EY], const char *varname)
Writes a 2-dimensional meteorological variable to a binary file.
Definition: mptrac.c:12582
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:10370
int read_atm_bin(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a binary file and populates the given atmospheric structure.
Definition: mptrac.c:7061
void get_met_replace(char *orig, char *search, char *repl)
Replaces occurrences of a substring in a string with another substring.
Definition: mptrac.c:2047
#define CY
Maximum number of latitudes for climatological data.
Definition: mptrac.h:338
void module_diff_meso(const ctl_t *ctl, cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Simulate mesoscale diffusion for atmospheric particles.
Definition: mptrac.c:3614
void module_dd(ctl_t *ctl, atm_t *atm, cache_t *cache, dd_t *dd, met_t **met)
Manages domain decomposition and particle communication in parallel processing.
void dd_sort_help(double *a, dd_t *dd, const int np)
Reorder an array according to a permutation vector.
void module_sort(const ctl_t *ctl, met_t *met0, atm_t *atm)
Sort particles according to box index.
Definition: mptrac.c:4769
double clim_ts(const clim_ts_t *ts, const double t)
Interpolates a time series of climatological variables.
Definition: mptrac.c:387
void jsec2time(const double jsec, int *year, int *mon, int *day, int *hour, int *min, int *sec, double *remain)
Converts Julian seconds to calendar date and time components.
Definition: mptrac.c:2582
int read_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Reads meteorological data from a binary file.
Definition: mptrac.c:7523
void write_atm_clams(const char *filename, const ctl_t *ctl, const atm_t *atm)
Writes air parcel data to a NetCDF file in the CLaMS format.
Definition: mptrac.c:11413
void module_diff_turb(const ctl_t *ctl, cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Applies turbulent diffusion processes to atmospheric particles.
Definition: mptrac.c:3816
int read_atm_clams(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads atmospheric data from a CLAMS NetCDF file.
Definition: mptrac.c:7117
void dd_assign_rect_subdomains_atm(atm_t *atm, ctl_t *ctl, dd_t *dd, int init)
Assign atmospheric particles to rectangular subdomains.
int mptrac_read_met(const char *filename, const ctl_t *ctl, const clim_t *clim, met_t *met, dd_t *dd)
Reads meteorological data from a file, supporting multiple formats and MPI broadcasting.
Definition: mptrac.c:6409
void write_vtk(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes VTK (Visualization Toolkit) data to a specified file.
Definition: mptrac.c:13399
#define MPI_Datatype
Placeholder when MPI is not available.
Definition: mptrac.h:145
#define EP
Maximum number of pressure levels for meteo data.
Definition: mptrac.h:283
void module_tracer_chem(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Simulate chemical reactions involving long-lived atmospheric tracers.
Definition: mptrac.c:4950
void mptrac_read_ctl(const char *filename, int argc, char *argv[], ctl_t *ctl)
Reads control parameters from a configuration file and populates the given structure.
Definition: mptrac.c:5514
void mptrac_free(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, dd_t *dd)
Frees memory resources allocated for MPTRAC.
Definition: mptrac.c:5209
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:10311
void module_h2o2_chem(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Perform chemical reactions involving H2O2 within cloud particles.
Definition: mptrac.c:3931
void write_grid_nc(const char *filename, const ctl_t *ctl, const double *cd, double *mean[NQ], double *sigma[NQ], const double *vmr_impl, const double t, const double *z, const double *lon, const double *lat, const double *area, const double dz, const int *np)
Writes grid data to a NetCDF file.
Definition: mptrac.c:12340
double pbl_weight(const ctl_t *ctl, const atm_t *atm, const int ip, const double pbl, const double ps)
Computes a weighting factor based on planetary boundary layer pressure.
Definition: mptrac.c:6997
void module_diff_pbl(const ctl_t *ctl, cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Computes particle diffusion within the planetary boundary layer (PBL).
Definition: mptrac.c:3691
void write_met_nc_3d(const int ncid, const char *varname, met_t *met, float var[EX][EY][EP], const float scl)
Writes a 3D meteorological variable to a NetCDF file.
Definition: mptrac.c:12894
void module_isosurf(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Apply the isosurface module to adjust atmospheric properties.
Definition: mptrac.c:4083
void module_kpp_chem(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
KPP chemistry module.
#define CO3
Maximum number of total column ozone data for climatological data.
Definition: mptrac.h:343
void module_oh_chem(const ctl_t *ctl, const cache_t *cache, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Perform hydroxyl chemistry calculations for atmospheric particles.
Definition: mptrac.c:4469
void read_met_grib_grid(codes_handle **handles, int count_handles, met_t *met)
Reads global meteorological information from a grib file.
void geo2cart(const double z, const double lon, const double lat, double *x)
Converts geographic coordinates (longitude, latitude, altitude) to Cartesian coordinates.
Definition: mptrac.c:1962
void read_met_nc_grid(const char *filename, const int ncid, const ctl_t *ctl, met_t *met, dd_t *dd)
Reads meteorological grid data from NetCDF files with domain decomposition.
Definition: mptrac.c:8250
double kernel_weight(const double kz[EP], const double kw[EP], const int nk, const double p)
Calculates the kernel weight based on altitude and given kernel data.
Definition: mptrac.c:2615
void compress_sz3(const char *varname, float *array, const int nx, const int ny, const int nz, const int precision, const double tolerance, const int decompress, FILE *inout)
Compresses or decompresses a 3-D float array using the SZ3 library.
void dd_register_MPI_type_particle(MPI_Datatype *MPI_Particle)
Registers a custom MPI datatype for particle structures.
int read_atm_asc(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from an ASCII file and populates the given atmospheric structure.
Definition: mptrac.c:7019
void intpol_check_lon_lat(const double *lons, const int nlon, const double *lats, const int nlat, const double lon, const double lat, double *lon2, double *lat2)
Adjusts longitude and latitude to ensure they fall within valid bounds.
Definition: mptrac.c:2114
void write_sample(const char *filename, const ctl_t *ctl, met_t *met0, met_t *met1, const atm_t *atm, const double t)
Writes sample data to a specified file.
Definition: mptrac.c:13151
void write_grid(const char *filename, const ctl_t *ctl, met_t *met0, met_t *met1, const atm_t *atm, const double t)
Writes grid data to a file in ASCII or netCDF format.
Definition: mptrac.c:12045
void module_dry_depo(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Simulate dry deposition of atmospheric particles.
Definition: mptrac.c:3868
void write_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data in binary format to a specified file.
Definition: mptrac.c:12470
void write_atm_bin(const char *filename, const ctl_t *ctl, const atm_t *atm)
Writes air parcel data to a binary file.
Definition: mptrac.c:11363
void read_met_cape(const ctl_t *ctl, const clim_t *clim, met_t *met)
Calculates Convective Available Potential Energy (CAPE) for each grid point.
Definition: mptrac.c:7806
void mptrac_write_met(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a file, supporting multiple formats and compression options.
Definition: mptrac.c:6838
#define CSZA
Maximum number of solar zenith angles for climatological data.
Definition: mptrac.h:353
double lapse_rate(const double t, const double h2o)
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
Definition: mptrac.c:2641
#define DD_NNMAX
Maximum number of neighbours to communicate with in domain decomposition.
Definition: mptrac.h:373
void write_csi(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes Critical Success Index (CSI) data to a file.
Definition: mptrac.c:11673
void write_atm_nc(const char *filename, const ctl_t *ctl, const atm_t *atm)
Writes air parcel data to a NetCDF file.
Definition: mptrac.c:11624
Air parcel data.
Definition: mptrac.h:3164
int np
Number of air parcels.
Definition: mptrac.h:3167
Cache data structure.
Definition: mptrac.h:3219
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3231
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3251
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3257
int np
Number of pressure levels.
Definition: mptrac.h:3254
int no3c
Number of total ozone columns.
Definition: mptrac.h:3260
Climatological data.
Definition: mptrac.h:3359
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3401
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3377
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3389
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3380
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3362
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3407
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3395
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3398
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3392
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3386
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3365
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3383
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3404
Climatological data in the form of time series.
Definition: mptrac.h:3307
int ntime
Number of timesteps.
Definition: mptrac.h:3310
Climatological data in the form of zonal means.
Definition: mptrac.h:3327
int np
Number of pressure levels.
Definition: mptrac.h:3336
int ntime
Number of timesteps.
Definition: mptrac.h:3330
int nlat
Number of latitudes.
Definition: mptrac.h:3333
Control parameters.
Definition: mptrac.h:2131
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3025
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2243
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:2986
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2399
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:2874
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2477
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2276
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:2962
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2736
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2222
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2423
int dd_halos_size
Domain decomposition size of halos given in grid-points.
Definition: mptrac.h:3152
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2799
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2823
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2162
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2432
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2171
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2255
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:2956
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2264
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2724
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:2977
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2231
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3103
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2784
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2635
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2796
double stat_r
Search radius around station [km].
Definition: mptrac.h:3109
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:2868
int met_zstd_level
ZSTD compression level (from -5 to 22).
Definition: mptrac.h:2486
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:2980
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3133
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2820
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2603
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2252
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:2838
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2688
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2411
double met_cms_eps_pv
cmultiscale compression epsilon for potential vorticity.
Definition: mptrac.h:2525
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2330
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:3028
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2441
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2417
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2555
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2622
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2294
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2366
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:2971
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:2983
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2670
int met_pbl
Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta).
Definition: mptrac.h:2600
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2246
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2679
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:3013
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3031
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:2927
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2697
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3043
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2177
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2321
double met_cms_eps_h2o
cmultiscale compression epsilon for water vapor.
Definition: mptrac.h:2528
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2273
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:3034
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2300
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2619
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2360
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2460
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:2841
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2591
double met_cms_eps_u
cmultiscale compression epsilon for zonal wind.
Definition: mptrac.h:2516
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2664
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2165
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2198
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2342
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2712
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3115
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2661
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3049
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:2974
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2204
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:3019
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2327
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:2829
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2730
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2312
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2588
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2561
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2174
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2652
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2639
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2718
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2180
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:3058
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:2950
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2597
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:2959
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2558
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2832
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2676
double met_cms_eps_iwc
cmultiscale compression epsilon for cloud ice water content.
Definition: mptrac.h:2540
double met_cms_eps_swc
cmultiscale compression epsilon for cloud snow water content.
Definition: mptrac.h:2543
double met_cms_eps_v
cmultiscale compression epsilon for meridional wind.
Definition: mptrac.h:2519
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3061
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2237
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2703
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2613
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3067
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2159
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2610
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2168
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2628
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2787
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2369
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2297
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:2968
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3112
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:2850
int dd
Domain decomposition (0=no, 1=yes, with 2x2 if not specified).
Definition: mptrac.h:3140
int qnt_eta
Quantity array index for eta vertical coordinate.
Definition: mptrac.h:2354
double wet_depo_so2_ph
pH value used to calculate effective Henry constant of SO2.
Definition: mptrac.h:2886
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2793
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2318
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:2932
int met_cms_nd0x
cmultiscale number of cells of coarsest grid in x-direction.
Definition: mptrac.h:2501
int met_nlev
Number of meteo data model levels.
Definition: mptrac.h:2579
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:2859
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:2895
int qnt_shf
Quantity array index for surface sensible heat flux.
Definition: mptrac.h:2195
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2186
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2396
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3121
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2447
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2694
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2288
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2474
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2216
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2336
double met_cms_eps_cc
cmultiscale compression epsilon for cloud cover.
Definition: mptrac.h:2546
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2709
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2606
int met_dx
Stride for longitudes.
Definition: mptrac.h:2549
int qnt_destination
Quantity array index for destination subdomain in domain decomposition.
Definition: mptrac.h:2438
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2808
int met_convention
Meteo data layout (0=[lev, lat, lon], 1=[lon, lat, lev]).
Definition: mptrac.h:2463
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2348
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:2862
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2450
int diffusion
Diffusion scheme (0=off, 1=fixed-K, 2=PBL).
Definition: mptrac.h:2655
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2384
int qnt_eta_dot
Quantity array index for velocity of eta vertical coordinate.
Definition: mptrac.h:2357
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2378
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2219
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3130
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2234
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2315
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2706
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2625
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2291
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2402
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2576
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2844
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2240
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:3076
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2339
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2228
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3097
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2742
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:2941
double met_cms_eps_lwc
cmultiscale compression epsilon for cloud liquid water content.
Definition: mptrac.h:2534
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2183
double met_cms_eps_z
cmultiscale compression epsilon for geopotential height.
Definition: mptrac.h:2510
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3037
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2426
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2420
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2811
int nens
Number of ensembles.
Definition: mptrac.h:2989
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2207
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2267
int advect
Advection scheme (0=off, 1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2645
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3064
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2225
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:2920
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:2856
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2345
double conv_pbl_trans
Depth of PBL transition layer (fraction of PBL depth).
Definition: mptrac.h:2685
int met_vert_coord
Vertical coordinate of input meteo data (0=plev, 1=mlev_p_file, 2=mlev_ab_file, 3=mlev_ab_full,...
Definition: mptrac.h:2467
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:2965
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2363
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3106
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2405
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:3040
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2429
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2390
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2567
int conv_mix_pbl
Vertical mixing in the PBL (0=off, 1=on).
Definition: mptrac.h:2682
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2721
int dd_nbr_neighbours
Domain decomposition number of neighbours to communicate with.
Definition: mptrac.h:3149
double met_cms_eps_t
cmultiscale compression epsilon for temperature.
Definition: mptrac.h:2513
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2817
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2279
int qnt_zeta_dot
Quantity array index for velocity of zeta vertical coordinate.
Definition: mptrac.h:2351
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2700
int met_cms_nd0y
cmultiscale number of cells of coarsest grid in y-direction.
Definition: mptrac.h:2504
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2790
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2285
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2715
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2802
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2393
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2381
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:3022
int qnt_nss
Quantity array index for northward turbulent surface stress.
Definition: mptrac.h:2192
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:2995
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:2923
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2594
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2814
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:2917
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3082
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2495
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:2901
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2564
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3070
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2826
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2261
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2309
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2324
int qnt_subdomain
Quantity array index for current subdomain in domain decomposition.
Definition: mptrac.h:2435
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3079
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2282
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:2904
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3073
double met_cms_eps_rwc
cmultiscale compression epsilon for cloud rain water content.
Definition: mptrac.h:2537
int met_nc_quant
Number of digits for quantization of netCDF meteo files (0=off).
Definition: mptrac.h:2483
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:2853
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2414
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:2892
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2835
double met_cms_eps_o3
cmultiscale compression epsilon for ozone.
Definition: mptrac.h:2531
int met_cms_zstd
cmultiscale ZSTD compression (0=off, 1=on).
Definition: mptrac.h:2498
int met_cms_maxlev
cmultiscale maximum refinement level.
Definition: mptrac.h:2507
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:3010
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:2898
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2210
int met_np
Number of target pressure levels.
Definition: mptrac.h:2570
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2156
int met_nc_level
zlib compression level of netCDF meteo files (0=off).
Definition: mptrac.h:2480
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2781
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2306
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3127
double met_cms_eps_w
cmultiscale compression epsilon for vertical velocity.
Definition: mptrac.h:2522
double turb_dx_pbl
Horizontal turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2658
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2691
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2372
int advect_vert_coord
Vertical velocity of air parcels (0=omega_on_plev, 1=zetadot_on_mlev, 2=omega_on_mlev,...
Definition: mptrac.h:2649
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2303
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2408
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2201
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2805
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:2935
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:2889
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2333
int qnt_ess
Quantity array index for eastward turbulent surface stress.
Definition: mptrac.h:2189
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:2877
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:2871
int met_dy
Stride for latitudes.
Definition: mptrac.h:2552
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2387
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2673
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2727
int dd_subdomains_zonal
Domain decomposition zonal subdomain number.
Definition: mptrac.h:3143
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2153
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2616
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2249
double t_start
Start time of simulation [s].
Definition: mptrac.h:2444
int nq
Number of quantities.
Definition: mptrac.h:2138
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2739
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3094
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3124
double turb_dz_pbl
Vertical turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2667
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3046
int dd_subdomains_meridional
Domain decomposition meridional subdomain number.
Definition: mptrac.h:3146
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2213
int met_type
Type of meteo data files (0=netCDF, 1=binary, 2=pck, 3=ZFP, 4=ZSTD, 5=cms, 6=grib,...
Definition: mptrac.h:2471
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2258
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2270
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:3007
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2375
Domain decomposition data structure.
Definition: mptrac.h:3592
int halo_offset_end
Hyperslab of boundary halos count.
Definition: mptrac.h:3644
int rank
Rank of node.
Definition: mptrac.h:3599
double subdomain_lon_min
Rectangular grid limit of subdomain.
Definition: mptrac.h:3620
double subdomain_lat_max
Rectangular grid limit of subdomain.
Definition: mptrac.h:3623
int init
Shows if domain decomposition was initialized.
Definition: mptrac.h:3651
double subdomain_lon_max
Rectangular grid limit of subdomain.
Definition: mptrac.h:3617
int halo_offset_start
Hyperslab of boundary halos count.
Definition: mptrac.h:3641
int size
Size of node.
Definition: mptrac.h:3602
double subdomain_lat_min
Rectangular grid limit of subdomain.
Definition: mptrac.h:3626
Meteo data structure.
Definition: mptrac.h:3418
int nx
Number of longitudes.
Definition: mptrac.h:3424
int ny
Number of latitudes.
Definition: mptrac.h:3427
int np
Number of pressure levels.
Definition: mptrac.h:3430
int npl
Number of model levels.
Definition: mptrac.h:3433
double time
Time [s].
Definition: mptrac.h:3421
Particle data.
Definition: mptrac.h:3193
double p
Pressure [hPa].
Definition: mptrac.h:3199
double lat
Latitude [deg].
Definition: mptrac.h:3205
double time
Time [s].
Definition: mptrac.h:3196
double lon
Longitude [deg].
Definition: mptrac.h:3202