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
2636
2639
2642
2645
2648
2651
2654
2657
2660
2663
2666
2669
2672
2675
2678
2681
2684
2687
2690
2693
2696
2699
2701 double met_p[EP];
2702
2705
2708
2710 double met_lev_hyam[EP];
2711
2713 double met_lev_hybm[EP];
2714
2717
2720
2723
2726
2729
2732
2735
2739
2742
2745
2748
2751
2754
2757
2758 /* ------------------------------------------------------------
2759 Geophysical module parameters...
2760 ------------------------------------------------------------ */
2761
2763 double sort_dt;
2764
2768
2770 char balloon[LEN];
2771
2774
2778
2781
2784
2787
2790
2793
2796
2799
2802
2805
2808
2811
2814
2817
2819 double conv_cin;
2820
2822 double conv_dt;
2823
2826
2829
2832
2835
2838
2841
2843 double bound_p0;
2844
2846 double bound_p1;
2847
2850
2853
2856
2859
2861 char species[LEN];
2862
2864 double molmass;
2865
2868
2871
2874
2876 char clim_hno3_filename[LEN];
2877
2879 char clim_oh_filename[LEN];
2880
2882 char clim_h2o2_filename[LEN];
2883
2885 char clim_ho2_filename[LEN];
2886
2888 char clim_o1d_filename[LEN];
2889
2891 char clim_o3_filename[LEN];
2892
2894 char clim_ccl4_timeseries[LEN];
2895
2897 char clim_ccl3f_timeseries[LEN];
2898
2900 char clim_ccl2f2_timeseries[LEN];
2901
2903 char clim_n2o_timeseries[LEN];
2904
2906 char clim_sf6_timeseries[LEN];
2907
2910
2913
2916
2919
2922
2925
2928
2931
2934
2937
2940
2943
2946
2949
2952
2955
2958
2961
2964
2967
2970
2973
2975 double oh_chem[4];
2976
2979
2982
2985
2987 double dt_kpp;
2988
2991
2993 double wet_depo_pre[2];
2994
2997
3000
3003
3006
3008 double wet_depo_ic_h[2];
3009
3011 double wet_depo_bc_h[2];
3012
3015
3018
3021
3024
3027
3029 double psc_h2o;
3030
3032 double psc_hno3;
3033
3034 /* ------------------------------------------------------------
3035 Output parameters...
3036 ------------------------------------------------------------ */
3037
3039 char atm_basename[LEN];
3040
3042 char atm_gpfile[LEN];
3043
3046
3049
3052
3056
3061
3064
3066 int atm_nc_quant[NQ];
3067
3070
3072 char csi_basename[LEN];
3073
3075 char csi_kernel[LEN];
3076
3079
3081 char csi_obsfile[LEN];
3082
3085
3088
3091
3093 double csi_z0;
3094
3096 double csi_z1;
3097
3100
3102 double csi_lon0;
3103
3105 double csi_lon1;
3106
3109
3111 double csi_lat0;
3112
3114 double csi_lat1;
3115
3117 int nens;
3118
3120 char ens_basename[LEN];
3121
3124
3126 char grid_basename[LEN];
3127
3129 char grid_kernel[LEN];
3130
3132 char grid_gpfile[LEN];
3133
3136
3139
3142
3144 int grid_nc_quant[NQ];
3145
3148
3151
3153 double grid_z0;
3154
3156 double grid_z1;
3157
3160
3163
3166
3169
3172
3175
3178
3180 char prof_basename[LEN];
3181
3183 char prof_obsfile[LEN];
3184
3187
3189 double prof_z0;
3190
3192 double prof_z1;
3193
3196
3199
3202
3205
3208
3211
3213 char sample_basename[LEN];
3214
3216 char sample_kernel[LEN];
3217
3219 char sample_obsfile[LEN];
3220
3223
3226
3228 char stat_basename[LEN];
3229
3231 double stat_lon;
3232
3234 double stat_lat;
3235
3237 double stat_r;
3238
3240 double stat_t0;
3241
3243 double stat_t1;
3244
3246 char vtk_basename[LEN];
3247
3250
3253
3256
3259
3262
3263 /* ------------------------------------------------------------
3264 Domain decomposition...
3265 ------------------------------------------------------------ */
3266
3268 int dd;
3269
3272
3275
3278
3281
3282} ctl_t;
3283
3292typedef struct {
3293
3295 int np;
3296
3298 double time[NP];
3299
3301 double p[NP];
3302
3304 double lon[NP];
3305
3307 double lat[NP];
3308
3310 double q[NQ][NP];
3311
3312} atm_t;
3313
3321typedef struct {
3322
3324 double time;
3325
3327 double p;
3328
3330 double lon;
3331
3333 double lat;
3334
3336 double q[NQ];
3337
3338} particle_t;
3339
3340
3347typedef struct {
3348
3350 double iso_var[NP];
3351
3353 double iso_ps[NP];
3354
3356 double iso_ts[NP];
3357
3360
3362 float uvwp[NP][3];
3363
3365 double rs[3 * NP + 1];
3366
3368 double dt[NP];
3369
3370} cache_t;
3371
3379typedef struct {
3380
3382 int np;
3383
3385 int nsza;
3386
3388 int no3c;
3389
3391 double p[CP];
3392
3394 double sza[CSZA];
3395
3397 double o3c[CO3];
3398
3400 double n2o[CP][CSZA][CO3];
3401
3403 double ccl4[CP][CSZA][CO3];
3404
3406 double ccl3f[CP][CSZA][CO3];
3407
3409 double ccl2f2[CP][CSZA][CO3];
3410
3412 double o2[CP][CSZA][CO3];
3413
3415 double o3_1[CP][CSZA][CO3];
3416
3418 double o3_2[CP][CSZA][CO3];
3419
3421 double h2o2[CP][CSZA][CO3];
3422
3424 double h2o[CP][CSZA][CO3];
3425
3426} clim_photo_t;
3427
3435typedef struct {
3436
3439
3441 double time[CTS];
3442
3444 double vmr[CTS];
3445
3446} clim_ts_t;
3447
3455typedef struct {
3456
3459
3461 int nlat;
3462
3464 int np;
3465
3467 double time[CT];
3468
3470 double lat[CY];
3471
3473 double p[CP];
3474
3476 double vmr[CT][CP][CY];
3477
3478} clim_zm_t;
3479
3487typedef struct {
3488
3491
3494
3496 double tropo_time[12];
3497
3499 double tropo_lat[73];
3500
3502 double tropo[12][73];
3503
3506
3509
3512
3515
3518
3521
3524
3527
3530
3533
3536
3537} clim_t;
3538
3546typedef struct {
3547
3549 double time;
3550
3552 int nx;
3553
3555 int ny;
3556
3558 int np;
3559
3561 int npl;
3562
3564 double lon[EX];
3565
3567 double lat[EY];
3568
3570 double p[EP];
3571
3573 double hybrid[EP];
3574
3576 double hyam[EP];
3577
3579 double hybm[EP];
3580
3582 double eta[EP];
3583
3585 float ps[EX][EY];
3586
3588 float ts[EX][EY];
3589
3591 float zs[EX][EY];
3592
3594 float us[EX][EY];
3595
3597 float vs[EX][EY];
3598
3600 float ess[EX][EY];
3601
3603 float nss[EX][EY];
3604
3606 float shf[EX][EY];
3607
3609 float lsm[EX][EY];
3610
3612 float sst[EX][EY];
3613
3615 float pbl[EX][EY];
3616
3618 float pt[EX][EY];
3619
3621 float tt[EX][EY];
3622
3624 float zt[EX][EY];
3625
3627 float h2ot[EX][EY];
3628
3630 float pct[EX][EY];
3631
3633 float pcb[EX][EY];
3634
3636 float cl[EX][EY];
3637
3639 float plcl[EX][EY];
3640
3642 float plfc[EX][EY];
3643
3645 float pel[EX][EY];
3646
3648 float cape[EX][EY];
3649
3651 float cin[EX][EY];
3652
3654 float o3c[EX][EY];
3655
3657 float z[EX][EY][EP];
3658
3660 float t[EX][EY][EP];
3661
3663 float u[EX][EY][EP];
3664
3666 float v[EX][EY][EP];
3667
3669 float w[EX][EY][EP];
3670
3672 float pv[EX][EY][EP];
3673
3675 float h2o[EX][EY][EP];
3676
3678 float o3[EX][EY][EP];
3679
3681 float lwc[EX][EY][EP];
3682
3684 float rwc[EX][EY][EP];
3685
3687 float iwc[EX][EY][EP];
3688
3690 float swc[EX][EY][EP];
3691
3693 float cc[EX][EY][EP];
3694
3696 float pl[EX][EY][EP];
3697
3699 float ul[EX][EY][EP];
3700
3702 float vl[EX][EY][EP];
3703
3705 float wl[EX][EY][EP];
3706
3708 float zetal[EX][EY][EP];
3709
3711 float zeta_dotl[EX][EY][EP];
3712
3713} met_t;
3714
3720typedef struct {
3721
3722 /* ------------------------------------------------------------
3723 MPI Information
3724 ------------------------------------------------------------ */
3725
3727 int rank;
3728
3730 int size;
3731
3733 int neighbours[DD_NNMAX];
3734
3735#ifdef DD
3737 MPI_Datatype MPI_Particle;
3738#endif
3739
3740 /* ------------------------------------------------------------
3741 Properties of subdomains
3742 ------------------------------------------------------------ */
3743
3746
3749
3752
3755
3757 size_t subdomain_start[4];
3758
3760 size_t subdomain_count[4];
3761
3763 size_t halo_bnd_start[4];
3764
3766 size_t halo_bnd_count[4];
3767
3770
3773
3774 /* ------------------------------------------------------------
3775 Caches
3776 ------------------------------------------------------------ */
3777
3779 int init;
3780
3781#ifdef DD
3782
3784 double a[NP];
3785
3787 int p[NP];
3788
3790 double help[NP];
3791
3792#endif
3793
3794} dd_t;
3795
3796/* ------------------------------------------------------------
3797 OpenACC routines...
3798 ------------------------------------------------------------ */
3799
3800#ifdef _OPENACC
3801#pragma acc routine (clim_oh)
3802#pragma acc routine (clim_photo)
3803#pragma acc routine (clim_tropo)
3804#pragma acc routine (clim_ts)
3805#pragma acc routine (clim_zm)
3806#pragma acc routine (intpol_check_lon_lat)
3807#pragma acc routine (intpol_met_4d_zeta)
3808#pragma acc routine (intpol_met_space_3d)
3809#pragma acc routine (intpol_met_space_2d)
3810#pragma acc routine (intpol_met_time_3d)
3811#pragma acc routine (intpol_met_time_2d)
3812#pragma acc routine (kernel_weight)
3813#pragma acc routine (lapse_rate)
3814#pragma acc routine (locate_irr)
3815#pragma acc routine (locate_irr_float)
3816#pragma acc routine (locate_reg)
3817#pragma acc routine (locate_vert)
3818#pragma acc routine (nat_temperature)
3819#pragma acc routine (pbl_weight)
3820#pragma acc routine (sedi)
3821#pragma acc routine (stddev)
3822#pragma acc routine (sza_calc)
3823#pragma acc routine (tropo_weight)
3824#endif
3825
3826/* ------------------------------------------------------------
3827 Functions...
3828 ------------------------------------------------------------ */
3829
3852 void *data,
3853 size_t N);
3854
3869void cart2geo(
3870 const double *x,
3871 double *z,
3872 double *lon,
3873 double *lat);
3874
3897double clim_oh(
3898 const ctl_t * ctl,
3899 const clim_t * clim,
3900 const double t,
3901 const double lon,
3902 const double lat,
3903 const double p);
3904
3924 const ctl_t * ctl,
3925 clim_t * clim);
3926
3956double clim_photo(
3957 const double rate[CP][CSZA][CO3],
3958 const clim_photo_t * photo,
3959 const double p,
3960 const double sza,
3961 const double o3c);
3962
3988double clim_tropo(
3989 const clim_t * clim,
3990 const double t,
3991 const double lat);
3992
4011void clim_tropo_init(
4012 clim_t * clim);
4013
4030double clim_ts(
4031 const clim_ts_t * ts,
4032 const double t);
4033
4055double clim_zm(
4056 const clim_zm_t * zm,
4057 const double t,
4058 const double lat,
4059 const double p);
4060
4102 const ctl_t * ctl,
4103 const char *varname,
4104 float *array,
4105 const size_t nx,
4106 const size_t ny,
4107 const size_t np,
4108 const int decompress,
4109 FILE * inout);
4110
4143void compress_pck(
4144 const char *varname,
4145 float *array,
4146 const size_t nxy,
4147 const size_t nz,
4148 const int decompress,
4149 FILE * inout);
4150
4181 const char *varname,
4182 float *array,
4183 const int nx,
4184 const int ny,
4185 const int nz,
4186 const int precision,
4187 const double tolerance,
4188 const int decompress,
4189 FILE * inout);
4190
4230 const char *varname,
4231 float *array,
4232 const int nx,
4233 const int ny,
4234 const int nz,
4235 const int precision,
4236 const double tolerance,
4237 const int decompress,
4238 FILE * inout);
4239
4262 const char *varname,
4263 float *array,
4264 const size_t n,
4265 const int decompress,
4266 const int level,
4267 FILE * inout);
4268
4291void day2doy(
4292 const int year,
4293 const int mon,
4294 const int day,
4295 int *doy);
4296
4344 atm_t * atm,
4345 ctl_t * ctl,
4346 dd_t * dd,
4347 int init);
4348
4372 atm_t * atm,
4373 particle_t * particles,
4374 ctl_t * ctl,
4375 int *nparticles,
4376 cache_t * cache,
4377 int rank);
4378
4406 double lon,
4407 double lat,
4408 met_t * met,
4409 ctl_t * ctl,
4410 int mpi_size,
4411 int nx_glob,
4412 int ny_glob);
4413
4444 particle_t * particles,
4445 int *nparticles,
4446 MPI_Datatype MPI_Particle,
4447 int *neighbours,
4448 int nneighbours,
4449 ctl_t ctl);
4450
4474 const ctl_t ctl,
4475 dd_t * dd);
4476
4504 ctl_t * ctl,
4505 dd_t * dd,
4506 atm_t * atm);
4507
4532 met_t * met,
4533 int nx_glob);
4534
4560 atm_t * atm,
4561 particle_t * particles,
4562 ctl_t * ctl,
4563 int *nparticles,
4564 cache_t * cache);
4565
4588 MPI_Datatype * MPI_Particle);
4589
4624 const ctl_t * ctl,
4625 met_t * met0,
4626 atm_t * atm,
4627 dd_t * dd,
4628 int *nparticles,
4629 int *rank);
4630
4659 double *a,
4660 dd_t * dd,
4661 const int np);
4662
4684void doy2day(
4685 const int year,
4686 const int doy,
4687 int *mon,
4688 int *day);
4689
4716void fft_help(
4717 double *fcReal,
4718 double *fcImag,
4719 const int n);
4720
4747void geo2cart(
4748 const double z,
4749 const double lon,
4750 const double lat,
4751 double *x);
4752
4777void get_met_help(
4778 const ctl_t * ctl,
4779 const double t,
4780 const int direct,
4781 const char *metbase,
4782 const double dt_met,
4783 char *filename);
4784
4808void get_met_replace(
4809 char *orig,
4810 char *search,
4811 char *repl);
4812
4849void get_tropo(
4850 const int met_tropo,
4851 ctl_t * ctl,
4852 clim_t * clim,
4853 met_t * met,
4854 const double *lons,
4855 const int nx,
4856 const double *lats,
4857 const int ny,
4858 double *pt,
4859 double *zt,
4860 double *tt,
4861 double *qt,
4862 double *o3t,
4863 double *ps,
4864 double *zs);
4865
4887 const double *lons,
4888 const int nlon,
4889 const double *lats,
4890 const int nlat,
4891 const double lon,
4892 const double lat,
4893 double *lon2,
4894 double *lat2);
4895
4938 const met_t * met0,
4939 float height0[EX][EY][EP],
4940 float array0[EX][EY][EP],
4941 const met_t * met1,
4942 float height1[EX][EY][EP],
4943 float array1[EX][EY][EP],
4944 const double ts,
4945 const double height,
4946 const double lon,
4947 const double lat,
4948 double *var,
4949 int *ci,
4950 double *cw,
4951 const int init);
4952
4988 const met_t * met,
4989 float array[EX][EY][EP],
4990 const double p,
4991 const double lon,
4992 const double lat,
4993 double *var,
4994 int *ci,
4995 double *cw,
4996 const int init);
4997
5033 const met_t * met,
5034 float array[EX][EY],
5035 const double lon,
5036 const double lat,
5037 double *var,
5038 int *ci,
5039 double *cw,
5040 const int init);
5041
5076 const met_t * met0,
5077 float array0[EX][EY][EP],
5078 const met_t * met1,
5079 float array1[EX][EY][EP],
5080 const double ts,
5081 const double p,
5082 const double lon,
5083 const double lat,
5084 double *var,
5085 int *ci,
5086 double *cw,
5087 const int init);
5088
5124 const met_t * met0,
5125 float array0[EX][EY],
5126 const met_t * met1,
5127 float array1[EX][EY],
5128 const double ts,
5129 const double lon,
5130 const double lat,
5131 double *var,
5132 int *ci,
5133 double *cw,
5134 const int init);
5135
5173void intpol_tropo_3d(
5174 const double time0,
5175 float array0[EX][EY],
5176 const double time1,
5177 float array1[EX][EY],
5178 const double lons[EX],
5179 const double lats[EY],
5180 const int nlon,
5181 const int nlat,
5182 const double time,
5183 const double lon,
5184 const double lat,
5185 const int method,
5186 double *var,
5187 double *sigma);
5188
5215void jsec2time(
5216 const double jsec,
5217 int *year,
5218 int *mon,
5219 int *day,
5220 int *hour,
5221 int *min,
5222 int *sec,
5223 double *remain);
5224
5251double kernel_weight(
5252 const double kz[EP],
5253 const double kw[EP],
5254 const int nk,
5255 const double p);
5256
5295double lapse_rate(
5296 const double t,
5297 const double h2o);
5298
5328 ctl_t * ctl);
5329
5349int locate_irr(
5350 const double *xx,
5351 const int n,
5352 const double x);
5353
5380 const float *xx,
5381 const int n,
5382 const double x,
5383 const int ig);
5384
5405int locate_reg(
5406 const double *xx,
5407 const int n,
5408 const double x);
5409
5431void locate_vert(
5432 float profiles[EX][EY][EP],
5433 const int np,
5434 const int lon_ap_ind,
5435 const int lat_ap_ind,
5436 const double alt_ap,
5437 int *ind);
5438
5464void module_advect(
5465 const ctl_t * ctl,
5466 const cache_t * cache,
5467 met_t * met0,
5468 met_t * met1,
5469 atm_t * atm);
5470
5494 const ctl_t * ctl,
5495 const cache_t * cache,
5496 met_t * met0,
5497 met_t * met1,
5498 atm_t * atm);
5499
5537 const ctl_t * ctl,
5538 const cache_t * cache,
5539 const clim_t * clim,
5540 met_t * met0,
5541 met_t * met1,
5542 atm_t * atm);
5543
5585void module_chem_grid(
5586 const ctl_t * ctl,
5587 met_t * met0,
5588 met_t * met1,
5589 atm_t * atm,
5590 const double t);
5591
5618void module_chem_init(
5619 const ctl_t * ctl,
5620 const cache_t * cache,
5621 const clim_t * clim,
5622 met_t * met0,
5623 met_t * met1,
5624 atm_t * atm);
5625
5650 const ctl_t * ctl,
5651 cache_t * cache,
5652 met_t * met0,
5653 met_t * met1,
5654 atm_t * atm);
5655
5684 ctl_t * ctl,
5685 atm_t * atm,
5686 cache_t * cache,
5687 dd_t * dd,
5688 met_t ** met);
5689
5716void module_decay(
5717 const ctl_t * ctl,
5718 const cache_t * cache,
5719 const clim_t * clim,
5720 atm_t * atm);
5721
5758void module_diff_meso(
5759 const ctl_t * ctl,
5760 cache_t * cache,
5761 met_t * met0,
5762 met_t * met1,
5763 atm_t * atm);
5764
5798void module_diff_pbl(
5799 const ctl_t * ctl,
5800 cache_t * cache,
5801 met_t * met0,
5802 met_t * met1,
5803 atm_t * atm);
5804
5859void module_diff_turb(
5860 const ctl_t * ctl,
5861 cache_t * cache,
5862 const clim_t * clim,
5863 met_t * met0,
5864 met_t * met1,
5865 atm_t * atm);
5866
5886void module_dry_depo(
5887 const ctl_t * ctl,
5888 const cache_t * cache,
5889 met_t * met0,
5890 met_t * met1,
5891 atm_t * atm);
5892
5925void module_h2o2_chem(
5926 const ctl_t * ctl,
5927 const cache_t * cache,
5928 const clim_t * clim,
5929 met_t * met0,
5930 met_t * met1,
5931 atm_t * atm);
5932
5953 const ctl_t * ctl,
5954 cache_t * cache,
5955 met_t * met0,
5956 met_t * met1,
5957 atm_t * atm);
5958
5976void module_isosurf(
5977 const ctl_t * ctl,
5978 const cache_t * cache,
5979 met_t * met0,
5980 met_t * met1,
5981 atm_t * atm);
5982
6015 ctl_t * ctl,
6016 cache_t * cache,
6017 clim_t * clim,
6018 met_t * met0,
6019 met_t * met1,
6020 atm_t * atm);
6021
6040void module_meteo(
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
6065void module_mixing(
6066 const ctl_t * ctl,
6067 const clim_t * clim,
6068 atm_t * atm,
6069 const double t);
6070
6099 const ctl_t * ctl,
6100 const clim_t * clim,
6101 atm_t * atm,
6102 const int *ixs,
6103 const int *iys,
6104 const int *izs,
6105 const int qnt_idx,
6106 const int use_ensemble);
6107
6140void module_oh_chem(
6141 const ctl_t * ctl,
6142 const cache_t * cache,
6143 const clim_t * clim,
6144 met_t * met0,
6145 met_t * met1,
6146 atm_t * atm);
6147
6175void module_position(
6176 const cache_t * cache,
6177 met_t * met0,
6178 met_t * met1,
6179 atm_t * atm);
6180
6205void module_rng_init(
6206 const int ntask);
6207
6233void module_rng(
6234 const ctl_t * ctl,
6235 double *rs,
6236 const size_t n,
6237 const int method);
6238
6261void module_sedi(
6262 const ctl_t * ctl,
6263 const cache_t * cache,
6264 met_t * met0,
6265 met_t * met1,
6266 atm_t * atm);
6267
6291void module_sort(
6292 const ctl_t * ctl,
6293 met_t * met0,
6294 atm_t * atm);
6295
6315void module_sort_help(
6316 double *a,
6317 const int *p,
6318 const int np);
6319
6343void module_timesteps(
6344 const ctl_t * ctl,
6345 cache_t * cache,
6346 met_t * met0,
6347 atm_t * atm,
6348 const double t);
6349
6371 ctl_t * ctl,
6372 const atm_t * atm);
6373
6407 const ctl_t * ctl,
6408 const cache_t * cache,
6409 const clim_t * clim,
6410 met_t * met0,
6411 met_t * met1,
6412 atm_t * atm);
6413
6443void module_wet_depo(
6444 const ctl_t * ctl,
6445 const cache_t * cache,
6446 met_t * met0,
6447 met_t * met1,
6448 atm_t * atm);
6449
6480void mptrac_alloc(
6481 ctl_t ** ctl,
6482 cache_t ** cache,
6483 clim_t ** clim,
6484 met_t ** met0,
6485 met_t ** met1,
6486 atm_t ** atm,
6487 dd_t ** dd);
6488
6518void mptrac_free(
6519 ctl_t * ctl,
6520 cache_t * cache,
6521 clim_t * clim,
6522 met_t * met0,
6523 met_t * met1,
6524 atm_t * atm,
6525 dd_t * dd);
6526
6561void mptrac_get_met(
6562 ctl_t * ctl,
6563 clim_t * clim,
6564 const double t,
6565 met_t ** met0,
6566 met_t ** met1,
6567 dd_t * dd);
6568
6588void mptrac_init(
6589 ctl_t * ctl,
6590 cache_t * cache,
6591 clim_t * clim,
6592 atm_t * atm,
6593 const int ntask);
6594
6630int mptrac_read_atm(
6631 const char *filename,
6632 const ctl_t * ctl,
6633 atm_t * atm);
6634
6666void mptrac_read_clim(
6667 const ctl_t * ctl,
6668 clim_t * clim);
6669
6699void mptrac_read_ctl(
6700 const char *filename,
6701 int argc,
6702 char *argv[],
6703 ctl_t * ctl);
6704
6734int mptrac_read_met(
6735 const char *filename,
6736 const ctl_t * ctl,
6737 const clim_t * clim,
6738 met_t * met,
6739 dd_t * dd);
6740
6762 ctl_t * ctl,
6763 cache_t * cache,
6764 clim_t * clim,
6765 met_t ** met0,
6766 met_t ** met1,
6767 atm_t * atm,
6768 double t,
6769 dd_t * dd);
6770
6800void mptrac_write_atm(
6801 const char *filename,
6802 const ctl_t * ctl,
6803 const atm_t * atm,
6804 const double t);
6805
6843void mptrac_write_met(
6844 const char *filename,
6845 const ctl_t * ctl,
6846 met_t * met);
6847
6882 const char *dirname,
6883 const ctl_t * ctl,
6884 met_t * met0,
6885 met_t * met1,
6886 atm_t * atm,
6887 const double t);
6888
6920 const ctl_t * ctl,
6921 const cache_t * cache,
6922 const clim_t * clim,
6923 met_t ** met0,
6924 met_t ** met1,
6925 const atm_t * atm);
6926
6957 const ctl_t * ctl,
6958 const cache_t * cache,
6959 const clim_t * clim,
6960 met_t ** met0,
6961 met_t ** met1,
6962 const atm_t * atm);
6963
6991double nat_temperature(
6992 const double p,
6993 const double h2o,
6994 const double hno3);
6995
7016double pbl_weight(
7017 const ctl_t * ctl,
7018 const atm_t * atm,
7019 const int ip,
7020 const double pbl,
7021 const double ps);
7022
7055int read_atm_asc(
7056 const char *filename,
7057 const ctl_t * ctl,
7058 atm_t * atm);
7059
7090int read_atm_bin(
7091 const char *filename,
7092 const ctl_t * ctl,
7093 atm_t * atm);
7094
7119int read_atm_clams(
7120 const char *filename,
7121 const ctl_t * ctl,
7122 atm_t * atm);
7123
7153int read_atm_nc(
7154 const char *filename,
7155 const ctl_t * ctl,
7156 atm_t * atm);
7157
7186void read_clim_photo(
7187 const char *filename,
7188 clim_photo_t * photo);
7189
7207 const int ncid,
7208 const char *varname,
7209 const clim_photo_t * photo,
7210 double var[CP][CSZA][CO3]);
7211
7235int read_clim_ts(
7236 const char *filename,
7237 clim_ts_t * ts);
7238
7265void read_clim_zm(
7266 const char *filename,
7267 const char *varname,
7268 clim_zm_t * zm);
7269
7297void read_kernel(
7298 const char *filename,
7299 double kz[EP],
7300 double kw[EP],
7301 int *nk);
7302
7334int read_met_bin(
7335 const char *filename,
7336 const ctl_t * ctl,
7337 met_t * met);
7338
7364void read_met_bin_2d(
7365 FILE * in,
7366 const met_t * met,
7367 float var[EX][EY],
7368 const char *varname);
7369
7407void read_met_bin_3d(
7408 FILE * in,
7409 const ctl_t * ctl,
7410 const met_t * met,
7411 float var[EX][EY][EP],
7412 const char *varname,
7413 const float bound_min,
7414 const float bound_max);
7415
7442void read_met_cape(
7443 const ctl_t * ctl,
7444 const clim_t * clim,
7445 met_t * met);
7446
7469void read_met_cloud(
7470 met_t * met);
7471
7497void read_met_detrend(
7498 const ctl_t * ctl,
7499 met_t * met);
7500
7524 met_t * met);
7525
7552void read_met_geopot(
7553 const ctl_t * ctl,
7554 met_t * met);
7555
7583 const char *filename,
7584 const ctl_t * ctl,
7585 met_t * met);
7586
7608 codes_handle ** handles,
7609 int count_handles,
7610 met_t * met);
7611
7632 codes_handle ** handles,
7633 const int num_messages,
7634 const ctl_t * ctl,
7635 met_t * met);
7636
7667 codes_handle ** handles,
7668 const int num_messages,
7669 const ctl_t * ctl,
7670 met_t * met);
7671
7700void read_met_ml2pl(
7701 const ctl_t * ctl,
7702 const met_t * met,
7703 float var[EX][EY][EP],
7704 const char *varname);
7705
7728 const ctl_t * ctl,
7729 met_t * met);
7730
7760int read_met_nc(
7761 const char *filename,
7762 const ctl_t * ctl,
7763 met_t * met,
7764 dd_t * dd);
7765
7798void read_met_nc_grid(
7799 const char *filename,
7800 const int ncid,
7801 const ctl_t * ctl,
7802 met_t * met,
7803 dd_t * dd);
7804
7850 dd_t * dd,
7851 const ctl_t * ctl,
7852 met_t * met,
7853 const int ncid);
7854
7886 const int ncid,
7887 const ctl_t * ctl,
7888 met_t * met,
7889 dd_t * dd);
7890
7920 const int ncid,
7921 const ctl_t * ctl,
7922 met_t * met,
7923 dd_t * dd);
7924
7954int read_met_nc_2d(
7955 const int ncid,
7956 const char *varname,
7957 const char *varname2,
7958 const char *varname3,
7959 const char *varname4,
7960 const char *varname5,
7961 const char *varname6,
7962 const ctl_t * ctl,
7963 const met_t * met,
7964 dd_t * dd,
7965 float dest[EX][EY],
7966 const float scl,
7967 const int init);
7968
7999int read_met_nc_3d(
8000 const int ncid,
8001 const char *varname,
8002 const char *varname2,
8003 const char *varname3,
8004 const char *varname4,
8005 const ctl_t * ctl,
8006 const met_t * met,
8007 dd_t * dd,
8008 float dest[EX][EY][EP],
8009 const float scl);
8010
8056void read_met_pbl(
8057 const ctl_t * ctl,
8058 met_t * met);
8059
8092 met_t * met);
8093
8124 met_t * met);
8125
8156void read_met_pv(
8157 met_t * met);
8158
8181void read_met_ozone(
8182 met_t * met);
8183
8212void read_met_sample(
8213 const ctl_t * ctl,
8214 met_t * met);
8215
8244void read_met_tropo(
8245 const ctl_t * ctl,
8246 const clim_t * clim,
8247 met_t * met);
8248
8280void read_obs(
8281 const char *filename,
8282 const ctl_t * ctl,
8283 double *rt,
8284 double *rz,
8285 double *rlon,
8286 double *rlat,
8287 double *robs,
8288 int *nobs);
8289
8317void read_obs_asc(
8318 const char *filename,
8319 double *rt,
8320 double *rz,
8321 double *rlon,
8322 double *rlat,
8323 double *robs,
8324 int *nobs);
8325
8352void read_obs_nc(
8353 const char *filename,
8354 double *rt,
8355 double *rz,
8356 double *rlon,
8357 double *rlat,
8358 double *robs,
8359 int *nobs);
8360
8394double scan_ctl(
8395 const char *filename,
8396 int argc,
8397 char *argv[],
8398 const char *varname,
8399 const int arridx,
8400 const char *defvalue,
8401 char *value);
8402
8429double sedi(
8430 const double p,
8431 const double T,
8432 const double rp,
8433 const double rhop);
8434
8464void spline(
8465 const double *x,
8466 const double *y,
8467 const int n,
8468 const double *x2,
8469 double *y2,
8470 const int n2,
8471 const int method);
8472
8495float stddev(
8496 const float *data,
8497 const int n);
8498
8518double sza_calc(
8519 const double sec,
8520 const double lon,
8521 const double lat);
8522
8547void time2jsec(
8548 const int year,
8549 const int mon,
8550 const int day,
8551 const int hour,
8552 const int min,
8553 const int sec,
8554 const double remain,
8555 double *jsec);
8556
8585void timer(
8586 const char *name,
8587 const char *group,
8588 const int output);
8589
8615double time_from_filename(
8616 const char *filename,
8617 const int offset);
8618
8636double tropo_weight(
8637 const clim_t * clim,
8638 const atm_t * atm,
8639 const int ip);
8640
8663void write_atm_asc(
8664 const char *filename,
8665 const ctl_t * ctl,
8666 const atm_t * atm,
8667 const double t);
8668
8692void write_atm_bin(
8693 const char *filename,
8694 const ctl_t * ctl,
8695 const atm_t * atm);
8696
8720void write_atm_clams(
8721 const char *filename,
8722 const ctl_t * ctl,
8723 const atm_t * atm);
8724
8750 const char *dirname,
8751 const ctl_t * ctl,
8752 const atm_t * atm,
8753 const double t);
8754
8778void write_atm_nc(
8779 const char *filename,
8780 const ctl_t * ctl,
8781 const atm_t * atm);
8782
8811void write_csi(
8812 const char *filename,
8813 const ctl_t * ctl,
8814 const atm_t * atm,
8815 const double t);
8816
8858 const char *filename,
8859 const ctl_t * ctl,
8860 const atm_t * atm,
8861 const double t);
8862
8890void write_ens(
8891 const char *filename,
8892 const ctl_t * ctl,
8893 const atm_t * atm,
8894 const double t);
8895
8934void write_grid(
8935 const char *filename,
8936 const ctl_t * ctl,
8937 met_t * met0,
8938 met_t * met1,
8939 const atm_t * atm,
8940 const double t);
8941
8987void write_grid_asc(
8988 const char *filename,
8989 const ctl_t * ctl,
8990 const double *cd,
8991 double *mean[NQ],
8992 double *sigma[NQ],
8993 const double *vmr_impl,
8994 const double t,
8995 const double *z,
8996 const double *lon,
8997 const double *lat,
8998 const double *area,
8999 const double dz,
9000 const int *np);
9001
9044void write_grid_nc(
9045 const char *filename,
9046 const ctl_t * ctl,
9047 const double *cd,
9048 double *mean[NQ],
9049 double *sigma[NQ],
9050 const double *vmr_impl,
9051 const double t,
9052 const double *z,
9053 const double *lon,
9054 const double *lat,
9055 const double *area,
9056 const double dz,
9057 const int *np);
9058
9088void write_met_bin(
9089 const char *filename,
9090 const ctl_t * ctl,
9091 met_t * met);
9092
9120void write_met_bin_2d(
9121 FILE * out,
9122 met_t * met,
9123 float var[EX][EY],
9124 const char *varname);
9125
9163void write_met_bin_3d(
9164 FILE * out,
9165 const ctl_t * ctl,
9166 met_t * met,
9167 float var[EX][EY][EP],
9168 const char *varname,
9169 const int precision,
9170 const double tolerance);
9171
9199void write_met_nc(
9200 const char *filename,
9201 const ctl_t * ctl,
9202 met_t * met);
9203
9228void write_met_nc_2d(
9229 const int ncid,
9230 const char *varname,
9231 met_t * met,
9232 float var[EX][EY],
9233 const float scl);
9234
9260void write_met_nc_3d(
9261 const int ncid,
9262 const char *varname,
9263 met_t * met,
9264 float var[EX][EY][EP],
9265 const float scl);
9266
9297void write_prof(
9298 const char *filename,
9299 const ctl_t * ctl,
9300 met_t * met0,
9301 met_t * met1,
9302 const atm_t * atm,
9303 const double t);
9304
9336void write_sample(
9337 const char *filename,
9338 const ctl_t * ctl,
9339 met_t * met0,
9340 met_t * met1,
9341 const atm_t * atm,
9342 const double t);
9343
9370void write_station(
9371 const char *filename,
9372 const ctl_t * ctl,
9373 atm_t * atm,
9374 const double t);
9375
9404void write_vtk(
9405 const char *filename,
9406 const ctl_t * ctl,
9407 const atm_t * atm,
9408 const double t);
9409
9410#endif /* LIBTRAC_H */
void read_met_geopot(const ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:8070
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:5108
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:6726
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:1004
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:8030
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:11455
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:8700
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:12854
void read_met_sample(const ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:10453
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:12600
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:10798
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:2925
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:4825
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:4142
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:7158
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:7869
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:3528
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:10971
#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:2324
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:8962
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:7125
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:10061
void read_met_detrend(const ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:7926
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:10626
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:10842
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:3373
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:2886
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:2024
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:2905
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:8503
void read_met_monotonize(const ctl_t *ctl, met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:9696
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:7277
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:10198
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:6466
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:4872
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:11937
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 int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats using a custom multiscale compression algorithm.
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:4249
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:406
#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:4320
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:7249
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:9654
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:205
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:10870
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:7619
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:2822
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:3966
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:2612
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:2094
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:12225
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:6614
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:11113
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:5316
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:2382
#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:1876
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:4973
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:673
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:6921
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:11004
#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:148
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:7331
#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:9821
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:4693
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:9781
void timer(const char *name, const char *group, const int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:11144
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:11270
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:2266
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:3415
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:7430
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:3115
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:10899
#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:3088
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:5194
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:4787
float stddev(const float *data, const int n)
Calculates the standard deviation of a set of data.
Definition: mptrac.c:11051
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:2444
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:7648
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:2852
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:11212
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:12913
void dd_atm2particles(atm_t *atm, particle_t *particles, ctl_t *ctl, int *nparticles, cache_t *cache, int rank)
Converts atmospheric data to particle data.
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:5406
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:3211
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:11247
void write_met_nc(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a NetCDF file.
Definition: mptrac.c:12690
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:4557
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:5335
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:6670
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:6830
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:10424
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)
Assigns rectangular subdomains to atmospheric data particles.
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:8365
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:233
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:4588
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:1933
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:13302
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
double sza_calc(const double sec, const double lon, const double lat)
Calculates the solar zenith angle.
Definition: mptrac.c:11072
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:1846
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:2411
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:4506
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:12571
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:10318
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:7009
void get_met_replace(char *orig, char *search, char *repl)
Replaces occurrences of a substring in a string with another substring.
Definition: mptrac.c:2000
#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:3567
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:4722
double clim_ts(const clim_ts_t *ts, const double t)
Interpolates a time series of climatological variables.
Definition: mptrac.c:388
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:2535
int read_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Reads meteorological data from a binary file.
Definition: mptrac.c:7471
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:11402
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:3769
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:7065
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:6357
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:13388
#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:4903
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:5466
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:5161
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:10259
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:3884
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:12329
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:6945
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:3644
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:12883
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:4036
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:4422
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:1915
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:8198
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:2568
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:6967
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:2067
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:13140
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:12034
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:3821
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:12459
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:11352
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:7754
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:6786
#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:2594
#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:11662
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:11613
Air parcel data.
Definition: mptrac.h:3292
int np
Number of air parcels.
Definition: mptrac.h:3295
Cache data structure.
Definition: mptrac.h:3347
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3359
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3379
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3385
int np
Number of pressure levels.
Definition: mptrac.h:3382
int no3c
Number of total ozone columns.
Definition: mptrac.h:3388
Climatological data.
Definition: mptrac.h:3487
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3529
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3505
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3517
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3508
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3490
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3535
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3523
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3526
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3520
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3514
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3493
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3511
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3532
Climatological data in the form of time series.
Definition: mptrac.h:3435
int ntime
Number of timesteps.
Definition: mptrac.h:3438
Climatological data in the form of zonal means.
Definition: mptrac.h:3455
int np
Number of pressure levels.
Definition: mptrac.h:3464
int ntime
Number of timesteps.
Definition: mptrac.h:3458
int nlat
Number of latitudes.
Definition: mptrac.h:3461
Control parameters.
Definition: mptrac.h:2264
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3153
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:3114
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:3002
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:3090
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2864
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:3280
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2927
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2951
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:3084
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:2852
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:3105
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2364
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3231
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2912
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2763
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2924
double stat_r
Search radius around station [km].
Definition: mptrac.h:3237
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:2996
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:3108
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3261
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2948
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2731
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:2966
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2816
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:2653
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:3156
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:2683
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2750
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:3099
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:3111
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2798
int met_pbl
Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta).
Definition: mptrac.h:2728
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:2807
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:3141
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3159
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:3055
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2825
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3171
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:2656
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:3162
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:2747
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:2969
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2719
double met_cms_eps_u
cmultiscale compression epsilon for zonal wind.
Definition: mptrac.h:2644
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2792
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:2840
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3243
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2789
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3177
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:3102
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:3147
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:2957
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2858
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:2716
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2689
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:2780
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2767
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2846
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:3186
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:3078
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2725
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:3087
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2686
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2960
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2804
double met_cms_eps_iwc
cmultiscale compression epsilon for cloud ice water content.
Definition: mptrac.h:2668
double met_cms_eps_swc
cmultiscale compression epsilon for cloud snow water content.
Definition: mptrac.h:2671
double met_cms_eps_v
cmultiscale compression epsilon for meridional wind.
Definition: mptrac.h:2647
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3189
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:2831
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2741
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3195
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:2738
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:2756
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2915
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:3096
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3240
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:2978
int dd
Domain decomposition (0=no, 1=yes, with 2x2 if not specified).
Definition: mptrac.h:3268
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:3014
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2921
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:3060
int met_nlev
Number of meteo data model levels.
Definition: mptrac.h:2707
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:2987
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:3023
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:3249
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2580
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2822
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:2674
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2837
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2734
int met_dx
Stride for longitudes.
Definition: mptrac.h:2677
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:2936
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:2990
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:2783
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:3258
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:2834
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2753
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:2704
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2972
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:3204
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:3225
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2870
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3069
double met_cms_eps_lwc
cmultiscale compression epsilon for cloud liquid water content.
Definition: mptrac.h:2662
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:2638
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3165
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:2939
int nens
Number of ensembles.
Definition: mptrac.h:3117
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:2773
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3192
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:3048
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:2984
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:2813
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:3093
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2496
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3234
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:3168
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:2695
int conv_mix_pbl
Vertical mixing in the PBL (0=off, 1=on).
Definition: mptrac.h:2810
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2849
int dd_nbr_neighbours
Domain decomposition number of neighbours to communicate with.
Definition: mptrac.h:3277
double met_cms_eps_t
cmultiscale compression epsilon for temperature.
Definition: mptrac.h:2641
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2945
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:2828
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2918
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:2843
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2930
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:3150
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:3123
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:3051
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2722
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2942
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:3045
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3210
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2628
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:3029
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2692
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3198
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2954
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:3207
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:3032
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3201
double met_cms_eps_rwc
cmultiscale compression epsilon for cloud rain water content.
Definition: mptrac.h:2665
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:2981
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:3020
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2963
double met_cms_eps_o3
cmultiscale compression epsilon for ozone.
Definition: mptrac.h:2659
int met_cms_zstd
cmultiscale ZSTD compression (0=off, 1=on).
Definition: mptrac.h:2631
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:3138
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:3026
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2343
int met_np
Number of target pressure levels.
Definition: mptrac.h:2698
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:2909
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:3255
double met_cms_eps_w
cmultiscale compression epsilon for vertical velocity.
Definition: mptrac.h:2650
double turb_dx_pbl
Horizontal turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2786
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2819
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:2777
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:2933
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:3063
int met_cms_heur
cmultiscale coarsening heuristics (0=default, 1=mean diff, 2=median diff, 3=max diff).
Definition: mptrac.h:2635
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:3017
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:3005
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:2999
int met_dy
Stride for latitudes.
Definition: mptrac.h:2680
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:2801
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2855
int dd_subdomains_zonal
Domain decomposition zonal subdomain number.
Definition: mptrac.h:3271
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:2744
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:2867
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3222
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3252
double turb_dz_pbl
Vertical turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2795
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3174
int dd_subdomains_meridional
Domain decomposition meridional subdomain number.
Definition: mptrac.h:3274
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:3135
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2508
Domain decomposition data structure.
Definition: mptrac.h:3720
int halo_offset_end
Hyperslab of boundary halos count.
Definition: mptrac.h:3772
int rank
Rank of node.
Definition: mptrac.h:3727
double subdomain_lon_min
Rectangular grid limit of subdomain.
Definition: mptrac.h:3748
double subdomain_lat_max
Rectangular grid limit of subdomain.
Definition: mptrac.h:3751
int init
Shows if domain decomposition was initialized.
Definition: mptrac.h:3779
double subdomain_lon_max
Rectangular grid limit of subdomain.
Definition: mptrac.h:3745
int halo_offset_start
Hyperslab of boundary halos count.
Definition: mptrac.h:3769
int size
Size of node.
Definition: mptrac.h:3730
double subdomain_lat_min
Rectangular grid limit of subdomain.
Definition: mptrac.h:3754
Meteo data structure.
Definition: mptrac.h:3546
int nx
Number of longitudes.
Definition: mptrac.h:3552
int ny
Number of latitudes.
Definition: mptrac.h:3555
int np
Number of pressure levels.
Definition: mptrac.h:3558
int npl
Number of model levels.
Definition: mptrac.h:3561
double time
Time [s].
Definition: mptrac.h:3549
Particle data.
Definition: mptrac.h:3321
double p
Pressure [hPa].
Definition: mptrac.h:3327
double lat
Latitude [deg].
Definition: mptrac.h:3333
double time
Time [s].
Definition: mptrac.h:3324
double lon
Longitude [deg].
Definition: mptrac.h:3330