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
2123#define SELECT_TIMER(id, group, color) { \
2124 NVTX_POP; \
2125 NVTX_PUSH(id, color); \
2126 timer(id, group, 0); \
2127 }
2128
2142#define START_TIMERS \
2143 NVTX_PUSH("START", NVTX_CPU);
2144
2157#define STOP_TIMERS \
2158 NVTX_POP;
2159
2160/* ------------------------------------------------------------
2161 NVIDIA Tools Extension (NVTX)...
2162 ------------------------------------------------------------ */
2163
2164#ifdef NVTX
2165#include "nvToolsExt.h"
2166
2168#define NVTX_CPU 0xFFADD8E6
2169
2171#define NVTX_GPU 0xFF00008B
2172
2174#define NVTX_H2D 0xFFFFFF00
2175
2177#define NVTX_D2H 0xFFFF8800
2178
2180#define NVTX_READ 0xFFFFCCCB
2181
2183#define NVTX_WRITE 0xFF8B0000
2184
2186#define NVTX_RECV 0xFFCCFFCB
2187
2189#define NVTX_SEND 0xFF008B00
2190
2220#define NVTX_PUSH(range_title, range_color) { \
2221 nvtxEventAttributes_t eventAttrib = {0}; \
2222 eventAttrib.version = NVTX_VERSION; \
2223 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
2224 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
2225 eventAttrib.colorType = NVTX_COLOR_ARGB; \
2226 eventAttrib.color = range_color; \
2227 eventAttrib.message.ascii = range_title; \
2228 nvtxRangePushEx(&eventAttrib); \
2229 }
2230
2243#define NVTX_POP { \
2244 nvtxRangePop(); \
2245 }
2246#else
2247
2248/* Empty definitions of NVTX_PUSH and NVTX_POP... */
2249#define NVTX_PUSH(range_title, range_color) {}
2250#define NVTX_POP {}
2251#endif
2252
2253/* ------------------------------------------------------------
2254 Structs...
2255 ------------------------------------------------------------ */
2256
2264typedef struct {
2265
2266 /* ------------------------------------------------------------
2267 Quantity parameters...
2268 ------------------------------------------------------------ */
2269
2271 int nq;
2272
2274 char qnt_name[NQ][LEN];
2275
2277 char qnt_longname[NQ][LEN];
2278
2280 char qnt_unit[NQ][LEN];
2281
2283 char qnt_format[NQ][LEN];
2284
2287
2290
2293
2296
2299
2302
2305
2308
2311
2314
2317
2320
2323
2326
2329
2332
2335
2338
2341
2344
2347
2350
2353
2356
2359
2362
2365
2368
2371
2374
2377
2380
2383
2386
2389
2392
2395
2398
2401
2404
2407
2410
2413
2416
2419
2422
2425
2428
2431
2434
2437
2440
2443
2446
2449
2452
2455
2458
2461
2464
2467
2470
2473
2476
2479
2482
2485
2488
2491
2494
2497
2500
2503
2506
2509
2512
2515
2518
2521
2524
2527
2530
2533
2536
2539
2542
2545
2548
2551
2554
2557
2560
2563
2566
2569
2572
2575
2577 double t_start;
2578
2580 double t_stop;
2581
2583 double dt_mod;
2584
2585 /* ------------------------------------------------------------
2586 Meteo data parameters...
2587 ------------------------------------------------------------ */
2588
2590 char metbase[LEN];
2591
2593 double dt_met;
2594
2597
2601
2605
2608
2611
2614
2617
2620
2622 int met_comp_prec[METVAR];
2623
2625 double met_comp_tol[METVAR];
2626
2629
2632
2635
2638
2641
2644
2647
2650
2653
2656
2659
2662
2665
2668
2671
2674
2677
2680
2683
2686
2689
2692
2695
2698
2701
2704
2706 double met_p[EP];
2707
2710
2713
2715 double met_lev_hyam[EP];
2716
2718 double met_lev_hybm[EP];
2719
2722
2725
2728
2731
2734
2737
2740
2744
2747
2750
2753
2756
2759
2762
2763 /* ------------------------------------------------------------
2764 Geophysical module parameters...
2765 ------------------------------------------------------------ */
2766
2768 double sort_dt;
2769
2773
2775 char balloon[LEN];
2776
2779
2783
2786
2789
2792
2795
2798
2801
2804
2807
2810
2813
2816
2819
2822
2824 double conv_cin;
2825
2827 double conv_dt;
2828
2831
2834
2837
2840
2843
2846
2848 double bound_p0;
2849
2851 double bound_p1;
2852
2855
2858
2861
2864
2866 char species[LEN];
2867
2869 double molmass;
2870
2873
2876
2879
2881 char clim_hno3_filename[LEN];
2882
2884 char clim_oh_filename[LEN];
2885
2887 char clim_h2o2_filename[LEN];
2888
2890 char clim_ho2_filename[LEN];
2891
2893 char clim_o1d_filename[LEN];
2894
2896 char clim_o3_filename[LEN];
2897
2899 char clim_ccl4_timeseries[LEN];
2900
2902 char clim_ccl3f_timeseries[LEN];
2903
2905 char clim_ccl2f2_timeseries[LEN];
2906
2908 char clim_n2o_timeseries[LEN];
2909
2911 char clim_sf6_timeseries[LEN];
2912
2915
2918
2921
2924
2927
2930
2933
2936
2939
2942
2945
2948
2951
2954
2957
2960
2963
2966
2969
2972
2975
2978
2980 double oh_chem[4];
2981
2984
2987
2990
2992 double dt_kpp;
2993
2996
2998 double wet_depo_pre[2];
2999
3002
3005
3008
3011
3013 double wet_depo_ic_h[2];
3014
3016 double wet_depo_bc_h[2];
3017
3020
3023
3026
3029
3032
3034 double psc_h2o;
3035
3037 double psc_hno3;
3038
3039 /* ------------------------------------------------------------
3040 Output parameters...
3041 ------------------------------------------------------------ */
3042
3044 char atm_basename[LEN];
3045
3047 char atm_gpfile[LEN];
3048
3051
3054
3057
3061
3066
3069
3071 int atm_nc_quant[NQ];
3072
3075
3077 char csi_basename[LEN];
3078
3080 char csi_kernel[LEN];
3081
3084
3086 char csi_obsfile[LEN];
3087
3090
3093
3096
3098 double csi_z0;
3099
3101 double csi_z1;
3102
3105
3107 double csi_lon0;
3108
3110 double csi_lon1;
3111
3114
3116 double csi_lat0;
3117
3119 double csi_lat1;
3120
3122 int nens;
3123
3125 char ens_basename[LEN];
3126
3129
3131 char grid_basename[LEN];
3132
3134 char grid_kernel[LEN];
3135
3137 char grid_gpfile[LEN];
3138
3141
3144
3147
3149 int grid_nc_quant[NQ];
3150
3153
3156
3158 double grid_z0;
3159
3161 double grid_z1;
3162
3165
3168
3171
3174
3177
3180
3183
3185 char prof_basename[LEN];
3186
3188 char prof_obsfile[LEN];
3189
3192
3194 double prof_z0;
3195
3197 double prof_z1;
3198
3201
3204
3207
3210
3213
3216
3218 char sample_basename[LEN];
3219
3221 char sample_kernel[LEN];
3222
3224 char sample_obsfile[LEN];
3225
3228
3231
3233 char stat_basename[LEN];
3234
3236 double stat_lon;
3237
3239 double stat_lat;
3240
3242 double stat_r;
3243
3245 double stat_t0;
3246
3248 double stat_t1;
3249
3251 char vtk_basename[LEN];
3252
3255
3258
3261
3264
3267
3268 /* ------------------------------------------------------------
3269 Domain decomposition...
3270 ------------------------------------------------------------ */
3271
3273 int dd;
3274
3277
3280
3283
3286
3287} ctl_t;
3288
3297typedef struct {
3298
3300 int np;
3301
3303 double time[NP];
3304
3306 double p[NP];
3307
3309 double lon[NP];
3310
3312 double lat[NP];
3313
3315 double q[NQ][NP];
3316
3317} atm_t;
3318
3326typedef struct {
3327
3329 double time;
3330
3332 double p;
3333
3335 double lon;
3336
3338 double lat;
3339
3341 double q[NQ];
3342
3343} particle_t;
3344
3345
3352typedef struct {
3353
3355 double iso_var[NP];
3356
3358 double iso_ps[NP];
3359
3361 double iso_ts[NP];
3362
3365
3367 float uvwp[NP][3];
3368
3370 double rs[3 * NP + 1];
3371
3373 double dt[NP];
3374
3375} cache_t;
3376
3384typedef struct {
3385
3387 int np;
3388
3390 int nsza;
3391
3393 int no3c;
3394
3396 double p[CP];
3397
3399 double sza[CSZA];
3400
3402 double o3c[CO3];
3403
3405 double n2o[CP][CSZA][CO3];
3406
3408 double ccl4[CP][CSZA][CO3];
3409
3411 double ccl3f[CP][CSZA][CO3];
3412
3414 double ccl2f2[CP][CSZA][CO3];
3415
3417 double o2[CP][CSZA][CO3];
3418
3420 double o3_1[CP][CSZA][CO3];
3421
3423 double o3_2[CP][CSZA][CO3];
3424
3426 double h2o2[CP][CSZA][CO3];
3427
3429 double h2o[CP][CSZA][CO3];
3430
3431} clim_photo_t;
3432
3440typedef struct {
3441
3444
3446 double time[CTS];
3447
3449 double vmr[CTS];
3450
3451} clim_ts_t;
3452
3460typedef struct {
3461
3464
3466 int nlat;
3467
3469 int np;
3470
3472 double time[CT];
3473
3475 double lat[CY];
3476
3478 double p[CP];
3479
3481 double vmr[CT][CP][CY];
3482
3483} clim_zm_t;
3484
3492typedef struct {
3493
3496
3499
3501 double tropo_time[12];
3502
3504 double tropo_lat[73];
3505
3507 double tropo[12][73];
3508
3511
3514
3517
3520
3523
3526
3529
3532
3535
3538
3541
3542} clim_t;
3543
3551typedef struct {
3552
3554 double time;
3555
3557 int nx;
3558
3560 int ny;
3561
3563 int np;
3564
3566 int npl;
3567
3569 double lon[EX];
3570
3572 double lat[EY];
3573
3575 double p[EP];
3576
3578 double hybrid[EP];
3579
3581 double hyam[EP];
3582
3584 double hybm[EP];
3585
3587 double eta[EP];
3588
3590 float ps[EX][EY];
3591
3593 float ts[EX][EY];
3594
3596 float zs[EX][EY];
3597
3599 float us[EX][EY];
3600
3602 float vs[EX][EY];
3603
3605 float ess[EX][EY];
3606
3608 float nss[EX][EY];
3609
3611 float shf[EX][EY];
3612
3614 float lsm[EX][EY];
3615
3617 float sst[EX][EY];
3618
3620 float pbl[EX][EY];
3621
3623 float pt[EX][EY];
3624
3626 float tt[EX][EY];
3627
3629 float zt[EX][EY];
3630
3632 float h2ot[EX][EY];
3633
3635 float pct[EX][EY];
3636
3638 float pcb[EX][EY];
3639
3641 float cl[EX][EY];
3642
3644 float plcl[EX][EY];
3645
3647 float plfc[EX][EY];
3648
3650 float pel[EX][EY];
3651
3653 float cape[EX][EY];
3654
3656 float cin[EX][EY];
3657
3659 float o3c[EX][EY];
3660
3662 float z[EX][EY][EP];
3663
3665 float t[EX][EY][EP];
3666
3668 float u[EX][EY][EP];
3669
3671 float v[EX][EY][EP];
3672
3674 float w[EX][EY][EP];
3675
3677 float pv[EX][EY][EP];
3678
3680 float h2o[EX][EY][EP];
3681
3683 float o3[EX][EY][EP];
3684
3686 float lwc[EX][EY][EP];
3687
3689 float rwc[EX][EY][EP];
3690
3692 float iwc[EX][EY][EP];
3693
3695 float swc[EX][EY][EP];
3696
3698 float cc[EX][EY][EP];
3699
3701 float pl[EX][EY][EP];
3702
3704 float ul[EX][EY][EP];
3705
3707 float vl[EX][EY][EP];
3708
3710 float wl[EX][EY][EP];
3711
3713 float zetal[EX][EY][EP];
3714
3716 float zeta_dotl[EX][EY][EP];
3717
3718} met_t;
3719
3725typedef struct {
3726
3727 /* ------------------------------------------------------------
3728 MPI Information
3729 ------------------------------------------------------------ */
3730
3732 int rank;
3733
3735 int size;
3736
3738 int neighbours[DD_NNMAX];
3739
3740#ifdef DD
3742 MPI_Datatype MPI_Particle;
3743#endif
3744
3745 /* ------------------------------------------------------------
3746 Properties of subdomains
3747 ------------------------------------------------------------ */
3748
3751
3754
3757
3760
3762 size_t subdomain_start[4];
3763
3765 size_t subdomain_count[4];
3766
3768 size_t halo_bnd_start[4];
3769
3771 size_t halo_bnd_count[4];
3772
3775
3778
3779 /* ------------------------------------------------------------
3780 Caches
3781 ------------------------------------------------------------ */
3782
3784 int init;
3785
3786#ifdef DD
3787
3789 double a[NP];
3790
3792 int p[NP];
3793
3795 double help[NP];
3796
3797#endif
3798
3799} dd_t;
3800
3801/* ------------------------------------------------------------
3802 OpenACC routines...
3803 ------------------------------------------------------------ */
3804
3805#ifdef _OPENACC
3806#pragma acc routine (clim_oh)
3807#pragma acc routine (clim_photo)
3808#pragma acc routine (clim_tropo)
3809#pragma acc routine (clim_ts)
3810#pragma acc routine (clim_zm)
3811#pragma acc routine (cos_sza)
3812#pragma acc routine (intpol_check_lon_lat)
3813#pragma acc routine (intpol_met_4d_zeta)
3814#pragma acc routine (intpol_met_space_3d)
3815#pragma acc routine (intpol_met_space_2d)
3816#pragma acc routine (intpol_met_time_3d)
3817#pragma acc routine (intpol_met_time_2d)
3818#pragma acc routine (kernel_weight)
3819#pragma acc routine (lapse_rate)
3820#pragma acc routine (locate_irr)
3821#pragma acc routine (locate_irr_float)
3822#pragma acc routine (locate_reg)
3823#pragma acc routine (locate_vert)
3824#pragma acc routine (nat_temperature)
3825#pragma acc routine (pbl_weight)
3826#pragma acc routine (sedi)
3827#pragma acc routine (stddev)
3828#pragma acc routine (tropo_weight)
3829#endif
3830
3831/* ------------------------------------------------------------
3832 Functions...
3833 ------------------------------------------------------------ */
3834
3857 void *data,
3858 size_t N);
3859
3874void cart2geo(
3875 const double *x,
3876 double *z,
3877 double *lon,
3878 double *lat);
3879
3902double clim_oh(
3903 const ctl_t * ctl,
3904 const clim_t * clim,
3905 const double t,
3906 const double lon,
3907 const double lat,
3908 const double p);
3909
3929 const ctl_t * ctl,
3930 clim_t * clim);
3931
3961double clim_photo(
3962 const double rate[CP][CSZA][CO3],
3963 const clim_photo_t * photo,
3964 const double p,
3965 const double sza,
3966 const double o3c);
3967
3993double clim_tropo(
3994 const clim_t * clim,
3995 const double t,
3996 const double lat);
3997
4016void clim_tropo_init(
4017 clim_t * clim);
4018
4035double clim_ts(
4036 const clim_ts_t * ts,
4037 const double t);
4038
4060double clim_zm(
4061 const clim_zm_t * zm,
4062 const double t,
4063 const double lat,
4064 const double p);
4065
4108 const ctl_t * ctl,
4109 const char *varname,
4110 float *array,
4111 const size_t nx,
4112 const size_t ny,
4113 const size_t np,
4114 const double *plev,
4115 const int decompress,
4116 FILE * inout);
4117
4150void compress_pck(
4151 const char *varname,
4152 float *array,
4153 const size_t nxy,
4154 const size_t nz,
4155 const int decompress,
4156 FILE * inout);
4157
4188 const char *varname,
4189 float *array,
4190 const int nx,
4191 const int ny,
4192 const int nz,
4193 const int precision,
4194 const double tolerance,
4195 const int decompress,
4196 FILE * inout);
4197
4237 const char *varname,
4238 float *array,
4239 const int nx,
4240 const int ny,
4241 const int nz,
4242 const int precision,
4243 const double tolerance,
4244 const int decompress,
4245 FILE * inout);
4246
4269 const char *varname,
4270 float *array,
4271 const size_t n,
4272 const int decompress,
4273 const int level,
4274 FILE * inout);
4275
4300double cos_sza(
4301 const double sec,
4302 const double lon,
4303 const double lat);
4304
4327void day2doy(
4328 const int year,
4329 const int mon,
4330 const int day,
4331 int *doy);
4332
4380 atm_t * atm,
4381 ctl_t * ctl,
4382 dd_t * dd,
4383 int init);
4384
4450 atm_t * atm,
4451 particle_t * particles,
4452 ctl_t * ctl,
4453 int *nparticles,
4454 cache_t * cache,
4455 int rank);
4456
4521 double lon,
4522 double lat,
4523 met_t * met,
4524 ctl_t * ctl,
4525 int mpi_size,
4526 int nx_glob,
4527 int ny_glob);
4528
4559 particle_t * particles,
4560 int *nparticles,
4561 MPI_Datatype MPI_Particle,
4562 int *neighbours,
4563 int nneighbours,
4564 ctl_t ctl);
4565
4589 const ctl_t ctl,
4590 dd_t * dd);
4591
4617 ctl_t * ctl,
4618 dd_t * dd,
4619 atm_t * atm);
4620
4645 met_t * met,
4646 int nx_glob);
4647
4673 atm_t * atm,
4674 particle_t * particles,
4675 ctl_t * ctl,
4676 int *nparticles,
4677 cache_t * cache);
4678
4701 MPI_Datatype * MPI_Particle);
4702
4738 const ctl_t * ctl,
4739 met_t * met0,
4740 atm_t * atm,
4741 dd_t * dd,
4742 int *nparticles,
4743 int *rank);
4744
4773 double *a,
4774 dd_t * dd,
4775 const int np);
4776
4798void doy2day(
4799 const int year,
4800 const int doy,
4801 int *mon,
4802 int *day);
4803
4830void fft_help(
4831 double *fcReal,
4832 double *fcImag,
4833 const int n);
4834
4861void geo2cart(
4862 const double z,
4863 const double lon,
4864 const double lat,
4865 double *x);
4866
4891void get_met_help(
4892 const ctl_t * ctl,
4893 const double t,
4894 const int direct,
4895 const char *metbase,
4896 const double dt_met,
4897 char *filename);
4898
4922void get_met_replace(
4923 char *orig,
4924 char *search,
4925 char *repl);
4926
4963void get_tropo(
4964 const int met_tropo,
4965 ctl_t * ctl,
4966 clim_t * clim,
4967 met_t * met,
4968 const double *lons,
4969 const int nx,
4970 const double *lats,
4971 const int ny,
4972 double *pt,
4973 double *zt,
4974 double *tt,
4975 double *qt,
4976 double *o3t,
4977 double *ps,
4978 double *zs);
4979
5001 const double *lons,
5002 const int nlon,
5003 const double *lats,
5004 const int nlat,
5005 const double lon,
5006 const double lat,
5007 double *lon2,
5008 double *lat2);
5009
5052 const met_t * met0,
5053 float height0[EX][EY][EP],
5054 float array0[EX][EY][EP],
5055 const met_t * met1,
5056 float height1[EX][EY][EP],
5057 float array1[EX][EY][EP],
5058 const double ts,
5059 const double height,
5060 const double lon,
5061 const double lat,
5062 double *var,
5063 int *ci,
5064 double *cw,
5065 const int init);
5066
5102 const met_t * met,
5103 float array[EX][EY][EP],
5104 const double p,
5105 const double lon,
5106 const double lat,
5107 double *var,
5108 int *ci,
5109 double *cw,
5110 const int init);
5111
5147 const met_t * met,
5148 float array[EX][EY],
5149 const double lon,
5150 const double lat,
5151 double *var,
5152 int *ci,
5153 double *cw,
5154 const int init);
5155
5190 const met_t * met0,
5191 float array0[EX][EY][EP],
5192 const met_t * met1,
5193 float array1[EX][EY][EP],
5194 const double ts,
5195 const double p,
5196 const double lon,
5197 const double lat,
5198 double *var,
5199 int *ci,
5200 double *cw,
5201 const int init);
5202
5238 const met_t * met0,
5239 float array0[EX][EY],
5240 const met_t * met1,
5241 float array1[EX][EY],
5242 const double ts,
5243 const double lon,
5244 const double lat,
5245 double *var,
5246 int *ci,
5247 double *cw,
5248 const int init);
5249
5287void intpol_tropo_3d(
5288 const double time0,
5289 float array0[EX][EY],
5290 const double time1,
5291 float array1[EX][EY],
5292 const double lons[EX],
5293 const double lats[EY],
5294 const int nlon,
5295 const int nlat,
5296 const double time,
5297 const double lon,
5298 const double lat,
5299 const int method,
5300 double *var,
5301 double *sigma);
5302
5329void jsec2time(
5330 const double jsec,
5331 int *year,
5332 int *mon,
5333 int *day,
5334 int *hour,
5335 int *min,
5336 int *sec,
5337 double *remain);
5338
5365double kernel_weight(
5366 const double kz[EP],
5367 const double kw[EP],
5368 const int nk,
5369 const double p);
5370
5409double lapse_rate(
5410 const double t,
5411 const double h2o);
5412
5442 ctl_t * ctl);
5443
5463int locate_irr(
5464 const double *xx,
5465 const int n,
5466 const double x);
5467
5494 const float *xx,
5495 const int n,
5496 const double x,
5497 const int ig);
5498
5519int locate_reg(
5520 const double *xx,
5521 const int n,
5522 const double x);
5523
5545void locate_vert(
5546 float profiles[EX][EY][EP],
5547 const int np,
5548 const int lon_ap_ind,
5549 const int lat_ap_ind,
5550 const double alt_ap,
5551 int *ind);
5552
5578void module_advect(
5579 const ctl_t * ctl,
5580 const cache_t * cache,
5581 met_t * met0,
5582 met_t * met1,
5583 atm_t * atm);
5584
5608 const ctl_t * ctl,
5609 const cache_t * cache,
5610 met_t * met0,
5611 met_t * met1,
5612 atm_t * atm);
5613
5651 const ctl_t * ctl,
5652 const cache_t * cache,
5653 const clim_t * clim,
5654 met_t * met0,
5655 met_t * met1,
5656 atm_t * atm);
5657
5699void module_chem_grid(
5700 const ctl_t * ctl,
5701 met_t * met0,
5702 met_t * met1,
5703 atm_t * atm,
5704 const double t);
5705
5733void module_chem_init(
5734 const ctl_t * ctl,
5735 const cache_t * cache,
5736 const clim_t * clim,
5737 met_t * met0,
5738 met_t * met1,
5739 atm_t * atm);
5740
5765 const ctl_t * ctl,
5766 cache_t * cache,
5767 met_t * met0,
5768 met_t * met1,
5769 atm_t * atm);
5770
5799 ctl_t * ctl,
5800 atm_t * atm,
5801 cache_t * cache,
5802 dd_t * dd,
5803 met_t ** met);
5804
5831void module_decay(
5832 const ctl_t * ctl,
5833 const cache_t * cache,
5834 const clim_t * clim,
5835 atm_t * atm);
5836
5873void module_diff_meso(
5874 const ctl_t * ctl,
5875 cache_t * cache,
5876 met_t * met0,
5877 met_t * met1,
5878 atm_t * atm);
5879
5913void module_diff_pbl(
5914 const ctl_t * ctl,
5915 cache_t * cache,
5916 met_t * met0,
5917 met_t * met1,
5918 atm_t * atm);
5919
5974void module_diff_turb(
5975 const ctl_t * ctl,
5976 cache_t * cache,
5977 const clim_t * clim,
5978 met_t * met0,
5979 met_t * met1,
5980 atm_t * atm);
5981
6001void module_dry_depo(
6002 const ctl_t * ctl,
6003 const cache_t * cache,
6004 met_t * met0,
6005 met_t * met1,
6006 atm_t * atm);
6007
6040void module_h2o2_chem(
6041 const ctl_t * ctl,
6042 const cache_t * cache,
6043 const clim_t * clim,
6044 met_t * met0,
6045 met_t * met1,
6046 atm_t * atm);
6047
6068 const ctl_t * ctl,
6069 cache_t * cache,
6070 met_t * met0,
6071 met_t * met1,
6072 atm_t * atm);
6073
6091void module_isosurf(
6092 const ctl_t * ctl,
6093 const cache_t * cache,
6094 met_t * met0,
6095 met_t * met1,
6096 atm_t * atm);
6097
6130 ctl_t * ctl,
6131 cache_t * cache,
6132 clim_t * clim,
6133 met_t * met0,
6134 met_t * met1,
6135 atm_t * atm);
6136
6155void module_meteo(
6156 const ctl_t * ctl,
6157 const cache_t * cache,
6158 const clim_t * clim,
6159 met_t * met0,
6160 met_t * met1,
6161 atm_t * atm);
6162
6180void module_mixing(
6181 const ctl_t * ctl,
6182 const clim_t * clim,
6183 atm_t * atm,
6184 const double t);
6185
6214 const ctl_t * ctl,
6215 const clim_t * clim,
6216 atm_t * atm,
6217 const int *ixs,
6218 const int *iys,
6219 const int *izs,
6220 const int qnt_idx,
6221 const int use_ensemble);
6222
6255void module_oh_chem(
6256 const ctl_t * ctl,
6257 const cache_t * cache,
6258 const clim_t * clim,
6259 met_t * met0,
6260 met_t * met1,
6261 atm_t * atm);
6262
6290void module_position(
6291 const cache_t * cache,
6292 met_t * met0,
6293 met_t * met1,
6294 atm_t * atm);
6295
6320void module_rng_init(
6321 const int ntask);
6322
6348void module_rng(
6349 const ctl_t * ctl,
6350 double *rs,
6351 const size_t n,
6352 const int method);
6353
6376void module_sedi(
6377 const ctl_t * ctl,
6378 const cache_t * cache,
6379 met_t * met0,
6380 met_t * met1,
6381 atm_t * atm);
6382
6406void module_sort(
6407 const ctl_t * ctl,
6408 met_t * met0,
6409 atm_t * atm);
6410
6430void module_sort_help(
6431 double *a,
6432 const int *p,
6433 const int np);
6434
6458void module_timesteps(
6459 const ctl_t * ctl,
6460 cache_t * cache,
6461 met_t * met0,
6462 atm_t * atm,
6463 const double t);
6464
6486 ctl_t * ctl,
6487 const atm_t * atm);
6488
6522 const ctl_t * ctl,
6523 const cache_t * cache,
6524 const clim_t * clim,
6525 met_t * met0,
6526 met_t * met1,
6527 atm_t * atm);
6528
6558void module_wet_depo(
6559 const ctl_t * ctl,
6560 const cache_t * cache,
6561 met_t * met0,
6562 met_t * met1,
6563 atm_t * atm);
6564
6596void mptrac_alloc(
6597 ctl_t ** ctl,
6598 cache_t ** cache,
6599 clim_t ** clim,
6600 met_t ** met0,
6601 met_t ** met1,
6602 atm_t ** atm,
6603 dd_t ** dd);
6604
6635void mptrac_free(
6636 ctl_t * ctl,
6637 cache_t * cache,
6638 clim_t * clim,
6639 met_t * met0,
6640 met_t * met1,
6641 atm_t * atm,
6642 dd_t * dd);
6643
6679void mptrac_get_met(
6680 ctl_t * ctl,
6681 clim_t * clim,
6682 const double t,
6683 met_t ** met0,
6684 met_t ** met1,
6685 dd_t * dd);
6686
6706void mptrac_init(
6707 ctl_t * ctl,
6708 cache_t * cache,
6709 clim_t * clim,
6710 atm_t * atm,
6711 const int ntask);
6712
6748int mptrac_read_atm(
6749 const char *filename,
6750 const ctl_t * ctl,
6751 atm_t * atm);
6752
6784void mptrac_read_clim(
6785 const ctl_t * ctl,
6786 clim_t * clim);
6787
6817void mptrac_read_ctl(
6818 const char *filename,
6819 int argc,
6820 char *argv[],
6821 ctl_t * ctl);
6822
6853int mptrac_read_met(
6854 const char *filename,
6855 const ctl_t * ctl,
6856 const clim_t * clim,
6857 met_t * met,
6858 dd_t * dd);
6859
6881 ctl_t * ctl,
6882 cache_t * cache,
6883 clim_t * clim,
6884 met_t ** met0,
6885 met_t ** met1,
6886 atm_t * atm,
6887 double t,
6888 dd_t * dd);
6889
6919void mptrac_write_atm(
6920 const char *filename,
6921 const ctl_t * ctl,
6922 const atm_t * atm,
6923 const double t);
6924
6962void mptrac_write_met(
6963 const char *filename,
6964 const ctl_t * ctl,
6965 met_t * met);
6966
7001 const char *dirname,
7002 const ctl_t * ctl,
7003 met_t * met0,
7004 met_t * met1,
7005 atm_t * atm,
7006 const double t);
7007
7039 const ctl_t * ctl,
7040 const cache_t * cache,
7041 const clim_t * clim,
7042 met_t ** met0,
7043 met_t ** met1,
7044 const atm_t * atm);
7045
7076 const ctl_t * ctl,
7077 const cache_t * cache,
7078 const clim_t * clim,
7079 met_t ** met0,
7080 met_t ** met1,
7081 const atm_t * atm);
7082
7110double nat_temperature(
7111 const double p,
7112 const double h2o,
7113 const double hno3);
7114
7135double pbl_weight(
7136 const ctl_t * ctl,
7137 const atm_t * atm,
7138 const int ip,
7139 const double pbl,
7140 const double ps);
7141
7174int read_atm_asc(
7175 const char *filename,
7176 const ctl_t * ctl,
7177 atm_t * atm);
7178
7209int read_atm_bin(
7210 const char *filename,
7211 const ctl_t * ctl,
7212 atm_t * atm);
7213
7238int read_atm_clams(
7239 const char *filename,
7240 const ctl_t * ctl,
7241 atm_t * atm);
7242
7272int read_atm_nc(
7273 const char *filename,
7274 const ctl_t * ctl,
7275 atm_t * atm);
7276
7305void read_clim_photo(
7306 const char *filename,
7307 clim_photo_t * photo);
7308
7326 const int ncid,
7327 const char *varname,
7328 const clim_photo_t * photo,
7329 double var[CP][CSZA][CO3]);
7330
7354int read_clim_ts(
7355 const char *filename,
7356 clim_ts_t * ts);
7357
7384void read_clim_zm(
7385 const char *filename,
7386 const char *varname,
7387 clim_zm_t * zm);
7388
7416void read_kernel(
7417 const char *filename,
7418 double kz[EP],
7419 double kw[EP],
7420 int *nk);
7421
7453int read_met_bin(
7454 const char *filename,
7455 const ctl_t * ctl,
7456 met_t * met);
7457
7483void read_met_bin_2d(
7484 FILE * in,
7485 const met_t * met,
7486 float var[EX][EY],
7487 const char *varname);
7488
7526void read_met_bin_3d(
7527 FILE * in,
7528 const ctl_t * ctl,
7529 const met_t * met,
7530 float var[EX][EY][EP],
7531 const char *varname,
7532 const float bound_min,
7533 const float bound_max);
7534
7562void read_met_cape(
7563 const ctl_t * ctl,
7564 const clim_t * clim,
7565 met_t * met);
7566
7589void read_met_cloud(
7590 met_t * met);
7591
7617void read_met_detrend(
7618 const ctl_t * ctl,
7619 met_t * met);
7620
7644 met_t * met);
7645
7672void read_met_geopot(
7673 const ctl_t * ctl,
7674 met_t * met);
7675
7703 const char *filename,
7704 const ctl_t * ctl,
7705 met_t * met);
7706
7728 codes_handle ** handles,
7729 int count_handles,
7730 met_t * met);
7731
7752 codes_handle ** handles,
7753 const int num_messages,
7754 const ctl_t * ctl,
7755 met_t * met);
7756
7787 codes_handle ** handles,
7788 const int num_messages,
7789 const ctl_t * ctl,
7790 met_t * met);
7791
7820void read_met_ml2pl(
7821 const ctl_t * ctl,
7822 const met_t * met,
7823 float var[EX][EY][EP],
7824 const char *varname);
7825
7848 const ctl_t * ctl,
7849 met_t * met);
7850
7881int read_met_nc(
7882 const char *filename,
7883 const ctl_t * ctl,
7884 met_t * met,
7885 dd_t * dd);
7886
7921void read_met_nc_grid(
7922 const char *filename,
7923 const int ncid,
7924 const ctl_t * ctl,
7925 met_t * met,
7926 dd_t * dd);
7927
7973 dd_t * dd,
7974 const ctl_t * ctl,
7975 met_t * met,
7976 const int ncid);
7977
8010 const int ncid,
8011 const ctl_t * ctl,
8012 met_t * met,
8013 dd_t * dd);
8014
8045 const int ncid,
8046 const ctl_t * ctl,
8047 met_t * met,
8048 dd_t * dd);
8049
8082int read_met_nc_2d(
8083 const int ncid,
8084 const char *varname,
8085 const char *varname2,
8086 const char *varname3,
8087 const char *varname4,
8088 const char *varname5,
8089 const char *varname6,
8090 const ctl_t * ctl,
8091 const met_t * met,
8092 dd_t * dd,
8093 float dest[EX][EY],
8094 const float scl,
8095 const int init);
8096
8126int read_met_nc_3d(
8127 const int ncid,
8128 const char *varname,
8129 const char *varname2,
8130 const char *varname3,
8131 const char *varname4,
8132 const ctl_t * ctl,
8133 const met_t * met,
8134 dd_t * dd,
8135 float dest[EX][EY][EP],
8136 const float scl);
8137
8183void read_met_pbl(
8184 const ctl_t * ctl,
8185 met_t * met);
8186
8219 met_t * met);
8220
8251 met_t * met);
8252
8283void read_met_pv(
8284 met_t * met);
8285
8308void read_met_ozone(
8309 met_t * met);
8310
8339void read_met_sample(
8340 const ctl_t * ctl,
8341 met_t * met);
8342
8371void read_met_tropo(
8372 const ctl_t * ctl,
8373 const clim_t * clim,
8374 met_t * met);
8375
8407void read_obs(
8408 const char *filename,
8409 const ctl_t * ctl,
8410 double *rt,
8411 double *rz,
8412 double *rlon,
8413 double *rlat,
8414 double *robs,
8415 int *nobs);
8416
8444void read_obs_asc(
8445 const char *filename,
8446 double *rt,
8447 double *rz,
8448 double *rlon,
8449 double *rlat,
8450 double *robs,
8451 int *nobs);
8452
8479void read_obs_nc(
8480 const char *filename,
8481 double *rt,
8482 double *rz,
8483 double *rlon,
8484 double *rlat,
8485 double *robs,
8486 int *nobs);
8487
8521double scan_ctl(
8522 const char *filename,
8523 int argc,
8524 char *argv[],
8525 const char *varname,
8526 const int arridx,
8527 const char *defvalue,
8528 char *value);
8529
8556double sedi(
8557 const double p,
8558 const double T,
8559 const double rp,
8560 const double rhop);
8561
8591void spline(
8592 const double *x,
8593 const double *y,
8594 const int n,
8595 const double *x2,
8596 double *y2,
8597 const int n2,
8598 const int method);
8599
8622float stddev(
8623 const float *data,
8624 const int n);
8625
8650void time2jsec(
8651 const int year,
8652 const int mon,
8653 const int day,
8654 const int hour,
8655 const int min,
8656 const int sec,
8657 const double remain,
8658 double *jsec);
8659
8688void timer(
8689 const char *name,
8690 const char *group,
8691 const int output);
8692
8718double time_from_filename(
8719 const char *filename,
8720 const int offset);
8721
8739double tropo_weight(
8740 const clim_t * clim,
8741 const atm_t * atm,
8742 const int ip);
8743
8766void write_atm_asc(
8767 const char *filename,
8768 const ctl_t * ctl,
8769 const atm_t * atm,
8770 const double t);
8771
8795void write_atm_bin(
8796 const char *filename,
8797 const ctl_t * ctl,
8798 const atm_t * atm);
8799
8823void write_atm_clams(
8824 const char *filename,
8825 const ctl_t * ctl,
8826 const atm_t * atm);
8827
8853 const char *dirname,
8854 const ctl_t * ctl,
8855 const atm_t * atm,
8856 const double t);
8857
8881void write_atm_nc(
8882 const char *filename,
8883 const ctl_t * ctl,
8884 const atm_t * atm);
8885
8914void write_csi(
8915 const char *filename,
8916 const ctl_t * ctl,
8917 const atm_t * atm,
8918 const double t);
8919
8961 const char *filename,
8962 const ctl_t * ctl,
8963 const atm_t * atm,
8964 const double t);
8965
8993void write_ens(
8994 const char *filename,
8995 const ctl_t * ctl,
8996 const atm_t * atm,
8997 const double t);
8998
9037void write_grid(
9038 const char *filename,
9039 const ctl_t * ctl,
9040 met_t * met0,
9041 met_t * met1,
9042 const atm_t * atm,
9043 const double t);
9044
9090void write_grid_asc(
9091 const char *filename,
9092 const ctl_t * ctl,
9093 const double *cd,
9094 double *mean[NQ],
9095 double *sigma[NQ],
9096 const double *vmr_impl,
9097 const double t,
9098 const double *z,
9099 const double *lon,
9100 const double *lat,
9101 const double *area,
9102 const double dz,
9103 const int *np);
9104
9147void write_grid_nc(
9148 const char *filename,
9149 const ctl_t * ctl,
9150 const double *cd,
9151 double *mean[NQ],
9152 double *sigma[NQ],
9153 const double *vmr_impl,
9154 const double t,
9155 const double *z,
9156 const double *lon,
9157 const double *lat,
9158 const double *area,
9159 const double dz,
9160 const int *np);
9161
9191void write_met_bin(
9192 const char *filename,
9193 const ctl_t * ctl,
9194 met_t * met);
9195
9223void write_met_bin_2d(
9224 FILE * out,
9225 met_t * met,
9226 float var[EX][EY],
9227 const char *varname);
9228
9266void write_met_bin_3d(
9267 FILE * out,
9268 const ctl_t * ctl,
9269 met_t * met,
9270 float var[EX][EY][EP],
9271 const char *varname,
9272 const int precision,
9273 const double tolerance);
9274
9302void write_met_nc(
9303 const char *filename,
9304 const ctl_t * ctl,
9305 met_t * met);
9306
9329void write_met_nc_2d(
9330 const int ncid,
9331 const char *varname,
9332 met_t * met,
9333 float var[EX][EY],
9334 const float scl);
9335
9359void write_met_nc_3d(
9360 const int ncid,
9361 const char *varname,
9362 met_t * met,
9363 float var[EX][EY][EP],
9364 const float scl);
9365
9396void write_prof(
9397 const char *filename,
9398 const ctl_t * ctl,
9399 met_t * met0,
9400 met_t * met1,
9401 const atm_t * atm,
9402 const double t);
9403
9435void write_sample(
9436 const char *filename,
9437 const ctl_t * ctl,
9438 met_t * met0,
9439 met_t * met1,
9440 const atm_t * atm,
9441 const double t);
9442
9469void write_station(
9470 const char *filename,
9471 const ctl_t * ctl,
9472 atm_t * atm,
9473 const double t);
9474
9503void write_vtk(
9504 const char *filename,
9505 const ctl_t * ctl,
9506 const atm_t * atm,
9507 const double t);
9508
9509#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:1051
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:1010
#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 3D array of floats using a custom multiscale compression algorithm.
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:679
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:3297
int np
Number of air parcels.
Definition: mptrac.h:3300
Cache data structure.
Definition: mptrac.h:3352
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3364
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3384
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3390
int np
Number of pressure levels.
Definition: mptrac.h:3387
int no3c
Number of total ozone columns.
Definition: mptrac.h:3393
Climatological data.
Definition: mptrac.h:3492
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3534
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3510
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3522
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3513
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3495
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3540
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3528
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3531
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3525
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3519
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3498
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3516
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3537
Climatological data in the form of time series.
Definition: mptrac.h:3440
int ntime
Number of timesteps.
Definition: mptrac.h:3443
Climatological data in the form of zonal means.
Definition: mptrac.h:3460
int np
Number of pressure levels.
Definition: mptrac.h:3469
int ntime
Number of timesteps.
Definition: mptrac.h:3463
int nlat
Number of latitudes.
Definition: mptrac.h:3466
Control parameters.
Definition: mptrac.h:2264
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3158
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2376
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:3119
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2532
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:3007
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2610
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2409
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:3095
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2869
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2355
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2556
int dd_halos_size
Domain decomposition size of halos given in grid-points.
Definition: mptrac.h:3285
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2932
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2956
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2295
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2565
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2304
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2388
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:3089
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2397
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2857
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:3110
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2364
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3236
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2917
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2768
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2929
double stat_r
Search radius around station [km].
Definition: mptrac.h:3242
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:3001
int met_zstd_level
ZSTD compression level (from -5 to 22).
Definition: mptrac.h:2619
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:3113
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3266
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2953
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2736
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2385
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:2971
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2821
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2544
double met_cms_eps_pv
cmultiscale compression epsilon for potential vorticity.
Definition: mptrac.h:2658
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2463
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:3161
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2574
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2550
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2688
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2755
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2427
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2499
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:3104
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:3116
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2803
int met_pbl
Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta).
Definition: mptrac.h:2733
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2379
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2812
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:3146
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3164
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:3060
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2830
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3176
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2310
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2454
double met_cms_eps_h2o
cmultiscale compression epsilon for water vapor.
Definition: mptrac.h:2661
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2406
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:3167
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2433
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2752
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2493
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2593
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:2974
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2724
double met_cms_eps_u
cmultiscale compression epsilon for zonal wind.
Definition: mptrac.h:2649
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2797
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2298
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2331
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2475
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2845
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3248
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2794
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3182
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:3107
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2337
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:3152
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2460
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:2962
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2863
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2445
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2721
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2694
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2307
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2785
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2772
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2851
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2313
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:3191
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:3083
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2730
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:3092
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2691
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2965
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2809
double met_cms_eps_iwc
cmultiscale compression epsilon for cloud ice water content.
Definition: mptrac.h:2673
double met_cms_eps_swc
cmultiscale compression epsilon for cloud snow water content.
Definition: mptrac.h:2676
double met_cms_eps_v
cmultiscale compression epsilon for meridional wind.
Definition: mptrac.h:2652
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3194
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2370
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2836
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2746
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3200
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2292
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2743
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2301
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2761
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2920
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2502
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2430
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:3101
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3245
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:2983
int dd
Domain decomposition (0=no, 1=yes, with 2x2 if not specified).
Definition: mptrac.h:3273
int qnt_eta
Quantity array index for eta vertical coordinate.
Definition: mptrac.h:2487
double wet_depo_so2_ph
pH value used to calculate effective Henry constant of SO2.
Definition: mptrac.h:3019
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2926
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2451
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:3065
int met_cms_nd0x
cmultiscale number of cells of coarsest grid in x-direction.
Definition: mptrac.h:2634
int met_nlev
Number of meteo data model levels.
Definition: mptrac.h:2712
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:2992
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:3028
int qnt_shf
Quantity array index for surface sensible heat flux.
Definition: mptrac.h:2328
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2319
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2529
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3254
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2580
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2827
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2421
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2607
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2349
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2469
double met_cms_eps_cc
cmultiscale compression epsilon for cloud cover.
Definition: mptrac.h:2679
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2842
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2739
int met_dx
Stride for longitudes.
Definition: mptrac.h:2682
int qnt_destination
Quantity array index for destination subdomain in domain decomposition.
Definition: mptrac.h:2571
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2941
int met_convention
Meteo data layout (0=[lev, lat, lon], 1=[lon, lat, lev]).
Definition: mptrac.h:2596
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2481
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:2995
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2583
int diffusion
Diffusion scheme (0=off, 1=fixed-K, 2=PBL).
Definition: mptrac.h:2788
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2517
int qnt_eta_dot
Quantity array index for velocity of eta vertical coordinate.
Definition: mptrac.h:2490
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2511
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2352
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3263
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2367
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2448
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2839
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2758
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2424
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2535
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2709
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2977
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2373
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:3209
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2472
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2361
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3230
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2875
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3074
double met_cms_eps_lwc
cmultiscale compression epsilon for cloud liquid water content.
Definition: mptrac.h:2667
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2316
double met_cms_eps_z
cmultiscale compression epsilon for geopotential height.
Definition: mptrac.h:2643
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3170
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2559
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2553
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2944
int nens
Number of ensembles.
Definition: mptrac.h:3122
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2340
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2400
int advect
Advection scheme (0=off, 1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2778
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3197
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2358
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:3053
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:2989
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2478
double conv_pbl_trans
Depth of PBL transition layer (fraction of PBL depth).
Definition: mptrac.h:2818
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:2600
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:3098
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2496
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3239
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2538
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:3173
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2562
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2523
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2700
int conv_mix_pbl
Vertical mixing in the PBL (0=off, 1=on).
Definition: mptrac.h:2815
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2854
int dd_nbr_neighbours
Domain decomposition number of neighbours to communicate with.
Definition: mptrac.h:3282
double met_cms_eps_t
cmultiscale compression epsilon for temperature.
Definition: mptrac.h:2646
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2950
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2412
int qnt_zeta_dot
Quantity array index for velocity of zeta vertical coordinate.
Definition: mptrac.h:2484
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2833
int met_cms_nd0y
cmultiscale number of cells of coarsest grid in y-direction.
Definition: mptrac.h:2637
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2923
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2418
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2848
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2935
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2526
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2514
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:3155
int qnt_nss
Quantity array index for northward turbulent surface stress.
Definition: mptrac.h:2325
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:3128
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:3056
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2727
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2947
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:3050
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3215
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2628
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:3034
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2697
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3203
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2959
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2394
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2442
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2457
int qnt_subdomain
Quantity array index for current subdomain in domain decomposition.
Definition: mptrac.h:2568
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3212
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2415
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:3037
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3206
double met_cms_eps_rwc
cmultiscale compression epsilon for cloud rain water content.
Definition: mptrac.h:2670
int met_nc_quant
Number of digits for quantization of netCDF meteo files (0=off).
Definition: mptrac.h:2616
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:2986
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2547
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:3025
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2968
double met_cms_eps_o3
cmultiscale compression epsilon for ozone.
Definition: mptrac.h:2664
int met_cms_zstd
cmultiscale ZSTD compression (0=off, 1=on).
Definition: mptrac.h:2631
int met_cms_maxlev
cmultiscale maximum refinement level.
Definition: mptrac.h:2640
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:3143
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:3031
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2343
int met_np
Number of target pressure levels.
Definition: mptrac.h:2703
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2289
int met_nc_level
zlib compression level of netCDF meteo files (0=off).
Definition: mptrac.h:2613
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2914
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2439
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3260
double met_cms_eps_w
cmultiscale compression epsilon for vertical velocity.
Definition: mptrac.h:2655
double turb_dx_pbl
Horizontal turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2791
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2824
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2505
int advect_vert_coord
Vertical velocity of air parcels (0=omega_on_plev, 1=zetadot_on_mlev, 2=omega_on_mlev,...
Definition: mptrac.h:2782
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2436
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2541
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2334
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2938
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:3068
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:3022
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2466
int qnt_ess
Quantity array index for eastward turbulent surface stress.
Definition: mptrac.h:2322
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:3010
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:3004
int met_dy
Stride for latitudes.
Definition: mptrac.h:2685
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2520
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2806
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2860
int dd_subdomains_zonal
Domain decomposition zonal subdomain number.
Definition: mptrac.h:3276
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2286
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2749
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2382
double t_start
Start time of simulation [s].
Definition: mptrac.h:2577
int nq
Number of quantities.
Definition: mptrac.h:2271
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2872
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3227
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3257
double turb_dz_pbl
Vertical turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2800
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3179
int dd_subdomains_meridional
Domain decomposition meridional subdomain number.
Definition: mptrac.h:3279
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2346
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:2604
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2391
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2403
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:3140
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2508
Domain decomposition data structure.
Definition: mptrac.h:3725
int halo_offset_end
Hyperslab of boundary halos count.
Definition: mptrac.h:3777
int rank
Rank of node.
Definition: mptrac.h:3732
double subdomain_lon_min
Rectangular grid limit of subdomain.
Definition: mptrac.h:3753
double subdomain_lat_max
Rectangular grid limit of subdomain.
Definition: mptrac.h:3756
int init
Shows if domain decomposition was initialized.
Definition: mptrac.h:3784
double subdomain_lon_max
Rectangular grid limit of subdomain.
Definition: mptrac.h:3750
int halo_offset_start
Hyperslab of boundary halos count.
Definition: mptrac.h:3774
int size
Size of node.
Definition: mptrac.h:3735
double subdomain_lat_min
Rectangular grid limit of subdomain.
Definition: mptrac.h:3759
Meteo data structure.
Definition: mptrac.h:3551
int nx
Number of longitudes.
Definition: mptrac.h:3557
int ny
Number of latitudes.
Definition: mptrac.h:3560
int np
Number of pressure levels.
Definition: mptrac.h:3563
int npl
Number of model levels.
Definition: mptrac.h:3566
double time
Time [s].
Definition: mptrac.h:3554
Particle data.
Definition: mptrac.h:3326
double p
Pressure [hPa].
Definition: mptrac.h:3332
double lat
Latitude [deg].
Definition: mptrac.h:3338
double time
Time [s].
Definition: mptrac.h:3329
double lon
Longitude [deg].
Definition: mptrac.h:3335