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
570#define DEG2DX(dlon, lat) \
571 (RE * DEG2RAD(dlon) * cos(DEG2RAD(lat)))
572
591#define DEG2DY(dlat) \
592 (RE * DEG2RAD(dlat))
593
608#define DEG2RAD(deg) \
609 ((deg) * (M_PI / 180.0))
610
633#define DP2DZ(dp, p) \
634 (- (dp) * H0 / (p))
635
655#define DX2DEG(dx, lat) \
656 (((lat) < -89.999 || (lat) > 89.999) ? 0 \
657 : (dx) * 180. / (M_PI * RE * cos(DEG2RAD(lat))))
658
673#define DY2DEG(dy) \
674 ((dy) * 180. / (M_PI * RE))
675
692#define DZ2DP(dz, p) \
693 (-(dz) * (p) / H0)
694
708#define DIST(a, b) \
709 sqrt(DIST2(a, b))
710
724#define DIST2(a, b) \
725 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
726
740#define DOTP(a, b) \
741 (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
742
754#define ECC(cmd) { \
755 int ecc_result=(cmd); \
756 if(ecc_result!=0) \
757 ERRMSG("ECCODES error: %s", codes_get_error_message(ecc_result)); \
758 }
759
773#define ECC_READ_2D(variable, target, scaling_factor, found_flag) { \
774 if(strcmp(short_name, variable) == 0) { \
775 if ((found_flag) == 0) \
776 LOG(2, "Read 2-D variable: %s (GRIB)", variable); \
777 for (int ix = 0; ix < met->nx; ix++) \
778 for (int iy = 0; iy < met->ny; iy++) \
779 target[ix][iy] = (float)(values[iy * met->nx + ix] * scaling_factor); \
780 found_flag = 1; \
781 } \
782 }
783
798#define ECC_READ_3D(variable, level, target, scaling_factor, found_flag) { \
799 if(strcmp(short_name, variable) == 0) { \
800 if ((found_flag) == 0) \
801 LOG(2, "Read 3-D variable: %s (GRIB)", variable); \
802 for (int ix = 0; ix < met->nx; ix++) \
803 for (int iy = 0; iy < met->ny; iy++) \
804 target[ix][iy][level] = (float) (values[iy * met->nx + ix] * scaling_factor); \
805 found_flag += 1; \
806 } \
807 }
808
825#define FMOD(x, y) \
826 ((x) - (int) ((x) / (y)) * (y))
827
843#define FREAD(ptr, type, size, in) { \
844 if(fread(ptr, sizeof(type), size, in)!=size) \
845 ERRMSG("Error while reading!"); \
846 }
847
863#define FWRITE(ptr, type, size, out) { \
864 if(fwrite(ptr, sizeof(type), size, out)!=size) \
865 ERRMSG("Error while writing!"); \
866 }
867
878#define INTPOL_INIT \
879 double cw[4] = {0.0, 0.0, 0.0, 0.0}; int ci[3] = {0, 0, 0};
880
892#define INTPOL_2D(var, init) \
893 intpol_met_time_2d(met0, met0->var, met1, met1->var, \
894 atm->time[ip], atm->lon[ip], atm->lat[ip], \
895 &var, ci, cw, init);
896
909#define INTPOL_3D(var, init) \
910 intpol_met_time_3d(met0, met0->var, met1, met1->var, \
911 atm->time[ip], atm->p[ip], \
912 atm->lon[ip], atm->lat[ip], \
913 &var, ci, cw, init);
914
928#define INTPOL_SPACE_ALL(p, lon, lat) { \
929 intpol_met_space_3d(met, met->z, p, lon, lat, &z, ci, cw, 1); \
930 intpol_met_space_3d(met, met->t, p, lon, lat, &t, ci, cw, 0); \
931 intpol_met_space_3d(met, met->u, p, lon, lat, &u, ci, cw, 0); \
932 intpol_met_space_3d(met, met->v, p, lon, lat, &v, ci, cw, 0); \
933 intpol_met_space_3d(met, met->w, p, lon, lat, &w, ci, cw, 0); \
934 intpol_met_space_3d(met, met->pv, p, lon, lat, &pv, ci, cw, 0); \
935 intpol_met_space_3d(met, met->h2o, p, lon, lat, &h2o, ci, cw, 0); \
936 intpol_met_space_3d(met, met->o3, p, lon, lat, &o3, ci, cw, 0); \
937 intpol_met_space_3d(met, met->lwc, p, lon, lat, &lwc, ci, cw, 0); \
938 intpol_met_space_3d(met, met->rwc, p, lon, lat, &rwc, ci, cw, 0); \
939 intpol_met_space_3d(met, met->iwc, p, lon, lat, &iwc, ci, cw, 0); \
940 intpol_met_space_3d(met, met->swc, p, lon, lat, &swc, ci, cw, 0); \
941 intpol_met_space_3d(met, met->cc, p, lon, lat, &cc, ci, cw, 0); \
942 intpol_met_space_2d(met, met->ps, lon, lat, &ps, ci, cw, 0); \
943 intpol_met_space_2d(met, met->ts, lon, lat, &ts, ci, cw, 0); \
944 intpol_met_space_2d(met, met->zs, lon, lat, &zs, ci, cw, 0); \
945 intpol_met_space_2d(met, met->us, lon, lat, &us, ci, cw, 0); \
946 intpol_met_space_2d(met, met->vs, lon, lat, &vs, ci, cw, 0); \
947 intpol_met_space_2d(met, met->ess, ess, lat, &ess, ci, cw, 0); \
948 intpol_met_space_2d(met, met->nss, nss, lat, &nss, ci, cw, 0); \
949 intpol_met_space_2d(met, met->shf, shf, lat, &shf, ci, cw, 0); \
950 intpol_met_space_2d(met, met->lsm, lon, lat, &lsm, ci, cw, 0); \
951 intpol_met_space_2d(met, met->sst, lon, lat, &sst, ci, cw, 0); \
952 intpol_met_space_2d(met, met->pbl, lon, lat, &pbl, ci, cw, 0); \
953 intpol_met_space_2d(met, met->pt, lon, lat, &pt, ci, cw, 0); \
954 intpol_met_space_2d(met, met->tt, lon, lat, &tt, ci, cw, 0); \
955 intpol_met_space_2d(met, met->zt, lon, lat, &zt, ci, cw, 0); \
956 intpol_met_space_2d(met, met->h2ot, lon, lat, &h2ot, ci, cw, 0); \
957 intpol_met_space_2d(met, met->pct, lon, lat, &pct, ci, cw, 0); \
958 intpol_met_space_2d(met, met->pcb, lon, lat, &pcb, ci, cw, 0); \
959 intpol_met_space_2d(met, met->cl, lon, lat, &cl, ci, cw, 0); \
960 intpol_met_space_2d(met, met->plcl, lon, lat, &plcl, ci, cw, 0); \
961 intpol_met_space_2d(met, met->plfc, lon, lat, &plfc, ci, cw, 0); \
962 intpol_met_space_2d(met, met->pel, lon, lat, &pel, ci, cw, 0); \
963 intpol_met_space_2d(met, met->cape, lon, lat, &cape, ci, cw, 0); \
964 intpol_met_space_2d(met, met->cin, lon, lat, &cin, ci, cw, 0); \
965 intpol_met_space_2d(met, met->o3c, lon, lat, &o3c, ci, cw, 0); \
966 }
967
982#define INTPOL_TIME_ALL(time, p, lon, lat) { \
983 intpol_met_time_3d(met0, met0->z, met1, met1->z, time, p, lon, lat, &z, ci, cw, 1); \
984 intpol_met_time_3d(met0, met0->t, met1, met1->t, time, p, lon, lat, &t, ci, cw, 0); \
985 intpol_met_time_3d(met0, met0->u, met1, met1->u, time, p, lon, lat, &u, ci, cw, 0); \
986 intpol_met_time_3d(met0, met0->v, met1, met1->v, time, p, lon, lat, &v, ci, cw, 0); \
987 intpol_met_time_3d(met0, met0->w, met1, met1->w, time, p, lon, lat, &w, ci, cw, 0); \
988 intpol_met_time_3d(met0, met0->pv, met1, met1->pv, time, p, lon, lat, &pv, ci, cw, 0); \
989 intpol_met_time_3d(met0, met0->h2o, met1, met1->h2o, time, p, lon, lat, &h2o, ci, cw, 0); \
990 intpol_met_time_3d(met0, met0->o3, met1, met1->o3, time, p, lon, lat, &o3, ci, cw, 0); \
991 intpol_met_time_3d(met0, met0->lwc, met1, met1->lwc, time, p, lon, lat, &lwc, ci, cw, 0); \
992 intpol_met_time_3d(met0, met0->rwc, met1, met1->rwc, time, p, lon, lat, &rwc, ci, cw, 0); \
993 intpol_met_time_3d(met0, met0->iwc, met1, met1->iwc, time, p, lon, lat, &iwc, ci, cw, 0); \
994 intpol_met_time_3d(met0, met0->swc, met1, met1->swc, time, p, lon, lat, &swc, ci, cw, 0); \
995 intpol_met_time_3d(met0, met0->cc, met1, met1->cc, time, p, lon, lat, &cc, ci, cw, 0); \
996 intpol_met_time_2d(met0, met0->ps, met1, met1->ps, time, lon, lat, &ps, ci, cw, 0); \
997 intpol_met_time_2d(met0, met0->ts, met1, met1->ts, time, lon, lat, &ts, ci, cw, 0); \
998 intpol_met_time_2d(met0, met0->zs, met1, met1->zs, time, lon, lat, &zs, ci, cw, 0); \
999 intpol_met_time_2d(met0, met0->us, met1, met1->us, time, lon, lat, &us, ci, cw, 0); \
1000 intpol_met_time_2d(met0, met0->vs, met1, met1->vs, time, lon, lat, &vs, ci, cw, 0); \
1001 intpol_met_time_2d(met0, met0->ess, met1, met1->ess, time, lon, lat, &ess, ci, cw, 0); \
1002 intpol_met_time_2d(met0, met0->nss, met1, met1->nss, time, lon, lat, &nss, ci, cw, 0); \
1003 intpol_met_time_2d(met0, met0->shf, met1, met1->shf, time, lon, lat, &shf, ci, cw, 0); \
1004 intpol_met_time_2d(met0, met0->lsm, met1, met1->lsm, time, lon, lat, &lsm, ci, cw, 0); \
1005 intpol_met_time_2d(met0, met0->sst, met1, met1->sst, time, lon, lat, &sst, ci, cw, 0); \
1006 intpol_met_time_2d(met0, met0->pbl, met1, met1->pbl, time, lon, lat, &pbl, ci, cw, 0); \
1007 intpol_met_time_2d(met0, met0->pt, met1, met1->pt, time, lon, lat, &pt, ci, cw, 0); \
1008 intpol_met_time_2d(met0, met0->tt, met1, met1->tt, time, lon, lat, &tt, ci, cw, 0); \
1009 intpol_met_time_2d(met0, met0->zt, met1, met1->zt, time, lon, lat, &zt, ci, cw, 0); \
1010 intpol_met_time_2d(met0, met0->h2ot, met1, met1->h2ot, time, lon, lat, &h2ot, ci, cw, 0); \
1011 intpol_met_time_2d(met0, met0->pct, met1, met1->pct, time, lon, lat, &pct, ci, cw, 0); \
1012 intpol_met_time_2d(met0, met0->pcb, met1, met1->pcb, time, lon, lat, &pcb, ci, cw, 0); \
1013 intpol_met_time_2d(met0, met0->cl, met1, met1->cl, time, lon, lat, &cl, ci, cw, 0); \
1014 intpol_met_time_2d(met0, met0->plcl, met1, met1->plcl, time, lon, lat, &plcl, ci, cw, 0); \
1015 intpol_met_time_2d(met0, met0->plfc, met1, met1->plfc, time, lon, lat, &plfc, ci, cw, 0); \
1016 intpol_met_time_2d(met0, met0->pel, met1, met1->pel, time, lon, lat, &pel, ci, cw, 0); \
1017 intpol_met_time_2d(met0, met0->cape, met1, met1->cape, time, lon, lat, &cape, ci, cw, 0); \
1018 intpol_met_time_2d(met0, met0->cin, met1, met1->cin, time, lon, lat, &cin, ci, cw, 0); \
1019 intpol_met_time_2d(met0, met0->o3c, met1, met1->o3c, time, lon, lat, &o3c, ci, cw, 0); \
1020 }
1021
1036#define LAPSE(p1, t1, p2, t2) \
1037 (1e3 * G0 / RA * ((t2) - (t1)) / ((t2) + (t1)) \
1038 * ((p2) + (p1)) / ((p2) - (p1)))
1039
1055#define LIN(x0, y0, x1, y1, x) \
1056 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
1057
1082#define MAX(a,b) \
1083 (((a)>(b))?(a):(b))
1084
1096#define MET_HEADER \
1097 fprintf(out, \
1098 "# $1 = time [s]\n" \
1099 "# $2 = altitude [km]\n" \
1100 "# $3 = longitude [deg]\n" \
1101 "# $4 = latitude [deg]\n" \
1102 "# $5 = pressure [hPa]\n" \
1103 "# $6 = temperature [K]\n" \
1104 "# $7 = zonal wind [m/s]\n" \
1105 "# $8 = meridional wind [m/s]\n" \
1106 "# $9 = vertical velocity [hPa/s]\n" \
1107 "# $10 = H2O volume mixing ratio [ppv]\n"); \
1108 fprintf(out, \
1109 "# $11 = O3 volume mixing ratio [ppv]\n" \
1110 "# $12 = geopotential height [km]\n" \
1111 "# $13 = potential vorticity [PVU]\n" \
1112 "# $14 = surface pressure [hPa]\n" \
1113 "# $15 = surface temperature [K]\n" \
1114 "# $16 = surface geopotential height [km]\n" \
1115 "# $17 = surface zonal wind [m/s]\n" \
1116 "# $18 = surface meridional wind [m/s]\n" \
1117 "# $19 = eastward turbulent surface stress [N/m^2]\n" \
1118 "# $20 = northward turbulent surface stress [N/m^2]\n"); \
1119 fprintf(out, \
1120 "# $21 = surface sensible heat flux [W/m^2]\n" \
1121 "# $22 = land-sea mask [1]\n" \
1122 "# $23 = sea surface temperature [K]\n" \
1123 "# $24 = tropopause pressure [hPa]\n" \
1124 "# $25 = tropopause geopotential height [km]\n" \
1125 "# $26 = tropopause temperature [K]\n" \
1126 "# $27 = tropopause water vapor [ppv]\n" \
1127 "# $28 = cloud liquid water content [kg/kg]\n" \
1128 "# $29 = cloud rain water content [kg/kg]\n" \
1129 "# $30 = cloud ice water content [kg/kg]\n"); \
1130 fprintf(out, \
1131 "# $31 = cloud snow water content [kg/kg]\n" \
1132 "# $32 = cloud cover [1]\n" \
1133 "# $33 = total column cloud water [kg/m^2]\n" \
1134 "# $34 = cloud top pressure [hPa]\n" \
1135 "# $35 = cloud bottom pressure [hPa]\n" \
1136 "# $36 = pressure at lifted condensation level (LCL) [hPa]\n" \
1137 "# $37 = pressure at level of free convection (LFC) [hPa]\n" \
1138 "# $38 = pressure at equilibrium level (EL) [hPa]\n" \
1139 "# $39 = convective available potential energy (CAPE) [J/kg]\n" \
1140 "# $40 = convective inhibition (CIN) [J/kg]\n"); \
1141 fprintf(out, \
1142 "# $41 = relative humidity over water [%%]\n" \
1143 "# $42 = relative humidity over ice [%%]\n" \
1144 "# $43 = dew point temperature [K]\n" \
1145 "# $44 = frost point temperature [K]\n" \
1146 "# $45 = NAT temperature [K]\n" \
1147 "# $46 = HNO3 volume mixing ratio [ppv]\n" \
1148 "# $47 = OH volume mixing ratio [ppv]\n" \
1149 "# $48 = H2O2 volume mixing ratio [ppv]\n" \
1150 "# $49 = HO2 volume mixing ratio [ppv]\n" \
1151 "# $50 = O(1D) volume mixing ratio [ppv]\n"); \
1152 fprintf(out, \
1153 "# $51 = boundary layer pressure [hPa]\n" \
1154 "# $52 = total column ozone [DU]\n" \
1155 "# $53 = number of data points\n" \
1156 "# $54 = number of tropopause data points\n" \
1157 "# $55 = number of CAPE data points\n");
1158
1183#define MIN(a,b) \
1184 (((a)<(b))?(a):(b))
1185
1198#define MOLEC_DENS(p,t) \
1199 (AVO * 1e-6 * ((p) * 100) / (RI * (t)))
1200
1212#define NC(cmd) { \
1213 int nc_result=(cmd); \
1214 if(nc_result!=NC_NOERR) \
1215 ERRMSG("%s", nc_strerror(nc_result)); \
1216 }
1217
1241#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units, level, quant) { \
1242 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
1243 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
1244 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
1245 if((quant) > 0) \
1246 NC(nc_def_var_quantize(ncid, varid, NC_QUANTIZE_GRANULARBR, quant)); \
1247 if((level) != 0) { \
1248 NC(nc_def_var_deflate(ncid, varid, 1, 1, level)); \
1249 /* unsigned int ulevel = (unsigned int)level; */ \
1250 /* NC(nc_def_var_filter(ncid, varid, 32015, 1, (unsigned int[]){ulevel})); */ \
1251 } \
1252 }
1253
1271#define NC_GET_DOUBLE(varname, ptr, force) { \
1272 if(force) { \
1273 NC(nc_inq_varid(ncid, varname, &varid)); \
1274 NC(nc_get_var_double(ncid, varid, ptr)); \
1275 } else { \
1276 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
1277 NC(nc_get_var_double(ncid, varid, ptr)); \
1278 } else \
1279 WARN("netCDF variable %s is missing!", varname); \
1280 } \
1281 }
1282
1301#define NC_INQ_DIM(dimname, ptr, min, max, check) { \
1302 int dimid; size_t naux; \
1303 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
1304 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
1305 *ptr = (int)naux; \
1306 if (check) \
1307 if ((*ptr) < (min) || (*ptr) > (max)) \
1308 ERRMSG("Dimension %s is out of range!", dimname); \
1309 }
1310
1325#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
1326 NC(nc_inq_varid(ncid, varname, &varid)); \
1327 if(hyperslab) { \
1328 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
1329 } else { \
1330 NC(nc_put_var_double(ncid, varid, ptr)); \
1331 } \
1332 }
1333
1349#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
1350 NC(nc_inq_varid(ncid, varname, &varid)); \
1351 if(hyperslab) { \
1352 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
1353 } else { \
1354 NC(nc_put_var_float(ncid, varid, ptr)); \
1355 } \
1356 }
1357
1372#define NC_PUT_INT(varname, ptr, hyperslab) { \
1373 NC(nc_inq_varid(ncid, varname, &varid)); \
1374 if(hyperslab) { \
1375 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
1376 } else { \
1377 NC(nc_put_var_int(ncid, varid, ptr)); \
1378 } \
1379 }
1380
1394#define NC_PUT_ATT(varname, attname, text) { \
1395 NC(nc_inq_varid(ncid, varname, &varid)); \
1396 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
1397 }
1398
1411#define NC_PUT_ATT_GLOBAL(attname, text) \
1412 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
1413
1431#define NN(x0, y0, x1, y1, x) \
1432 (fabs((x) - (x0)) <= fabs((x) - (x1)) ? (y0) : (y1))
1433
1449#ifdef _OPENACC
1450#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1451 const int ip0_const = ip0; \
1452 const int ip1_const = ip1; \
1453 _Pragma(__VA_ARGS__) \
1454 _Pragma("acc parallel loop independent gang vector") \
1455 for (int ip = ip0_const; ip < ip1_const; ip++) \
1456 if (!check_dt || cache->dt[ip] != 0)
1457#else
1458#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1459 const int ip0_const = ip0; \
1460 const int ip1_const = ip1; \
1461 _Pragma("omp parallel for default(shared)") \
1462 for (int ip = ip0_const; ip < ip1_const; ip++) \
1463 if (!check_dt || cache->dt[ip] != 0)
1464#endif
1465
1488#define P(z) \
1489 (P0 * exp(-(z) / H0))
1490
1512#define PSAT(t) \
1513 (6.112 * exp(17.62 * ((t) - T0) / (243.12 + (t) - T0)))
1514
1536#define PSICE(t) \
1537 (6.112 * exp(22.46 * ((t) - T0) / (272.62 + (t) - T0)))
1538
1563#define PW(p, h2o) \
1564 ((p) * MAX((h2o), 0.1e-6) / (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1565
1580#define RAD2DEG(rad) \
1581 ((rad) * (180.0 / M_PI))
1582
1610#define RH(p, t, h2o) \
1611 (PW(p, h2o) / PSAT(t) * 100.)
1612
1640#define RHICE(p, t, h2o) \
1641 (PW(p, h2o) / PSICE(t) * 100.)
1642
1665#define RHO(p, t) \
1666 (100. * (p) / (RA * (t)))
1667
1684#define SET_ATM(qnt, val) \
1685 if (ctl->qnt >= 0) \
1686 atm->q[ctl->qnt][ip] = val;
1687
1707#define SET_QNT(qnt, name, longname, unit) \
1708 if (strcasecmp(ctl->qnt_name[iq], name) == 0) { \
1709 ctl->qnt = iq; \
1710 sprintf(ctl->qnt_longname[iq], longname); \
1711 sprintf(ctl->qnt_unit[iq], unit); \
1712 } else
1713
1728#define SH(h2o) \
1729 (EPS * MAX((h2o), 0.1e-6))
1730
1741#define SQR(x) \
1742 ((x)*(x))
1743
1755#define SWAP(x, y, type) \
1756 do {type tmp = x; x = y; y = tmp;} while(0);
1757
1779#define TDEW(p, h2o) \
1780 (T0 + 243.12 * log(PW((p), (h2o)) / 6.112) \
1781 / (17.62 - log(PW((p), (h2o)) / 6.112)))
1782
1804#define TICE(p, h2o) \
1805 (T0 + 272.62 * log(PW((p), (h2o)) / 6.112) \
1806 / (22.46 - log(PW((p), (h2o)) / 6.112)))
1807
1828#define THETA(p, t) \
1829 ((t) * pow(1000. / (p), 0.286))
1830
1857#define THETAVIRT(p, t, h2o) \
1858 (TVIRT(THETA((p), (t)), MAX((h2o), 0.1e-6)))
1859
1878#define TOK(line, tok, format, var) { \
1879 if(((tok)=strtok((line), " \t"))) { \
1880 if(sscanf(tok, format, &(var))!=1) continue; \
1881 } else ERRMSG("Error while reading!"); \
1882 }
1883
1903#define TVIRT(t, h2o) \
1904 ((t) * (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1905
1917#define USAGE \
1918 do { \
1919 int iusage; \
1920 for (iusage = 1; iusage < argc; iusage++) \
1921 if (!strcmp(argv[iusage], "-h") \
1922 || !strcmp(argv[iusage], "--help")) { \
1923 usage(); \
1924 return EXIT_SUCCESS; \
1925 } \
1926 } while (0)
1927
1947#define Z(p) \
1948 (H0 * log(P0 / (p)))
1949
1978#define ZDIFF(lnp0, t0, h2o0, lnp1, t1, h2o1) \
1979 (RI / MA / G0 * 0.5 * (TVIRT((t0), (h2o0)) + TVIRT((t1), (h2o1))) \
1980 * ((lnp0) - (lnp1)))
1981
1997#define ZETA(ps, p, t) \
1998 (((p) / (ps) <= 0.3 ? 1. : \
1999 sin(M_PI / 2. * (1. - (p) / (ps)) / (1. - 0.3))) \
2000 * THETA((p), (t)))
2001
2002/* ------------------------------------------------------------
2003 Log messages...
2004 ------------------------------------------------------------ */
2005
2007#ifndef LOGLEV
2008#define LOGLEV 2
2009#endif
2010
2040#define LOG(level, ...) { \
2041 if(level >= 2) \
2042 printf(" "); \
2043 if(level <= LOGLEV) { \
2044 printf(__VA_ARGS__); \
2045 printf("\n"); \
2046 } \
2047 }
2048
2077#define WARN(...) { \
2078 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2079 LOG(0, __VA_ARGS__); \
2080 }
2081
2110#define ERRMSG(...) { \
2111 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2112 LOG(0, __VA_ARGS__); \
2113 exit(EXIT_FAILURE); \
2114 }
2115
2145#define PRINT(format, var) \
2146 printf("Print (%s, %s, l%d): %s= "format"\n", \
2147 __FILE__, __func__, __LINE__, #var, var);
2148
2149/* ------------------------------------------------------------
2150 Timers...
2151 ------------------------------------------------------------ */
2152
2154#define NTIMER 100
2155
2169#define PRINT_TIMERS \
2170 timer("END", "END", 1);
2171
2184#define SELECT_TIMER(id, group) \
2185 timer(id, group, 0);
2186
2187/* ------------------------------------------------------------
2188 Structs...
2189 ------------------------------------------------------------ */
2190
2198typedef struct {
2199
2200 /* ------------------------------------------------------------
2201 Quantity parameters...
2202 ------------------------------------------------------------ */
2203
2205 int nq;
2206
2208 char qnt_name[NQ][LEN];
2209
2211 char qnt_longname[NQ][LEN];
2212
2214 char qnt_unit[NQ][LEN];
2215
2217 char qnt_format[NQ][LEN];
2218
2221
2224
2227
2230
2233
2236
2239
2242
2245
2248
2251
2254
2257
2260
2263
2266
2269
2272
2275
2278
2281
2284
2287
2290
2293
2296
2299
2302
2305
2308
2311
2314
2317
2320
2323
2326
2329
2332
2335
2338
2341
2344
2347
2350
2353
2356
2359
2362
2365
2368
2371
2374
2377
2380
2383
2386
2389
2392
2395
2398
2401
2404
2407
2410
2413
2416
2419
2422
2425
2428
2431
2434
2437
2440
2443
2446
2449
2452
2455
2458
2461
2464
2467
2470
2473
2476
2479
2482
2485
2488
2491
2494
2497
2500
2503
2506
2509
2512
2515
2518
2521
2524
2527
2529 double t_start;
2530
2532 double t_stop;
2533
2535 double dt_mod;
2536
2537 /* ------------------------------------------------------------
2538 Meteo data parameters...
2539 ------------------------------------------------------------ */
2540
2542 char metbase[LEN];
2543
2545 double dt_met;
2546
2549
2553
2557
2560
2563
2566
2569
2572
2575
2578
2581
2583 int met_zfp_prec[METVAR];
2584
2586 double met_zfp_tol[METVAR];
2587
2589 int met_sz3_prec[METVAR];
2590
2592 double met_sz3_tol[METVAR];
2593
2595 int met_lossy_scale[METVAR];
2596
2598 char met_comp_logfile[LEN];
2599
2602
2605
2608
2611
2614
2616 double met_cms_eps[METVAR];
2617
2620
2623
2626
2629
2632
2635
2638
2641
2643 double met_p[EP];
2644
2647
2650
2652 double met_lev_hyam[EP];
2653
2655 double met_lev_hybm[EP];
2656
2659
2662
2665
2668
2671
2674
2677
2681
2684
2687
2690
2693
2696
2699
2700 /* ------------------------------------------------------------
2701 Geophysical module parameters...
2702 ------------------------------------------------------------ */
2703
2705 double sort_dt;
2706
2710
2712 char balloon[LEN];
2713
2716
2720
2723
2726
2729
2732
2735
2738
2741
2744
2747
2750
2753
2756
2759
2761 double conv_cin;
2762
2764 double conv_dt;
2765
2768
2771
2774
2777
2780
2783
2785 double bound_p0;
2786
2788 double bound_p1;
2789
2792
2795
2798
2801
2803 char species[LEN];
2804
2806 double molmass;
2807
2810
2813
2816
2818 char clim_hno3_filename[LEN];
2819
2821 char clim_oh_filename[LEN];
2822
2824 char clim_h2o2_filename[LEN];
2825
2827 char clim_ho2_filename[LEN];
2828
2830 char clim_o1d_filename[LEN];
2831
2833 char clim_o3_filename[LEN];
2834
2836 char clim_ccl4_timeseries[LEN];
2837
2839 char clim_ccl3f_timeseries[LEN];
2840
2842 char clim_ccl2f2_timeseries[LEN];
2843
2845 char clim_n2o_timeseries[LEN];
2846
2848 char clim_sf6_timeseries[LEN];
2849
2852
2855
2858
2861
2864
2867
2870
2873
2876
2879
2882
2885
2888
2891
2894
2897
2900
2903
2906
2909
2912
2915
2917 double oh_chem[4];
2918
2921
2924
2927
2929 double dt_kpp;
2930
2933
2936
2938 double wet_depo_pre[2];
2939
2942
2945
2948
2951
2953 double wet_depo_ic_h[2];
2954
2956 double wet_depo_bc_h[2];
2957
2960
2963
2966
2969
2972
2974 double psc_h2o;
2975
2977 double psc_hno3;
2978
2979 /* ------------------------------------------------------------
2980 Output parameters...
2981 ------------------------------------------------------------ */
2982
2984 char atm_basename[LEN];
2985
2987 char atm_gpfile[LEN];
2988
2991
2994
2997
3001
3006
3009
3011 int atm_nc_quant[NQ];
3012
3015
3017 char csi_basename[LEN];
3018
3020 char csi_kernel[LEN];
3021
3024
3026 char csi_obsfile[LEN];
3027
3030
3033
3036
3038 double csi_z0;
3039
3041 double csi_z1;
3042
3045
3047 double csi_lon0;
3048
3050 double csi_lon1;
3051
3054
3056 double csi_lat0;
3057
3059 double csi_lat1;
3060
3062 int nens;
3063
3065 char ens_basename[LEN];
3066
3069
3071 char grid_basename[LEN];
3072
3074 char grid_kernel[LEN];
3075
3077 char grid_gpfile[LEN];
3078
3081
3084
3087
3089 int grid_nc_quant[NQ];
3090
3093
3096
3098 double grid_z0;
3099
3101 double grid_z1;
3102
3105
3108
3111
3114
3117
3120
3123
3125 char prof_basename[LEN];
3126
3128 char prof_obsfile[LEN];
3129
3132
3134 double prof_z0;
3135
3137 double prof_z1;
3138
3141
3144
3147
3150
3153
3156
3158 char sample_basename[LEN];
3159
3161 char sample_kernel[LEN];
3162
3164 char sample_obsfile[LEN];
3165
3168
3171
3173 char stat_basename[LEN];
3174
3176 double stat_lon;
3177
3179 double stat_lat;
3180
3182 double stat_r;
3183
3185 double stat_t0;
3186
3188 double stat_t1;
3189
3191 char vtk_basename[LEN];
3192
3195
3198
3201
3204
3207
3208 /* ------------------------------------------------------------
3209 Domain decomposition...
3210 ------------------------------------------------------------ */
3211
3213 int dd;
3214
3217
3220
3223
3224} ctl_t;
3225
3234typedef struct {
3235
3237 int np;
3238
3240 double time[NP];
3241
3243 double p[NP];
3244
3246 double lon[NP];
3247
3249 double lat[NP];
3250
3252 double q[NQ][NP];
3253
3254} atm_t;
3255
3263typedef struct {
3264
3266 double time;
3267
3269 double p;
3270
3272 double lon;
3273
3275 double lat;
3276
3278 double q[NQ];
3279
3280} particle_t;
3281
3282
3289typedef struct {
3290
3292 double iso_var[NP];
3293
3295 double iso_ps[NP];
3296
3298 double iso_ts[NP];
3299
3302
3304 float uvwp[NP][3];
3305
3307 double rs[3 * NP + 1];
3308
3310 double dt[NP];
3311
3312} cache_t;
3313
3321typedef struct {
3322
3324 int np;
3325
3327 int nsza;
3328
3330 int no3c;
3331
3333 double p[CP];
3334
3336 double sza[CSZA];
3337
3339 double o3c[CO3];
3340
3342 double n2o[CP][CSZA][CO3];
3343
3345 double ccl4[CP][CSZA][CO3];
3346
3348 double ccl3f[CP][CSZA][CO3];
3349
3351 double ccl2f2[CP][CSZA][CO3];
3352
3354 double o2[CP][CSZA][CO3];
3355
3357 double o3_1[CP][CSZA][CO3];
3358
3360 double o3_2[CP][CSZA][CO3];
3361
3363 double h2o2[CP][CSZA][CO3];
3364
3366 double h2o[CP][CSZA][CO3];
3367
3368} clim_photo_t;
3369
3377typedef struct {
3378
3381
3383 double time[CTS];
3384
3386 double vmr[CTS];
3387
3388} clim_ts_t;
3389
3397typedef struct {
3398
3401
3403 int nlat;
3404
3406 int np;
3407
3409 double time[CT];
3410
3412 double lat[CY];
3413
3415 double p[CP];
3416
3418 double vmr[CT][CP][CY];
3419
3420} clim_zm_t;
3421
3429typedef struct {
3430
3433
3436
3438 double tropo_time[12];
3439
3441 double tropo_lat[73];
3442
3444 double tropo[12][73];
3445
3448
3451
3454
3457
3460
3463
3466
3469
3472
3475
3478
3479} clim_t;
3480
3488typedef struct {
3489
3491 double time;
3492
3494 int nx;
3495
3497 int ny;
3498
3500 int np;
3501
3503 int npl;
3504
3506 double lon[EX];
3507
3509 double lat[EY];
3510
3512 double p[EP];
3513
3515 double hybrid[EP];
3516
3518 double hyam[EP];
3519
3521 double hybm[EP];
3522
3524 double eta[EP];
3525
3527 float ps[EX][EY];
3528
3530 float ts[EX][EY];
3531
3533 float zs[EX][EY];
3534
3536 float us[EX][EY];
3537
3539 float vs[EX][EY];
3540
3542 float ess[EX][EY];
3543
3545 float nss[EX][EY];
3546
3548 float shf[EX][EY];
3549
3551 float lsm[EX][EY];
3552
3554 float sst[EX][EY];
3555
3557 float pbl[EX][EY];
3558
3560 float pt[EX][EY];
3561
3563 float tt[EX][EY];
3564
3566 float zt[EX][EY];
3567
3569 float h2ot[EX][EY];
3570
3572 float pct[EX][EY];
3573
3575 float pcb[EX][EY];
3576
3578 float cl[EX][EY];
3579
3581 float plcl[EX][EY];
3582
3584 float plfc[EX][EY];
3585
3587 float pel[EX][EY];
3588
3590 float cape[EX][EY];
3591
3593 float cin[EX][EY];
3594
3596 float o3c[EX][EY];
3597
3599 float z[EX][EY][EP];
3600
3602 float t[EX][EY][EP];
3603
3605 float u[EX][EY][EP];
3606
3608 float v[EX][EY][EP];
3609
3611 float w[EX][EY][EP];
3612
3614 float pv[EX][EY][EP];
3615
3617 float h2o[EX][EY][EP];
3618
3620 float o3[EX][EY][EP];
3621
3623 float lwc[EX][EY][EP];
3624
3626 float rwc[EX][EY][EP];
3627
3629 float iwc[EX][EY][EP];
3630
3632 float swc[EX][EY][EP];
3633
3635 float cc[EX][EY][EP];
3636
3638 float pl[EX][EY][EP];
3639
3641 float ul[EX][EY][EP];
3642
3644 float vl[EX][EY][EP];
3645
3647 float wl[EX][EY][EP];
3648
3650 float zetal[EX][EY][EP];
3651
3653 float zeta_dotl[EX][EY][EP];
3654
3655} met_t;
3656
3662typedef struct {
3663
3664 /* ------------------------------------------------------------
3665 Global grid...
3666 ------------------------------------------------------------ */
3667
3670
3673
3675 double lon_glob[DD_EX_GLOB];
3676
3678 double lat_glob[DD_EY_GLOB];
3679
3680 /* ------------------------------------------------------------
3681 Subdomains...
3682 ------------------------------------------------------------ */
3683
3685 size_t subdomain_start[4];
3686
3688 size_t subdomain_count[4];
3689
3691 size_t halo_bnd_start[4];
3692
3694 size_t halo_bnd_count[4];
3695
3698
3701
3702 /* ------------------------------------------------------------
3703 Helpers...
3704 ------------------------------------------------------------ */
3705
3706#ifdef DD
3707
3709 MPI_Datatype MPI_Particle;
3710
3712 double sort_key[NP];
3713
3715 int perm[NP];
3716
3718 double tmp[NP];
3719
3720#endif
3721
3722} dd_t;
3723
3724/* ------------------------------------------------------------
3725 Functions...
3726 ------------------------------------------------------------ */
3727
3750 void *data,
3751 size_t N);
3752
3767void cart2geo(
3768 const double *x,
3769 double *z,
3770 double *lon,
3771 double *lat);
3772
3795double clim_oh(
3796 const ctl_t * ctl,
3797 const clim_t * clim,
3798 const double t,
3799 const double lon,
3800 const double lat,
3801 const double p);
3802
3822 const ctl_t * ctl,
3823 clim_t * clim);
3824
3854double clim_photo(
3855 const double rate[CP][CSZA][CO3],
3856 const clim_photo_t * photo,
3857 const double p,
3858 const double sza,
3859 const double o3c);
3860
3886double clim_tropo(
3887 const clim_t * clim,
3888 const double t,
3889 const double lat);
3890
3909void clim_tropo_init(
3910 clim_t * clim);
3911
3928double clim_ts(
3929 const clim_ts_t * ts,
3930 const double t);
3931
3953double clim_zm(
3954 const clim_zm_t * zm,
3955 const double t,
3956 const double lat,
3957 const double p);
3958
3971double compress_speed_mib(
3972 const size_t nbytes,
3973 const double dt);
3974
3997 const float *org,
3998 const float *cmp,
3999 const size_t n,
4000 double *mean,
4001 double *stddev,
4002 double *min,
4003 double *max,
4004 double *nrmse,
4005 double *org_mean,
4006 double *range);
4007
4016 FILE * out);
4017
4043 FILE * out,
4044 const char *codec,
4045 const char *varname,
4046 const size_t lev,
4047 const double plev,
4048 const double ratio,
4049 const double bpv,
4050 const double rho,
4051 const double t_comp,
4052 const double t_decomp,
4053 const size_t n,
4054 const size_t nbytes,
4055 const float *org,
4056 const float *cmp);
4057
4104 const ctl_t * ctl,
4105 const char *varname,
4106 float *array,
4107 const size_t nx,
4108 const size_t ny,
4109 const size_t np,
4110 const double *plev,
4111 const int decompress,
4112 FILE * level_log,
4113 FILE * inout);
4114
4131 float *array,
4132 const size_t nxy,
4133 const size_t nz,
4134 double *off,
4135 double *scl);
4136
4153 float *array,
4154 const size_t nxy,
4155 const size_t nz,
4156 const double *off,
4157 const double *scl);
4158
4171 const char *varname);
4172
4213void compress_pck(
4214 const char *varname,
4215 float *array,
4216 const size_t nxy,
4217 const size_t nz,
4218 const double *plev,
4219 const int decompress,
4220 const int pck_zstd,
4221 const int zstd_level,
4222 const int zstd_nworkers,
4223 FILE * level_log,
4224 FILE * inout);
4225
4260 const char *varname,
4261 float *array,
4262 const int nx,
4263 const int ny,
4264 const int nz,
4265 const double *plev,
4266 const int precision,
4267 const double tolerance,
4268 const int lossy_scale,
4269 const int decompress,
4270 FILE * level_log,
4271 FILE * inout);
4272
4316 const char *varname,
4317 float *array,
4318 const int nx,
4319 const int ny,
4320 const int nz,
4321 const double *plev,
4322 const int precision,
4323 const double tolerance,
4324 const int lossy_scale,
4325 const int decompress,
4326 FILE * level_log,
4327 FILE * inout);
4328
4356 const char *varname,
4357 float *array,
4358 const size_t nxy,
4359 const size_t nz,
4360 const double *plev,
4361 const int decompress,
4362 const int level,
4363 const int nworkers,
4364 FILE * level_log,
4365 FILE * inout);
4366
4392 const char *varname,
4393 float *array,
4394 const size_t nxy,
4395 const size_t nz,
4396 const double *plev,
4397 const int decompress,
4398 const int acceleration,
4399 FILE * level_log,
4400 FILE * inout);
4401
4426double cos_sza(
4427 const double sec,
4428 const double lon,
4429 const double lat);
4430
4453void day2doy(
4454 const int year,
4455 const int mon,
4456 const int day,
4457 int *doy);
4458
4512 const ctl_t * ctl,
4513 const dd_t * dd,
4514 atm_t * atm,
4515 const int init);
4516
4569 const ctl_t * ctl,
4570 cache_t * cache,
4571 atm_t * atm,
4572 particle_t * particles,
4573 const int npart);
4574
4604 const ctl_t * ctl,
4605 const dd_t * dd,
4606 const double lon,
4607 const double lat);
4608
4665 const ctl_t * ctl,
4666 const dd_t * dd,
4667 particle_t ** particles,
4668 int *npart,
4669 int *capacity);
4670
4710 const ctl_t * ctl,
4711 dd_t * dd,
4712 atm_t * atm);
4713
4748 const dd_t * dd,
4749 double *lon,
4750 double *lat);
4751
4800 const ctl_t * ctl,
4801 cache_t * cache,
4802 const particle_t * particles,
4803 const int npart,
4804 atm_t * atm);
4805
4864 const ctl_t * ctl,
4865 const met_t * met0,
4866 atm_t * atm,
4867 dd_t * dd,
4868 int *npart);
4869
4899 double *a,
4900 dd_t * dd,
4901 const int np);
4902
4924void doy2day(
4925 const int year,
4926 const int doy,
4927 int *mon,
4928 int *day);
4929
4956void fft_help(
4957 double *fcReal,
4958 double *fcImag,
4959 const int n);
4960
4987void geo2cart(
4988 const double z,
4989 const double lon,
4990 const double lat,
4991 double *x);
4992
5017void get_met_filename(
5018 const ctl_t * ctl,
5019 const double t,
5020 const int direct,
5021 const char *metbase,
5022 const double dt_met,
5023 char *filename);
5024
5048void get_met_replace(
5049 char *orig,
5050 const char *search,
5051 const char *repl);
5052
5089void get_tropo(
5090 const int met_tropo,
5091 ctl_t * ctl,
5092 const clim_t * clim,
5093 met_t * met,
5094 const double *lons,
5095 const int nx,
5096 const double *lats,
5097 const int ny,
5098 double *pt,
5099 double *zt,
5100 double *tt,
5101 double *qt,
5102 double *o3t,
5103 double *ps,
5104 double *zs);
5105
5127 const double *lons,
5128 const int nlon,
5129 const double *lats,
5130 const int nlat,
5131 const double lon,
5132 const double lat,
5133 double *lon2,
5134 double *lat2);
5135
5178 const met_t * met0,
5179 float height0[EX][EY][EP],
5180 float array0[EX][EY][EP],
5181 const met_t * met1,
5182 float height1[EX][EY][EP],
5183 float array1[EX][EY][EP],
5184 const double ts,
5185 const double height,
5186 const double lon,
5187 const double lat,
5188 double *var,
5189 int *ci,
5190 double *cw,
5191 const int init);
5192
5228 const met_t * met,
5229 float array[EX][EY][EP],
5230 const double p,
5231 const double lon,
5232 const double lat,
5233 double *var,
5234 int *ci,
5235 double *cw,
5236 const int init);
5237
5273 const met_t * met,
5274 float array[EX][EY],
5275 const double lon,
5276 const double lat,
5277 double *var,
5278 int *ci,
5279 double *cw,
5280 const int init);
5281
5316 const met_t * met0,
5317 float array0[EX][EY][EP],
5318 const met_t * met1,
5319 float array1[EX][EY][EP],
5320 const double ts,
5321 const double p,
5322 const double lon,
5323 const double lat,
5324 double *var,
5325 int *ci,
5326 double *cw,
5327 const int init);
5328
5364 const met_t * met0,
5365 float array0[EX][EY],
5366 const met_t * met1,
5367 float array1[EX][EY],
5368 const double ts,
5369 const double lon,
5370 const double lat,
5371 double *var,
5372 int *ci,
5373 double *cw,
5374 const int init);
5375
5413void intpol_tropo_3d(
5414 const double time0,
5415 float array0[EX][EY],
5416 const double time1,
5417 float array1[EX][EY],
5418 const double lons[EX],
5419 const double lats[EY],
5420 const int nlon,
5421 const int nlat,
5422 const double time,
5423 const double lon,
5424 const double lat,
5425 const int method,
5426 double *var,
5427 double *sigma);
5428
5455void jsec2time(
5456 const double jsec,
5457 int *year,
5458 int *mon,
5459 int *day,
5460 int *hour,
5461 int *min,
5462 int *sec,
5463 double *remain);
5464
5491double kernel_weight(
5492 const double kz[EP],
5493 const double kw[EP],
5494 const int nk,
5495 const double p);
5496
5535double lapse_rate(
5536 const double t,
5537 const double h2o);
5538
5566 ctl_t * ctl);
5567
5587int locate_irr(
5588 const double *xx,
5589 const int n,
5590 const double x);
5591
5618 const float *xx,
5619 const int n,
5620 const double x,
5621 const int ig);
5622
5643int locate_reg(
5644 const double *xx,
5645 const int n,
5646 const double x);
5647
5669void locate_vert(
5670 float profiles[EX][EY][EP],
5671 const int np,
5672 const int lon_ap_ind,
5673 const int lat_ap_ind,
5674 const double alt_ap,
5675 int *ind);
5676
5702void module_advect(
5703 const ctl_t * ctl,
5704 const cache_t * cache,
5705 met_t * met0,
5706 met_t * met1,
5707 atm_t * atm);
5708
5732 const ctl_t * ctl,
5733 const cache_t * cache,
5734 met_t * met0,
5735 met_t * met1,
5736 atm_t * atm);
5737
5775 const ctl_t * ctl,
5776 const cache_t * cache,
5777 const clim_t * clim,
5778 met_t * met0,
5779 met_t * met1,
5780 atm_t * atm);
5781
5823void module_chem_grid(
5824 const ctl_t * ctl,
5825 met_t * met0,
5826 met_t * met1,
5827 atm_t * atm,
5828 const double t);
5829
5857void module_chem_init(
5858 const ctl_t * ctl,
5859 const cache_t * cache,
5860 const clim_t * clim,
5861 met_t * met0,
5862 met_t * met1,
5863 atm_t * atm);
5864
5889 const ctl_t * ctl,
5890 cache_t * cache,
5891 met_t * met0,
5892 met_t * met1,
5893 atm_t * atm);
5894
5939 const ctl_t * ctl,
5940 cache_t * cache,
5941 dd_t * dd,
5942 atm_t * atm,
5943 met_t ** met);
5944
5971void module_decay(
5972 const ctl_t * ctl,
5973 const cache_t * cache,
5974 const clim_t * clim,
5975 atm_t * atm);
5976
6013void module_diff_meso(
6014 const ctl_t * ctl,
6015 cache_t * cache,
6016 met_t * met0,
6017 met_t * met1,
6018 atm_t * atm);
6019
6053void module_diff_pbl(
6054 const ctl_t * ctl,
6055 cache_t * cache,
6056 met_t * met0,
6057 met_t * met1,
6058 atm_t * atm);
6059
6114void module_diff_turb(
6115 const ctl_t * ctl,
6116 cache_t * cache,
6117 const clim_t * clim,
6118 met_t * met0,
6119 met_t * met1,
6120 atm_t * atm);
6121
6141void module_dry_depo(
6142 const ctl_t * ctl,
6143 const cache_t * cache,
6144 met_t * met0,
6145 met_t * met1,
6146 atm_t * atm);
6147
6180void module_h2o2_chem(
6181 const ctl_t * ctl,
6182 const cache_t * cache,
6183 const clim_t * clim,
6184 met_t * met0,
6185 met_t * met1,
6186 atm_t * atm);
6187
6208 const ctl_t * ctl,
6209 cache_t * cache,
6210 met_t * met0,
6211 met_t * met1,
6212 atm_t * atm);
6213
6231void module_isosurf(
6232 const ctl_t * ctl,
6233 const cache_t * cache,
6234 met_t * met0,
6235 met_t * met1,
6236 atm_t * atm);
6237
6270 ctl_t * ctl,
6271 cache_t * cache,
6272 clim_t * clim,
6273 met_t * met0,
6274 met_t * met1,
6275 atm_t * atm);
6276
6295void module_meteo(
6296 const ctl_t * ctl,
6297 const cache_t * cache,
6298 const clim_t * clim,
6299 met_t * met0,
6300 met_t * met1,
6301 atm_t * atm);
6302
6320void module_mixing(
6321 const ctl_t * ctl,
6322 const clim_t * clim,
6323 atm_t * atm,
6324 const double t);
6325
6354 const ctl_t * ctl,
6355 const clim_t * clim,
6356 atm_t * atm,
6357 const int *ixs,
6358 const int *iys,
6359 const int *izs,
6360 const int qnt_idx,
6361 const int use_ensemble);
6362
6395void module_oh_chem(
6396 const ctl_t * ctl,
6397 const cache_t * cache,
6398 const clim_t * clim,
6399 met_t * met0,
6400 met_t * met1,
6401 atm_t * atm);
6402
6430void module_position(
6431 const cache_t * cache,
6432 met_t * met0,
6433 met_t * met1,
6434 atm_t * atm);
6435
6460void module_rng_init(
6461 const int ntask);
6462
6488void module_rng(
6489 const ctl_t * ctl,
6490 double *rs,
6491 const size_t n,
6492 const int method);
6493
6529 const ctl_t * ctl,
6530 const cache_t * cache,
6531 atm_t * atm);
6532
6555void module_sedi(
6556 const ctl_t * ctl,
6557 const cache_t * cache,
6558 met_t * met0,
6559 met_t * met1,
6560 atm_t * atm);
6561
6585void module_sort(
6586 const ctl_t * ctl,
6587 const met_t * met0,
6588 atm_t * atm);
6589
6609void module_sort_help(
6610 double *a,
6611 const int *p,
6612 const int np);
6613
6637void module_timesteps(
6638 const ctl_t * ctl,
6639 cache_t * cache,
6640 met_t * met0,
6641 atm_t * atm,
6642 const double t);
6643
6665 ctl_t * ctl,
6666 const atm_t * atm);
6667
6701 const ctl_t * ctl,
6702 const cache_t * cache,
6703 const clim_t * clim,
6704 met_t * met0,
6705 met_t * met1,
6706 atm_t * atm);
6707
6737void module_wet_depo(
6738 const ctl_t * ctl,
6739 const cache_t * cache,
6740 met_t * met0,
6741 met_t * met1,
6742 atm_t * atm);
6743
6775void mptrac_alloc(
6776 ctl_t ** ctl,
6777 cache_t ** cache,
6778 clim_t ** clim,
6779 met_t ** met0,
6780 met_t ** met1,
6781 atm_t ** atm,
6782 dd_t ** dd);
6783
6814void mptrac_free(
6815 ctl_t * ctl,
6816 cache_t * cache,
6817 clim_t * clim,
6818 met_t * met0,
6819 met_t * met1,
6820 atm_t * atm,
6821 dd_t * dd);
6822
6858void mptrac_get_met(
6859 ctl_t * ctl,
6860 clim_t * clim,
6861 const double t,
6862 met_t ** met0,
6863 met_t ** met1,
6864 dd_t * dd);
6865
6885void mptrac_init(
6886 ctl_t * ctl,
6887 cache_t * cache,
6888 clim_t * clim,
6889 atm_t * atm,
6890 const int ntask);
6891
6927int mptrac_read_atm(
6928 const char *filename,
6929 const ctl_t * ctl,
6930 atm_t * atm);
6931
6963void mptrac_read_clim(
6964 const ctl_t * ctl,
6965 clim_t * clim);
6966
6996void mptrac_read_ctl(
6997 const char *filename,
6998 int argc,
6999 char *argv[],
7000 ctl_t * ctl);
7001
7032int mptrac_read_met(
7033 const char *filename,
7034 const ctl_t * ctl,
7035 const clim_t * clim,
7036 met_t * met,
7037 dd_t * dd);
7038
7060 ctl_t * ctl,
7061 cache_t * cache,
7062 clim_t * clim,
7063 met_t ** met0,
7064 met_t ** met1,
7065 atm_t * atm,
7066 double t,
7067 dd_t * dd);
7068
7098void mptrac_write_atm(
7099 const char *filename,
7100 const ctl_t * ctl,
7101 const atm_t * atm,
7102 const double t);
7103
7143void mptrac_write_met(
7144 const char *filename,
7145 const ctl_t * ctl,
7146 met_t * met);
7147
7182 const char *dirname,
7183 const ctl_t * ctl,
7184 met_t * met0,
7185 met_t * met1,
7186 atm_t * atm,
7187 const double t);
7188
7220 const ctl_t * ctl,
7221 const cache_t * cache,
7222 const clim_t * clim,
7223 met_t ** met0,
7224 met_t ** met1,
7225 const atm_t * atm);
7226
7257 const ctl_t * ctl,
7258 const cache_t * cache,
7259 const clim_t * clim,
7260 met_t ** met0,
7261 met_t ** met1,
7262 const atm_t * atm);
7263
7291double nat_temperature(
7292 const double p,
7293 const double h2o,
7294 const double hno3);
7295
7316double pbl_weight(
7317 const ctl_t * ctl,
7318 const atm_t * atm,
7319 const int ip,
7320 const double pbl,
7321 const double ps);
7322
7355int read_atm_asc(
7356 const char *filename,
7357 const ctl_t * ctl,
7358 atm_t * atm);
7359
7390int read_atm_bin(
7391 const char *filename,
7392 const ctl_t * ctl,
7393 atm_t * atm);
7394
7419int read_atm_clams(
7420 const char *filename,
7421 const ctl_t * ctl,
7422 atm_t * atm);
7423
7453int read_atm_nc(
7454 const char *filename,
7455 const ctl_t * ctl,
7456 atm_t * atm);
7457
7486void read_clim_photo(
7487 const char *filename,
7488 clim_photo_t * photo);
7489
7507 const int ncid,
7508 const char *varname,
7509 const clim_photo_t * photo,
7510 double var[CP][CSZA][CO3]);
7511
7535int read_clim_ts(
7536 const char *filename,
7537 clim_ts_t * ts);
7538
7565void read_clim_zm(
7566 const char *filename,
7567 const char *varname,
7568 clim_zm_t * zm);
7569
7597void read_kernel(
7598 const char *filename,
7599 double kz[EP],
7600 double kw[EP],
7601 int *nk);
7602
7634int read_met_bin(
7635 const char *filename,
7636 const ctl_t * ctl,
7637 met_t * met);
7638
7664void read_met_bin_2d(
7665 FILE * in,
7666 const met_t * met,
7667 float var[EX][EY],
7668 const char *varname);
7669
7707void read_met_bin_3d(
7708 FILE * in,
7709 const ctl_t * ctl,
7710 const met_t * met,
7711 float var[EX][EY][EP],
7712 const char *varname,
7713 const float bound_min,
7714 const float bound_max);
7715
7743void read_met_cape(
7744 const ctl_t * ctl,
7745 const clim_t * clim,
7746 met_t * met);
7747
7770void read_met_cloud(
7771 met_t * met);
7772
7798void read_met_detrend(
7799 const ctl_t * ctl,
7800 met_t * met);
7801
7825 met_t * met);
7826
7853void read_met_geopot(
7854 const ctl_t * ctl,
7855 met_t * met);
7856
7884 const char *filename,
7885 const ctl_t * ctl,
7886 met_t * met);
7887
7909 codes_handle ** handles,
7910 int count_handles,
7911 met_t * met);
7912
7933 codes_handle ** handles,
7934 const int num_messages,
7935 const ctl_t * ctl,
7936 met_t * met);
7937
7968 codes_handle ** handles,
7969 const int num_messages,
7970 const ctl_t * ctl,
7971 met_t * met);
7972
8001void read_met_ml2pl(
8002 const ctl_t * ctl,
8003 const met_t * met,
8004 float var[EX][EY][EP],
8005 const char *varname);
8006
8029 const ctl_t * ctl,
8030 met_t * met);
8031
8062int read_met_nc(
8063 const char *filename,
8064 const ctl_t * ctl,
8065 met_t * met,
8066 dd_t * dd);
8067
8102void read_met_nc_grid(
8103 const char *filename,
8104 const int ncid,
8105 const ctl_t * ctl,
8106 met_t * met,
8107 dd_t * dd);
8108
8154 dd_t * dd,
8155 const ctl_t * ctl,
8156 met_t * met,
8157 const int ncid);
8158
8191 const int ncid,
8192 const ctl_t * ctl,
8193 met_t * met,
8194 dd_t * dd);
8195
8226 const int ncid,
8227 const ctl_t * ctl,
8228 met_t * met,
8229 dd_t * dd);
8230
8263int read_met_nc_2d(
8264 const int ncid,
8265 const char *varname,
8266 const char *varname2,
8267 const char *varname3,
8268 const char *varname4,
8269 const char *varname5,
8270 const char *varname6,
8271 const ctl_t * ctl,
8272 const met_t * met,
8273 dd_t * dd,
8274 float dest[EX][EY],
8275 const float scl,
8276 const int init);
8277
8307int read_met_nc_3d(
8308 const int ncid,
8309 const char *varname,
8310 const char *varname2,
8311 const char *varname3,
8312 const char *varname4,
8313 const ctl_t * ctl,
8314 const met_t * met,
8315 dd_t * dd,
8316 float dest[EX][EY][EP],
8317 const float scl);
8318
8364void read_met_pbl(
8365 const ctl_t * ctl,
8366 met_t * met);
8367
8400 met_t * met);
8401
8432 met_t * met);
8433
8464void read_met_pv(
8465 met_t * met);
8466
8489void read_met_ozone(
8490 met_t * met);
8491
8520void read_met_sample(
8521 const ctl_t * ctl,
8522 met_t * met);
8523
8552void read_met_tropo(
8553 const ctl_t * ctl,
8554 const clim_t * clim,
8555 met_t * met);
8556
8588void read_obs(
8589 const char *filename,
8590 const ctl_t * ctl,
8591 double *rt,
8592 double *rz,
8593 double *rlon,
8594 double *rlat,
8595 double *robs,
8596 int *nobs);
8597
8625void read_obs_asc(
8626 const char *filename,
8627 double *rt,
8628 double *rz,
8629 double *rlon,
8630 double *rlat,
8631 double *robs,
8632 int *nobs);
8633
8660void read_obs_nc(
8661 const char *filename,
8662 double *rt,
8663 double *rz,
8664 double *rlon,
8665 double *rlat,
8666 double *robs,
8667 int *nobs);
8668
8702double scan_ctl(
8703 const char *filename,
8704 int argc,
8705 char *argv[],
8706 const char *varname,
8707 const int arridx,
8708 const char *defvalue,
8709 char *value);
8710
8737double sedi(
8738 const double p,
8739 const double T,
8740 const double rp,
8741 const double rhop);
8742
8772void spline(
8773 const double *x,
8774 const double *y,
8775 const int n,
8776 const double *x2,
8777 double *y2,
8778 const int n2,
8779 const int method);
8780
8803float stddev(
8804 const float *data,
8805 const int n);
8806
8831void time2jsec(
8832 const int year,
8833 const int mon,
8834 const int day,
8835 const int hour,
8836 const int min,
8837 const int sec,
8838 const double remain,
8839 double *jsec);
8840
8869void timer(
8870 const char *name,
8871 const char *group,
8872 const int output);
8873
8899double time_from_filename(
8900 const char *filename,
8901 const int offset);
8902
8920double tropo_weight(
8921 const clim_t * clim,
8922 const atm_t * atm,
8923 const int ip);
8924
8947void write_atm_asc(
8948 const char *filename,
8949 const ctl_t * ctl,
8950 const atm_t * atm,
8951 const double t);
8952
8976void write_atm_bin(
8977 const char *filename,
8978 const ctl_t * ctl,
8979 const atm_t * atm);
8980
9004void write_atm_clams(
9005 const char *filename,
9006 const ctl_t * ctl,
9007 const atm_t * atm);
9008
9034 const char *dirname,
9035 const ctl_t * ctl,
9036 const atm_t * atm,
9037 const double t);
9038
9062void write_atm_nc(
9063 const char *filename,
9064 const ctl_t * ctl,
9065 const atm_t * atm);
9066
9095void write_csi(
9096 const char *filename,
9097 const ctl_t * ctl,
9098 const atm_t * atm,
9099 const double t);
9100
9142 const char *filename,
9143 const ctl_t * ctl,
9144 const atm_t * atm,
9145 const double t);
9146
9174void write_ens(
9175 const char *filename,
9176 const ctl_t * ctl,
9177 const atm_t * atm,
9178 const double t);
9179
9218void write_grid(
9219 const char *filename,
9220 const ctl_t * ctl,
9221 met_t * met0,
9222 met_t * met1,
9223 const atm_t * atm,
9224 const double t);
9225
9271void write_grid_asc(
9272 const char *filename,
9273 const ctl_t * ctl,
9274 const double *cd,
9275 double *mean[NQ],
9276 double *sigma[NQ],
9277 const double *vmr_impl,
9278 const double t,
9279 const double *z,
9280 const double *lon,
9281 const double *lat,
9282 const double *area,
9283 const double dz,
9284 const int *np);
9285
9328void write_grid_nc(
9329 const char *filename,
9330 const ctl_t * ctl,
9331 const double *cd,
9332 double *mean[NQ],
9333 double *sigma[NQ],
9334 const double *vmr_impl,
9335 const double t,
9336 const double *z,
9337 const double *lon,
9338 const double *lat,
9339 const double *area,
9340 const double dz,
9341 const int *np);
9342
9372void write_met_bin(
9373 const char *filename,
9374 const ctl_t * ctl,
9375 met_t * met);
9376
9404void write_met_bin_2d(
9405 FILE * out,
9406 met_t * met,
9407 float var[EX][EY],
9408 const char *varname);
9409
9449void write_met_bin_3d(
9450 FILE * out,
9451 const ctl_t * ctl,
9452 met_t * met,
9453 float var[EX][EY][EP],
9454 const char *varname,
9455 const int metvar,
9456 FILE * level_log);
9457
9485void write_met_nc(
9486 const char *filename,
9487 const ctl_t * ctl,
9488 met_t * met);
9489
9512void write_met_nc_2d(
9513 const int ncid,
9514 const char *varname,
9515 met_t * met,
9516 float var[EX][EY],
9517 const float scl);
9518
9542void write_met_nc_3d(
9543 const int ncid,
9544 const char *varname,
9545 met_t * met,
9546 float var[EX][EY][EP],
9547 const float scl);
9548
9579void write_prof(
9580 const char *filename,
9581 const ctl_t * ctl,
9582 met_t * met0,
9583 met_t * met1,
9584 const atm_t * atm,
9585 const double t);
9586
9618void write_sample(
9619 const char *filename,
9620 const ctl_t * ctl,
9621 met_t * met0,
9622 met_t * met1,
9623 const atm_t * atm,
9624 const double t);
9625
9652void write_station(
9653 const char *filename,
9654 const ctl_t * ctl,
9655 atm_t * atm,
9656 const double t);
9657
9686void write_vtk(
9687 const char *filename,
9688 const ctl_t * ctl,
9689 const atm_t * atm,
9690 const double t);
9691
9692/* ------------------------------------------------------------
9693 OpenACC routines...
9694 ------------------------------------------------------------ */
9695
9696#ifdef _OPENACC
9697#pragma acc routine (clim_oh)
9698#pragma acc routine (clim_photo)
9699#pragma acc routine (clim_tropo)
9700#pragma acc routine (clim_ts)
9701#pragma acc routine (clim_zm)
9702#pragma acc routine (cos_sza)
9703#pragma acc routine (dd_calc_subdomain_from_coords)
9704#pragma acc routine (dd_normalize_lon_lat)
9705#pragma acc routine (intpol_check_lon_lat)
9706#pragma acc routine (intpol_met_4d_zeta)
9707#pragma acc routine (intpol_met_space_3d)
9708#pragma acc routine (intpol_met_space_2d)
9709#pragma acc routine (intpol_met_time_3d)
9710#pragma acc routine (intpol_met_time_2d)
9711#pragma acc routine (kernel_weight)
9712#pragma acc routine (lapse_rate)
9713#pragma acc routine (locate_irr)
9714#pragma acc routine (locate_irr_float)
9715#pragma acc routine (locate_reg)
9716#pragma acc routine (locate_vert)
9717#pragma acc routine (nat_temperature)
9718#pragma acc routine (pbl_weight)
9719#pragma acc routine (sedi)
9720#pragma acc routine (stddev)
9721#pragma acc routine (tropo_weight)
9722#endif
9723
9724#endif /* LIBTRAC_H */
void read_met_geopot(const ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:8818
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:5780
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:7453
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:1943
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:8778
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:12198
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:9448
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:13611
void read_met_sample(const ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:11237
void compress_cms(const ctl_t *ctl, const char *varname, float *array, const size_t nx, const size_t ny, const size_t np, const double *plev, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3-D meteorological field using cmultiscale.
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:11582
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:3520
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:5496
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:4745
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:7890
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:8617
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:4131
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:11755
double cos_sza(const double sec, const double lon, const double lat)
Calculates the cosine of the solar zenith angle.
Definition: mptrac.c:1902
#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:2976
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:9770
void compress_sz3(const char *varname, float *array, const int nx, const int ny, const int nz, const double *plev, const int precision, const double tolerance, const int lossy_scale, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3-D float array using the SZ3 library.
void compress_pck(const char *varname, float *array, const size_t nxy, const size_t nz, const double *plev, const int decompress, const int pck_zstd, const int zstd_level, const int zstd_nworkers, FILE *level_log, FILE *inout)
Compresses or decompresses a 3D array of floats.
Definition: mptrac.c:993
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:7857
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:10845
void read_met_detrend(const ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:8674
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:11410
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:11626
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:3968
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:3481
void compress_log_header(FILE *out)
Write the ASCII header for per-level compression diagnostics.
Definition: mptrac.c:757
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:3500
void compress_zstd(const char *varname, float *array, const size_t nxy, const size_t nz, const double *plev, const int decompress, const int level, const int nworkers, FILE *level_log, FILE *inout)
Compresses or decompresses a float array using Zstandard (ZSTD).
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:9251
void read_met_monotonize(const ctl_t *ctl, met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:10544
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:8009
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:10982
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:7187
int compress_metvar_index(const char *varname)
Maps a meteorological variable name to its internal MPTRAC variable index.
Definition: mptrac.c:957
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:5543
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:12680
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:4852
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:403
#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:4924
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:7981
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:10502
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:202
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:11654
double compress_speed_mib(const size_t nbytes, const double dt)
Calculate compression throughput in MiB/s.
Definition: mptrac.c:696
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:8351
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:3417
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:4569
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:3264
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:2746
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:12968
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:7341
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:11856
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:5991
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:3034
#define codes_handle
Placeholder when ECCODES is not available.
Definition: mptrac.h:241
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:2583
void fft_help(double *fcReal, double *fcImag, const int n)
Computes the Fast Fourier Transform (FFT) of a complex sequence.
Definition: mptrac.c:2526
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:5645
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:7653
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:11788
void compress_error_stats(const float *org, const float *cmp, const size_t n, double *mean, double *stddev, double *min, double *max, double *nrmse, double *org_mean, double *range)
Compute error statistics between original and reconstructed data.
Definition: mptrac.c:706
#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:145
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:8063
#define EX
Maximum number of longitudes for meteo data.
Definition: mptrac.h:339
void read_met_nc_grid_dd_naive(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:10669
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:5355
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:10629
void timer(const char *name, const char *group, const int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:11887
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:12013
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:2918
void module_sort(const ctl_t *ctl, const met_t *met0, atm_t *atm)
Sort particles according to box index.
Definition: mptrac.c:5384
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:4010
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:899
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:8162
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:3710
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:11683
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:3683
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:5161
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:5869
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:5458
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:11835
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:3096
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:8380
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:3447
double time_from_filename(const char *filename, const int offset)
Extracts and converts a timestamp from a filename to Julian seconds.
Definition: mptrac.c:11955
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:13672
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:6081
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:3806
double tropo_weight(const clim_t *clim, const atm_t *atm, const int ip)
Computes a weighting factor based on tropopause pressure.
Definition: mptrac.c:11990
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 rho, 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:784
void write_met_nc(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a NetCDF file.
Definition: mptrac.c:13447
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:5219
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:6010
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:7397
void compress_lz4(const char *varname, float *array, const size_t nxy, const size_t nz, const double *plev, const int decompress, const int acceleration, FILE *level_log, FILE *inout)
Compresses or decompresses a float array using LZ4.
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:7562
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:87
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:13339
#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:11208
void broadcast_large_data(void *data, size_t N)
Broadcasts large data across all processes in an MPI communicator.
void read_met_nc_surface(const int ncid, const ctl_t *ctl, met_t *met, dd_t *dd)
Reads and processes surface meteorological data from NetCDF files with domain decomposition.
Definition: mptrac.c:9113
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:230
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:5250
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:14061
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: mptrac.c:72
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:2496
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:3063
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:5110
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:113
void module_dd(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_zfp(const char *varname, float *array, const int nx, const int ny, const int nz, const double *plev, const int precision, const double tolerance, const int lossy_scale, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3D array of floats using the ZFP library.
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:13310
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:11102
#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:7741
#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:4170
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:385
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:3187
int read_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Reads meteorological data from a binary file.
Definition: mptrac.c:8203
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:12145
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:2652
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:4372
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:7797
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:7078
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:14147
#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:5574
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:6141
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:5833
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:11043
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:4487
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:13072
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:7677
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:4247
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:13641
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:4639
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:5026
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:2565
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:8946
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:2676
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:3220
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:938
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:7699
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:2719
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:13899
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:12777
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:4424
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:13202
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:12095
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:8502
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:7513
#define CSZA
Maximum number of solar zenith angles for climatological data.
Definition: mptrac.h:404
double lapse_rate(const double t, const double h2o)
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
Definition: mptrac.c:3246
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:12405
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:12356
Air parcel data.
Definition: mptrac.h:3234
int np
Number of air parcels.
Definition: mptrac.h:3237
Cache data structure.
Definition: mptrac.h:3289
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3301
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3321
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3327
int np
Number of pressure levels.
Definition: mptrac.h:3324
int no3c
Number of total ozone columns.
Definition: mptrac.h:3330
Climatological data.
Definition: mptrac.h:3429
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3471
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3447
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3459
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3450
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3432
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3477
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3465
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3468
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3462
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3456
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3435
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3453
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3474
Climatological data in the form of time series.
Definition: mptrac.h:3377
int ntime
Number of timesteps.
Definition: mptrac.h:3380
Climatological data in the form of zonal means.
Definition: mptrac.h:3397
int np
Number of pressure levels.
Definition: mptrac.h:3406
int ntime
Number of timesteps.
Definition: mptrac.h:3400
int nlat
Number of latitudes.
Definition: mptrac.h:3403
Control parameters.
Definition: mptrac.h:2198
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3098
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2310
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:3059
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2466
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:2947
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2562
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2343
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:3035
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2806
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2289
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2490
int dd_halos_size
Domain decomposition size of halos given in grid-points.
Definition: mptrac.h:3222
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2869
int met_zstd_nworkers
ZSTD number of worker threads (0=single-threaded, default=4).
Definition: mptrac.h:2574
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2893
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2229
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2499
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2238
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2322
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:3029
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2331
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2794
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:3050
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2298
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3176
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2854
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2705
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2866
double stat_r
Search radius around station [km].
Definition: mptrac.h:3182
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:2941
int met_zstd_level
ZSTD compression level (from -5 to 22, default=-3).
Definition: mptrac.h:2571
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:3053
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3206
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2890
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2673
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2319
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:2908
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2758
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2478
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2397
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:3101
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2526
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2484
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2625
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2692
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2361
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2433
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:3044
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:3056
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2740
int met_pbl
Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta).
Definition: mptrac.h:2670
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2313
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2749
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:3086
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3104
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:3000
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2767
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3116
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2244
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2388
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2340
int qnt_Acs137
Quantity array index for radioactive activity of Cs-137.
Definition: mptrac.h:2511
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:3107
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2367
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2689
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2427
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2545
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:2911
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2661
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2734
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2232
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2265
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2409
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2782
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3188
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2731
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3122
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:3047
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2271
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:3092
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2394
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:2899
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2800
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2379
int radio_decay
Switch for radioactive decay module (0=off, 1=on).
Definition: mptrac.h:2935
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2658
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2631
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2241
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2722
int met_pck_zstd
Apply an additional ZSTD compression step to PCK payloads (0=off, 1=on).
Definition: mptrac.h:2580
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2709
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2788
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2247
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:3131
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:3023
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2667
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:3032
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2628
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2902
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2746
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3134
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2304
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2773
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2683
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3140
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2226
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2680
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2235
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2698
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2857
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2436
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2364
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:3041
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3185
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:2920
int dd
Domain decomposition (0=no, 1=yes, with 2x2 if not specified).
Definition: mptrac.h:3213
int qnt_eta
Quantity array index for eta vertical coordinate.
Definition: mptrac.h:2421
double wet_depo_so2_ph
pH value used to calculate effective Henry constant of SO2.
Definition: mptrac.h:2959
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2863
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2385
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:3005
int met_cms_nd0x
cmultiscale number of cells of coarsest grid in x-direction.
Definition: mptrac.h:2607
int met_nlev
Number of meteo data model levels.
Definition: mptrac.h:2649
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:2929
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:2968
int qnt_shf
Quantity array index for surface sensible heat flux.
Definition: mptrac.h:2262
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2253
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2463
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3194
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2532
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2764
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2355
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2559
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2283
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2403
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2779
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2676
int met_dx
Stride for longitudes.
Definition: mptrac.h:2619
int qnt_destination
Quantity array index for destination subdomain in domain decomposition.
Definition: mptrac.h:2523
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2878
int met_convention
Meteo data layout (0=[lev, lat, lon], 1=[lon, lat, lev]).
Definition: mptrac.h:2548
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2415
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:2932
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2535
int diffusion
Diffusion scheme (0=off, 1=fixed-K, 2=PBL).
Definition: mptrac.h:2725
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2451
int qnt_eta_dot
Quantity array index for velocity of eta vertical coordinate.
Definition: mptrac.h:2424
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2445
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2286
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3203
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2301
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2382
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2776
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2695
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2358
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2469
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2646
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2914
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2307
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:3149
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2406
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2295
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3170
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2812
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3014
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2250
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3110
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2493
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2487
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2881
int nens
Number of ensembles.
Definition: mptrac.h:3062
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2274
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2334
int advect
Advection scheme (0=off, 1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2715
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3137
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2292
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:2993
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:2926
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2412
double conv_pbl_trans
Depth of PBL transition layer (fraction of PBL depth).
Definition: mptrac.h:2755
int met_lz4_accel
LZ4 acceleration factor (>=1, default=8).
Definition: mptrac.h:2577
int qnt_Ai131
Quantity array index for radioactive activity of I-131.
Definition: mptrac.h:2514
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:2552
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:3038
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2430
int qnt_Apb210
Quantity array index for radioactive activity of Pb-210.
Definition: mptrac.h:2505
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3179
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2472
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:3113
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2496
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2457
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2637
int conv_mix_pbl
Vertical mixing in the PBL (0=off, 1=on).
Definition: mptrac.h:2752
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2791
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2887
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2346
int qnt_zeta_dot
Quantity array index for velocity of zeta vertical coordinate.
Definition: mptrac.h:2418
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2770
int met_cms_nd0y
cmultiscale number of cells of coarsest grid in y-direction.
Definition: mptrac.h:2610
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2860
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2352
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2785
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2872
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2460
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2448
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:3095
int qnt_nss
Quantity array index for northward turbulent surface stress.
Definition: mptrac.h:2259
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:3068
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:2996
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2664
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2884
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:2990
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3155
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2601
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:2974
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2634
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3143
int qnt_Axe133
Quantity array index for radioactive activity of Xe-133.
Definition: mptrac.h:2517
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2896
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2328
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2376
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2391
int qnt_subdomain
Quantity array index for current subdomain in domain decomposition.
Definition: mptrac.h:2520
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3152
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2349
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:2977
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3146
int met_nc_quant
Number of digits for quantization of netCDF meteo files (0=off).
Definition: mptrac.h:2568
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:2923
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2481
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:2965
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2905
int qnt_Abe7
Quantity array index for radioactive activity of Be-7.
Definition: mptrac.h:2508
int met_cms_zstd
cmultiscale ZSTD compression (0=off, 1=on).
Definition: mptrac.h:2604
int met_cms_maxlev
cmultiscale maximum refinement level.
Definition: mptrac.h:2613
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:3083
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:2971
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2277
int met_np
Number of target pressure levels.
Definition: mptrac.h:2640
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2223
int met_nc_level
zlib compression level of netCDF meteo files (0=off).
Definition: mptrac.h:2565
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2851
int qnt_Arn222
Quantity array index for radioactive activity of Rn-222.
Definition: mptrac.h:2502
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2373
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3200
double turb_dx_pbl
Horizontal turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2728
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2761
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2439
int advect_vert_coord
Vertical velocity of air parcels (0=omega_on_plev, 1=zetadot_on_mlev, 2=omega_on_mlev,...
Definition: mptrac.h:2719
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2370
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2475
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2268
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2875
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:3008
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:2962
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2400
int qnt_ess
Quantity array index for eastward turbulent surface stress.
Definition: mptrac.h:2256
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:2950
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:2944
int met_dy
Stride for latitudes.
Definition: mptrac.h:2622
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2454
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2743
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2797
int dd_subdomains_zonal
Domain decomposition zonal subdomain number.
Definition: mptrac.h:3216
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2220
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2686
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2316
double t_start
Start time of simulation [s].
Definition: mptrac.h:2529
int nq
Number of quantities.
Definition: mptrac.h:2205
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2809
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3167
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3197
double turb_dz_pbl
Vertical turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2737
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3119
int dd_subdomains_meridional
Domain decomposition meridional subdomain number.
Definition: mptrac.h:3219
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2280
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:2556
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2325
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2337
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:3080
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2442
Domain decomposition data structure.
Definition: mptrac.h:3662
int halo_offset_end
Offset of the periodic halo block at the end of the local x-array.
Definition: mptrac.h:3700
int nx_glob
Number of global longitudes.
Definition: mptrac.h:3669
int halo_offset_start
Offset of the periodic halo block at the beginning of the local x-array.
Definition: mptrac.h:3697
int ny_glob
Number of global latitudes.
Definition: mptrac.h:3672
Meteo data structure.
Definition: mptrac.h:3488
int nx
Number of longitudes.
Definition: mptrac.h:3494
int ny
Number of latitudes.
Definition: mptrac.h:3497
int np
Number of pressure levels.
Definition: mptrac.h:3500
int npl
Number of model levels.
Definition: mptrac.h:3503
double time
Time [s].
Definition: mptrac.h:3491
Particle data.
Definition: mptrac.h:3263
double p
Pressure [hPa].
Definition: mptrac.h:3269
double lat
Latitude [deg].
Definition: mptrac.h:3275
double time
Time [s].
Definition: mptrac.h:3266
double lon
Longitude [deg].
Definition: mptrac.h:3272