MPTRAC
mptrac.h
Go to the documentation of this file.
1/*
2 This file is part of MPTRAC.
3
4 MPTRAC is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 MPTRAC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2013-2026 Forschungszentrum Juelich GmbH
18*/
19
166#ifndef LIBTRAC_H
167#define LIBTRAC_H
168
169/* ------------------------------------------------------------
170 Includes...
171 ------------------------------------------------------------ */
172
173#include <ctype.h>
174#include <gsl/gsl_fft_complex.h>
175#include <gsl/gsl_math.h>
176#include <gsl/gsl_randist.h>
177#include <gsl/gsl_rng.h>
178#include <gsl/gsl_sort.h>
179#include <gsl/gsl_spline.h>
180#include <gsl/gsl_statistics.h>
181#include <math.h>
182#include <netcdf.h>
183#include <omp.h>
184#include <stdint.h>
185#include <stdio.h>
186#include <stdlib.h>
187#include <string.h>
188#include <time.h>
189#include <sys/time.h>
190
191#ifdef MPI
192#include "mpi.h"
193#endif
194
195#ifdef DD
196#include <netcdf_par.h>
197#endif
198
199#ifdef _OPENACC
200#include "openacc.h"
201#endif
202
203#ifdef CURAND
204#include "curand.h"
205#endif
206
207#ifdef THRUST
208#include "thrustsort.h"
209#endif
210
211#ifdef ZFP
212#include "zfp.h"
213#endif
214
215#ifdef ZSTD
216#include "zstd.h"
217#endif
218
219#ifdef LZ4
220#include "lz4.h"
221#endif
222
223#ifdef SZ3
224#include "SZ3c/sz3c.h"
225#endif
226
227#ifdef CMS
228#include "cmultiscale.h"
229#endif
230
231#ifdef KPP
232#include "chem_Parameters.h"
233#include "chem_Global.h"
234#include "chem_Sparse.h"
235#endif
236
237#ifdef ECCODES
238#include "eccodes.h"
239#else
241#define codes_handle void*
242#endif
243
244/* ------------------------------------------------------------
245 Constants...
246 ------------------------------------------------------------ */
247
249#ifndef AVO
250#define AVO 6.02214076e23
251#endif
252
254#ifndef CPD
255#define CPD 1003.5
256#endif
257
259#ifndef EPS
260#define EPS (MH2O / MA)
261#endif
262
264#ifndef G0
265#define G0 9.80665
266#endif
267
269#ifndef H0
270#define H0 7.0
271#endif
272
274#ifndef LV
275#define LV 2501000.
276#endif
277
279#ifndef KARMAN
280#define KARMAN 0.40
281#endif
282
284#ifndef KB
285#define KB 1.3806504e-23
286#endif
287
289#ifndef MA
290#define MA 28.9644
291#endif
292
294#ifndef MH2O
295#define MH2O 18.01528
296#endif
297
299#ifndef MO3
300#define MO3 48.00
301#endif
302
304#ifndef P0
305#define P0 1013.25
306#endif
307
309#ifndef RA
310#define RA (1e3 * RI / MA)
311#endif
312
314#ifndef RE
315#define RE 6367.421
316#endif
317
319#ifndef RI
320#define RI 8.3144598
321#endif
322
324#ifndef T0
325#define T0 273.15
326#endif
327
328/* ------------------------------------------------------------
329 Dimensions...
330 ------------------------------------------------------------ */
331
333#ifndef EP
334#define EP 140
335#endif
336
338#ifndef EX
339#define EX 1444
340#endif
341
343#ifndef EY
344#define EY 724
345#endif
346
348#ifndef LEN
349#define LEN 5000
350#endif
351
353#ifndef METVAR
354#define METVAR 13
355#endif
356
358#ifndef NP
359#define NP 10000000
360#endif
361
363#ifndef NQ
364#define NQ 15
365#endif
366
368#ifndef NCSI
369#define NCSI 1000000
370#endif
371
373#ifndef NENS
374#define NENS 2000
375#endif
376
378#ifndef NOBS
379#define NOBS 10000000
380#endif
381
383#ifndef NTHREADS
384#define NTHREADS 512
385#endif
386
388#ifndef CY
389#define CY 250
390#endif
391
393#ifndef CO3
394#define CO3 30
395#endif
396
398#ifndef CP
399#define CP 70
400#endif
401
403#ifndef CSZA
404#define CSZA 50
405#endif
406
408#ifndef CT
409#define CT 12
410#endif
411
413#ifndef CTS
414#define CTS 1000
415#endif
416
418#ifndef DD_EX_GLOB
419#define DD_EX_GLOB (EX * 16)
420#endif
421
423#ifndef DD_EY_GLOB
424#define DD_EY_GLOB (EY * 16)
425#endif
426
427/* ------------------------------------------------------------
428 Macros...
429 ------------------------------------------------------------ */
430
450#ifdef _OPENACC
451#define ALLOC(ptr, type, n) \
452 if(acc_get_num_devices(acc_device_nvidia) <= 0) \
453 ERRMSG("Not running on a GPU device!"); \
454 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
455 ERRMSG("Out of memory!");
456#else
457#define ALLOC(ptr, type, n) \
458 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
459 ERRMSG("Out of memory!");
460#endif
461
480#define ARRAY_2D(ix, iy, ny) \
481 ((ix) * (ny) + (iy))
482
499#define ARRAY_3D(ix, iy, ny, iz, nz) \
500 (((ix)*(ny) + (iy)) * (nz) + (iz))
501
524#define ARRHENIUS(a, b, t) \
525 ((a) * exp( -(b) / (t)))
526
546#define CLAMP(v, lo, hi) \
547 (((v) < (lo)) ? (lo) : (((v) > (hi)) ? (hi) : (v)))
548
561#define COMPRESS_SPEED(nbytes, dt) \
562 ((dt) > 0 ? ((double)(nbytes)) / ((dt) * 1024. * 1024.) : NAN)
563
585#define DEG2DX(dlon, lat) \
586 (RE * DEG2RAD(dlon) * cos(DEG2RAD(lat)))
587
606#define DEG2DY(dlat) \
607 (RE * DEG2RAD(dlat))
608
623#define DEG2RAD(deg) \
624 ((deg) * (M_PI / 180.0))
625
648#define DP2DZ(dp, p) \
649 (- (dp) * H0 / (p))
650
670#define DX2DEG(dx, lat) \
671 (((lat) < -89.999 || (lat) > 89.999) ? 0 \
672 : (dx) * 180. / (M_PI * RE * cos(DEG2RAD(lat))))
673
688#define DY2DEG(dy) \
689 ((dy) * 180. / (M_PI * RE))
690
707#define DZ2DP(dz, p) \
708 (-(dz) * (p) / H0)
709
732#define DX2COORD(met, dx, lat) (((met)->coord_type == 0)? DX2DEG((dx) / 1000.0, (lat)) : ((dx) ))
733
755#define DY2COORD(met, dy) (((met)->coord_type == 0)? DY2DEG((dy) / 1000.0) : ((dy) ))
756
770#define DIST(a, b) \
771 sqrt(DIST2(a, b))
772
786#define DIST2(a, b) \
787 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
788
802#define DOTP(a, b) \
803 (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
804
816#define ECC(cmd) { \
817 int ecc_result=(cmd); \
818 if(ecc_result!=0) \
819 ERRMSG("ECCODES error: %s", codes_get_error_message(ecc_result)); \
820 }
821
835#define ECC_READ_2D(variable, target, scaling_factor, found_flag) { \
836 if(strcmp(short_name, variable) == 0) { \
837 if ((found_flag) == 0) \
838 LOG(2, "Read 2-D variable: %s (GRIB)", variable); \
839 for (int ix = 0; ix < met->nx; ix++) \
840 for (int iy = 0; iy < met->ny; iy++) \
841 target[ix][iy] = (float)(values[iy * met->nx + ix] * scaling_factor); \
842 found_flag = 1; \
843 } \
844 }
845
860#define ECC_READ_3D(variable, level, target, scaling_factor, found_flag) { \
861 if(strcmp(short_name, variable) == 0) { \
862 if ((found_flag) == 0) \
863 LOG(2, "Read 3-D variable: %s (GRIB)", variable); \
864 for (int ix = 0; ix < met->nx; ix++) \
865 for (int iy = 0; iy < met->ny; iy++) \
866 target[ix][iy][level] = (float) (values[iy * met->nx + ix] * scaling_factor); \
867 found_flag += 1; \
868 } \
869 }
870
887#define FMOD(x, y) \
888 ((x) - (int) ((x) / (y)) * (y))
889
905#define FREAD(ptr, type, size, in) { \
906 if(fread(ptr, sizeof(type), size, in)!=size) \
907 ERRMSG("Error while reading!"); \
908 }
909
925#define FWRITE(ptr, type, size, out) { \
926 if(fwrite(ptr, sizeof(type), size, out)!=size) \
927 ERRMSG("Error while writing!"); \
928 }
929
940#define INTPOL_INIT \
941 double cw[4] = {0.0, 0.0, 0.0, 0.0}; int ci[3] = {0, 0, 0};
942
954#define INTPOL_2D(var, init) \
955 intpol_met_time_2d(met0, met0->var, met1, met1->var, \
956 atm->time[ip], atm->lon[ip], atm->lat[ip], \
957 &var, ci, cw, init);
958
971#define INTPOL_3D(var, init) \
972 intpol_met_time_3d(met0, met0->var, met1, met1->var, \
973 atm->time[ip], atm->p[ip], \
974 atm->lon[ip], atm->lat[ip], \
975 &var, ci, cw, init);
976
990#define INTPOL_SPACE_ALL(p, lon, lat) { \
991 intpol_met_space_3d(met, met->z, p, lon, lat, &z, ci, cw, 1); \
992 intpol_met_space_3d(met, met->t, p, lon, lat, &t, ci, cw, 0); \
993 intpol_met_space_3d(met, met->u, p, lon, lat, &u, ci, cw, 0); \
994 intpol_met_space_3d(met, met->v, p, lon, lat, &v, ci, cw, 0); \
995 intpol_met_space_3d(met, met->w, p, lon, lat, &w, ci, cw, 0); \
996 intpol_met_space_3d(met, met->pv, p, lon, lat, &pv, ci, cw, 0); \
997 intpol_met_space_3d(met, met->h2o, p, lon, lat, &h2o, ci, cw, 0); \
998 intpol_met_space_3d(met, met->o3, p, lon, lat, &o3, ci, cw, 0); \
999 intpol_met_space_3d(met, met->lwc, p, lon, lat, &lwc, ci, cw, 0); \
1000 intpol_met_space_3d(met, met->rwc, p, lon, lat, &rwc, ci, cw, 0); \
1001 intpol_met_space_3d(met, met->iwc, p, lon, lat, &iwc, ci, cw, 0); \
1002 intpol_met_space_3d(met, met->swc, p, lon, lat, &swc, ci, cw, 0); \
1003 intpol_met_space_3d(met, met->cc, p, lon, lat, &cc, ci, cw, 0); \
1004 intpol_met_space_2d(met, met->ps, lon, lat, &ps, ci, cw, 0); \
1005 intpol_met_space_2d(met, met->ts, lon, lat, &ts, ci, cw, 0); \
1006 intpol_met_space_2d(met, met->zs, lon, lat, &zs, ci, cw, 0); \
1007 intpol_met_space_2d(met, met->us, lon, lat, &us, ci, cw, 0); \
1008 intpol_met_space_2d(met, met->vs, lon, lat, &vs, ci, cw, 0); \
1009 intpol_met_space_2d(met, met->ess, ess, lat, &ess, ci, cw, 0); \
1010 intpol_met_space_2d(met, met->nss, nss, lat, &nss, ci, cw, 0); \
1011 intpol_met_space_2d(met, met->shf, shf, lat, &shf, ci, cw, 0); \
1012 intpol_met_space_2d(met, met->lsm, lon, lat, &lsm, ci, cw, 0); \
1013 intpol_met_space_2d(met, met->sst, lon, lat, &sst, ci, cw, 0); \
1014 intpol_met_space_2d(met, met->pbl, lon, lat, &pbl, ci, cw, 0); \
1015 intpol_met_space_2d(met, met->pt, lon, lat, &pt, ci, cw, 0); \
1016 intpol_met_space_2d(met, met->tt, lon, lat, &tt, ci, cw, 0); \
1017 intpol_met_space_2d(met, met->zt, lon, lat, &zt, ci, cw, 0); \
1018 intpol_met_space_2d(met, met->h2ot, lon, lat, &h2ot, ci, cw, 0); \
1019 intpol_met_space_2d(met, met->pct, lon, lat, &pct, ci, cw, 0); \
1020 intpol_met_space_2d(met, met->pcb, lon, lat, &pcb, ci, cw, 0); \
1021 intpol_met_space_2d(met, met->cl, lon, lat, &cl, ci, cw, 0); \
1022 intpol_met_space_2d(met, met->plcl, lon, lat, &plcl, ci, cw, 0); \
1023 intpol_met_space_2d(met, met->plfc, lon, lat, &plfc, ci, cw, 0); \
1024 intpol_met_space_2d(met, met->pel, lon, lat, &pel, ci, cw, 0); \
1025 intpol_met_space_2d(met, met->cape, lon, lat, &cape, ci, cw, 0); \
1026 intpol_met_space_2d(met, met->cin, lon, lat, &cin, ci, cw, 0); \
1027 intpol_met_space_2d(met, met->o3c, lon, lat, &o3c, ci, cw, 0); \
1028 }
1029
1044#define INTPOL_TIME_ALL(time, p, lon, lat) { \
1045 intpol_met_time_3d(met0, met0->z, met1, met1->z, time, p, lon, lat, &z, ci, cw, 1); \
1046 intpol_met_time_3d(met0, met0->t, met1, met1->t, time, p, lon, lat, &t, ci, cw, 0); \
1047 intpol_met_time_3d(met0, met0->u, met1, met1->u, time, p, lon, lat, &u, ci, cw, 0); \
1048 intpol_met_time_3d(met0, met0->v, met1, met1->v, time, p, lon, lat, &v, ci, cw, 0); \
1049 intpol_met_time_3d(met0, met0->w, met1, met1->w, time, p, lon, lat, &w, ci, cw, 0); \
1050 intpol_met_time_3d(met0, met0->pv, met1, met1->pv, time, p, lon, lat, &pv, ci, cw, 0); \
1051 intpol_met_time_3d(met0, met0->h2o, met1, met1->h2o, time, p, lon, lat, &h2o, ci, cw, 0); \
1052 intpol_met_time_3d(met0, met0->o3, met1, met1->o3, time, p, lon, lat, &o3, ci, cw, 0); \
1053 intpol_met_time_3d(met0, met0->lwc, met1, met1->lwc, time, p, lon, lat, &lwc, ci, cw, 0); \
1054 intpol_met_time_3d(met0, met0->rwc, met1, met1->rwc, time, p, lon, lat, &rwc, ci, cw, 0); \
1055 intpol_met_time_3d(met0, met0->iwc, met1, met1->iwc, time, p, lon, lat, &iwc, ci, cw, 0); \
1056 intpol_met_time_3d(met0, met0->swc, met1, met1->swc, time, p, lon, lat, &swc, ci, cw, 0); \
1057 intpol_met_time_3d(met0, met0->cc, met1, met1->cc, time, p, lon, lat, &cc, ci, cw, 0); \
1058 intpol_met_time_2d(met0, met0->ps, met1, met1->ps, time, lon, lat, &ps, ci, cw, 0); \
1059 intpol_met_time_2d(met0, met0->ts, met1, met1->ts, time, lon, lat, &ts, ci, cw, 0); \
1060 intpol_met_time_2d(met0, met0->zs, met1, met1->zs, time, lon, lat, &zs, ci, cw, 0); \
1061 intpol_met_time_2d(met0, met0->us, met1, met1->us, time, lon, lat, &us, ci, cw, 0); \
1062 intpol_met_time_2d(met0, met0->vs, met1, met1->vs, time, lon, lat, &vs, ci, cw, 0); \
1063 intpol_met_time_2d(met0, met0->ess, met1, met1->ess, time, lon, lat, &ess, ci, cw, 0); \
1064 intpol_met_time_2d(met0, met0->nss, met1, met1->nss, time, lon, lat, &nss, ci, cw, 0); \
1065 intpol_met_time_2d(met0, met0->shf, met1, met1->shf, time, lon, lat, &shf, ci, cw, 0); \
1066 intpol_met_time_2d(met0, met0->lsm, met1, met1->lsm, time, lon, lat, &lsm, ci, cw, 0); \
1067 intpol_met_time_2d(met0, met0->sst, met1, met1->sst, time, lon, lat, &sst, ci, cw, 0); \
1068 intpol_met_time_2d(met0, met0->pbl, met1, met1->pbl, time, lon, lat, &pbl, ci, cw, 0); \
1069 intpol_met_time_2d(met0, met0->pt, met1, met1->pt, time, lon, lat, &pt, ci, cw, 0); \
1070 intpol_met_time_2d(met0, met0->tt, met1, met1->tt, time, lon, lat, &tt, ci, cw, 0); \
1071 intpol_met_time_2d(met0, met0->zt, met1, met1->zt, time, lon, lat, &zt, ci, cw, 0); \
1072 intpol_met_time_2d(met0, met0->h2ot, met1, met1->h2ot, time, lon, lat, &h2ot, ci, cw, 0); \
1073 intpol_met_time_2d(met0, met0->pct, met1, met1->pct, time, lon, lat, &pct, ci, cw, 0); \
1074 intpol_met_time_2d(met0, met0->pcb, met1, met1->pcb, time, lon, lat, &pcb, ci, cw, 0); \
1075 intpol_met_time_2d(met0, met0->cl, met1, met1->cl, time, lon, lat, &cl, ci, cw, 0); \
1076 intpol_met_time_2d(met0, met0->plcl, met1, met1->plcl, time, lon, lat, &plcl, ci, cw, 0); \
1077 intpol_met_time_2d(met0, met0->plfc, met1, met1->plfc, time, lon, lat, &plfc, ci, cw, 0); \
1078 intpol_met_time_2d(met0, met0->pel, met1, met1->pel, time, lon, lat, &pel, ci, cw, 0); \
1079 intpol_met_time_2d(met0, met0->cape, met1, met1->cape, time, lon, lat, &cape, ci, cw, 0); \
1080 intpol_met_time_2d(met0, met0->cin, met1, met1->cin, time, lon, lat, &cin, ci, cw, 0); \
1081 intpol_met_time_2d(met0, met0->o3c, met1, met1->o3c, time, lon, lat, &o3c, ci, cw, 0); \
1082 }
1083
1098#define LAPSE(p1, t1, p2, t2) \
1099 (1e3 * G0 / RA * ((t2) - (t1)) / ((t2) + (t1)) \
1100 * ((p2) + (p1)) / ((p2) - (p1)))
1101
1117#define LIN(x0, y0, x1, y1, x) \
1118 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
1119
1144#define MAX(a,b) \
1145 (((a)>(b))?(a):(b))
1146
1158#define MET_HEADER \
1159 fprintf(out, \
1160 "# $1 = time [s]\n" \
1161 "# $2 = altitude [km]\n" \
1162 "# $3 = longitude [deg]\n" \
1163 "# $4 = latitude [deg]\n" \
1164 "# $5 = pressure [hPa]\n" \
1165 "# $6 = temperature [K]\n" \
1166 "# $7 = zonal wind [m/s]\n" \
1167 "# $8 = meridional wind [m/s]\n" \
1168 "# $9 = vertical velocity [hPa/s]\n" \
1169 "# $10 = H2O volume mixing ratio [ppv]\n"); \
1170 fprintf(out, \
1171 "# $11 = O3 volume mixing ratio [ppv]\n" \
1172 "# $12 = geopotential height [km]\n" \
1173 "# $13 = potential vorticity [PVU]\n" \
1174 "# $14 = surface pressure [hPa]\n" \
1175 "# $15 = surface temperature [K]\n" \
1176 "# $16 = surface geopotential height [km]\n" \
1177 "# $17 = surface zonal wind [m/s]\n" \
1178 "# $18 = surface meridional wind [m/s]\n" \
1179 "# $19 = eastward turbulent surface stress [N/m^2]\n" \
1180 "# $20 = northward turbulent surface stress [N/m^2]\n"); \
1181 fprintf(out, \
1182 "# $21 = surface sensible heat flux [W/m^2]\n" \
1183 "# $22 = land-sea mask [1]\n" \
1184 "# $23 = sea surface temperature [K]\n" \
1185 "# $24 = tropopause pressure [hPa]\n" \
1186 "# $25 = tropopause geopotential height [km]\n" \
1187 "# $26 = tropopause temperature [K]\n" \
1188 "# $27 = tropopause water vapor [ppv]\n" \
1189 "# $28 = cloud liquid water content [kg/kg]\n" \
1190 "# $29 = cloud rain water content [kg/kg]\n" \
1191 "# $30 = cloud ice water content [kg/kg]\n"); \
1192 fprintf(out, \
1193 "# $31 = cloud snow water content [kg/kg]\n" \
1194 "# $32 = cloud cover [1]\n" \
1195 "# $33 = total column cloud water [kg/m^2]\n" \
1196 "# $34 = cloud top pressure [hPa]\n" \
1197 "# $35 = cloud bottom pressure [hPa]\n" \
1198 "# $36 = pressure at lifted condensation level (LCL) [hPa]\n" \
1199 "# $37 = pressure at level of free convection (LFC) [hPa]\n" \
1200 "# $38 = pressure at equilibrium level (EL) [hPa]\n" \
1201 "# $39 = convective available potential energy (CAPE) [J/kg]\n" \
1202 "# $40 = convective inhibition (CIN) [J/kg]\n"); \
1203 fprintf(out, \
1204 "# $41 = relative humidity over water [%%]\n" \
1205 "# $42 = relative humidity over ice [%%]\n" \
1206 "# $43 = dew point temperature [K]\n" \
1207 "# $44 = frost point temperature [K]\n" \
1208 "# $45 = NAT temperature [K]\n" \
1209 "# $46 = HNO3 volume mixing ratio [ppv]\n" \
1210 "# $47 = OH volume mixing ratio [ppv]\n" \
1211 "# $48 = H2O2 volume mixing ratio [ppv]\n" \
1212 "# $49 = HO2 volume mixing ratio [ppv]\n" \
1213 "# $50 = O(1D) volume mixing ratio [ppv]\n"); \
1214 fprintf(out, \
1215 "# $51 = boundary layer pressure [hPa]\n" \
1216 "# $52 = total column ozone [DU]\n" \
1217 "# $53 = number of data points\n" \
1218 "# $54 = number of tropopause data points\n" \
1219 "# $55 = number of CAPE data points\n");
1220
1245#define MIN(a,b) \
1246 (((a)<(b))?(a):(b))
1247
1260#define MOLEC_DENS(p,t) \
1261 (AVO * 1e-6 * ((p) * 100) / (RI * (t)))
1262
1274#define NC(cmd) { \
1275 int nc_result=(cmd); \
1276 if(nc_result!=NC_NOERR) \
1277 ERRMSG("%s", nc_strerror(nc_result)); \
1278 }
1279
1303#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units, level, quant) { \
1304 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
1305 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
1306 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
1307 if((quant) > 0) \
1308 NC(nc_def_var_quantize(ncid, varid, NC_QUANTIZE_GRANULARBR, quant)); \
1309 if((level) != 0) { \
1310 NC(nc_def_var_deflate(ncid, varid, 1, 1, level)); \
1311 /* unsigned int ulevel = (unsigned int)level; */ \
1312 /* NC(nc_def_var_filter(ncid, varid, 32015, 1, (unsigned int[]){ulevel})); */ \
1313 } \
1314 }
1315
1333#define NC_GET_DOUBLE(varname, ptr, force) { \
1334 if(force) { \
1335 NC(nc_inq_varid(ncid, varname, &varid)); \
1336 NC(nc_get_var_double(ncid, varid, ptr)); \
1337 } else { \
1338 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
1339 NC(nc_get_var_double(ncid, varid, ptr)); \
1340 } else \
1341 WARN("netCDF variable %s is missing!", varname); \
1342 } \
1343 }
1344
1363#define NC_INQ_DIM(dimname, ptr, min, max, check) { \
1364 int dimid; size_t naux; \
1365 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
1366 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
1367 *ptr = (int)naux; \
1368 if (check) \
1369 if ((*ptr) < (min) || (*ptr) > (max)) \
1370 ERRMSG("Dimension %s is out of range!", dimname); \
1371 }
1372
1387#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
1388 NC(nc_inq_varid(ncid, varname, &varid)); \
1389 if(hyperslab) { \
1390 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
1391 } else { \
1392 NC(nc_put_var_double(ncid, varid, ptr)); \
1393 } \
1394 }
1395
1411#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
1412 NC(nc_inq_varid(ncid, varname, &varid)); \
1413 if(hyperslab) { \
1414 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
1415 } else { \
1416 NC(nc_put_var_float(ncid, varid, ptr)); \
1417 } \
1418 }
1419
1434#define NC_PUT_INT(varname, ptr, hyperslab) { \
1435 NC(nc_inq_varid(ncid, varname, &varid)); \
1436 if(hyperslab) { \
1437 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
1438 } else { \
1439 NC(nc_put_var_int(ncid, varid, ptr)); \
1440 } \
1441 }
1442
1456#define NC_PUT_ATT(varname, attname, text) { \
1457 NC(nc_inq_varid(ncid, varname, &varid)); \
1458 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
1459 }
1460
1473#define NC_PUT_ATT_GLOBAL(attname, text) \
1474 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
1475
1493#define NN(x0, y0, x1, y1, x) \
1494 (fabs((x) - (x0)) <= fabs((x) - (x1)) ? (y0) : (y1))
1495
1511#ifdef _OPENACC
1512#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1513 const int ip0_const = ip0; \
1514 const int ip1_const = ip1; \
1515 _Pragma(__VA_ARGS__) \
1516 _Pragma("acc parallel loop independent gang vector") \
1517 for (int ip = ip0_const; ip < ip1_const; ip++) \
1518 if (!check_dt || cache->dt[ip] != 0)
1519#else
1520#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1521 const int ip0_const = ip0; \
1522 const int ip1_const = ip1; \
1523 _Pragma("omp parallel for default(shared)") \
1524 for (int ip = ip0_const; ip < ip1_const; ip++) \
1525 if (!check_dt || cache->dt[ip] != 0)
1526#endif
1527
1550#define P(z) \
1551 (P0 * exp(-(z) / H0))
1552
1574#define PSAT(t) \
1575 (6.112 * exp(17.62 * ((t) - T0) / (243.12 + (t) - T0)))
1576
1598#define PSICE(t) \
1599 (6.112 * exp(22.46 * ((t) - T0) / (272.62 + (t) - T0)))
1600
1625#define PW(p, h2o) \
1626 ((p) * MAX((h2o), 0.1e-6) / (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1627
1642#define RAD2DEG(rad) \
1643 ((rad) * (180.0 / M_PI))
1644
1672#define RH(p, t, h2o) \
1673 (PW(p, h2o) / PSAT(t) * 100.)
1674
1702#define RHICE(p, t, h2o) \
1703 (PW(p, h2o) / PSICE(t) * 100.)
1704
1727#define RHO(p, t) \
1728 (100. * (p) / (RA * (t)))
1729
1746#define SET_ATM(qnt, val) \
1747 if (ctl->qnt >= 0) \
1748 atm->q[ctl->qnt][ip] = val;
1749
1769#define SET_QNT(qnt, name, longname, unit) \
1770 if (strcasecmp(ctl->qnt_name[iq], name) == 0) { \
1771 ctl->qnt = iq; \
1772 sprintf(ctl->qnt_longname[iq], longname); \
1773 sprintf(ctl->qnt_unit[iq], unit); \
1774 } else
1775
1790#define SH(h2o) \
1791 (EPS * MAX((h2o), 0.1e-6))
1792
1803#define SQR(x) \
1804 ((x)*(x))
1805
1817#define SWAP(x, y, type) \
1818 do {type tmp = x; x = y; y = tmp;} while(0);
1819
1841#define TDEW(p, h2o) \
1842 (T0 + 243.12 * log(PW((p), (h2o)) / 6.112) \
1843 / (17.62 - log(PW((p), (h2o)) / 6.112)))
1844
1866#define TICE(p, h2o) \
1867 (T0 + 272.62 * log(PW((p), (h2o)) / 6.112) \
1868 / (22.46 - log(PW((p), (h2o)) / 6.112)))
1869
1890#define THETA(p, t) \
1891 ((t) * pow(1000. / (p), 0.286))
1892
1919#define THETAVIRT(p, t, h2o) \
1920 (TVIRT(THETA((p), (t)), MAX((h2o), 0.1e-6)))
1921
1940#define TOK(line, tok, format, var) { \
1941 if(((tok)=strtok((line), " \t"))) { \
1942 if(sscanf(tok, format, &(var))!=1) continue; \
1943 } else ERRMSG("Error while reading!"); \
1944 }
1945
1965#define TVIRT(t, h2o) \
1966 ((t) * (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1967
1979#define USAGE \
1980 do { \
1981 int iusage; \
1982 for (iusage = 1; iusage < argc; iusage++) \
1983 if (!strcmp(argv[iusage], "-h") \
1984 || !strcmp(argv[iusage], "--help")) { \
1985 usage(); \
1986 return EXIT_SUCCESS; \
1987 } \
1988 } while (0)
1989
2009#define Z(p) \
2010 (H0 * log(P0 / (p)))
2011
2040#define ZDIFF(lnp0, t0, h2o0, lnp1, t1, h2o1) \
2041 (RI / MA / G0 * 0.5 * (TVIRT((t0), (h2o0)) + TVIRT((t1), (h2o1))) \
2042 * ((lnp0) - (lnp1)))
2043
2059#define ZETA(ps, p, t) \
2060 (((p) / (ps) <= 0.3 ? 1. : \
2061 sin(M_PI / 2. * (1. - (p) / (ps)) / (1. - 0.3))) \
2062 * THETA((p), (t)))
2063
2064/* ------------------------------------------------------------
2065 Log messages...
2066 ------------------------------------------------------------ */
2067
2069#ifndef LOGLEV
2070#define LOGLEV 2
2071#endif
2072
2102#define LOG(level, ...) { \
2103 if(level >= 2) \
2104 printf(" "); \
2105 if(level <= LOGLEV) { \
2106 printf(__VA_ARGS__); \
2107 printf("\n"); \
2108 } \
2109 }
2110
2139#define WARN(...) { \
2140 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2141 LOG(0, __VA_ARGS__); \
2142 }
2143
2172#define ERRMSG(...) { \
2173 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
2174 LOG(0, __VA_ARGS__); \
2175 exit(EXIT_FAILURE); \
2176 }
2177
2207#define PRINT(format, var) \
2208 printf("Print (%s, %s, l%d): %s= "format"\n", \
2209 __FILE__, __func__, __LINE__, #var, var);
2210
2211/* ------------------------------------------------------------
2212 Timers...
2213 ------------------------------------------------------------ */
2214
2216#define NTIMER 100
2217
2231#define PRINT_TIMERS \
2232 timer("END", "END", 1);
2233
2246#define SELECT_TIMER(id, group) \
2247 timer(id, group, 0);
2248
2249/* ------------------------------------------------------------
2250 Structs...
2251 ------------------------------------------------------------ */
2252
2260typedef struct {
2261
2262 /* ------------------------------------------------------------
2263 Quantity parameters...
2264 ------------------------------------------------------------ */
2265
2267 int nq;
2268
2270 char qnt_name[NQ][LEN];
2271
2273 char qnt_longname[NQ][LEN];
2274
2276 char qnt_unit[NQ][LEN];
2277
2279 char qnt_format[NQ][LEN];
2280
2283
2286
2289
2292
2295
2298
2301
2304
2307
2310
2313
2316
2319
2322
2325
2328
2331
2334
2337
2340
2343
2346
2349
2352
2355
2358
2361
2364
2367
2370
2373
2376
2379
2382
2385
2388
2391
2394
2397
2400
2403
2406
2409
2412
2415
2418
2421
2424
2427
2430
2433
2436
2439
2442
2445
2448
2451
2454
2457
2460
2463
2466
2469
2472
2475
2478
2481
2484
2487
2490
2493
2496
2499
2502
2505
2508
2511
2514
2517
2520
2523
2526
2529
2532
2535
2538
2541
2544
2547
2550
2553
2556
2559
2562
2565
2568
2571
2574
2577
2580
2583
2586
2589
2591 double t_start;
2592
2594 double t_stop;
2595
2597 double dt_mod;
2598
2599 /* ------------------------------------------------------------
2600 Meteo data parameters...
2601 ------------------------------------------------------------ */
2602
2604 char metbase[LEN];
2605
2607 double dt_met;
2608
2611
2614
2617
2620
2624
2627
2631
2634
2637
2640
2643
2646
2649
2652
2655
2657 int met_zfp_prec[METVAR];
2658
2660 double met_zfp_tol[METVAR];
2661
2663 int met_sz3_prec[METVAR];
2664
2666 double met_sz3_tol[METVAR];
2667
2669 int met_lossy_scale[METVAR];
2670
2672 char met_comp_logfile[LEN];
2673
2676
2679
2682
2685
2688
2690 double met_cms_eps[METVAR];
2691
2694
2697
2700
2703
2706
2709
2712
2715
2717 double met_p[EP];
2718
2721
2724
2726 double met_lev_hyam[EP];
2727
2729 double met_lev_hybm[EP];
2730
2733
2736
2739
2742
2745
2748
2751
2755
2758
2761
2764
2767
2770
2773
2774 /* ------------------------------------------------------------
2775 Geophysical module parameters...
2776 ------------------------------------------------------------ */
2777
2779 double sort_dt;
2780
2784
2786 char balloon[LEN];
2787
2790
2794
2797
2800
2803
2806
2809
2812
2815
2818
2821
2824
2827
2830
2833
2836
2839
2841 double conv_cin;
2842
2844 double conv_dt;
2845
2848
2851
2854
2857
2860
2863
2865 double bound_p0;
2866
2868 double bound_p1;
2869
2872
2875
2878
2881
2883 char species[LEN];
2884
2886 double molmass;
2887
2890
2893
2896
2898 char clim_hno3_filename[LEN];
2899
2901 char clim_oh_filename[LEN];
2902
2904 char clim_h2o2_filename[LEN];
2905
2907 char clim_ho2_filename[LEN];
2908
2910 char clim_o1d_filename[LEN];
2911
2913 char clim_o3_filename[LEN];
2914
2916 char clim_ccl4_timeseries[LEN];
2917
2919 char clim_ccl3f_timeseries[LEN];
2920
2922 char clim_ccl2f2_timeseries[LEN];
2923
2925 char clim_n2o_timeseries[LEN];
2926
2928 char clim_sf6_timeseries[LEN];
2929
2932
2935
2938
2941
2944
2947
2950
2953
2956
2959
2962
2965
2968
2971
2974
2977
2980
2983
2986
2989
2992
2995
2997 double oh_chem[4];
2998
3001
3004
3007
3009 double dt_kpp;
3010
3013
3016
3018 double wet_depo_pre[2];
3019
3022
3025
3028
3031
3033 double wet_depo_ic_h[2];
3034
3036 double wet_depo_bc_h[2];
3037
3040
3043
3046
3049
3052
3054 double psc_h2o;
3055
3057 double psc_hno3;
3058
3059 /* ------------------------------------------------------------
3060 Output parameters...
3061 ------------------------------------------------------------ */
3062
3064 char atm_basename[LEN];
3065
3067 char atm_gpfile[LEN];
3068
3071
3074
3077
3081
3086
3089
3091 int atm_nc_quant[NQ];
3092
3095
3097 char csi_basename[LEN];
3098
3100 char csi_kernel[LEN];
3101
3104
3106 char csi_obsfile[LEN];
3107
3110
3113
3116
3118 double csi_z0;
3119
3121 double csi_z1;
3122
3125
3127 double csi_lon0;
3128
3130 double csi_lon1;
3131
3134
3136 double csi_lat0;
3137
3139 double csi_lat1;
3140
3142 int nens;
3143
3145 char ens_basename[LEN];
3146
3149
3151 char grid_basename[LEN];
3152
3154 char grid_kernel[LEN];
3155
3157 char grid_gpfile[LEN];
3158
3161
3164
3167
3169 int grid_nc_quant[NQ];
3170
3173
3176
3178 double grid_z0;
3179
3181 double grid_z1;
3182
3185
3188
3191
3194
3197
3200
3203
3205 char prof_basename[LEN];
3206
3208 char prof_obsfile[LEN];
3209
3212
3214 double prof_z0;
3215
3217 double prof_z1;
3218
3221
3224
3227
3230
3233
3236
3238 char sample_basename[LEN];
3239
3241 char sample_kernel[LEN];
3242
3244 char sample_obsfile[LEN];
3245
3248
3251
3253 char stat_basename[LEN];
3254
3256 double stat_lon;
3257
3259 double stat_lat;
3260
3262 double stat_r;
3263
3265 double stat_t0;
3266
3268 double stat_t1;
3269
3271 char vtk_basename[LEN];
3272
3275
3278
3281
3284
3287
3288 /* ------------------------------------------------------------
3289 Domain decomposition...
3290 ------------------------------------------------------------ */
3291
3293 int dd;
3294
3297
3300
3303
3306
3307} ctl_t;
3308
3317typedef struct {
3318
3320 int np;
3321
3323 double time[NP];
3324
3326 double p[NP];
3327
3329 double lon[NP];
3330
3332 double lat[NP];
3333
3335 double q[NQ][NP];
3336
3337} atm_t;
3338
3346typedef struct {
3347
3349 double time;
3350
3352 double p;
3353
3355 double lon;
3356
3358 double lat;
3359
3361 double q[NQ];
3362
3363} particle_t;
3364
3365
3372typedef struct {
3373
3375 double iso_var[NP];
3376
3378 double iso_ps[NP];
3379
3381 double iso_ts[NP];
3382
3385
3387 float uvwp[NP][3];
3388
3390 double rs[3 * NP + 1];
3391
3393 double dt[NP];
3394
3395} cache_t;
3396
3404typedef struct {
3405
3407 int np;
3408
3410 int nsza;
3411
3413 int no3c;
3414
3416 double p[CP];
3417
3419 double sza[CSZA];
3420
3422 double o3c[CO3];
3423
3425 double n2o[CP][CSZA][CO3];
3426
3428 double ccl4[CP][CSZA][CO3];
3429
3431 double ccl3f[CP][CSZA][CO3];
3432
3434 double ccl2f2[CP][CSZA][CO3];
3435
3437 double o2[CP][CSZA][CO3];
3438
3440 double o3_1[CP][CSZA][CO3];
3441
3443 double o3_2[CP][CSZA][CO3];
3444
3446 double h2o2[CP][CSZA][CO3];
3447
3449 double h2o[CP][CSZA][CO3];
3450
3451} clim_photo_t;
3452
3460typedef struct {
3461
3464
3466 double time[CTS];
3467
3469 double vmr[CTS];
3470
3471} clim_ts_t;
3472
3480typedef struct {
3481
3484
3486 int nlat;
3487
3489 int np;
3490
3492 double time[CT];
3493
3495 double lat[CY];
3496
3498 double p[CP];
3499
3501 double vmr[CT][CP][CY];
3502
3503} clim_zm_t;
3504
3512typedef struct {
3513
3516
3519
3521 double tropo_time[12];
3522
3524 double tropo_lat[73];
3525
3527 double tropo[12][73];
3528
3531
3534
3537
3540
3543
3546
3549
3552
3555
3558
3561
3562} clim_t;
3563
3571typedef struct {
3572
3574 double time;
3575
3576 /* Grid type: 0=lat/lon [deg], 1=UTM [m]. */
3578
3580 int nx;
3581
3583 int ny;
3584
3586 int np;
3587
3589 int npl;
3590
3592 double lon[EX];
3593
3595 double lat[EY];
3596
3598 double p[EP];
3599
3601 double hybrid[EP];
3602
3604 double hyam[EP];
3605
3607 double hybm[EP];
3608
3610 double eta[EP];
3611
3613 float ps[EX][EY];
3614
3616 float ts[EX][EY];
3617
3619 float zs[EX][EY];
3620
3622 float us[EX][EY];
3623
3625 float vs[EX][EY];
3626
3628 float ess[EX][EY];
3629
3631 float nss[EX][EY];
3632
3634 float shf[EX][EY];
3635
3637 float lsm[EX][EY];
3638
3640 float sst[EX][EY];
3641
3643 float pbl[EX][EY];
3644
3646 float pt[EX][EY];
3647
3649 float tt[EX][EY];
3650
3652 float zt[EX][EY];
3653
3655 float h2ot[EX][EY];
3656
3658 float pct[EX][EY];
3659
3661 float pcb[EX][EY];
3662
3664 float cl[EX][EY];
3665
3667 float plcl[EX][EY];
3668
3670 float plfc[EX][EY];
3671
3673 float pel[EX][EY];
3674
3676 float cape[EX][EY];
3677
3679 float cin[EX][EY];
3680
3682 float o3c[EX][EY];
3683
3685 float z[EX][EY][EP];
3686
3688 float t[EX][EY][EP];
3689
3691 float u[EX][EY][EP];
3692
3694 float v[EX][EY][EP];
3695
3697 float w[EX][EY][EP];
3698
3700 float pv[EX][EY][EP];
3701
3703 float h2o[EX][EY][EP];
3704
3706 float o3[EX][EY][EP];
3707
3709 float lwc[EX][EY][EP];
3710
3712 float rwc[EX][EY][EP];
3713
3715 float iwc[EX][EY][EP];
3716
3718 float swc[EX][EY][EP];
3719
3721 float cc[EX][EY][EP];
3722
3724 float pl[EX][EY][EP];
3725
3727 float ul[EX][EY][EP];
3728
3730 float vl[EX][EY][EP];
3731
3733 float wl[EX][EY][EP];
3734
3736 float zetal[EX][EY][EP];
3737
3739 float zeta_dotl[EX][EY][EP];
3740
3741} met_t;
3742
3748typedef struct {
3749
3750 /* ------------------------------------------------------------
3751 Global grid...
3752 ------------------------------------------------------------ */
3753
3756
3759
3761 double lon_glob[DD_EX_GLOB];
3762
3764 double lat_glob[DD_EY_GLOB];
3765
3766 /* ------------------------------------------------------------
3767 Subdomains...
3768 ------------------------------------------------------------ */
3769
3771 size_t subdomain_start[4];
3772
3774 size_t subdomain_count[4];
3775
3777 size_t halo_bnd_start[4];
3778
3780 size_t halo_bnd_count[4];
3781
3784
3787
3788 /* ------------------------------------------------------------
3789 Helpers...
3790 ------------------------------------------------------------ */
3791
3792#ifdef DD
3793
3795 MPI_Datatype MPI_Particle;
3796
3798 double sort_key[NP];
3799
3801 int perm[NP];
3802
3804 double tmp[NP];
3805
3806#endif
3807
3808} dd_t;
3809
3810/* ------------------------------------------------------------
3811 Functions...
3812 ------------------------------------------------------------ */
3813
3836 void *data,
3837 size_t N);
3838
3853void cart2geo(
3854 const double *x,
3855 double *z,
3856 double *lon,
3857 double *lat);
3858
3881double clim_oh(
3882 const ctl_t * ctl,
3883 const clim_t * clim,
3884 const double t,
3885 const double lon,
3886 const double lat,
3887 const double p);
3888
3908 const ctl_t * ctl,
3909 clim_t * clim);
3910
3940double clim_photo(
3941 const double rate[CP][CSZA][CO3],
3942 const clim_photo_t * photo,
3943 const double p,
3944 const double sza,
3945 const double o3c);
3946
3972double clim_tropo(
3973 const clim_t * clim,
3974 const double t,
3975 const double lat);
3976
3995void clim_tropo_init(
3996 clim_t * clim);
3997
4014double clim_ts(
4015 const clim_ts_t * ts,
4016 const double t);
4017
4039double clim_zm(
4040 const clim_zm_t * zm,
4041 const double t,
4042 const double lat,
4043 const double p);
4044
4067 const float *org,
4068 const float *cmp,
4069 const size_t n,
4070 double *mean,
4071 double *stddev,
4072 double *min,
4073 double *max,
4074 double *nrmse,
4075 double *org_mean,
4076 double *range);
4077
4086 FILE * out);
4087
4113 FILE * out,
4114 const char *codec,
4115 const char *varname,
4116 const size_t lev,
4117 const double plev,
4118 const double ratio,
4119 const double bpv,
4120 const double rho,
4121 const double t_comp,
4122 const double t_decomp,
4123 const size_t n,
4124 const size_t nbytes,
4125 const float *org,
4126 const float *cmp);
4127
4148 const ctl_t * ctl,
4149 const met_t * met,
4150 const char *varname,
4151 float *array,
4152 const int decompress,
4153 FILE * level_log,
4154 FILE * inout);
4155
4172 float *array,
4173 const size_t nxy,
4174 const size_t nz,
4175 double *off,
4176 double *scl);
4177
4194 float *array,
4195 const size_t nxy,
4196 const size_t nz,
4197 const double *off,
4198 const double *scl);
4199
4212 const char *varname);
4213
4233void compress_pck(
4234 const ctl_t * ctl,
4235 const met_t * met,
4236 const char *varname,
4237 float *array,
4238 const int decompress,
4239 FILE * level_log,
4240 FILE * inout);
4241
4270 const ctl_t * ctl,
4271 const met_t * met,
4272 const char *varname,
4273 float *array,
4274 const int decompress,
4275 FILE * level_log,
4276 FILE * inout);
4277
4315 const ctl_t * ctl,
4316 const met_t * met,
4317 const char *varname,
4318 float *array,
4319 const int decompress,
4320 FILE * level_log,
4321 FILE * inout);
4322
4341 const ctl_t * ctl,
4342 const met_t * met,
4343 const char *varname,
4344 float *array,
4345 const int decompress,
4346 FILE * level_log,
4347 FILE * inout);
4348
4367 const ctl_t * ctl,
4368 const met_t * met,
4369 const char *varname,
4370 float *array,
4371 const int decompress,
4372 FILE * level_log,
4373 FILE * inout);
4374
4399double cos_sza(
4400 const double sec,
4401 const double lon,
4402 const double lat);
4403
4426void day2doy(
4427 const int year,
4428 const int mon,
4429 const int day,
4430 int *doy);
4431
4485 const ctl_t * ctl,
4486 const dd_t * dd,
4487 atm_t * atm,
4488 const int init);
4489
4542 const ctl_t * ctl,
4543 cache_t * cache,
4544 atm_t * atm,
4545 particle_t * particles,
4546 const int npart);
4547
4577 const ctl_t * ctl,
4578 const dd_t * dd,
4579 const double lon,
4580 const double lat);
4581
4638 const ctl_t * ctl,
4639 const dd_t * dd,
4640 particle_t ** particles,
4641 int *npart,
4642 int *capacity);
4643
4683 const ctl_t * ctl,
4684 dd_t * dd,
4685 atm_t * atm);
4686
4721 const dd_t * dd,
4722 double *lon,
4723 double *lat);
4724
4773 const ctl_t * ctl,
4774 cache_t * cache,
4775 const particle_t * particles,
4776 const int npart,
4777 atm_t * atm);
4778
4779
4825 const ctl_t * ctl,
4826 atm_t * atm,
4827 cache_t * cache,
4828 int *npart);
4829
4830
4876 dd_t * dd,
4877 const ctl_t * ctl,
4878 met_t * met,
4879 const int ncid);
4880
4939 const ctl_t * ctl,
4940 const met_t * met0,
4941 atm_t * atm,
4942 dd_t * dd,
4943 int *npart);
4944
4974 double *a,
4975 dd_t * dd,
4976 const int np);
4977
4999void doy2day(
5000 const int year,
5001 const int doy,
5002 int *mon,
5003 int *day);
5004
5031void fft_help(
5032 double *fcReal,
5033 double *fcImag,
5034 const int n);
5035
5062void geo2cart(
5063 const double z,
5064 const double lon,
5065 const double lat,
5066 double *x);
5067
5092void get_met_filename(
5093 const ctl_t * ctl,
5094 const double t,
5095 const int direct,
5096 const char *metbase,
5097 const double dt_met,
5098 char *filename);
5099
5123void get_met_replace(
5124 char *orig,
5125 const char *search,
5126 const char *repl);
5127
5164void get_tropo(
5165 const int met_tropo,
5166 ctl_t * ctl,
5167 const clim_t * clim,
5168 met_t * met,
5169 const double *lons,
5170 const int nx,
5171 const double *lats,
5172 const int ny,
5173 double *pt,
5174 double *zt,
5175 double *tt,
5176 double *qt,
5177 double *o3t,
5178 double *ps,
5179 double *zs);
5180
5202 const double *lons,
5203 const int nlon,
5204 const double *lats,
5205 const int nlat,
5206 const double lon,
5207 const double lat,
5208 double *lon2,
5209 double *lat2);
5210
5230 const double *lons,
5231 const int nlon,
5232 const double *lats,
5233 const int nlat,
5234 const double lon,
5235 const double lat,
5236 double *lon2,
5237 double *lat2);
5238
5281 const met_t * met0,
5282 float height0[EX][EY][EP],
5283 float array0[EX][EY][EP],
5284 const met_t * met1,
5285 float height1[EX][EY][EP],
5286 float array1[EX][EY][EP],
5287 const double ts,
5288 const double height,
5289 const double lon,
5290 const double lat,
5291 double *var,
5292 int *ci,
5293 double *cw,
5294 const int init);
5295
5331 const met_t * met,
5332 float array[EX][EY][EP],
5333 const double p,
5334 const double lon,
5335 const double lat,
5336 double *var,
5337 int *ci,
5338 double *cw,
5339 const int init);
5340
5376 const met_t * met,
5377 float array[EX][EY],
5378 const double lon,
5379 const double lat,
5380 double *var,
5381 int *ci,
5382 double *cw,
5383 const int init);
5384
5419 const met_t * met0,
5420 float array0[EX][EY][EP],
5421 const met_t * met1,
5422 float array1[EX][EY][EP],
5423 const double ts,
5424 const double p,
5425 const double lon,
5426 const double lat,
5427 double *var,
5428 int *ci,
5429 double *cw,
5430 const int init);
5431
5467 const met_t * met0,
5468 float array0[EX][EY],
5469 const met_t * met1,
5470 float array1[EX][EY],
5471 const double ts,
5472 const double lon,
5473 const double lat,
5474 double *var,
5475 int *ci,
5476 double *cw,
5477 const int init);
5478
5516void intpol_tropo_3d(
5517 const double time0,
5518 float array0[EX][EY],
5519 const double time1,
5520 float array1[EX][EY],
5521 const double lons[EX],
5522 const double lats[EY],
5523 const int nlon,
5524 const int nlat,
5525 const double time,
5526 const double lon,
5527 const double lat,
5528 const int method,
5529 double *var,
5530 double *sigma);
5531
5558void jsec2time(
5559 const double jsec,
5560 int *year,
5561 int *mon,
5562 int *day,
5563 int *hour,
5564 int *min,
5565 int *sec,
5566 double *remain);
5567
5594double kernel_weight(
5595 const double kz[EP],
5596 const double kw[EP],
5597 const int nk,
5598 const double p);
5599
5638double lapse_rate(
5639 const double t,
5640 const double h2o);
5641
5669 ctl_t * ctl);
5670
5690int locate_irr(
5691 const double *xx,
5692 const int n,
5693 const double x);
5694
5721 const float *xx,
5722 const int n,
5723 const double x,
5724 const int ig);
5725
5746int locate_reg(
5747 const double *xx,
5748 const int n,
5749 const double x);
5750
5772void locate_vert(
5773 float profiles[EX][EY][EP],
5774 const int np,
5775 const int lon_ap_ind,
5776 const int lat_ap_ind,
5777 const double alt_ap,
5778 int *ind);
5779
5805void module_advect(
5806 const ctl_t * ctl,
5807 const cache_t * cache,
5808 met_t * met0,
5809 met_t * met1,
5810 atm_t * atm);
5811
5835 const ctl_t * ctl,
5836 const cache_t * cache,
5837 met_t * met0,
5838 met_t * met1,
5839 atm_t * atm);
5840
5878 const ctl_t * ctl,
5879 const cache_t * cache,
5880 const clim_t * clim,
5881 met_t * met0,
5882 met_t * met1,
5883 atm_t * atm);
5884
5926void module_chem_grid(
5927 const ctl_t * ctl,
5928 met_t * met0,
5929 met_t * met1,
5930 atm_t * atm,
5931 const double t);
5932
5960void module_chem_init(
5961 const ctl_t * ctl,
5962 const cache_t * cache,
5963 const clim_t * clim,
5964 met_t * met0,
5965 met_t * met1,
5966 atm_t * atm);
5967
5992 const ctl_t * ctl,
5993 cache_t * cache,
5994 met_t * met0,
5995 met_t * met1,
5996 atm_t * atm);
5997
6042 double t,
6043 const ctl_t * ctl,
6044 cache_t * cache,
6045 dd_t * dd,
6046 atm_t * atm,
6047 met_t ** met);
6048
6075void module_decay(
6076 const ctl_t * ctl,
6077 const cache_t * cache,
6078 const clim_t * clim,
6079 atm_t * atm);
6080
6117void module_diff_meso(
6118 const ctl_t * ctl,
6119 cache_t * cache,
6120 met_t * met0,
6121 met_t * met1,
6122 atm_t * atm);
6123
6157void module_diff_pbl(
6158 const ctl_t * ctl,
6159 cache_t * cache,
6160 met_t * met0,
6161 met_t * met1,
6162 atm_t * atm);
6163
6218void module_diff_turb(
6219 const ctl_t * ctl,
6220 cache_t * cache,
6221 const clim_t * clim,
6222 met_t * met0,
6223 met_t * met1,
6224 atm_t * atm);
6225
6245void module_dry_depo(
6246 const ctl_t * ctl,
6247 const cache_t * cache,
6248 met_t * met0,
6249 met_t * met1,
6250 atm_t * atm);
6251
6284void module_h2o2_chem(
6285 const ctl_t * ctl,
6286 const cache_t * cache,
6287 const clim_t * clim,
6288 met_t * met0,
6289 met_t * met1,
6290 atm_t * atm);
6291
6312 const ctl_t * ctl,
6313 cache_t * cache,
6314 met_t * met0,
6315 met_t * met1,
6316 atm_t * atm);
6317
6335void module_isosurf(
6336 const ctl_t * ctl,
6337 const cache_t * cache,
6338 met_t * met0,
6339 met_t * met1,
6340 atm_t * atm);
6341
6374 ctl_t * ctl,
6375 cache_t * cache,
6376 clim_t * clim,
6377 met_t * met0,
6378 met_t * met1,
6379 atm_t * atm);
6380
6399void module_meteo(
6400 const ctl_t * ctl,
6401 const cache_t * cache,
6402 const clim_t * clim,
6403 met_t * met0,
6404 met_t * met1,
6405 atm_t * atm);
6406
6424void module_mixing(
6425 const ctl_t * ctl,
6426 const clim_t * clim,
6427 atm_t * atm,
6428 const double t);
6429
6458 const ctl_t * ctl,
6459 const clim_t * clim,
6460 atm_t * atm,
6461 const int *ixs,
6462 const int *iys,
6463 const int *izs,
6464 const int qnt_idx,
6465 const int use_ensemble);
6466
6499void module_oh_chem(
6500 const ctl_t * ctl,
6501 const cache_t * cache,
6502 const clim_t * clim,
6503 met_t * met0,
6504 met_t * met1,
6505 atm_t * atm);
6506
6534void module_position(
6535 const cache_t * cache,
6536 met_t * met0,
6537 met_t * met1,
6538 atm_t * atm);
6539
6564void module_rng_init(
6565 const int ntask);
6566
6592void module_rng(
6593 const ctl_t * ctl,
6594 double *rs,
6595 const size_t n,
6596 const int method);
6597
6633 const ctl_t * ctl,
6634 const cache_t * cache,
6635 atm_t * atm);
6636
6659void module_sedi(
6660 const ctl_t * ctl,
6661 const cache_t * cache,
6662 met_t * met0,
6663 met_t * met1,
6664 atm_t * atm);
6665
6689void module_sort(
6690 const ctl_t * ctl,
6691 const met_t * met0,
6692 atm_t * atm);
6693
6713void module_sort_help(
6714 double *a,
6715 const int *p,
6716 const int np);
6717
6741void module_timesteps(
6742 const ctl_t * ctl,
6743 cache_t * cache,
6744 met_t * met0,
6745 atm_t * atm,
6746 const double t);
6747
6769 ctl_t * ctl,
6770 const atm_t * atm);
6771
6805 const ctl_t * ctl,
6806 const cache_t * cache,
6807 const clim_t * clim,
6808 met_t * met0,
6809 met_t * met1,
6810 atm_t * atm);
6811
6841void module_wet_depo(
6842 const ctl_t * ctl,
6843 const cache_t * cache,
6844 met_t * met0,
6845 met_t * met1,
6846 atm_t * atm);
6847
6879void mptrac_alloc(
6880 ctl_t ** ctl,
6881 cache_t ** cache,
6882 clim_t ** clim,
6883 met_t ** met0,
6884 met_t ** met1,
6885 atm_t ** atm,
6886 dd_t ** dd);
6887
6918void mptrac_free(
6919 ctl_t * ctl,
6920 cache_t * cache,
6921 clim_t * clim,
6922 met_t * met0,
6923 met_t * met1,
6924 atm_t * atm,
6925 dd_t * dd);
6926
6962void mptrac_get_met(
6963 ctl_t * ctl,
6964 clim_t * clim,
6965 const double t,
6966 met_t ** met0,
6967 met_t ** met1,
6968 dd_t * dd);
6969
6989void mptrac_init(
6990 ctl_t * ctl,
6991 cache_t * cache,
6992 clim_t * clim,
6993 atm_t * atm,
6994 const int ntask);
6995
7031int mptrac_read_atm(
7032 const char *filename,
7033 const ctl_t * ctl,
7034 atm_t * atm);
7035
7067void mptrac_read_clim(
7068 const ctl_t * ctl,
7069 clim_t * clim);
7070
7100void mptrac_read_ctl(
7101 const char *filename,
7102 int argc,
7103 char *argv[],
7104 ctl_t * ctl);
7105
7136int mptrac_read_met(
7137 const char *filename,
7138 const ctl_t * ctl,
7139 const clim_t * clim,
7140 met_t * met,
7141 dd_t * dd);
7142
7164 ctl_t * ctl,
7165 cache_t * cache,
7166 clim_t * clim,
7167 met_t ** met0,
7168 met_t ** met1,
7169 atm_t * atm,
7170 double t,
7171 dd_t * dd);
7172
7202void mptrac_write_atm(
7203 const char *filename,
7204 const ctl_t * ctl,
7205 const atm_t * atm,
7206 const double t);
7207
7247void mptrac_write_met(
7248 const char *filename,
7249 const ctl_t * ctl,
7250 met_t * met);
7251
7286 const char *dirname,
7287 const ctl_t * ctl,
7288 met_t * met0,
7289 met_t * met1,
7290 atm_t * atm,
7291 const double t);
7292
7324 const ctl_t * ctl,
7325 const cache_t * cache,
7326 const clim_t * clim,
7327 met_t ** met0,
7328 met_t ** met1,
7329 const atm_t * atm);
7330
7361 const ctl_t * ctl,
7362 const cache_t * cache,
7363 const clim_t * clim,
7364 met_t ** met0,
7365 met_t ** met1,
7366 const atm_t * atm);
7367
7395double nat_temperature(
7396 const double p,
7397 const double h2o,
7398 const double hno3);
7399
7422double pbl_weight(
7423 const ctl_t * ctl,
7424 const atm_t * atm,
7425 const int ip,
7426 const double pbl,
7427 const double ps);
7428
7461int read_atm_asc(
7462 const char *filename,
7463 const ctl_t * ctl,
7464 atm_t * atm);
7465
7496int read_atm_bin(
7497 const char *filename,
7498 const ctl_t * ctl,
7499 atm_t * atm);
7500
7525int read_atm_clams(
7526 const char *filename,
7527 const ctl_t * ctl,
7528 atm_t * atm);
7529
7559int read_atm_nc(
7560 const char *filename,
7561 const ctl_t * ctl,
7562 atm_t * atm);
7563
7592void read_clim_photo(
7593 const char *filename,
7594 clim_photo_t * photo);
7595
7613 const int ncid,
7614 const char *varname,
7615 const clim_photo_t * photo,
7616 double var[CP][CSZA][CO3]);
7617
7641int read_clim_ts(
7642 const char *filename,
7643 clim_ts_t * ts);
7644
7671void read_clim_zm(
7672 const char *filename,
7673 const char *varname,
7674 clim_zm_t * zm);
7675
7703void read_kernel(
7704 const char *filename,
7705 double kz[EP],
7706 double kw[EP],
7707 int *nk);
7708
7740int read_met_bin(
7741 const char *filename,
7742 const ctl_t * ctl,
7743 met_t * met);
7744
7770void read_met_bin_2d(
7771 FILE * in,
7772 const met_t * met,
7773 float var[EX][EY],
7774 const char *varname);
7775
7813void read_met_bin_3d(
7814 FILE * in,
7815 const ctl_t * ctl,
7816 const met_t * met,
7817 float var[EX][EY][EP],
7818 const char *varname,
7819 const float bound_min,
7820 const float bound_max);
7821
7849void read_met_cape(
7850 const ctl_t * ctl,
7851 const clim_t * clim,
7852 met_t * met);
7853
7876void read_met_cloud(
7877 met_t * met);
7878
7904void read_met_detrend(
7905 const ctl_t * ctl,
7906 met_t * met);
7907
7931 met_t * met);
7932
7959void read_met_geopot(
7960 const ctl_t * ctl,
7961 met_t * met);
7962
7990 const char *filename,
7991 const ctl_t * ctl,
7992 met_t * met);
7993
8015 codes_handle ** handles,
8016 int count_handles,
8017 met_t * met);
8018
8039 codes_handle ** handles,
8040 const int num_messages,
8041 const ctl_t * ctl,
8042 met_t * met);
8043
8074 codes_handle ** handles,
8075 const int num_messages,
8076 const ctl_t * ctl,
8077 met_t * met);
8078
8107void read_met_ml2pl(
8108 const ctl_t * ctl,
8109 const met_t * met,
8110 float var[EX][EY][EP],
8111 const char *varname);
8112
8135 const ctl_t * ctl,
8136 met_t * met);
8137
8168int read_met_nc(
8169 const char *filename,
8170 const ctl_t * ctl,
8171 met_t * met,
8172 dd_t * dd);
8173
8208void read_met_nc_grid(
8209 const char *filename,
8210 const int ncid,
8211 const ctl_t * ctl,
8212 met_t * met,
8213 dd_t * dd);
8214
8247 const int ncid,
8248 const ctl_t * ctl,
8249 met_t * met,
8250 dd_t * dd);
8251
8283 const int ncid,
8284 const ctl_t * ctl,
8285 met_t * met,
8286 dd_t * dd);
8287
8320int read_met_nc_2d(
8321 const int ncid,
8322 const char *varname,
8323 const char *varname2,
8324 const char *varname3,
8325 const char *varname4,
8326 const char *varname5,
8327 const char *varname6,
8328 const ctl_t * ctl,
8329 const met_t * met,
8330 dd_t * dd,
8331 float dest[EX][EY],
8332 const float scl,
8333 const int init);
8334
8364int read_met_nc_3d(
8365 const int ncid,
8366 const char *varname,
8367 const char *varname2,
8368 const char *varname3,
8369 const char *varname4,
8370 const ctl_t * ctl,
8371 const met_t * met,
8372 dd_t * dd,
8373 float dest[EX][EY][EP],
8374 const float scl);
8375
8421void read_met_pbl(
8422 const ctl_t * ctl,
8423 met_t * met);
8424
8457 met_t * met);
8458
8489 met_t * met);
8490
8521void read_met_pv(
8522 met_t * met);
8523
8546void read_met_ozone(
8547 met_t * met);
8548
8577void read_met_sample(
8578 const ctl_t * ctl,
8579 met_t * met);
8580
8609void read_met_tropo(
8610 const ctl_t * ctl,
8611 const clim_t * clim,
8612 met_t * met);
8613
8645void read_obs(
8646 const char *filename,
8647 const ctl_t * ctl,
8648 double *rt,
8649 double *rz,
8650 double *rlon,
8651 double *rlat,
8652 double *robs,
8653 int *nobs);
8654
8682void read_obs_asc(
8683 const char *filename,
8684 double *rt,
8685 double *rz,
8686 double *rlon,
8687 double *rlat,
8688 double *robs,
8689 int *nobs);
8690
8717void read_obs_nc(
8718 const char *filename,
8719 double *rt,
8720 double *rz,
8721 double *rlon,
8722 double *rlat,
8723 double *robs,
8724 int *nobs);
8725
8759double scan_ctl(
8760 const char *filename,
8761 int argc,
8762 char *argv[],
8763 const char *varname,
8764 const int arridx,
8765 const char *defvalue,
8766 char *value);
8767
8794double sedi(
8795 const double p,
8796 const double T,
8797 const double rp,
8798 const double rhop);
8799
8829void spline(
8830 const double *x,
8831 const double *y,
8832 const int n,
8833 const double *x2,
8834 double *y2,
8835 const int n2,
8836 const int method);
8837
8860float stddev(
8861 const float *data,
8862 const int n);
8863
8888void time2jsec(
8889 const int year,
8890 const int mon,
8891 const int day,
8892 const int hour,
8893 const int min,
8894 const int sec,
8895 const double remain,
8896 double *jsec);
8897
8926void timer(
8927 const char *name,
8928 const char *group,
8929 const int output);
8930
8960double time_from_filename(
8961 const char *filename,
8962 const int offset,
8963 const int with_seconds);
8964
8983double tropo_weight(
8984 const ctl_t * ctl,
8985 const clim_t * clim,
8986 const atm_t * atm,
8987 const int ip);
8988
9011void write_atm_asc(
9012 const char *filename,
9013 const ctl_t * ctl,
9014 const atm_t * atm,
9015 const double t);
9016
9040void write_atm_bin(
9041 const char *filename,
9042 const ctl_t * ctl,
9043 const atm_t * atm);
9044
9068void write_atm_clams(
9069 const char *filename,
9070 const ctl_t * ctl,
9071 const atm_t * atm);
9072
9098 const char *dirname,
9099 const ctl_t * ctl,
9100 const atm_t * atm,
9101 const double t);
9102
9126void write_atm_nc(
9127 const char *filename,
9128 const ctl_t * ctl,
9129 const atm_t * atm);
9130
9159void write_csi(
9160 const char *filename,
9161 const ctl_t * ctl,
9162 const atm_t * atm,
9163 const double t);
9164
9206 const char *filename,
9207 const ctl_t * ctl,
9208 const atm_t * atm,
9209 const double t);
9210
9238void write_ens(
9239 const char *filename,
9240 const ctl_t * ctl,
9241 const atm_t * atm,
9242 const double t);
9243
9282void write_grid(
9283 const char *filename,
9284 const ctl_t * ctl,
9285 met_t * met0,
9286 met_t * met1,
9287 const atm_t * atm,
9288 const double t);
9289
9335void write_grid_asc(
9336 const char *filename,
9337 const ctl_t * ctl,
9338 const double *cd,
9339 double *mean[NQ],
9340 double *sigma[NQ],
9341 const double *vmr_impl,
9342 const double t,
9343 const double *z,
9344 const double *lon,
9345 const double *lat,
9346 const double *area,
9347 const double dz,
9348 const int *np);
9349
9392void write_grid_nc(
9393 const char *filename,
9394 const ctl_t * ctl,
9395 const double *cd,
9396 double *mean[NQ],
9397 double *sigma[NQ],
9398 const double *vmr_impl,
9399 const double t,
9400 const double *z,
9401 const double *lon,
9402 const double *lat,
9403 const double *area,
9404 const double dz,
9405 const int *np);
9406
9436void write_met_bin(
9437 const char *filename,
9438 const ctl_t * ctl,
9439 met_t * met);
9440
9468void write_met_bin_2d(
9469 FILE * out,
9470 met_t * met,
9471 float var[EX][EY],
9472 const char *varname);
9473
9513void write_met_bin_3d(
9514 FILE * out,
9515 const ctl_t * ctl,
9516 met_t * met,
9517 float var[EX][EY][EP],
9518 const char *varname,
9519 const int metvar,
9520 FILE * level_log);
9521
9549void write_met_nc(
9550 const char *filename,
9551 const ctl_t * ctl,
9552 met_t * met);
9553
9576void write_met_nc_2d(
9577 const int ncid,
9578 const char *varname,
9579 met_t * met,
9580 float var[EX][EY],
9581 const float scl);
9582
9606void write_met_nc_3d(
9607 const int ncid,
9608 const char *varname,
9609 met_t * met,
9610 float var[EX][EY][EP],
9611 const float scl);
9612
9643void write_prof(
9644 const char *filename,
9645 const ctl_t * ctl,
9646 met_t * met0,
9647 met_t * met1,
9648 const atm_t * atm,
9649 const double t);
9650
9682void write_sample(
9683 const char *filename,
9684 const ctl_t * ctl,
9685 met_t * met0,
9686 met_t * met1,
9687 const atm_t * atm,
9688 const double t);
9689
9716void write_station(
9717 const char *filename,
9718 const ctl_t * ctl,
9719 atm_t * atm,
9720 const double t);
9721
9750void write_vtk(
9751 const char *filename,
9752 const ctl_t * ctl,
9753 const atm_t * atm,
9754 const double t);
9755
9756/* ------------------------------------------------------------
9757 OpenACC routines...
9758 ------------------------------------------------------------ */
9759
9760#ifdef _OPENACC
9761#pragma acc routine (clim_oh)
9762#pragma acc routine (clim_photo)
9763#pragma acc routine (clim_tropo)
9764#pragma acc routine (clim_ts)
9765#pragma acc routine (clim_zm)
9766#pragma acc routine (cos_sza)
9767#pragma acc routine (dd_calc_subdomain_from_coords)
9768#pragma acc routine (dd_normalize_lon_lat)
9769#pragma acc routine (intpol_check_lon_lat)
9770#pragma acc routine (intpol_met_4d_zeta)
9771#pragma acc routine (intpol_met_space_3d)
9772#pragma acc routine (intpol_met_space_2d)
9773#pragma acc routine (intpol_met_time_3d)
9774#pragma acc routine (intpol_met_time_2d)
9775#pragma acc routine (kernel_weight)
9776#pragma acc routine (lapse_rate)
9777#pragma acc routine (locate_irr)
9778#pragma acc routine (locate_irr_float)
9779#pragma acc routine (locate_reg)
9780#pragma acc routine (locate_vert)
9781#pragma acc routine (nat_temperature)
9782#pragma acc routine (pbl_weight)
9783#pragma acc routine (sedi)
9784#pragma acc routine (stddev)
9785#pragma acc routine (tropo_weight)
9786#endif
9787
9788#endif /* LIBTRAC_H */
void read_met_geopot(const ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:9144
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:6058
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:7764
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:1858
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:9104
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:12612
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:9794
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:14040
void dd_read_met_nc_grid(dd_t *dd, const ctl_t *ctl, met_t *met, const int ncid)
Read meteorological grid information and construct the domain-decomposed grid with halo regions.
Definition: mptrac.c:11035
void read_met_sample(const ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:11620
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:11967
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:3558
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:5771
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:5014
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:8208
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:8940
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:4179
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:12140
double cos_sza(const double sec, const double lon, const double lat)
Calculates the cosine of the solar zenith angle.
Definition: mptrac.c:1817
#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:3008
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:10116
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:8175
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:11211
void read_met_detrend(const ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:8997
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:11793
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:12011
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:4010
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:3519
void compress_log_header(FILE *out)
Write the ASCII header for per-level compression diagnostics.
Definition: mptrac.c:731
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:3538
void compress_zfp(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3D array of floats using the ZFP library.
void read_met_nc_levels(const int ncid, const ctl_t *ctl, met_t *met, dd_t *dd)
Reads and processes meteorological level data from NetCDF files with domain decomposition.
Definition: mptrac.c:9597
void compress_pck(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3‑D float array using the PCK format.
Definition: mptrac.c:895
void read_met_monotonize(const ctl_t *ctl, met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:10907
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:8327
void intpol_check_cartesian(const double *lons, const int nlon, const double *lats, const int nlat, const double lon, const double lat, double *lon2, double *lat2)
Clamps UTM coordinates to the valid bounds.
Definition: mptrac.c:2742
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:11348
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:7503
int compress_metvar_index(const char *varname)
Maps a meteorological variable name to its internal MPTRAC variable index.
Definition: mptrac.c:860
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:5818
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:13100
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:5121
double clim_zm(const clim_zm_t *zm, const double t, const double lat, const double p)
Interpolates monthly mean zonal mean climatological variables.
Definition: mptrac.c:414
#define EY
Maximum number of latitudes for meteo data.
Definition: mptrac.h:344
void module_mixing_help(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const int *ixs, const int *iys, const int *izs, const int qnt_idx, const int use_ensemble)
Perform subgrid-scale interparcel mixing of a given quantity.
Definition: mptrac.c:5193
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:8299
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:10865
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:213
void read_obs_nc(const char *filename, double *rt, double *rz, double *rlon, double *rlat, double *robs, int *nobs)
Reads observation data from a NetCDF file.
Definition: mptrac.c:12039
void compress_sz3(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3-D float array using the SZ3 library.
void read_met_bin_2d(FILE *in, const met_t *met, float var[EX][EY], const char *varname)
Reads a 2-dimensional meteorological variable from a binary file and stores it in the provided array.
Definition: mptrac.c:8681
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:3455
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:4838
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:3302
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:2768
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:13394
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:7652
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:12241
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:6272
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:3072
#define codes_handle
Placeholder when ECCODES is not available.
Definition: mptrac.h:241
void compress_zstd(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a float array using ZSTD.
void get_met_filename(const ctl_t *ctl, const double t, const int direct, const char *metbase, const double dt_met, char *filename)
Generates a formatted filename for meteorological data files based on the input parameters.
Definition: mptrac.c:2579
void fft_help(double *fcReal, double *fcImag, const int n)
Computes the Fast Fourier Transform (FFT) of a complex sequence.
Definition: mptrac.c:2522
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:5923
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:7968
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:12173
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:680
void compress_cms(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a 3-D meteorological field using cmultiscale.
#define CP
Maximum number of pressure levels for climatological data.
Definition: mptrac.h:399
#define NQ
Maximum number of quantities per data point.
Definition: mptrac.h:364
void dd_assign_subdomains(const ctl_t *ctl, const dd_t *dd, atm_t *atm, const int init)
Assign or update particle subdomain ownership.
double clim_photo(const double rate[CP][CSZA][CO3], const clim_photo_t *photo, const double p, const double sza, const double o3c)
Calculates the photolysis rate for a given set of atmospheric conditions.
Definition: mptrac.c:156
void read_clim_zm(const char *filename, const char *varname, clim_zm_t *zm)
Reads zonally averaged climatological data from a netCDF file and populates the given structure.
Definition: mptrac.c:8381
#define EX
Maximum number of longitudes for meteo data.
Definition: mptrac.h:339
void module_sedi(const ctl_t *ctl, const cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Simulate sedimentation of particles in the atmosphere.
Definition: mptrac.c:5631
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:10992
void timer(const char *name, const char *group, const int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:12272
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:12408
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:2945
void module_sort(const ctl_t *ctl, const met_t *met0, atm_t *atm)
Sort particles according to box index.
Definition: mptrac.c:5659
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:4054
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:802
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:8480
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:3749
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:12068
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:3722
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:5437
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:6147
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:5733
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:12220
void compress_lz4(const ctl_t *ctl, const met_t *met, const char *varname, float *array, const int decompress, FILE *level_log, FILE *inout)
Compresses or decompresses a float array using LZ4.
void intpol_tropo_3d(const double time0, float array0[EX][EY], const double time1, float array1[EX][EY], const double lons[EX], const double lats[EY], const int nlon, const int nlat, const double time, const double lon, const double lat, const int method, double *var, double *sigma)
Interpolates tropopause data in 3D (latitude, longitude, and time).
Definition: mptrac.c:3134
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:8710
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:3485
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:14101
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:6366
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:3845
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:758
void write_met_nc(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a NetCDF file.
Definition: mptrac.c:13858
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:5495
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:6291
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:7708
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:7877
double clim_oh(const ctl_t *ctl, const clim_t *clim, const double t, const double lon, const double lat, const double p)
Calculates the hydroxyl radical (OH) concentration from climatology data, with an optional diurnal co...
Definition: mptrac.c:89
void read_met_grib_levels(codes_handle **handles, const int num_messages, const ctl_t *ctl, met_t *met)
Reads meteorological variables at different vertical levels from a grib file.
void write_met_bin_3d(FILE *out, const ctl_t *ctl, met_t *met, float var[EX][EY][EP], const char *varname, const int metvar, FILE *level_log)
Writes a 3-dimensional meteorological variable to a binary file.
Definition: mptrac.c:13765
#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:11591
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:9459
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:241
void module_rng(const ctl_t *ctl, double *rs, const size_t n, const int method)
Generate random numbers using various methods and distributions.
Definition: mptrac.c:5526
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:14496
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: mptrac.c:74
double time_from_filename(const char *filename, const int offset, const int with_seconds)
Extracts and converts a timestamp from a filename to Julian seconds.
Definition: mptrac.c:12340
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:2492
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:3101
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:5379
void clim_oh_diurnal_correction(const ctl_t *ctl, clim_t *clim)
Applies a diurnal correction to the hydroxyl radical (OH) concentration in climatology data.
Definition: mptrac.c:124
void write_met_bin_2d(FILE *out, met_t *met, float var[EX][EY], const char *varname)
Writes a 2-dimensional meteorological variable to a binary file.
Definition: mptrac.c:13736
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:11471
#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:8056
#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:4218
void dd_sort_help(double *a, dd_t *dd, const int np)
Apply the sorting permutation to a particle data array.
double clim_ts(const clim_ts_t *ts, const double t)
Interpolates a time series of climatological variables.
Definition: mptrac.c:396
void jsec2time(const double jsec, int *year, int *mon, int *day, int *hour, int *min, int *sec, double *remain)
Converts Julian seconds to calendar date and time components.
Definition: mptrac.c:3225
int read_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Reads meteorological data from a binary file.
Definition: mptrac.c:8521
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:12556
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:2648
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:4540
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:8112
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:7394
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:14585
#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:5849
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:6426
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:6111
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:11409
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:4753
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:13498
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:7992
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:4295
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:14070
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:4908
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:5295
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:2561
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:9272
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:2672
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:3258
void module_dd(double t, const ctl_t *ctl, cache_t *cache, dd_t *dd, atm_t *atm, met_t **met)
Perform domain decomposition and exchange particles between MPI ranks.
void compress_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:841
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:8014
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:2715
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:14331
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:13200
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:4690
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:13628
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:12506
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:8820
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:7828
#define CSZA
Maximum number of solar zenith angles for climatological data.
Definition: mptrac.h:404
double tropo_weight(const ctl_t *ctl, const clim_t *clim, const atm_t *atm, const int ip)
Computes a weighting factor based on tropopause pressure.
Definition: mptrac.c:12382
void dd_push(const ctl_t *ctl, atm_t *atm, cache_t *cache, int *npart)
Compact and stage non-local particles for domain decomposition transfer.
double lapse_rate(const double t, const double h2o)
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
Definition: mptrac.c:3284
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:12822
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:12773
Air parcel data.
Definition: mptrac.h:3317
int np
Number of air parcels.
Definition: mptrac.h:3320
Cache data structure.
Definition: mptrac.h:3372
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3384
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3404
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3410
int np
Number of pressure levels.
Definition: mptrac.h:3407
int no3c
Number of total ozone columns.
Definition: mptrac.h:3413
Climatological data.
Definition: mptrac.h:3512
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3554
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3530
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3542
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3533
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3515
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3560
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3548
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3551
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3545
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3539
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3518
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3536
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3557
Climatological data in the form of time series.
Definition: mptrac.h:3460
int ntime
Number of timesteps.
Definition: mptrac.h:3463
Climatological data in the form of zonal means.
Definition: mptrac.h:3480
int np
Number of pressure levels.
Definition: mptrac.h:3489
int ntime
Number of timesteps.
Definition: mptrac.h:3483
int nlat
Number of latitudes.
Definition: mptrac.h:3486
Control parameters.
Definition: mptrac.h:2260
double met_utm_ref_lon
Reference longitude [deg] for UTM grid.
Definition: mptrac.h:2619
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3178
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2372
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:3139
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2528
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:3027
int qnt_target_subdomain
Quantity array index for destination subdomain in domain decomposition.
Definition: mptrac.h:2585
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2636
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2405
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:3115
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2886
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2351
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2552
int dd_halos_size
Domain decomposition size of halos given in grid-points.
Definition: mptrac.h:3302
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2949
int met_zstd_nworkers
ZSTD number of worker threads (0=single-threaded, default=4).
Definition: mptrac.h:2648
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2973
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2291
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2561
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2300
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2384
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:3109
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2393
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2874
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:3130
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2360
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3256
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2934
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2779
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2946
double stat_r
Search radius around station [km].
Definition: mptrac.h:3262
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:3021
int met_zstd_level
ZSTD compression level (from -5 to 22, default=-3).
Definition: mptrac.h:2645
double met_utm_ref_lat
Reference latitude [deg] for UTM grid.
Definition: mptrac.h:2616
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:3133
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3286
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2970
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2747
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2381
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:2988
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2838
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2540
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2459
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:3181
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2588
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2546
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2699
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2766
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2423
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2495
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:3124
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:3136
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2817
int met_pbl
Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta).
Definition: mptrac.h:2744
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2375
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2826
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:3166
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3184
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:3080
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2847
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3196
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2306
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2450
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2402
int qnt_Acs137
Quantity array index for radioactive activity of Cs-137.
Definition: mptrac.h:2573
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:3187
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2429
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2763
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2489
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2607
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:2991
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2735
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2811
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2294
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2327
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2471
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2862
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3268
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2808
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3202
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:3127
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2333
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:3172
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2456
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:2979
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2880
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2441
int radio_decay
Switch for radioactive decay module (0=off, 1=on).
Definition: mptrac.h:3015
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2732
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2705
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2303
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2796
int met_pck_zstd
Apply an additional ZSTD compression step to PCK payloads (0=off, 1=on).
Definition: mptrac.h:2654
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2783
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2868
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2309
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:3211
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:3103
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2741
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:3112
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2702
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2982
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2823
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3214
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2366
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2853
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2757
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3220
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2288
double dd_sort_dt
Sorting time interval for the compactification.
Definition: mptrac.h:3305
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2754
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2297
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2772
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2937
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2498
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2426
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:3121
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3265
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:3000
int dd
Domain decomposition (0=no, 1=yes, with 2x2 if not specified).
Definition: mptrac.h:3293
int qnt_eta
Quantity array index for eta vertical coordinate.
Definition: mptrac.h:2483
double wet_depo_so2_ph
pH value used to calculate effective Henry constant of SO2.
Definition: mptrac.h:3039
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2943
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2447
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:3085
int met_cms_nd0x
cmultiscale number of cells of coarsest grid in x-direction.
Definition: mptrac.h:2681
int met_nlev
Number of meteo data model levels.
Definition: mptrac.h:2723
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:3009
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:3048
int qnt_shf
Quantity array index for surface sensible heat flux.
Definition: mptrac.h:2324
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2315
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2525
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3274
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2594
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2844
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2417
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2633
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2345
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2465
int met_gp2z
Convert surface geopotential to geopotential height (0=no, 1=yes).
Definition: mptrac.h:2626
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2859
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2750
int met_dx
Stride for longitudes.
Definition: mptrac.h:2693
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2958
int met_convention
Meteo data layout (0=[lev, lat, lon], 1=[lon, lat, lev]).
Definition: mptrac.h:2610
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2477
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:3012
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2597
int diffusion
Diffusion switch (0=off, 1=on).
Definition: mptrac.h:2799
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2513
int qnt_eta_dot
Quantity array index for velocity of eta vertical coordinate.
Definition: mptrac.h:2486
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2507
int turb_pbl_scheme
PBL turbulence scheme (0=none, 1=closure).
Definition: mptrac.h:2802
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2348
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3283
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2363
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2444
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2856
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2769
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2420
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2531
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2720
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2994
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2369
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:3229
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2468
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2357
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3250
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2892
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3094
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2312
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3190
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2555
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2549
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2961
int nens
Number of ensembles.
Definition: mptrac.h:3142
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2336
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2396
int advect
Advection scheme (1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2789
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3217
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2354
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:3073
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:3006
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2474
double conv_pbl_trans
Depth of PBL transition layer (fraction of PBL pressure thickness).
Definition: mptrac.h:2835
int met_lz4_accel
LZ4 acceleration factor (>=1, default=8).
Definition: mptrac.h:2651
int qnt_Ai131
Quantity array index for radioactive activity of I-131.
Definition: mptrac.h:2576
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:2623
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:3118
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2492
int qnt_Apb210
Quantity array index for radioactive activity of Pb-210.
Definition: mptrac.h:2567
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3259
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2534
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:3193
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2558
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2519
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2711
int conv_mix_pbl
Vertical mixing in the PBL (0=off, 1=on).
Definition: mptrac.h:2832
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2871
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2967
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2408
int qnt_zeta_dot
Quantity array index for velocity of zeta vertical coordinate.
Definition: mptrac.h:2480
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2850
int met_cms_nd0y
cmultiscale number of cells of coarsest grid in y-direction.
Definition: mptrac.h:2684
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2940
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2414
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2865
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2952
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2522
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2510
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:3175
int qnt_nss
Quantity array index for northward turbulent surface stress.
Definition: mptrac.h:2321
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:3148
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:3076
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2738
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2964
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:3070
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3235
int qnt_current_subdomain
Quantity array index for current subdomain in domain decomposition.
Definition: mptrac.h:2582
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2675
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:3054
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2708
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3223
int qnt_Axe133
Quantity array index for radioactive activity of Xe-133.
Definition: mptrac.h:2579
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2976
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2390
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2438
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2453
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3232
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2411
double turb_pbl_trans
Depth of turbulent PBL transition layer (fraction of PBL pressure thickness).
Definition: mptrac.h:2829
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:3057
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3226
int met_nc_quant
Number of digits for quantization of netCDF meteo files (0=off).
Definition: mptrac.h:2642
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:3003
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2543
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:3045
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2985
int qnt_Abe7
Quantity array index for radioactive activity of Be-7.
Definition: mptrac.h:2570
int met_cms_zstd
cmultiscale ZSTD compression (0=off, 1=on).
Definition: mptrac.h:2678
int met_cms_maxlev
cmultiscale maximum refinement level.
Definition: mptrac.h:2687
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:3163
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:3051
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2339
int met_np
Number of target pressure levels.
Definition: mptrac.h:2714
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2285
int met_nc_level
zlib compression level of netCDF meteo files (0=off).
Definition: mptrac.h:2639
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2931
int qnt_Arn222
Quantity array index for radioactive activity of Rn-222.
Definition: mptrac.h:2564
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2435
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3280
double turb_dx_pbl
Horizontal turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2805
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2841
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2501
int advect_vert_coord
Vertical velocity of air parcels (0=omega_on_plev, 1=zetadot_on_mlev, 2=omega_on_mlev,...
Definition: mptrac.h:2793
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2432
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2537
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2330
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2955
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:3088
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:3042
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2462
int met_coord_type
Type of coordinates for meteo data (-1=detect, 0=lat/lon [deg], 1=UTM [m]).
Definition: mptrac.h:2613
int qnt_ess
Quantity array index for eastward turbulent surface stress.
Definition: mptrac.h:2318
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:3030
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:3024
int met_dy
Stride for latitudes.
Definition: mptrac.h:2696
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2516
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2820
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2877
int dd_subdomains_zonal
Domain decomposition zonal subdomain number.
Definition: mptrac.h:3296
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2282
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2760
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2378
double t_start
Start time of simulation [s].
Definition: mptrac.h:2591
int nq
Number of quantities.
Definition: mptrac.h:2267
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2889
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3247
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3277
double turb_dz_pbl
Vertical turbulent diffusion coefficient (PBL) [m^2/s].
Definition: mptrac.h:2814
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3199
int dd_subdomains_meridional
Domain decomposition meridional subdomain number.
Definition: mptrac.h:3299
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2342
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:2630
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2387
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2399
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:3160
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2504
Domain decomposition data structure.
Definition: mptrac.h:3748
int halo_offset_end
Offset of the periodic halo block at the end of the local x-array.
Definition: mptrac.h:3786
int nx_glob
Number of global longitudes.
Definition: mptrac.h:3755
int halo_offset_start
Offset of the periodic halo block at the beginning of the local x-array.
Definition: mptrac.h:3783
int ny_glob
Number of global latitudes.
Definition: mptrac.h:3758
Meteo data structure.
Definition: mptrac.h:3571
int coord_type
Definition: mptrac.h:3577
int nx
Number of longitudes.
Definition: mptrac.h:3580
int ny
Number of latitudes.
Definition: mptrac.h:3583
int np
Number of pressure levels.
Definition: mptrac.h:3586
int npl
Number of model levels.
Definition: mptrac.h:3589
double time
Time [s].
Definition: mptrac.h:3574
Particle data.
Definition: mptrac.h:3346
double p
Pressure [hPa].
Definition: mptrac.h:3352
double lat
Latitude [deg].
Definition: mptrac.h:3358
double time
Time [s].
Definition: mptrac.h:3349
double lon
Longitude [deg].
Definition: mptrac.h:3355