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-2026 Forschungszentrum Juelich GmbH
18*/
19
166#ifndef LIBTRAC_H
167#define LIBTRAC_H
168
169/* ------------------------------------------------------------
170 Includes...
171 ------------------------------------------------------------ */
172
173#include <ctype.h>
174#include <gsl/gsl_fft_complex.h>
175#include <gsl/gsl_math.h>
176#include <gsl/gsl_randist.h>
177#include <gsl/gsl_rng.h>
178#include <gsl/gsl_sort.h>
179#include <gsl/gsl_spline.h>
180#include <gsl/gsl_statistics.h>
181#include <math.h>
182#include <netcdf.h>
183#include <omp.h>
184#include <stdint.h>
185#include <stdio.h>
186#include <stdlib.h>
187#include <string.h>
188#include <time.h>
189#include <sys/time.h>
190
191#ifdef MPI
192#include "mpi.h"
193#endif
194
195#ifdef DD
196#include <netcdf_par.h>
197#endif
198
199#ifdef _OPENACC
200#include "openacc.h"
201#endif
202
203#ifdef CURAND
204#include "curand.h"
205#endif
206
207#ifdef THRUST
208#include "thrustsort.h"
209#endif
210
211#ifdef ZFP
212#include "zfp.h"
213#endif
214
215#ifdef ZSTD
216#include "zstd.h"
217#endif
218
219#ifdef LZ4
220#include "lz4.h"
221#endif
222
223#ifdef SZ3
224#include "SZ3c/sz3c.h"
225#endif
226
227#ifdef CMS
228#include "cmultiscale.h"
229#endif
230
231#ifdef KPP
232#include "chem_Parameters.h"
233#include "chem_Global.h"
234#include "chem_Sparse.h"
235#endif
236
237#ifdef ECCODES
238#include "eccodes.h"
239#else
241#define codes_handle void*
242#endif
243
244/* ------------------------------------------------------------
245 Constants...
246 ------------------------------------------------------------ */
247
249#ifndef AVO
250#define AVO 6.02214076e23
251#endif
252
254#ifndef CPD
255#define CPD 1003.5
256#endif
257
259#ifndef EPS
260#define EPS (MH2O / MA)
261#endif
262
264#ifndef G0
265#define G0 9.80665
266#endif
267
269#ifndef H0
270#define H0 7.0
271#endif
272
274#ifndef LV
275#define LV 2501000.
276#endif
277
279#ifndef KARMAN
280#define KARMAN 0.40
281#endif
282
284#ifndef KB
285#define KB 1.3806504e-23
286#endif
287
289#ifndef MA
290#define MA 28.9644
291#endif
292
294#ifndef MH2O
295#define MH2O 18.01528
296#endif
297
299#ifndef MO3
300#define MO3 48.00
301#endif
302
304#ifndef P0
305#define P0 1013.25
306#endif
307
309#ifndef RA
310#define RA (1e3 * RI / MA)
311#endif
312
314#ifndef RE
315#define RE 6367.421
316#endif
317
319#ifndef RI
320#define RI 8.3144598
321#endif
322
324#ifndef T0
325#define T0 273.15
326#endif
327
328/* ------------------------------------------------------------
329 Dimensions...
330 ------------------------------------------------------------ */
331
333#ifndef EP
334#define EP 140
335#endif
336
338#ifndef EX
339#define EX 1444
340#endif
341
343#ifndef EY
344#define EY 724
345#endif
346
348#ifndef LEN
349#define LEN 5000
350#endif
351
353#ifndef METVAR
354#define METVAR 13
355#endif
356
358#ifndef NP
359#define NP 10000000
360#endif
361
363#ifndef NQ
364#define NQ 15
365#endif
366
368#ifndef NCSI
369#define NCSI 1000000
370#endif
371
373#ifndef NENS
374#define NENS 2000
375#endif
376
378#ifndef NOBS
379#define NOBS 10000000
380#endif
381
383#ifndef NTHREADS
384#define NTHREADS 512
385#endif
386
388#ifndef CY
389#define CY 250
390#endif
391
393#ifndef CO3
394#define CO3 30
395#endif
396
398#ifndef CP
399#define CP 70
400#endif
401
403#ifndef CSZA
404#define CSZA 50
405#endif
406
408#ifndef CT
409#define CT 12
410#endif
411
413#ifndef CTS
414#define CTS 1000
415#endif
416
418#ifndef DD_EX_GLOB
419#define DD_EX_GLOB (EX * 16)
420#endif
421
423#ifndef DD_EY_GLOB
424#define DD_EY_GLOB (EY * 16)
425#endif
426
427/* ------------------------------------------------------------
428 Macros...
429 ------------------------------------------------------------ */
430
450#ifdef _OPENACC
451#define ALLOC(ptr, type, n) \
452 if(acc_get_num_devices(acc_device_nvidia) <= 0) \
453 ERRMSG("Not running on a GPU device!"); \
454 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
455 ERRMSG("Out of memory!");
456#else
457#define ALLOC(ptr, type, n) \
458 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
459 ERRMSG("Out of memory!");
460#endif
461
480#define ARRAY_2D(ix, iy, ny) \
481 ((ix) * (ny) + (iy))
482
499#define ARRAY_3D(ix, iy, ny, iz, nz) \
500 (((ix)*(ny) + (iy)) * (nz) + (iz))
501
524#define ARRHENIUS(a, b, t) \
525 ((a) * exp( -(b) / (t)))
526
546#define CLAMP(v, lo, hi) \
547 (((v) < (lo)) ? (lo) : (((v) > (hi)) ? (hi) : (v)))
548
561#define COMPRESS_SPEED(nbytes, dt) \
562 ((dt) > 0 ? ((double)(nbytes)) / ((dt) * 1024. * 1024.) : NAN)
563
573#define COMPRESS_RATIO(raw_size, stored_size) \
574 ((double) (raw_size) / (double) (stored_size))
575
585#define COMPRESS_BPV(n, stored_size) \
586 ((8.0 * (double) (stored_size)) / (double) (n))
587
609#define DEG2DX(dlon, lat) \
610 (RE * DEG2RAD(dlon) * cos(DEG2RAD(lat)))
611
630#define DEG2DY(dlat) \
631 (RE * DEG2RAD(dlat))
632
647#define DEG2RAD(deg) \
648 ((deg) * (M_PI / 180.0))
649
672#define DP2DZ(dp, p) \
673 (- (dp) * H0 / (p))
674
694#define DX2DEG(dx, lat) \
695 (((lat) < -89.999 || (lat) > 89.999) ? 0 \
696 : (dx) * 180. / (M_PI * RE * cos(DEG2RAD(lat))))
697
712#define DY2DEG(dy) \
713 ((dy) * 180. / (M_PI * RE))
714
731#define DZ2DP(dz, p) \
732 (-(dz) * (p) / H0)
733
756#define DX2COORD(met, dx, lat) (((met)->coord_type == 0)? DX2DEG((dx) / 1000.0, (lat)) : ((dx) ))
757
779#define DY2COORD(met, dy) (((met)->coord_type == 0)? DY2DEG((dy) / 1000.0) : ((dy) ))
780
794#define DIST(a, b) \
795 sqrt(DIST2(a, b))
796
810#define DIST2(a, b) \
811 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
812
826#define DOTP(a, b) \
827 (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
828
840#define ECC(cmd) { \
841 int ecc_result=(cmd); \
842 if(ecc_result!=0) \
843 ERRMSG("ECCODES error: %s", codes_get_error_message(ecc_result)); \
844 }
845
859#define ECC_READ_2D(variable, target, scaling_factor, found_flag) { \
860 if(strcmp(short_name, variable) == 0) { \
861 if ((found_flag) == 0) \
862 LOG(2, "Read 2-D variable: %s (GRIB)", variable); \
863 for (int ix = 0; ix < met->nx; ix++) \
864 for (int iy = 0; iy < met->ny; iy++) \
865 target[ix][iy] = (float)(values[iy * met->nx + ix] * scaling_factor); \
866 found_flag = 1; \
867 } \
868 }
869
884#define ECC_READ_3D(variable, level, target, scaling_factor, found_flag) { \
885 if(strcmp(short_name, variable) == 0) { \
886 if ((found_flag) == 0) \
887 LOG(2, "Read 3-D variable: %s (GRIB)", variable); \
888 for (int ix = 0; ix < met->nx; ix++) \
889 for (int iy = 0; iy < met->ny; iy++) \
890 target[ix][iy][level] = (float) (values[iy * met->nx + ix] * scaling_factor); \
891 found_flag += 1; \
892 } \
893 }
894
911#define FMOD(x, y) \
912 ((x) - (int) ((x) / (y)) * (y))
913
929#define FREAD(ptr, type, size, in) { \
930 if(fread(ptr, sizeof(type), size, in)!=size) \
931 ERRMSG("Error while reading!"); \
932 }
933
949#define FWRITE(ptr, type, size, out) { \
950 if(fwrite(ptr, sizeof(type), size, out)!=size) \
951 ERRMSG("Error while writing!"); \
952 }
953
964#define INTPOL_INIT \
965 double cw[4] = {0.0, 0.0, 0.0, 0.0}; int ci[3] = {0, 0, 0};
966
978#define INTPOL_2D(var, init) \
979 intpol_met_time_2d(met0, met0->var, met1, met1->var, \
980 atm->time[ip], atm->lon[ip], atm->lat[ip], \
981 &var, ci, cw, init);
982
995#define INTPOL_3D(var, init) \
996 intpol_met_time_3d(met0, met0->var, met1, met1->var, \
997 atm->time[ip], atm->p[ip], \
998 atm->lon[ip], atm->lat[ip], \
999 &var, ci, cw, init);
1000
1014#define INTPOL_SPACE_ALL(p, lon, lat) { \
1015 intpol_met_space_3d(met, met->z, p, lon, lat, &z, ci, cw, 1); \
1016 intpol_met_space_3d(met, met->t, p, lon, lat, &t, ci, cw, 0); \
1017 intpol_met_space_3d(met, met->u, p, lon, lat, &u, ci, cw, 0); \
1018 intpol_met_space_3d(met, met->v, p, lon, lat, &v, ci, cw, 0); \
1019 intpol_met_space_3d(met, met->w, p, lon, lat, &w, ci, cw, 0); \
1020 intpol_met_space_3d(met, met->pv, p, lon, lat, &pv, ci, cw, 0); \
1021 intpol_met_space_3d(met, met->h2o, p, lon, lat, &h2o, ci, cw, 0); \
1022 intpol_met_space_3d(met, met->o3, p, lon, lat, &o3, ci, cw, 0); \
1023 intpol_met_space_3d(met, met->lwc, p, lon, lat, &lwc, ci, cw, 0); \
1024 intpol_met_space_3d(met, met->rwc, p, lon, lat, &rwc, ci, cw, 0); \
1025 intpol_met_space_3d(met, met->iwc, p, lon, lat, &iwc, ci, cw, 0); \
1026 intpol_met_space_3d(met, met->swc, p, lon, lat, &swc, ci, cw, 0); \
1027 intpol_met_space_3d(met, met->cc, p, lon, lat, &cc, ci, cw, 0); \
1028 intpol_met_space_2d(met, met->ps, lon, lat, &ps, ci, cw, 0); \
1029 intpol_met_space_2d(met, met->ts, lon, lat, &ts, ci, cw, 0); \
1030 intpol_met_space_2d(met, met->zs, lon, lat, &zs, ci, cw, 0); \
1031 intpol_met_space_2d(met, met->us, lon, lat, &us, ci, cw, 0); \
1032 intpol_met_space_2d(met, met->vs, lon, lat, &vs, ci, cw, 0); \
1033 intpol_met_space_2d(met, met->ess, ess, lat, &ess, ci, cw, 0); \
1034 intpol_met_space_2d(met, met->nss, nss, lat, &nss, ci, cw, 0); \
1035 intpol_met_space_2d(met, met->shf, shf, lat, &shf, ci, cw, 0); \
1036 intpol_met_space_2d(met, met->lsm, lon, lat, &lsm, ci, cw, 0); \
1037 intpol_met_space_2d(met, met->sst, lon, lat, &sst, ci, cw, 0); \
1038 intpol_met_space_2d(met, met->pbl, lon, lat, &pbl, ci, cw, 0); \
1039 intpol_met_space_2d(met, met->pt, lon, lat, &pt, ci, cw, 0); \
1040 intpol_met_space_2d(met, met->tt, lon, lat, &tt, ci, cw, 0); \
1041 intpol_met_space_2d(met, met->zt, lon, lat, &zt, ci, cw, 0); \
1042 intpol_met_space_2d(met, met->h2ot, lon, lat, &h2ot, ci, cw, 0); \
1043 intpol_met_space_2d(met, met->pct, lon, lat, &pct, ci, cw, 0); \
1044 intpol_met_space_2d(met, met->pcb, lon, lat, &pcb, ci, cw, 0); \
1045 intpol_met_space_2d(met, met->cl, lon, lat, &cl, ci, cw, 0); \
1046 intpol_met_space_2d(met, met->plcl, lon, lat, &plcl, ci, cw, 0); \
1047 intpol_met_space_2d(met, met->plfc, lon, lat, &plfc, ci, cw, 0); \
1048 intpol_met_space_2d(met, met->pel, lon, lat, &pel, ci, cw, 0); \
1049 intpol_met_space_2d(met, met->cape, lon, lat, &cape, ci, cw, 0); \
1050 intpol_met_space_2d(met, met->cin, lon, lat, &cin, ci, cw, 0); \
1051 intpol_met_space_2d(met, met->o3c, lon, lat, &o3c, ci, cw, 0); \
1052 }
1053
1068#define INTPOL_TIME_ALL(time, p, lon, lat) { \
1069 intpol_met_time_3d(met0, met0->z, met1, met1->z, time, p, lon, lat, &z, ci, cw, 1); \
1070 intpol_met_time_3d(met0, met0->t, met1, met1->t, time, p, lon, lat, &t, ci, cw, 0); \
1071 intpol_met_time_3d(met0, met0->u, met1, met1->u, time, p, lon, lat, &u, ci, cw, 0); \
1072 intpol_met_time_3d(met0, met0->v, met1, met1->v, time, p, lon, lat, &v, ci, cw, 0); \
1073 intpol_met_time_3d(met0, met0->w, met1, met1->w, time, p, lon, lat, &w, ci, cw, 0); \
1074 intpol_met_time_3d(met0, met0->pv, met1, met1->pv, time, p, lon, lat, &pv, ci, cw, 0); \
1075 intpol_met_time_3d(met0, met0->h2o, met1, met1->h2o, time, p, lon, lat, &h2o, ci, cw, 0); \
1076 intpol_met_time_3d(met0, met0->o3, met1, met1->o3, time, p, lon, lat, &o3, ci, cw, 0); \
1077 intpol_met_time_3d(met0, met0->lwc, met1, met1->lwc, time, p, lon, lat, &lwc, ci, cw, 0); \
1078 intpol_met_time_3d(met0, met0->rwc, met1, met1->rwc, time, p, lon, lat, &rwc, ci, cw, 0); \
1079 intpol_met_time_3d(met0, met0->iwc, met1, met1->iwc, time, p, lon, lat, &iwc, ci, cw, 0); \
1080 intpol_met_time_3d(met0, met0->swc, met1, met1->swc, time, p, lon, lat, &swc, ci, cw, 0); \
1081 intpol_met_time_3d(met0, met0->cc, met1, met1->cc, time, p, lon, lat, &cc, ci, cw, 0); \
1082 intpol_met_time_2d(met0, met0->ps, met1, met1->ps, time, lon, lat, &ps, ci, cw, 0); \
1083 intpol_met_time_2d(met0, met0->ts, met1, met1->ts, time, lon, lat, &ts, ci, cw, 0); \
1084 intpol_met_time_2d(met0, met0->zs, met1, met1->zs, time, lon, lat, &zs, ci, cw, 0); \
1085 intpol_met_time_2d(met0, met0->us, met1, met1->us, time, lon, lat, &us, ci, cw, 0); \
1086 intpol_met_time_2d(met0, met0->vs, met1, met1->vs, time, lon, lat, &vs, ci, cw, 0); \
1087 intpol_met_time_2d(met0, met0->ess, met1, met1->ess, time, lon, lat, &ess, ci, cw, 0); \
1088 intpol_met_time_2d(met0, met0->nss, met1, met1->nss, time, lon, lat, &nss, ci, cw, 0); \
1089 intpol_met_time_2d(met0, met0->shf, met1, met1->shf, time, lon, lat, &shf, ci, cw, 0); \
1090 intpol_met_time_2d(met0, met0->lsm, met1, met1->lsm, time, lon, lat, &lsm, ci, cw, 0); \
1091 intpol_met_time_2d(met0, met0->sst, met1, met1->sst, time, lon, lat, &sst, ci, cw, 0); \
1092 intpol_met_time_2d(met0, met0->pbl, met1, met1->pbl, time, lon, lat, &pbl, ci, cw, 0); \
1093 intpol_met_time_2d(met0, met0->pt, met1, met1->pt, time, lon, lat, &pt, ci, cw, 0); \
1094 intpol_met_time_2d(met0, met0->tt, met1, met1->tt, time, lon, lat, &tt, ci, cw, 0); \
1095 intpol_met_time_2d(met0, met0->zt, met1, met1->zt, time, lon, lat, &zt, ci, cw, 0); \
1096 intpol_met_time_2d(met0, met0->h2ot, met1, met1->h2ot, time, lon, lat, &h2ot, ci, cw, 0); \
1097 intpol_met_time_2d(met0, met0->pct, met1, met1->pct, time, lon, lat, &pct, ci, cw, 0); \
1098 intpol_met_time_2d(met0, met0->pcb, met1, met1->pcb, time, lon, lat, &pcb, ci, cw, 0); \
1099 intpol_met_time_2d(met0, met0->cl, met1, met1->cl, time, lon, lat, &cl, ci, cw, 0); \
1100 intpol_met_time_2d(met0, met0->plcl, met1, met1->plcl, time, lon, lat, &plcl, ci, cw, 0); \
1101 intpol_met_time_2d(met0, met0->plfc, met1, met1->plfc, time, lon, lat, &plfc, ci, cw, 0); \
1102 intpol_met_time_2d(met0, met0->pel, met1, met1->pel, time, lon, lat, &pel, ci, cw, 0); \
1103 intpol_met_time_2d(met0, met0->cape, met1, met1->cape, time, lon, lat, &cape, ci, cw, 0); \
1104 intpol_met_time_2d(met0, met0->cin, met1, met1->cin, time, lon, lat, &cin, ci, cw, 0); \
1105 intpol_met_time_2d(met0, met0->o3c, met1, met1->o3c, time, lon, lat, &o3c, ci, cw, 0); \
1106 }
1107
1122#define LAPSE(p1, t1, p2, t2) \
1123 (1e3 * G0 / RA * ((t2) - (t1)) / ((t2) + (t1)) \
1124 * ((p2) + (p1)) / ((p2) - (p1)))
1125
1141#define LIN(x0, y0, x1, y1, x) \
1142 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
1143
1168#define MAX(a,b) \
1169 (((a)>(b))?(a):(b))
1170
1182#define MET_HEADER \
1183 fprintf(out, \
1184 "# $1 = time [s]\n" \
1185 "# $2 = altitude [km]\n" \
1186 "# $3 = longitude [deg]\n" \
1187 "# $4 = latitude [deg]\n" \
1188 "# $5 = pressure [hPa]\n" \
1189 "# $6 = temperature [K]\n" \
1190 "# $7 = zonal wind [m/s]\n" \
1191 "# $8 = meridional wind [m/s]\n" \
1192 "# $9 = vertical velocity [hPa/s]\n" \
1193 "# $10 = H2O volume mixing ratio [ppv]\n"); \
1194 fprintf(out, \
1195 "# $11 = O3 volume mixing ratio [ppv]\n" \
1196 "# $12 = geopotential height [km]\n" \
1197 "# $13 = potential vorticity [PVU]\n" \
1198 "# $14 = surface pressure [hPa]\n" \
1199 "# $15 = surface temperature [K]\n" \
1200 "# $16 = surface geopotential height [km]\n" \
1201 "# $17 = surface zonal wind [m/s]\n" \
1202 "# $18 = surface meridional wind [m/s]\n" \
1203 "# $19 = eastward turbulent surface stress [N/m^2]\n" \
1204 "# $20 = northward turbulent surface stress [N/m^2]\n"); \
1205 fprintf(out, \
1206 "# $21 = surface sensible heat flux [W/m^2]\n" \
1207 "# $22 = land-sea mask [1]\n" \
1208 "# $23 = sea surface temperature [K]\n" \
1209 "# $24 = tropopause pressure [hPa]\n" \
1210 "# $25 = tropopause geopotential height [km]\n" \
1211 "# $26 = tropopause temperature [K]\n" \
1212 "# $27 = tropopause water vapor [ppv]\n" \
1213 "# $28 = cloud liquid water content [kg/kg]\n" \
1214 "# $29 = cloud rain water content [kg/kg]\n" \
1215 "# $30 = cloud ice water content [kg/kg]\n"); \
1216 fprintf(out, \
1217 "# $31 = cloud snow water content [kg/kg]\n" \
1218 "# $32 = cloud cover [1]\n" \
1219 "# $33 = total column cloud water [kg/m^2]\n" \
1220 "# $34 = cloud top pressure [hPa]\n" \
1221 "# $35 = cloud bottom pressure [hPa]\n" \
1222 "# $36 = pressure at lifted condensation level (LCL) [hPa]\n" \
1223 "# $37 = pressure at level of free convection (LFC) [hPa]\n" \
1224 "# $38 = pressure at equilibrium level (EL) [hPa]\n" \
1225 "# $39 = convective available potential energy (CAPE) [J/kg]\n" \
1226 "# $40 = convective inhibition (CIN) [J/kg]\n"); \
1227 fprintf(out, \
1228 "# $41 = relative humidity over water [%%]\n" \
1229 "# $42 = relative humidity over ice [%%]\n" \
1230 "# $43 = dew point temperature [K]\n" \
1231 "# $44 = frost point temperature [K]\n" \
1232 "# $45 = NAT temperature [K]\n" \
1233 "# $46 = HNO3 volume mixing ratio [ppv]\n" \
1234 "# $47 = OH volume mixing ratio [ppv]\n" \
1235 "# $48 = H2O2 volume mixing ratio [ppv]\n" \
1236 "# $49 = HO2 volume mixing ratio [ppv]\n" \
1237 "# $50 = O(1D) volume mixing ratio [ppv]\n"); \
1238 fprintf(out, \
1239 "# $51 = boundary layer pressure [hPa]\n" \
1240 "# $52 = total column ozone [DU]\n" \
1241 "# $53 = number of data points\n" \
1242 "# $54 = number of tropopause data points\n" \
1243 "# $55 = number of CAPE data points\n");
1244
1269#define MIN(a,b) \
1270 (((a)<(b))?(a):(b))
1271
1284#define MOLEC_DENS(p,t) \
1285 (AVO * 1e-6 * ((p) * 100) / (RI * (t)))
1286
1298#define NC(cmd) { \
1299 int nc_result=(cmd); \
1300 if(nc_result!=NC_NOERR) \
1301 ERRMSG("%s", nc_strerror(nc_result)); \
1302 }
1303
1327#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units, level, quant) { \
1328 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
1329 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
1330 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
1331 if((quant) > 0) \
1332 NC(nc_def_var_quantize(ncid, varid, NC_QUANTIZE_GRANULARBR, quant)); \
1333 if((level) != 0) { \
1334 NC(nc_def_var_deflate(ncid, varid, 1, 1, level)); \
1335 /* unsigned int ulevel = (unsigned int)level; */ \
1336 /* NC(nc_def_var_filter(ncid, varid, 32015, 1, (unsigned int[]){ulevel})); */ \
1337 } \
1338 }
1339
1357#define NC_GET_DOUBLE(varname, ptr, force) { \
1358 if(force) { \
1359 NC(nc_inq_varid(ncid, varname, &varid)); \
1360 NC(nc_get_var_double(ncid, varid, ptr)); \
1361 } else { \
1362 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
1363 NC(nc_get_var_double(ncid, varid, ptr)); \
1364 } else \
1365 WARN("netCDF variable %s is missing!", varname); \
1366 } \
1367 }
1368
1387#define NC_INQ_DIM(dimname, ptr, min, max, check) { \
1388 int dimid; size_t naux; \
1389 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
1390 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
1391 *ptr = (int)naux; \
1392 if (check) \
1393 if ((*ptr) < (min) || (*ptr) > (max)) \
1394 ERRMSG("Dimension %s is out of range!", dimname); \
1395 }
1396
1411#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
1412 NC(nc_inq_varid(ncid, varname, &varid)); \
1413 if(hyperslab) { \
1414 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
1415 } else { \
1416 NC(nc_put_var_double(ncid, varid, ptr)); \
1417 } \
1418 }
1419
1435#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
1436 NC(nc_inq_varid(ncid, varname, &varid)); \
1437 if(hyperslab) { \
1438 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
1439 } else { \
1440 NC(nc_put_var_float(ncid, varid, ptr)); \
1441 } \
1442 }
1443
1458#define NC_PUT_INT(varname, ptr, hyperslab) { \
1459 NC(nc_inq_varid(ncid, varname, &varid)); \
1460 if(hyperslab) { \
1461 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
1462 } else { \
1463 NC(nc_put_var_int(ncid, varid, ptr)); \
1464 } \
1465 }
1466
1480#define NC_PUT_ATT(varname, attname, text) { \
1481 NC(nc_inq_varid(ncid, varname, &varid)); \
1482 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
1483 }
1484
1497#define NC_PUT_ATT_GLOBAL(attname, text) \
1498 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
1499
1517#define NN(x0, y0, x1, y1, x) \
1518 (fabs((x) - (x0)) <= fabs((x) - (x1)) ? (y0) : (y1))
1519
1535#ifdef _OPENACC
1536#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1537 const int ip0_const = ip0; \
1538 const int ip1_const = ip1; \
1539 _Pragma(__VA_ARGS__) \
1540 _Pragma("acc parallel loop independent gang vector") \
1541 for (int ip = ip0_const; ip < ip1_const; ip++) \
1542 if (!check_dt || cache->dt[ip] != 0)
1543#else
1544#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1545 const int ip0_const = ip0; \
1546 const int ip1_const = ip1; \
1547 _Pragma("omp parallel for default(shared)") \
1548 for (int ip = ip0_const; ip < ip1_const; ip++) \
1549 if (!check_dt || cache->dt[ip] != 0)
1550#endif
1551
1574#define P(z) \
1575 (P0 * exp(-(z) / H0))
1576
1598#define PSAT(t) \
1599 (6.112 * exp(17.62 * ((t) - T0) / (243.12 + (t) - T0)))
1600
1622#define PSICE(t) \
1623 (6.112 * exp(22.46 * ((t) - T0) / (272.62 + (t) - T0)))
1624
1649#define PW(p, h2o) \
1650 ((p) * MAX((h2o), 0.1e-6) / (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1651
1666#define RAD2DEG(rad) \
1667 ((rad) * (180.0 / M_PI))
1668
1696#define RH(p, t, h2o) \
1697 (PW(p, h2o) / PSAT(t) * 100.)
1698
1726#define RHICE(p, t, h2o) \
1727 (PW(p, h2o) / PSICE(t) * 100.)
1728
1751#define RHO(p, t) \
1752 (100. * (p) / (RA * (t)))
1753
1770#define SET_ATM(qnt, val) \
1771 if (ctl->qnt >= 0) \
1772 atm->q[ctl->qnt][ip] = val;
1773
1793#define SET_QNT(qnt, name, longname, unit) \
1794 if (strcasecmp(ctl->qnt_name[iq], name) == 0) { \
1795 ctl->qnt = iq; \
1796 sprintf(ctl->qnt_longname[iq], longname); \
1797 sprintf(ctl->qnt_unit[iq], unit); \
1798 } else
1799
1814#define SH(h2o) \
1815 (EPS * MAX((h2o), 0.1e-6))
1816
1827#define SQR(x) \
1828 ((x)*(x))
1829
1841#define SWAP(x, y, type) \
1842 do {type tmp = x; x = y; y = tmp;} while(0);
1843
1865#define TDEW(p, h2o) \
1866 (T0 + 243.12 * log(PW((p), (h2o)) / 6.112) \
1867 / (17.62 - log(PW((p), (h2o)) / 6.112)))
1868
1890#define TICE(p, h2o) \
1891 (T0 + 272.62 * log(PW((p), (h2o)) / 6.112) \
1892 / (22.46 - log(PW((p), (h2o)) / 6.112)))
1893
1914#define THETA(p, t) \
1915 ((t) * pow(1000. / (p), 0.286))
1916
1943#define THETAVIRT(p, t, h2o) \
1944 (TVIRT(THETA((p), (t)), MAX((h2o), 0.1e-6)))
1945
1964#define TOK(line, tok, format, var) { \
1965 if(((tok)=strtok((line), " \t"))) { \
1966 if(sscanf(tok, format, &(var))!=1) continue; \
1967 } else ERRMSG("Error while reading!"); \
1968 }
1969
1989#define TVIRT(t, h2o) \
1990 ((t) * (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1991
2003#define USAGE \
2004 do { \
2005 int iusage; \
2006 for (iusage = 1; iusage < argc; iusage++) \
2007 if (!strcmp(argv[iusage], "-h") \
2008 || !strcmp(argv[iusage], "--help")) { \
2009 usage(); \
2010 return EXIT_SUCCESS; \
2011 } \
2012 } while (0)
2013
2033#define Z(p) \
2034 (H0 * log(P0 / (p)))
2035
2064#define ZDIFF(lnp0, t0, h2o0, lnp1, t1, h2o1) \
2065 (RI / MA / G0 * 0.5 * (TVIRT((t0), (h2o0)) + TVIRT((t1), (h2o1))) \
2066 * ((lnp0) - (lnp1)))
2067
2083#define ZETA(ps, p, t) \
2084 (((p) / (ps) <= 0.3 ? 1. : \
2085 sin(M_PI / 2. * (1. - (p) / (ps)) / (1. - 0.3))) \
2086 * THETA((p), (t)))
2087
2088/* ------------------------------------------------------------
2089 Log messages...
2090 ------------------------------------------------------------ */
2091
2093#ifndef LOGLEV
2094#define LOGLEV 2
2095#endif
2096
2126#define LOG(level, ...) { \
2127 if(level >= 2) \
2128 printf(" "); \
2129 if(level <= LOGLEV) { \
2130 printf(__VA_ARGS__); \
2131 printf("\n"); \
2132 } \
2133 }
2134
2163#define WARN(...) { \
2164 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2165 LOG(0, __VA_ARGS__); \
2166 }
2167
2196#define ERRMSG(...) { \
2197 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2198 LOG(0, __VA_ARGS__); \
2199 exit(EXIT_FAILURE); \
2200 }
2201
2231#define PRINT(format, var) \
2232 printf("Print (%s, %s, l%d): %s= "format"\n", \
2233 __FILE__, __func__, __LINE__, #var, var);
2234
2235/* ------------------------------------------------------------
2236 Timers...
2237 ------------------------------------------------------------ */
2238
2240#define NTIMER 100
2241
2255#define PRINT_TIMERS \
2256 timer("END", "END", 1);
2257
2270#define SELECT_TIMER(id, group) \
2271 timer(id, group, 0);
2272
2273/* ------------------------------------------------------------
2274 Structs...
2275 ------------------------------------------------------------ */
2276
2284typedef struct {
2285
2286 /* ------------------------------------------------------------
2287 Quantity parameters...
2288 ------------------------------------------------------------ */
2289
2291 int nq;
2292
2294 char qnt_name[NQ][LEN];
2295
2297 char qnt_longname[NQ][LEN];
2298
2300 char qnt_unit[NQ][LEN];
2301
2303 char qnt_format[NQ][LEN];
2304
2307
2310
2313
2316
2319
2322
2325
2328
2331
2334
2337
2340
2343
2346
2349
2352
2355
2358
2361
2364
2367
2370
2373
2376
2379
2382
2385
2388
2391
2394
2397
2400
2403
2406
2409
2412
2415
2418
2421
2424
2427
2430
2433
2436
2439
2442
2445
2448
2451
2454
2457
2460
2463
2466
2469
2472
2475
2478
2481
2484
2487
2490
2493
2496
2499
2502
2505
2508
2511
2514
2517
2520
2523
2526
2529
2532
2535
2538
2541
2544
2547
2550
2553
2556
2559
2562
2565
2568
2571
2574
2577
2580
2583
2586
2589
2592
2595
2598
2601
2604
2607
2610
2613
2615 double t_start;
2616
2618 double t_stop;
2619
2621 double dt_mod;
2622
2623 /* ------------------------------------------------------------
2624 Meteo data parameters...
2625 ------------------------------------------------------------ */
2626
2628 char metbase[LEN];
2629
2631 double dt_met;
2632
2635
2638
2641
2644
2648
2651
2655
2658
2661
2664
2667
2670
2673
2676
2679
2681 int met_zfp_prec[METVAR];
2682
2684 double met_zfp_tol[METVAR];
2685
2687 int met_sz3_prec[METVAR];
2688
2690 double met_sz3_tol[METVAR];
2691
2693 int met_lossy_scale[METVAR];
2694
2696 char met_comp_logfile[LEN];
2697
2700
2703
2706
2709
2712
2714 double met_cms_eps[METVAR];
2715
2718
2721
2724
2727
2730
2733
2736
2739
2741 double met_p[EP];
2742
2745
2748
2750 double met_lev_hyam[EP];
2751
2753 double met_lev_hybm[EP];
2754
2757
2760
2763
2766
2769
2772
2775
2779
2782
2785
2788
2791
2794
2797
2798 /* ------------------------------------------------------------
2799 Geophysical module parameters...
2800 ------------------------------------------------------------ */
2801
2803 double sort_dt;
2804
2808
2810 char balloon[LEN];
2811
2814
2818
2821
2824
2827
2830
2833
2836
2839
2842
2845
2848
2851
2854
2857
2860
2863
2865 double conv_cin;
2866
2868 double conv_dt;
2869
2872
2875
2878
2881
2884
2887
2889 double bound_p0;
2890
2892 double bound_p1;
2893
2896
2899
2902
2905
2907 char species[LEN];
2908
2910 double molmass;
2911
2914
2917
2920
2922 char clim_hno3_filename[LEN];
2923
2925 char clim_oh_filename[LEN];
2926
2928 char clim_h2o2_filename[LEN];
2929
2931 char clim_ho2_filename[LEN];
2932
2934 char clim_o1d_filename[LEN];
2935
2937 char clim_o3_filename[LEN];
2938
2940 char clim_ccl4_timeseries[LEN];
2941
2943 char clim_ccl3f_timeseries[LEN];
2944
2946 char clim_ccl2f2_timeseries[LEN];
2947
2949 char clim_n2o_timeseries[LEN];
2950
2952 char clim_sf6_timeseries[LEN];
2953
2956
2959
2962
2965
2968
2971
2974
2977
2980
2983
2986
2989
2992
2995
2998
3001
3004
3007
3010
3013
3016
3019
3021 double oh_chem[4];
3022
3025
3028
3031
3033 double dt_kpp;
3034
3037
3040
3042 double wet_depo_pre[2];
3043
3046
3049
3052
3055
3057 double wet_depo_ic_h[2];
3058
3060 double wet_depo_bc_h[2];
3061
3064
3067
3070
3073
3076
3078 double psc_h2o;
3079
3081 double psc_hno3;
3082
3083 /* ------------------------------------------------------------
3084 Output parameters...
3085 ------------------------------------------------------------ */
3086
3088 char atm_basename[LEN];
3089
3091 char atm_gpfile[LEN];
3092
3095
3098
3101
3105
3110
3113
3115 int atm_nc_quant[NQ];
3116
3119
3121 char csi_basename[LEN];
3122
3124 char csi_kernel[LEN];
3125
3128
3130 char csi_obsfile[LEN];
3131
3134
3137
3140
3142 double csi_z0;
3143
3145 double csi_z1;
3146
3149
3151 double csi_lon0;
3152
3154 double csi_lon1;
3155
3158
3160 double csi_lat0;
3161
3163 double csi_lat1;
3164
3166 int nens;
3167
3169 char ens_basename[LEN];
3170
3173
3175 char grid_basename[LEN];
3176
3178 char grid_kernel[LEN];
3179
3181 char grid_gpfile[LEN];
3182
3185
3188
3191
3193 int grid_nc_quant[NQ];
3194
3197
3200
3202 double grid_z0;
3203
3205 double grid_z1;
3206
3209
3212
3215
3218
3221
3224
3227
3229 char prof_basename[LEN];
3230
3232 char prof_obsfile[LEN];
3233
3236
3238 double prof_z0;
3239
3241 double prof_z1;
3242
3245
3248
3251
3254
3257
3260
3262 char sample_basename[LEN];
3263
3265 char sample_kernel[LEN];
3266
3268 char sample_obsfile[LEN];
3269
3272
3275
3277 char stat_basename[LEN];
3278
3280 double stat_lon;
3281
3283 double stat_lat;
3284
3286 double stat_r;
3287
3289 double stat_t0;
3290
3292 double stat_t1;
3293
3295 char vtk_basename[LEN];
3296
3299
3302
3305
3308
3311
3312 /* ------------------------------------------------------------
3313 Domain decomposition...
3314 ------------------------------------------------------------ */
3315
3317 int dd;
3318
3321
3324
3327
3330
3331} ctl_t;
3332
3341typedef struct {
3342
3344 int np;
3345
3347 double time[NP];
3348
3350 double p[NP];
3351
3353 double lon[NP];
3354
3356 double lat[NP];
3357
3359 double q[NQ][NP];
3360
3361} atm_t;
3362
3370typedef struct {
3371
3373 double time;
3374
3376 double p;
3377
3379 double lon;
3380
3382 double lat;
3383
3385 double q[NQ];
3386
3387} particle_t;
3388
3389
3396typedef struct {
3397
3399 double iso_var[NP];
3400
3402 double iso_ps[NP];
3403
3405 double iso_ts[NP];
3406
3409
3411 float uvwp[NP][3];
3412
3414 double rs[3 * NP + 1];
3415
3417 double dt[NP];
3418
3419} cache_t;
3420
3428typedef struct {
3429
3431 int np;
3432
3434 int nsza;
3435
3437 int no3c;
3438
3440 double p[CP];
3441
3443 double sza[CSZA];
3444
3446 double o3c[CO3];
3447
3449 double n2o[CP][CSZA][CO3];
3450
3452 double ccl4[CP][CSZA][CO3];
3453
3455 double ccl3f[CP][CSZA][CO3];
3456
3458 double ccl2f2[CP][CSZA][CO3];
3459
3461 double o2[CP][CSZA][CO3];
3462
3464 double o3_1[CP][CSZA][CO3];
3465
3467 double o3_2[CP][CSZA][CO3];
3468
3470 double h2o2[CP][CSZA][CO3];
3471
3473 double h2o[CP][CSZA][CO3];
3474
3475} clim_photo_t;
3476
3484typedef struct {
3485
3488
3490 double time[CTS];
3491
3493 double vmr[CTS];
3494
3495} clim_ts_t;
3496
3504typedef struct {
3505
3508
3510 int nlat;
3511
3513 int np;
3514
3516 double time[CT];
3517
3519 double lat[CY];
3520
3522 double p[CP];
3523
3525 double vmr[CT][CP][CY];
3526
3527} clim_zm_t;
3528
3536typedef struct {
3537
3540
3543
3545 double tropo_time[12];
3546
3548 double tropo_lat[73];
3549
3551 double tropo[12][73];
3552
3555
3558
3561
3564
3567
3570
3573
3576
3579
3582
3585
3586} clim_t;
3587
3595typedef struct {
3596
3598 double time;
3599
3600 /* Grid type: 0=lat/lon [deg], 1=UTM [m]. */
3602
3604 int nx;
3605
3607 int ny;
3608
3610 int np;
3611
3613 int npl;
3614
3616 double lon[EX];
3617
3619 double lat[EY];
3620
3622 double p[EP];
3623
3625 double hybrid[EP];
3626
3628 double hyam[EP];
3629
3631 double hybm[EP];
3632
3634 double eta[EP];
3635
3637 float ps[EX][EY];
3638
3640 float ts[EX][EY];
3641
3643 float zs[EX][EY];
3644
3646 float us[EX][EY];
3647
3649 float vs[EX][EY];
3650
3652 float ess[EX][EY];
3653
3655 float nss[EX][EY];
3656
3658 float shf[EX][EY];
3659
3661 float lsm[EX][EY];
3662
3664 float sst[EX][EY];
3665
3667 float pbl[EX][EY];
3668
3670 float pt[EX][EY];
3671
3673 float tt[EX][EY];
3674
3676 float zt[EX][EY];
3677
3679 float h2ot[EX][EY];
3680
3682 float pct[EX][EY];
3683
3685 float pcb[EX][EY];
3686
3688 float cl[EX][EY];
3689
3691 float plcl[EX][EY];
3692
3694 float plfc[EX][EY];
3695
3697 float pel[EX][EY];
3698
3700 float cape[EX][EY];
3701
3703 float cin[EX][EY];
3704
3706 float o3c[EX][EY];
3707
3709 float z[EX][EY][EP];
3710
3712 float t[EX][EY][EP];
3713
3715 float u[EX][EY][EP];
3716
3718 float v[EX][EY][EP];
3719
3721 float w[EX][EY][EP];
3722
3724 float pv[EX][EY][EP];
3725
3727 float h2o[EX][EY][EP];
3728
3730 float o3[EX][EY][EP];
3731
3733 float lwc[EX][EY][EP];
3734
3736 float rwc[EX][EY][EP];
3737
3739 float iwc[EX][EY][EP];
3740
3742 float swc[EX][EY][EP];
3743
3745 float cc[EX][EY][EP];
3746
3748 float pl[EX][EY][EP];
3749
3751 float ul[EX][EY][EP];
3752
3754 float vl[EX][EY][EP];
3755
3757 float wl[EX][EY][EP];
3758
3760 float zetal[EX][EY][EP];
3761
3763 float zeta_dotl[EX][EY][EP];
3764
3765} met_t;
3766
3772typedef struct {
3773
3774 /* ------------------------------------------------------------
3775 Global grid...
3776 ------------------------------------------------------------ */
3777
3780
3783
3785 double lon_glob[DD_EX_GLOB];
3786
3788 double lat_glob[DD_EY_GLOB];
3789
3790 /* ------------------------------------------------------------
3791 Subdomains...
3792 ------------------------------------------------------------ */
3793
3795 size_t subdomain_start[4];
3796
3798 size_t subdomain_count[4];
3799
3801 size_t halo_bnd_start[4];
3802
3804 size_t halo_bnd_count[4];
3805
3808
3811
3812 /* ------------------------------------------------------------
3813 Helpers...
3814 ------------------------------------------------------------ */
3815
3816#ifdef DD
3817
3819 MPI_Datatype MPI_Particle;
3820
3822 double sort_key[NP];
3823
3825 int perm[NP];
3826
3828 double tmp[NP];
3829
3830#endif
3831
3832} dd_t;
3833
3834/* ------------------------------------------------------------
3835 Functions...
3836 ------------------------------------------------------------ */
3837
3860 void *data,
3861 size_t N);
3862
3877void cart2geo(
3878 const double *x,
3879 double *z,
3880 double *lon,
3881 double *lat);
3882
3905double clim_oh(
3906 const ctl_t * ctl,
3907 const clim_t * clim,
3908 const double t,
3909 const double lon,
3910 const double lat,
3911 const double p);
3912
3932 const ctl_t * ctl,
3933 clim_t * clim);
3934
3964double clim_photo(
3965 const double rate[CP][CSZA][CO3],
3966 const clim_photo_t * photo,
3967 const double p,
3968 const double sza,
3969 const double o3c);
3970
3996double clim_tropo(
3997 const clim_t * clim,
3998 const double t,
3999 const double lat);
4000
4019void clim_tropo_init(
4020 clim_t * clim);
4021
4038double clim_ts(
4039 const clim_ts_t * ts,
4040 const double t);
4041
4063double clim_zm(
4064 const clim_zm_t * zm,
4065 const double t,
4066 const double lat,
4067 const double p);
4068
4093 FILE * out,
4094 const char *codec,
4095 const char *varname,
4096 const size_t lev,
4097 const double plev,
4098 const double ratio,
4099 const double bpv,
4100 const double t_comp,
4101 const double t_decomp,
4102 const size_t n,
4103 const size_t nbytes,
4104 const float *org,
4105 const float *cmp);
4106
4130 FILE * out,
4131 const char *codec,
4132 const char *varname,
4133 const met_t * met,
4134 const float *org_all,
4135 const float *cmp_all,
4136 const size_t nxy,
4137 const size_t nz,
4138 const double ratio,
4139 const double bpv,
4140 const double t_comp,
4141 const double t_decomp,
4142 const size_t nbytes);
4143
4162 const ctl_t * ctl,
4163 const met_t * met,
4164 const char *varname,
4165 float *array,
4166 const int decompress,
4167 FILE * level_log,
4168 FILE * inout);
4169
4186 float *array,
4187 const size_t nxy,
4188 const size_t nz,
4189 double *off,
4190 double *scl);
4191
4208 float *array,
4209 const size_t nxy,
4210 const size_t nz,
4211 const double *off,
4212 const double *scl);
4213
4231 FILE * in,
4232 const size_t nz,
4233 double **off,
4234 double **scl);
4235
4255 FILE * out,
4256 const int enabled,
4257 float *array,
4258 const size_t nxy,
4259 const size_t nz,
4260 double **off,
4261 double **scl);
4262
4263#ifdef ZSTD
4276ZSTD_CCtx *compress_zstd_create_cctx(
4277 const int level,
4278 const int nworkers);
4279#endif
4280
4293 const char *varname);
4294
4314void compress_pck(
4315 const ctl_t * ctl,
4316 const met_t * met,
4317 const char *varname,
4318 float *array,
4319 const int decompress,
4320 FILE * level_log,
4321 FILE * inout);
4322
4351 const ctl_t * ctl,
4352 const met_t * met,
4353 const char *varname,
4354 float *array,
4355 const int decompress,
4356 FILE * level_log,
4357 FILE * inout);
4358
4396 const ctl_t * ctl,
4397 const met_t * met,
4398 const char *varname,
4399 float *array,
4400 const int decompress,
4401 FILE * level_log,
4402 FILE * inout);
4403
4424 const ctl_t * ctl,
4425 const met_t * met,
4426 const char *varname,
4427 float *array,
4428 const int decompress,
4429 FILE * level_log,
4430 FILE * inout);
4431
4453 const ctl_t * ctl,
4454 const met_t * met,
4455 const char *varname,
4456 float *array,
4457 const int decompress,
4458 FILE * level_log,
4459 FILE * inout);
4460
4485double cos_sza(
4486 const double sec,
4487 const double lon,
4488 const double lat);
4489
4512void day2doy(
4513 const int year,
4514 const int mon,
4515 const int day,
4516 int *doy);
4517
4571 const ctl_t * ctl,
4572 const dd_t * dd,
4573 atm_t * atm,
4574 const int init);
4575
4628 const ctl_t * ctl,
4629 cache_t * cache,
4630 atm_t * atm,
4631 particle_t * particles,
4632 const int npart);
4633
4663 const ctl_t * ctl,
4664 const dd_t * dd,
4665 const double lon,
4666 const double lat);
4667
4724 const ctl_t * ctl,
4725 const dd_t * dd,
4726 particle_t ** particles,
4727 int *npart,
4728 int *capacity);
4729
4769 const ctl_t * ctl,
4770 dd_t * dd,
4771 atm_t * atm);
4772
4807 const dd_t * dd,
4808 double *lon,
4809 double *lat);
4810
4859 const ctl_t * ctl,
4860 cache_t * cache,
4861 const particle_t * particles,
4862 const int npart,
4863 atm_t * atm);
4864
4865
4911 const ctl_t * ctl,
4912 atm_t * atm,
4913 cache_t * cache,
4914 int *npart);
4915
4916
4962 dd_t * dd,
4963 const ctl_t * ctl,
4964 met_t * met,
4965 const int ncid);
4966
5025 const ctl_t * ctl,
5026 const met_t * met0,
5027 atm_t * atm,
5028 dd_t * dd,
5029 int *npart);
5030
5060 double *a,
5061 dd_t * dd,
5062 const int np);
5063
5085void doy2day(
5086 const int year,
5087 const int doy,
5088 int *mon,
5089 int *day);
5090
5117void fft_help(
5118 double *fcReal,
5119 double *fcImag,
5120 const int n);
5121
5148void geo2cart(
5149 const double z,
5150 const double lon,
5151 const double lat,
5152 double *x);
5153
5178void get_met_filename(
5179 const ctl_t * ctl,
5180 const double t,
5181 const int direct,
5182 const char *metbase,
5183 const double dt_met,
5184 char *filename);
5185
5209void get_met_replace(
5210 char *orig,
5211 const char *search,
5212 const char *repl);
5213
5250void get_tropo(
5251 const int met_tropo,
5252 ctl_t * ctl,
5253 const clim_t * clim,
5254 met_t * met,
5255 const double *lons,
5256 const int nx,
5257 const double *lats,
5258 const int ny,
5259 double *pt,
5260 double *zt,
5261 double *tt,
5262 double *qt,
5263 double *o3t,
5264 double *ps,
5265 double *zs);
5266
5288 const double *lons,
5289 const int nlon,
5290 const double *lats,
5291 const int nlat,
5292 const double lon,
5293 const double lat,
5294 double *lon2,
5295 double *lat2);
5296
5316 const double *lons,
5317 const int nlon,
5318 const double *lats,
5319 const int nlat,
5320 const double lon,
5321 const double lat,
5322 double *lon2,
5323 double *lat2);
5324
5367 const met_t * met0,
5368 float height0[EX][EY][EP],
5369 float array0[EX][EY][EP],
5370 const met_t * met1,
5371 float height1[EX][EY][EP],
5372 float array1[EX][EY][EP],
5373 const double ts,
5374 const double height,
5375 const double lon,
5376 const double lat,
5377 double *var,
5378 int *ci,
5379 double *cw,
5380 const int init);
5381
5417 const met_t * met,
5418 float array[EX][EY][EP],
5419 const double p,
5420 const double lon,
5421 const double lat,
5422 double *var,
5423 int *ci,
5424 double *cw,
5425 const int init);
5426
5462 const met_t * met,
5463 float array[EX][EY],
5464 const double lon,
5465 const double lat,
5466 double *var,
5467 int *ci,
5468 double *cw,
5469 const int init);
5470
5505 const met_t * met0,
5506 float array0[EX][EY][EP],
5507 const met_t * met1,
5508 float array1[EX][EY][EP],
5509 const double ts,
5510 const double p,
5511 const double lon,
5512 const double lat,
5513 double *var,
5514 int *ci,
5515 double *cw,
5516 const int init);
5517
5553 const met_t * met0,
5554 float array0[EX][EY],
5555 const met_t * met1,
5556 float array1[EX][EY],
5557 const double ts,
5558 const double lon,
5559 const double lat,
5560 double *var,
5561 int *ci,
5562 double *cw,
5563 const int init);
5564
5602void intpol_tropo_3d(
5603 const double time0,
5604 float array0[EX][EY],
5605 const double time1,
5606 float array1[EX][EY],
5607 const double lons[EX],
5608 const double lats[EY],
5609 const int nlon,
5610 const int nlat,
5611 const double time,
5612 const double lon,
5613 const double lat,
5614 const int method,
5615 double *var,
5616 double *sigma);
5617
5644void jsec2time(
5645 const double jsec,
5646 int *year,
5647 int *mon,
5648 int *day,
5649 int *hour,
5650 int *min,
5651 int *sec,
5652 double *remain);
5653
5680double kernel_weight(
5681 const double kz[EP],
5682 const double kw[EP],
5683 const int nk,
5684 const double p);
5685
5724double lapse_rate(
5725 const double t,
5726 const double h2o);
5727
5755 ctl_t * ctl);
5756
5776int locate_irr(
5777 const double *xx,
5778 const int n,
5779 const double x);
5780
5807 const float *xx,
5808 const int n,
5809 const double x,
5810 const int ig);
5811
5832int locate_reg(
5833 const double *xx,
5834 const int n,
5835 const double x);
5836
5858void locate_vert(
5859 float profiles[EX][EY][EP],
5860 const int np,
5861 const int lon_ap_ind,
5862 const int lat_ap_ind,
5863 const double alt_ap,
5864 int *ind);
5865
5891void module_advect(
5892 const ctl_t * ctl,
5893 const cache_t * cache,
5894 met_t * met0,
5895 met_t * met1,
5896 atm_t * atm);
5897
5921 const ctl_t * ctl,
5922 const cache_t * cache,
5923 met_t * met0,
5924 met_t * met1,
5925 atm_t * atm);
5926
5964 const ctl_t * ctl,
5965 const cache_t * cache,
5966 const clim_t * clim,
5967 met_t * met0,
5968 met_t * met1,
5969 atm_t * atm);
5970
6012void module_chem_grid(
6013 const ctl_t * ctl,
6014 met_t * met0,
6015 met_t * met1,
6016 atm_t * atm,
6017 const double t);
6018
6046void module_chem_init(
6047 const ctl_t * ctl,
6048 const cache_t * cache,
6049 const clim_t * clim,
6050 met_t * met0,
6051 met_t * met1,
6052 atm_t * atm);
6053
6078 const ctl_t * ctl,
6079 cache_t * cache,
6080 met_t * met0,
6081 met_t * met1,
6082 atm_t * atm);
6083
6129 double t,
6130 const ctl_t * ctl,
6131 cache_t * cache,
6132 dd_t * dd,
6133 atm_t * atm,
6134 met_t ** met);
6135
6162void module_decay(
6163 const ctl_t * ctl,
6164 const cache_t * cache,
6165 const clim_t * clim,
6166 atm_t * atm);
6167
6204void module_diff_meso(
6205 const ctl_t * ctl,
6206 cache_t * cache,
6207 met_t * met0,
6208 met_t * met1,
6209 atm_t * atm);
6210
6244void module_diff_pbl(
6245 const ctl_t * ctl,
6246 cache_t * cache,
6247 met_t * met0,
6248 met_t * met1,
6249 atm_t * atm);
6250
6305void module_diff_turb(
6306 const ctl_t * ctl,
6307 cache_t * cache,
6308 const clim_t * clim,
6309 met_t * met0,
6310 met_t * met1,
6311 atm_t * atm);
6312
6332void module_dry_depo(
6333 const ctl_t * ctl,
6334 const cache_t * cache,
6335 met_t * met0,
6336 met_t * met1,
6337 atm_t * atm);
6338
6371void module_h2o2_chem(
6372 const ctl_t * ctl,
6373 const cache_t * cache,
6374 const clim_t * clim,
6375 met_t * met0,
6376 met_t * met1,
6377 atm_t * atm);
6378
6399 const ctl_t * ctl,
6400 cache_t * cache,
6401 met_t * met0,
6402 met_t * met1,
6403 atm_t * atm);
6404
6422void module_isosurf(
6423 const ctl_t * ctl,
6424 const cache_t * cache,
6425 met_t * met0,
6426 met_t * met1,
6427 atm_t * atm);
6428
6461 ctl_t * ctl,
6462 cache_t * cache,
6463 clim_t * clim,
6464 met_t * met0,
6465 met_t * met1,
6466 atm_t * atm);
6467
6486void module_meteo(
6487 const ctl_t * ctl,
6488 const cache_t * cache,
6489 const clim_t * clim,
6490 met_t * met0,
6491 met_t * met1,
6492 atm_t * atm);
6493
6511void module_mixing(
6512 const ctl_t * ctl,
6513 const clim_t * clim,
6514 atm_t * atm,
6515 const double t);
6516
6545 const ctl_t * ctl,
6546 const clim_t * clim,
6547 atm_t * atm,
6548 const int *ixs,
6549 const int *iys,
6550 const int *izs,
6551 const int qnt_idx,
6552 const int use_ensemble);
6553
6586void module_oh_chem(
6587 const ctl_t * ctl,
6588 const cache_t * cache,
6589 const clim_t * clim,
6590 met_t * met0,
6591 met_t * met1,
6592 atm_t * atm);
6593
6621void module_position(
6622 const cache_t * cache,
6623 met_t * met0,
6624 met_t * met1,
6625 atm_t * atm);
6626
6651void module_rng_init(
6652 const int ntask);
6653
6679void module_rng(
6680 const ctl_t * ctl,
6681 double *rs,
6682 const size_t n,
6683 const int method);
6684
6720 const ctl_t * ctl,
6721 const cache_t * cache,
6722 atm_t * atm);
6723
6746void module_sedi(
6747 const ctl_t * ctl,
6748 const cache_t * cache,
6749 met_t * met0,
6750 met_t * met1,
6751 atm_t * atm);
6752
6776void module_sort(
6777 const ctl_t * ctl,
6778 const met_t * met0,
6779 atm_t * atm);
6780
6800void module_sort_help(
6801 double *a,
6802 const int *p,
6803 const int np);
6804
6828void module_timesteps(
6829 const ctl_t * ctl,
6830 cache_t * cache,
6831 met_t * met0,
6832 atm_t * atm,
6833 const double t);
6834
6856 ctl_t * ctl,
6857 const atm_t * atm);
6858
6892 const ctl_t * ctl,
6893 const cache_t * cache,
6894 const clim_t * clim,
6895 met_t * met0,
6896 met_t * met1,
6897 atm_t * atm);
6898
6928void module_wet_depo(
6929 const ctl_t * ctl,
6930 const cache_t * cache,
6931 met_t * met0,
6932 met_t * met1,
6933 atm_t * atm);
6934
6966void mptrac_alloc(
6967 ctl_t ** ctl,
6968 cache_t ** cache,
6969 clim_t ** clim,
6970 met_t ** met0,
6971 met_t ** met1,
6972 atm_t ** atm,
6973 dd_t ** dd);
6974
7005void mptrac_free(
7006 ctl_t * ctl,
7007 cache_t * cache,
7008 clim_t * clim,
7009 met_t * met0,
7010 met_t * met1,
7011 atm_t * atm,
7012 dd_t * dd);
7013
7049void mptrac_get_met(
7050 ctl_t * ctl,
7051 clim_t * clim,
7052 const double t,
7053 met_t ** met0,
7054 met_t ** met1,
7055 dd_t * dd);
7056
7076void mptrac_init(
7077 ctl_t * ctl,
7078 cache_t * cache,
7079 clim_t * clim,
7080 atm_t * atm,
7081 const int ntask);
7082
7118int mptrac_read_atm(
7119 const char *filename,
7120 const ctl_t * ctl,
7121 atm_t * atm);
7122
7154void mptrac_read_clim(
7155 const ctl_t * ctl,
7156 clim_t * clim);
7157
7187void mptrac_read_ctl(
7188 const char *filename,
7189 int argc,
7190 char *argv[],
7191 ctl_t * ctl);
7192
7223int mptrac_read_met(
7224 const char *filename,
7225 const ctl_t * ctl,
7226 const clim_t * clim,
7227 met_t * met,
7228 dd_t * dd);
7229
7251 ctl_t * ctl,
7252 cache_t * cache,
7253 clim_t * clim,
7254 met_t ** met0,
7255 met_t ** met1,
7256 atm_t * atm,
7257 double t,
7258 dd_t * dd);
7259
7289void mptrac_write_atm(
7290 const char *filename,
7291 const ctl_t * ctl,
7292 const atm_t * atm,
7293 const double t);
7294
7334void mptrac_write_met(
7335 const char *filename,
7336 const ctl_t * ctl,
7337 met_t * met);
7338
7373 const char *dirname,
7374 const ctl_t * ctl,
7375 met_t * met0,
7376 met_t * met1,
7377 atm_t * atm,
7378 const double t);
7379
7411 const ctl_t * ctl,
7412 const cache_t * cache,
7413 const clim_t * clim,
7414 met_t ** met0,
7415 met_t ** met1,
7416 const atm_t * atm);
7417
7448 const ctl_t * ctl,
7449 const cache_t * cache,
7450 const clim_t * clim,
7451 met_t ** met0,
7452 met_t ** met1,
7453 const atm_t * atm);
7454
7482double nat_temperature(
7483 const double p,
7484 const double h2o,
7485 const double hno3);
7486
7509double pbl_weight(
7510 const ctl_t * ctl,
7511 const atm_t * atm,
7512 const int ip,
7513 const double pbl,
7514 const double ps);
7515
7548int read_atm_asc(
7549 const char *filename,
7550 const ctl_t * ctl,
7551 atm_t * atm);
7552
7583int read_atm_bin(
7584 const char *filename,
7585 const ctl_t * ctl,
7586 atm_t * atm);
7587
7612int read_atm_clams(
7613 const char *filename,
7614 const ctl_t * ctl,
7615 atm_t * atm);
7616
7646int read_atm_nc(
7647 const char *filename,
7648 const ctl_t * ctl,
7649 atm_t * atm);
7650
7679void read_clim_photo(
7680 const char *filename,
7681 clim_photo_t * photo);
7682
7700 const int ncid,
7701 const char *varname,
7702 const clim_photo_t * photo,
7703 double var[CP][CSZA][CO3]);
7704
7728int read_clim_ts(
7729 const char *filename,
7730 clim_ts_t * ts);
7731
7758void read_clim_zm(
7759 const char *filename,
7760 const char *varname,
7761 clim_zm_t * zm);
7762
7790void read_kernel(
7791 const char *filename,
7792 double kz[EP],
7793 double kw[EP],
7794 int *nk);
7795
7827int read_met_bin(
7828 const char *filename,
7829 const ctl_t * ctl,
7830 met_t * met);
7831
7857void read_met_bin_2d(
7858 FILE * in,
7859 const met_t * met,
7860 float var[EX][EY],
7861 const char *varname);
7862
7900void read_met_bin_3d(
7901 FILE * in,
7902 const ctl_t * ctl,
7903 const met_t * met,
7904 float var[EX][EY][EP],
7905 const char *varname,
7906 const float bound_min,
7907 const float bound_max);
7908
7936void read_met_cape(
7937 const ctl_t * ctl,
7938 const clim_t * clim,
7939 met_t * met);
7940
7963void read_met_cloud(
7964 met_t * met);
7965
7991void read_met_detrend(
7992 const ctl_t * ctl,
7993 met_t * met);
7994
8018 met_t * met);
8019
8046void read_met_geopot(
8047 const ctl_t * ctl,
8048 met_t * met);
8049
8077 const char *filename,
8078 const ctl_t * ctl,
8079 met_t * met);
8080
8102 codes_handle ** handles,
8103 int count_handles,
8104 met_t * met);
8105
8126 codes_handle ** handles,
8127 const int num_messages,
8128 const ctl_t * ctl,
8129 met_t * met);
8130
8161 codes_handle ** handles,
8162 const int num_messages,
8163 const ctl_t * ctl,
8164 met_t * met);
8165
8194void read_met_ml2pl(
8195 const ctl_t * ctl,
8196 const met_t * met,
8197 float var[EX][EY][EP],
8198 const char *varname);
8199
8222 const ctl_t * ctl,
8223 met_t * met);
8224
8255int read_met_nc(
8256 const char *filename,
8257 const ctl_t * ctl,
8258 met_t * met,
8259 dd_t * dd);
8260
8295void read_met_nc_grid(
8296 const char *filename,
8297 const int ncid,
8298 const ctl_t * ctl,
8299 met_t * met,
8300 dd_t * dd);
8301
8334 const int ncid,
8335 const ctl_t * ctl,
8336 met_t * met,
8337 dd_t * dd);
8338
8370 const int ncid,
8371 const ctl_t * ctl,
8372 met_t * met,
8373 dd_t * dd);
8374
8407int read_met_nc_2d(
8408 const int ncid,
8409 const char *varname,
8410 const char *varname2,
8411 const char *varname3,
8412 const char *varname4,
8413 const char *varname5,
8414 const char *varname6,
8415 const ctl_t * ctl,
8416 const met_t * met,
8417 dd_t * dd,
8418 float dest[EX][EY],
8419 const float scl,
8420 const int init);
8421
8451int read_met_nc_3d(
8452 const int ncid,
8453 const char *varname,
8454 const char *varname2,
8455 const char *varname3,
8456 const char *varname4,
8457 const ctl_t * ctl,
8458 const met_t * met,
8459 dd_t * dd,
8460 float dest[EX][EY][EP],
8461 const float scl);
8462
8508void read_met_pbl(
8509 const ctl_t * ctl,
8510 met_t * met);
8511
8544 met_t * met);
8545
8576 met_t * met);
8577
8608void read_met_pv(
8609 met_t * met);
8610
8633void read_met_ozone(
8634 met_t * met);
8635
8664void read_met_sample(
8665 const ctl_t * ctl,
8666 met_t * met);
8667
8696void read_met_tropo(
8697 const ctl_t * ctl,
8698 const clim_t * clim,
8699 met_t * met);
8700
8732void read_obs(
8733 const char *filename,
8734 const ctl_t * ctl,
8735 double *rt,
8736 double *rz,
8737 double *rlon,
8738 double *rlat,
8739 double *robs,
8740 int *nobs);
8741
8769void read_obs_asc(
8770 const char *filename,
8771 double *rt,
8772 double *rz,
8773 double *rlon,
8774 double *rlat,
8775 double *robs,
8776 int *nobs);
8777
8804void read_obs_nc(
8805 const char *filename,
8806 double *rt,
8807 double *rz,
8808 double *rlon,
8809 double *rlat,
8810 double *robs,
8811 int *nobs);
8812
8846double scan_ctl(
8847 const char *filename,
8848 int argc,
8849 char *argv[],
8850 const char *varname,
8851 const int arridx,
8852 const char *defvalue,
8853 char *value);
8854
8881double sedi(
8882 const double p,
8883 const double T,
8884 const double rp,
8885 const double rhop);
8886
8916void spline(
8917 const double *x,
8918 const double *y,
8919 const int n,
8920 const double *x2,
8921 double *y2,
8922 const int n2,
8923 const int method);
8924
8947float stddev(
8948 const float *data,
8949 const int n);
8950
8975void time2jsec(
8976 const int year,
8977 const int mon,
8978 const int day,
8979 const int hour,
8980 const int min,
8981 const int sec,
8982 const double remain,
8983 double *jsec);
8984
9013void timer(
9014 const char *name,
9015 const char *group,
9016 const int output);
9017
9047double time_from_filename(
9048 const char *filename,
9049 const int offset,
9050 const int with_seconds);
9051
9070double tropo_weight(
9071 const ctl_t * ctl,
9072 const clim_t * clim,
9073 const atm_t * atm,
9074 const int ip);
9075
9098void write_atm_asc(
9099 const char *filename,
9100 const ctl_t * ctl,
9101 const atm_t * atm,
9102 const double t);
9103
9127void write_atm_bin(
9128 const char *filename,
9129 const ctl_t * ctl,
9130 const atm_t * atm);
9131
9155void write_atm_clams(
9156 const char *filename,
9157 const ctl_t * ctl,
9158 const atm_t * atm);
9159
9185 const char *dirname,
9186 const ctl_t * ctl,
9187 const atm_t * atm,
9188 const double t);
9189
9213void write_atm_nc(
9214 const char *filename,
9215 const ctl_t * ctl,
9216 const atm_t * atm);
9217
9246void write_csi(
9247 const char *filename,
9248 const ctl_t * ctl,
9249 const atm_t * atm,
9250 const double t);
9251
9293 const char *filename,
9294 const ctl_t * ctl,
9295 const atm_t * atm,
9296 const double t);
9297
9325void write_ens(
9326 const char *filename,
9327 const ctl_t * ctl,
9328 const atm_t * atm,
9329 const double t);
9330
9369void write_grid(
9370 const char *filename,
9371 const ctl_t * ctl,
9372 met_t * met0,
9373 met_t * met1,
9374 const atm_t * atm,
9375 const double t);
9376
9422void write_grid_asc(
9423 const char *filename,
9424 const ctl_t * ctl,
9425 const double *cd,
9426 double *mean[NQ],
9427 double *sigma[NQ],
9428 const double *vmr_impl,
9429 const double t,
9430 const double *z,
9431 const double *lon,
9432 const double *lat,
9433 const double *area,
9434 const double dz,
9435 const int *np);
9436
9479void write_grid_nc(
9480 const char *filename,
9481 const ctl_t * ctl,
9482 const double *cd,
9483 double *mean[NQ],
9484 double *sigma[NQ],
9485 const double *vmr_impl,
9486 const double t,
9487 const double *z,
9488 const double *lon,
9489 const double *lat,
9490 const double *area,
9491 const double dz,
9492 const int *np);
9493
9523void write_met_bin(
9524 const char *filename,
9525 const ctl_t * ctl,
9526 met_t * met);
9527
9555void write_met_bin_2d(
9556 FILE * out,
9557 met_t * met,
9558 float var[EX][EY],
9559 const char *varname);
9560
9600void write_met_bin_3d(
9601 FILE * out,
9602 const ctl_t * ctl,
9603 met_t * met,
9604 float var[EX][EY][EP],
9605 const char *varname,
9606 const int metvar,
9607 FILE * level_log);
9608
9636void write_met_nc(
9637 const char *filename,
9638 const ctl_t * ctl,
9639 met_t * met);
9640
9663void write_met_nc_2d(
9664 const int ncid,
9665 const char *varname,
9666 met_t * met,
9667 float var[EX][EY],
9668 const float scl);
9669
9693void write_met_nc_3d(
9694 const int ncid,
9695 const char *varname,
9696 met_t * met,
9697 float var[EX][EY][EP],
9698 const float scl);
9699
9730void write_prof(
9731 const char *filename,
9732 const ctl_t * ctl,
9733 met_t * met0,
9734 met_t * met1,
9735 const atm_t * atm,
9736 const double t);
9737
9769void write_sample(
9770 const char *filename,
9771 const ctl_t * ctl,
9772 met_t * met0,
9773 met_t * met1,
9774 const atm_t * atm,
9775 const double t);
9776
9803void write_station(
9804 const char *filename,
9805 const ctl_t * ctl,
9806 atm_t * atm,
9807 const double t);
9808
9837void write_vtk(
9838 const char *filename,
9839 const ctl_t * ctl,
9840 const atm_t * atm,
9841 const double t);
9842
9843/* ------------------------------------------------------------
9844 OpenACC routines...
9845 ------------------------------------------------------------ */
9846
9847#ifdef _OPENACC
9848#pragma acc routine (clim_oh)
9849#pragma acc routine (clim_photo)
9850#pragma acc routine (clim_tropo)
9851#pragma acc routine (clim_ts)
9852#pragma acc routine (clim_zm)
9853#pragma acc routine (cos_sza)
9854#pragma acc routine (dd_calc_subdomain_from_coords)
9855#pragma acc routine (dd_normalize_lon_lat)
9856#pragma acc routine (intpol_check_lon_lat)
9857#pragma acc routine (intpol_met_4d_zeta)
9858#pragma acc routine (intpol_met_space_3d)
9859#pragma acc routine (intpol_met_space_2d)
9860#pragma acc routine (intpol_met_time_3d)
9861#pragma acc routine (intpol_met_time_2d)
9862#pragma acc routine (kernel_weight)
9863#pragma acc routine (lapse_rate)
9864#pragma acc routine (locate_irr)
9865#pragma acc routine (locate_irr_float)
9866#pragma acc routine (locate_reg)
9867#pragma acc routine (locate_vert)
9868#pragma acc routine (nat_temperature)
9869#pragma acc routine (pbl_weight)
9870#pragma acc routine (sedi)
9871#pragma acc routine (stddev)
9872#pragma acc routine (tropo_weight)
9873#endif
9874
9875#endif /* LIBTRAC_H */
void read_met_geopot(const ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:9186
void dd_init(const ctl_t *ctl, dd_t *dd, atm_t *atm)
Initialize the domain decomposition infrastructure.
#define LEN
Maximum length of ASCII data lines.
Definition: mptrac.h:349
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:6098
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:7806
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:1898
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:9146
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:12654
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:9836
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:14104
void dd_read_met_nc_grid(dd_t *dd, const ctl_t *ctl, met_t *met, const int ncid)
Read meteorological grid information and construct the domain-decomposed grid with halo regions.
Definition: mptrac.c:11077
void read_met_sample(const ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:11662
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:12009
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:3598
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:5811
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:5054
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:8250
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:8982
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:4219
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:12182
double cos_sza(const double sec, const double lon, const double lat)
Calculates the cosine of the solar zenith angle.
Definition: mptrac.c:1857
#define METVAR
Number of 3-D meteorological variables.
Definition: mptrac.h:354
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:3048
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:10158
void compress_log_levels_3d(FILE *out, const char *codec, const char *varname, const met_t *met, const float *org_all, const float *cmp_all, const size_t nxy, const size_t nz, const double ratio, const double bpv, const double t_comp, const double t_decomp, const size_t nbytes)
Write per-level compression diagnostics for a full 3-D field.
Definition: mptrac.c:765
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:8217
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:11253
void read_met_detrend(const ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:9039
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:11835
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:12053
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:4050
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:3559
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:3578
void compress_zfp(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3D array of floats using the ZFP library.
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:9639
void compress_pck(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3‑D float array using the PCK format.
Definition: mptrac.c:986
void read_met_monotonize(const ctl_t *ctl, met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:10949
int dd_calc_subdomain_from_coords(const ctl_t *ctl, const dd_t *dd, const double lon, const double lat)
Determine MPI subdomain from particle coordinates.
#define DD_EY_GLOB
Maximum number of latitudes of global meteo data.
Definition: mptrac.h:424
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:8369
void intpol_check_cartesian(const double *lons, const int nlon, const double *lats, const int nlat, const double lon, const double lat, double *lon2, double *lat2)
Clamps UTM coordinates to the valid bounds.
Definition: mptrac.c:2782
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:11390
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:7545
int compress_metvar_index(const char *varname)
Maps a meteorological variable name to its internal MPTRAC variable index.
Definition: mptrac.c:969
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:5858
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:13142
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:5161
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:414
#define EY
Maximum number of latitudes for meteo data.
Definition: mptrac.h:344
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:5233
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:8341
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:10907
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:213
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:12081
void compress_sz3(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3-D float array using the SZ3 library.
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:8723
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:3495
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:4878
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:3342
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:2808
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:13436
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:7694
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:12283
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:6312
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:3112
#define codes_handle
Placeholder when ECCODES is not available.
Definition: mptrac.h:241
void compress_zstd(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a float array using ZSTD.
void get_met_filename(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:2619
void fft_help(double *fcReal, double *fcImag, const int n)
Computes the Fast Fourier Transform (FFT) of a complex sequence.
Definition: mptrac.c:2562
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:5963
int compress_read_lossy_scale(FILE *in, const size_t nz, double **off, double **scl)
Read optional lossyscaling metadata for a 3-D field.
Definition: mptrac.c:874
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:8010
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:12215
void compress_cms(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3-D meteorological field using cmultiscale.
#define CP
Maximum number of pressure levels for climatological data.
Definition: mptrac.h:399
#define NQ
Maximum number of quantities per data point.
Definition: mptrac.h:364
void dd_assign_subdomains(const ctl_t *ctl, const dd_t *dd, atm_t *atm, const int init)
Assign or update particle subdomain ownership.
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:156
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:8423
#define EX
Maximum number of longitudes for meteo data.
Definition: mptrac.h:339
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:5671
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:11034
void timer(const char *name, const char *group, const int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:12314
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:12450
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:2985
void module_sort(const ctl_t *ctl, const met_t *met0, atm_t *atm)
Sort particles according to box index.
Definition: mptrac.c:5699
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:4094
void compress_scale_to_unit(float *array, const size_t nxy, const size_t nz, double *off, double *scl)
Scales each vertical level of a 3-D field independently to the interval [0,1].
Definition: mptrac.c:811
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:8522
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:3789
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:12110
void dd_normalize_lon_lat(const dd_t *dd, double *lon, double *lat)
Normalize geographic coordinates to the global grid convention.
#define CT
Maximum number of time steps for climatological data.
Definition: mptrac.h:409
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:3762
void module_radio_decay(const ctl_t *ctl, const cache_t *cache, atm_t *atm)
Apply radioactive decay to atmospheric tracer species.
Definition: mptrac.c:5477
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 dd_sort(const ctl_t *ctl, const met_t *met0, atm_t *atm, dd_t *dd, int *npart)
Sort local atmospheric particles and determine export counts for domain decomposition.
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:6187
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:5773
void dd_particles2atm(const ctl_t *ctl, cache_t *cache, const particle_t *particles, const int npart, atm_t *atm)
Copy received particles from the communication buffer into the atmospheric state.
float stddev(const float *data, const int n)
Calculates the standard deviation of a set of data.
Definition: mptrac.c:12262
void compress_lz4(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a float array using LZ4.
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:3174
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:8752
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:3525
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:14165
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:6406
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:3885
void write_met_nc(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a NetCDF file.
Definition: mptrac.c:13922
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:5535
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:6331
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:7750
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:7919
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.
void write_met_bin_3d(FILE *out, const ctl_t *ctl, met_t *met, float var[EX][EY][EP], const char *varname, const int metvar, FILE *level_log)
Writes a 3-dimensional meteorological variable to a binary file.
Definition: mptrac.c:13829
#define CTS
Maximum number of data points of climatological time series.
Definition: mptrac.h:414
void read_met_ozone(met_t *met)
Calculates the total column ozone from meteorological ozone data.
Definition: mptrac.c:11633
void broadcast_large_data(void *data, size_t N)
Broadcasts large data across all processes in an MPI communicator.
void compress_write_lossy_scale(FILE *out, const int enabled, float *array, const size_t nxy, const size_t nz, double **off, double **scl)
Write optional lossyscaling metadata for a 3-D field.
Definition: mptrac.c:909
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:9501
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:241
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:5566
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:14560
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: mptrac.c:74
double time_from_filename(const char *filename, const int offset, const int with_seconds)
Extracts and converts a timestamp from a filename to Julian seconds.
Definition: mptrac.c:12382
void dd_atm2particles(const ctl_t *ctl, cache_t *cache, atm_t *atm, particle_t *particles, const int npart)
Copy migratable atmospheric particles from the ATM state into a particle buffer.
#define NP
Maximum number of atmospheric data points.
Definition: mptrac.h:359
void dd_communicate_particles(const ctl_t *ctl, const dd_t *dd, particle_t **particles, int *npart, int *capacity)
Exchange particles between MPI ranks according to their destination rank.
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:2532
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:3141
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:5419
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:124
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:13800
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:11513
#define DD_EX_GLOB
Maximum number of longitudes of global meteo data.
Definition: mptrac.h:419
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:8098
#define CY
Maximum number of latitudes for climatological data.
Definition: mptrac.h:389
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:4258
void dd_sort_help(double *a, dd_t *dd, const int np)
Apply the sorting permutation to a particle data array.
double clim_ts(const clim_ts_t *ts, const double t)
Interpolates a time series of climatological variables.
Definition: mptrac.c:396
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:3265
int read_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Reads meteorological data from a binary file.
Definition: mptrac.c:8563
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:12598
void get_met_replace(char *orig, const char *search, const char *repl)
Replaces occurrences of a substring in a string with another substring.
Definition: mptrac.c:2688
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:4580
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:8154
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:7436
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:14649
#define EP
Maximum number of pressure levels for meteo data.
Definition: mptrac.h:334
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:5889
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:6466
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:6151
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:11451
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:4793
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:13540
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:8034
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:4335
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:14134
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:4948
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:394
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:5335
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:2601
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:9314
void get_tropo(const int met_tropo, ctl_t *ctl, const 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:2712
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:3298
void module_dd(double t, const ctl_t *ctl, cache_t *cache, dd_t *dd, atm_t *atm, met_t **met)
Perform domain decomposition and exchange particles between MPI ranks.
void compress_log_level(FILE *out, const char *codec, const char *varname, const size_t lev, const double plev, const double ratio, const double bpv, const double t_comp, const double t_decomp, const size_t n, const size_t nbytes, const float *org, const float *cmp)
Write one row of per-level compression diagnostics.
Definition: mptrac.c:666
void compress_unscale_from_unit(float *array, const size_t nxy, const size_t nz, const double *off, const double *scl)
Restores a levelwise [0,1]-scaled 3-D field to physical units.
Definition: mptrac.c:854
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:8056
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:2755
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:14395
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:13242
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:4730
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:13670
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:12548
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:8862
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:7870
#define CSZA
Maximum number of solar zenith angles for climatological data.
Definition: mptrac.h:404
double tropo_weight(const ctl_t *ctl, const clim_t *clim, const atm_t *atm, const int ip)
Computes a weighting factor based on tropopause pressure.
Definition: mptrac.c:12424
void dd_push(const ctl_t *ctl, atm_t *atm, cache_t *cache, int *npart)
Compact and stage non-local particles for domain decomposition transfer.
double lapse_rate(const double t, const double h2o)
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
Definition: mptrac.c:3324
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:12864
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:12815
Air parcel data.
Definition: mptrac.h:3341
int np
Number of air parcels.
Definition: mptrac.h:3344
Cache data structure.
Definition: mptrac.h:3396
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3408
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3428
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3434
int np
Number of pressure levels.
Definition: mptrac.h:3431
int no3c
Number of total ozone columns.
Definition: mptrac.h:3437
Climatological data.
Definition: mptrac.h:3536
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3578
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3554
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3566
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3557
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3539
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3584
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3572
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3575
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3569
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3563
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3542
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3560
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3581
Climatological data in the form of time series.
Definition: mptrac.h:3484
int ntime
Number of timesteps.
Definition: mptrac.h:3487
Climatological data in the form of zonal means.
Definition: mptrac.h:3504
int np
Number of pressure levels.
Definition: mptrac.h:3513
int ntime
Number of timesteps.
Definition: mptrac.h:3507
int nlat
Number of latitudes.
Definition: mptrac.h:3510
Control parameters.
Definition: mptrac.h:2284
double met_utm_ref_lon
Reference longitude [deg] for UTM grid.
Definition: mptrac.h:2643
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3202
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2396
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:3163
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2552
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:3051
int qnt_target_subdomain
Quantity array index for destination subdomain in domain decomposition.
Definition: mptrac.h:2609
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2660
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2429
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:3139
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2910
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2375
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2576
int dd_halos_size
Domain decomposition size of halos given in grid-points.
Definition: mptrac.h:3326
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2973
int met_zstd_nworkers
ZSTD number of worker threads (0=single-threaded, default=4).
Definition: mptrac.h:2672
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2997
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2315
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2585
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2324
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2408
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:3133
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2417
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2898
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:3154
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2384
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3280
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2958
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2803
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2970
double stat_r
Search radius around station [km].
Definition: mptrac.h:3286
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:3045
int met_zstd_level
ZSTD compression level (from -5 to 22, default=-3).
Definition: mptrac.h:2669
double met_utm_ref_lat
Reference latitude [deg] for UTM grid.
Definition: mptrac.h:2640
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:3157
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3310
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2994
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2771
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2405
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:3012
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2862
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2564
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2483
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:3205
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2612
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2570
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2723
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2790
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2447
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2519
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:3148
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:3160
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2841
int met_pbl
Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta).
Definition: mptrac.h:2768
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2399
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2850
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:3190
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3208
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:3104
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2871
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3220
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2330
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2474
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2426
int qnt_Acs137
Quantity array index for radioactive activity of Cs-137.
Definition: mptrac.h:2597
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:3211
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2453
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2787
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2513
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2631
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:3015
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2759
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2835
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2318
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2351
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2495
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2886
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3292
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2832
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3226
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:3151
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2357
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:3196
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2480
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:3003
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2904
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2465
int radio_decay
Switch for radioactive decay module (0=off, 1=on).
Definition: mptrac.h:3039
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2756
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2729
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2327
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2820
int met_pck_zstd
Apply an additional ZSTD compression step to PCK payloads (0=off, 1=on).
Definition: mptrac.h:2678
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2807
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2892
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2333
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:3235
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:3127
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2765
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:3136
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2726
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:3006
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2847
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3238
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2390
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2877
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2781
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3244
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2312
double dd_sort_dt
Sorting time interval for the compactification.
Definition: mptrac.h:3329
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2778
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2321
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2796
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2961
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2522
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2450
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:3145
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3289
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:3024
int dd
Domain decomposition (0=no, 1=yes, with 2x2 if not specified).
Definition: mptrac.h:3317
int qnt_eta
Quantity array index for eta vertical coordinate.
Definition: mptrac.h:2507
double wet_depo_so2_ph
pH value used to calculate effective Henry constant of SO2.
Definition: mptrac.h:3063
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2967
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2471
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:3109
int met_cms_nd0x
cmultiscale number of cells of coarsest grid in x-direction.
Definition: mptrac.h:2705
int met_nlev
Number of meteo data model levels.
Definition: mptrac.h:2747
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:3033
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:3072
int qnt_shf
Quantity array index for surface sensible heat flux.
Definition: mptrac.h:2348
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2339
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2549
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3298
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2618
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2868
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2441
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2657
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2369
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2489
int met_gp2z
Convert surface geopotential to geopotential height (0=no, 1=yes).
Definition: mptrac.h:2650
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2883
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2774
int met_dx
Stride for longitudes.
Definition: mptrac.h:2717
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2982
int met_convention
Meteo data layout (0=[lev, lat, lon], 1=[lon, lat, lev]).
Definition: mptrac.h:2634
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2501
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:3036
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2621
int diffusion
Diffusion switch (0=off, 1=on).
Definition: mptrac.h:2823
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2537
int qnt_eta_dot
Quantity array index for velocity of eta vertical coordinate.
Definition: mptrac.h:2510
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2531
int turb_pbl_scheme
PBL turbulence scheme (0=none, 1=closure).
Definition: mptrac.h:2826
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2372
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3307
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2387
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2468
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2880
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2793
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2444
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2555
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2744
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:3018
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2393
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:3253
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2492
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2381
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3274
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2916
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3118
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2336
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3214
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2579
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2573
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2985
int nens
Number of ensembles.
Definition: mptrac.h:3166
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2360
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2420
int advect
Advection scheme (1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2813
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3241
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2378
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:3097
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:3030
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2498
double conv_pbl_trans
Depth of PBL transition layer (fraction of PBL pressure thickness).
Definition: mptrac.h:2859
int met_lz4_accel
LZ4 acceleration factor (>=1, default=8).
Definition: mptrac.h:2675
int qnt_Ai131
Quantity array index for radioactive activity of I-131.
Definition: mptrac.h:2600
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:2647
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:3142
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2516
int qnt_Apb210
Quantity array index for radioactive activity of Pb-210.
Definition: mptrac.h:2591
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3283
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2558
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:3217
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2582
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2543
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2735
int conv_mix_pbl
Vertical mixing in the PBL (0=off, 1=on).
Definition: mptrac.h:2856
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2895
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2991
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2432
int qnt_zeta_dot
Quantity array index for velocity of zeta vertical coordinate.
Definition: mptrac.h:2504
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2874
int met_cms_nd0y
cmultiscale number of cells of coarsest grid in y-direction.
Definition: mptrac.h:2708
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2964
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2438
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2889
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2976
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2546
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2534
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:3199
int qnt_nss
Quantity array index for northward turbulent surface stress.
Definition: mptrac.h:2345
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:3172
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:3100
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2762
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2988
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:3094
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3259
int qnt_current_subdomain
Quantity array index for current subdomain in domain decomposition.
Definition: mptrac.h:2606
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2699
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:3078
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2732
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3247
int qnt_Axe133
Quantity array index for radioactive activity of Xe-133.
Definition: mptrac.h:2603
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:3000
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2414
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2462
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2477
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3256
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2435
double turb_pbl_trans
Depth of turbulent PBL transition layer (fraction of PBL pressure thickness).
Definition: mptrac.h:2853
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:3081
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3250
int met_nc_quant
Number of digits for quantization of netCDF meteo files (0=off).
Definition: mptrac.h:2666
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:3027
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2567
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:3069
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:3009
int qnt_Abe7
Quantity array index for radioactive activity of Be-7.
Definition: mptrac.h:2594
int met_cms_zstd
cmultiscale ZSTD compression (0=off, 1=on).
Definition: mptrac.h:2702
int met_cms_maxlev
cmultiscale maximum refinement level.
Definition: mptrac.h:2711
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:3187
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:3075
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2363
int met_np
Number of target pressure levels.
Definition: mptrac.h:2738
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2309
int met_nc_level
zlib compression level of netCDF meteo files (0=off).
Definition: mptrac.h:2663
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2955
int qnt_Arn222
Quantity array index for radioactive activity of Rn-222.
Definition: mptrac.h:2588
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2459
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3304
double turb_dx_pbl
Horizontal turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2829
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2865
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2525
int advect_vert_coord
Vertical velocity of air parcels (0=omega_on_plev, 1=zetadot_on_mlev, 2=omega_on_mlev,...
Definition: mptrac.h:2817
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2456
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2561
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2354
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2979
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:3112
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:3066
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2486
int met_coord_type
Type of coordinates for meteo data (-1=detect, 0=lat/lon [deg], 1=UTM [m]).
Definition: mptrac.h:2637
int qnt_ess
Quantity array index for eastward turbulent surface stress.
Definition: mptrac.h:2342
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:3054
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:3048
int met_dy
Stride for latitudes.
Definition: mptrac.h:2720
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2540
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2844
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2901
int dd_subdomains_zonal
Domain decomposition zonal subdomain number.
Definition: mptrac.h:3320
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2306
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2784
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2402
double t_start
Start time of simulation [s].
Definition: mptrac.h:2615
int nq
Number of quantities.
Definition: mptrac.h:2291
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2913
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3271
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3301
double turb_dz_pbl
Vertical turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2838
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3223
int dd_subdomains_meridional
Domain decomposition meridional subdomain number.
Definition: mptrac.h:3323
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2366
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:2654
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2411
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2423
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:3184
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2528
Domain decomposition data structure.
Definition: mptrac.h:3772
int halo_offset_end
Offset of the periodic halo block at the end of the local x-array.
Definition: mptrac.h:3810
int nx_glob
Number of global longitudes.
Definition: mptrac.h:3779
int halo_offset_start
Offset of the periodic halo block at the beginning of the local x-array.
Definition: mptrac.h:3807
int ny_glob
Number of global latitudes.
Definition: mptrac.h:3782
Meteo data structure.
Definition: mptrac.h:3595
int coord_type
Definition: mptrac.h:3601
int nx
Number of longitudes.
Definition: mptrac.h:3604
int ny
Number of latitudes.
Definition: mptrac.h:3607
int np
Number of pressure levels.
Definition: mptrac.h:3610
int npl
Number of model levels.
Definition: mptrac.h:3613
double time
Time [s].
Definition: mptrac.h:3598
Particle data.
Definition: mptrac.h:3370
double p
Pressure [hPa].
Definition: mptrac.h:3376
double lat
Latitude [deg].
Definition: mptrac.h:3382
double time
Time [s].
Definition: mptrac.h:3373
double lon
Longitude [deg].
Definition: mptrac.h:3379