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-2024 Forschungszentrum Juelich GmbH
18*/
19
97#ifndef LIBTRAC_H
98#define LIBTRAC_H
99
100/* ------------------------------------------------------------
101 Includes...
102 ------------------------------------------------------------ */
103
104#include <ctype.h>
105#include <gsl/gsl_fft_complex.h>
106#include <gsl/gsl_math.h>
107#include <gsl/gsl_randist.h>
108#include <gsl/gsl_rng.h>
109#include <gsl/gsl_spline.h>
110#include <gsl/gsl_statistics.h>
111#include <math.h>
112#include <netcdf.h>
113#include <omp.h>
114#include <stdint.h>
115#include <stdio.h>
116#include <stdlib.h>
117#include <string.h>
118#include <time.h>
119#include <sys/time.h>
120
121#ifdef MPI
122#include "mpi.h"
123#endif
124
125#ifdef _OPENACC
126#include "openacc.h"
127#endif
128
129#ifdef CURAND
130#include "curand.h"
131#endif
132
133#ifdef ZFP
134#include "zfp.h"
135#endif
136
137#ifdef ZSTD
138#include "zstd.h"
139#endif
140
141#ifdef CMS
142#include "cmultiscale.h"
143#endif
144
145#ifdef KPP
146#include "chem_Parameters.h"
147#include "chem_Global.h"
148#include "chem_Sparse.h"
149#endif
150
151/* ------------------------------------------------------------
152 Constants...
153 ------------------------------------------------------------ */
154
156#ifndef AVO
157#define AVO 6.02214076e23
158#endif
159
161#ifndef CPD
162#define CPD 1003.5
163#endif
164
166#ifndef EPS
167#define EPS (MH2O / MA)
168#endif
169
171#ifndef G0
172#define G0 9.80665
173#endif
174
176#ifndef H0
177#define H0 7.0
178#endif
179
181#ifndef LV
182#define LV 2501000.
183#endif
184
186#ifndef KB
187#define KB 1.3806504e-23
188#endif
189
191#ifndef MA
192#define MA 28.9644
193#endif
194
196#ifndef MH2O
197#define MH2O 18.01528
198#endif
199
201#ifndef MO3
202#define MO3 48.00
203#endif
204
206#ifndef P0
207#define P0 1013.25
208#endif
209
211#ifndef RA
212#define RA (1e3 * RI / MA)
213#endif
214
216#ifndef RE
217#define RE 6367.421
218#endif
219
221#ifndef RI
222#define RI 8.3144598
223#endif
224
226#ifndef T0
227#define T0 273.15
228#endif
229
230/* ------------------------------------------------------------
231 Dimensions...
232 ------------------------------------------------------------ */
233
235#ifndef LEN
236#define LEN 5000
237#endif
238
240#ifndef NP
241#define NP 10000000
242#endif
243
245#ifndef NQ
246#define NQ 15
247#endif
248
250#ifndef NCSI
251#define NCSI 1000000
252#endif
253
255#ifndef EP
256#define EP 140
257#endif
258
260#ifndef EX
261#define EX 1202
262#endif
263
265#ifndef EY
266#define EY 602
267#endif
268
270#ifndef NENS
271#define NENS 2000
272#endif
273
275#ifndef NOBS
276#define NOBS 10000000
277#endif
278
280#ifndef NTHREADS
281#define NTHREADS 512
282#endif
283
285#ifndef CY
286#define CY 250
287#endif
288
290#ifndef CO3
291#define CO3 30
292#endif
293
295#ifndef CP
296#define CP 70
297#endif
298
300#ifndef CSZA
301#define CSZA 50
302#endif
303
305#ifndef CT
306#define CT 12
307#endif
308
310#ifndef CTS
311#define CTS 1000
312#endif
313
314/* ------------------------------------------------------------
315 Macros...
316 ------------------------------------------------------------ */
317
337#ifdef _OPENACC
338#define ALLOC(ptr, type, n) \
339 if(acc_get_num_devices(acc_device_nvidia) <= 0) \
340 ERRMSG("Not running on a GPU device!"); \
341 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
342 ERRMSG("Out of memory!");
343#else
344#define ALLOC(ptr, type, n) \
345 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
346 ERRMSG("Out of memory!");
347#endif
348
367#define ARRAY_2D(ix, iy, ny) \
368 ((ix) * (ny) + (iy))
369
386#define ARRAY_3D(ix, iy, ny, iz, nz) \
387 (((ix)*(ny) + (iy)) * (nz) + (iz))
388
411#define ARRHENIUS(a, b, t) \
412 ((a) * exp( -(b) / (t)))
413
435#define DEG2DX(dlon, lat) \
436 ((dlon) * M_PI * RE / 180. * cos((lat) / 180. * M_PI))
437
456#define DEG2DY(dlat) \
457 ((dlat) * M_PI * RE / 180.)
458
479#define DP2DZ(dp, p) \
480 (- (dp) * H0 / (p))
481
501#define DX2DEG(dx, lat) \
502 (((lat) < -89.999 || (lat) > 89.999) ? 0 \
503 : (dx) * 180. / (M_PI * RE * cos((lat) / 180. * M_PI)))
504
519#define DY2DEG(dy) \
520 ((dy) * 180. / (M_PI * RE))
521
536#define DZ2DP(dz, p) \
537 (-(dz) * (p) / H0)
538
552#define DIST(a, b) \
553 sqrt(DIST2(a, b))
554
568#define DIST2(a, b) \
569 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
570
584#define DOTP(a, b) \
585 (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
586
603#define FMOD(x, y) \
604 ((x) - (int) ((x) / (y)) * (y))
605
621#define FREAD(ptr, type, size, in) { \
622 if(fread(ptr, sizeof(type), size, in)!=size) \
623 ERRMSG("Error while reading!"); \
624 }
625
641#define FWRITE(ptr, type, size, out) { \
642 if(fwrite(ptr, sizeof(type), size, out)!=size) \
643 ERRMSG("Error while writing!"); \
644 }
645
656#define INTPOL_INIT \
657 double cw[4] = {0.0, 0.0, 0.0, 0.0}; int ci[3] = {0, 0, 0};
658
670#define INTPOL_2D(var, init) \
671 intpol_met_time_2d(met0, met0->var, met1, met1->var, \
672 atm->time[ip], atm->lon[ip], atm->lat[ip], \
673 &var, ci, cw, init);
674
687#define INTPOL_3D(var, init) \
688 intpol_met_time_3d(met0, met0->var, met1, met1->var, \
689 atm->time[ip], atm->p[ip], \
690 atm->lon[ip], atm->lat[ip], \
691 &var, ci, cw, init);
692
706#define INTPOL_SPACE_ALL(p, lon, lat) { \
707 intpol_met_space_3d(met, met->z, p, lon, lat, &z, ci, cw, 1); \
708 intpol_met_space_3d(met, met->t, p, lon, lat, &t, ci, cw, 0); \
709 intpol_met_space_3d(met, met->u, p, lon, lat, &u, ci, cw, 0); \
710 intpol_met_space_3d(met, met->v, p, lon, lat, &v, ci, cw, 0); \
711 intpol_met_space_3d(met, met->w, p, lon, lat, &w, ci, cw, 0); \
712 intpol_met_space_3d(met, met->pv, p, lon, lat, &pv, ci, cw, 0); \
713 intpol_met_space_3d(met, met->h2o, p, lon, lat, &h2o, ci, cw, 0); \
714 intpol_met_space_3d(met, met->o3, p, lon, lat, &o3, ci, cw, 0); \
715 intpol_met_space_3d(met, met->lwc, p, lon, lat, &lwc, ci, cw, 0); \
716 intpol_met_space_3d(met, met->rwc, p, lon, lat, &rwc, ci, cw, 0); \
717 intpol_met_space_3d(met, met->iwc, p, lon, lat, &iwc, ci, cw, 0); \
718 intpol_met_space_3d(met, met->swc, p, lon, lat, &swc, ci, cw, 0); \
719 intpol_met_space_3d(met, met->cc, p, lon, lat, &cc, ci, cw, 0); \
720 intpol_met_space_2d(met, met->ps, lon, lat, &ps, ci, cw, 0); \
721 intpol_met_space_2d(met, met->ts, lon, lat, &ts, ci, cw, 0); \
722 intpol_met_space_2d(met, met->zs, lon, lat, &zs, ci, cw, 0); \
723 intpol_met_space_2d(met, met->us, lon, lat, &us, ci, cw, 0); \
724 intpol_met_space_2d(met, met->vs, lon, lat, &vs, ci, cw, 0); \
725 intpol_met_space_2d(met, met->lsm, lon, lat, &lsm, ci, cw, 0); \
726 intpol_met_space_2d(met, met->sst, lon, lat, &sst, ci, cw, 0); \
727 intpol_met_space_2d(met, met->pbl, lon, lat, &pbl, ci, cw, 0); \
728 intpol_met_space_2d(met, met->pt, lon, lat, &pt, ci, cw, 0); \
729 intpol_met_space_2d(met, met->tt, lon, lat, &tt, ci, cw, 0); \
730 intpol_met_space_2d(met, met->zt, lon, lat, &zt, ci, cw, 0); \
731 intpol_met_space_2d(met, met->h2ot, lon, lat, &h2ot, ci, cw, 0); \
732 intpol_met_space_2d(met, met->pct, lon, lat, &pct, ci, cw, 0); \
733 intpol_met_space_2d(met, met->pcb, lon, lat, &pcb, ci, cw, 0); \
734 intpol_met_space_2d(met, met->cl, lon, lat, &cl, ci, cw, 0); \
735 intpol_met_space_2d(met, met->plcl, lon, lat, &plcl, ci, cw, 0); \
736 intpol_met_space_2d(met, met->plfc, lon, lat, &plfc, ci, cw, 0); \
737 intpol_met_space_2d(met, met->pel, lon, lat, &pel, ci, cw, 0); \
738 intpol_met_space_2d(met, met->cape, lon, lat, &cape, ci, cw, 0); \
739 intpol_met_space_2d(met, met->cin, lon, lat, &cin, ci, cw, 0); \
740 intpol_met_space_2d(met, met->o3c, lon, lat, &o3c, ci, cw, 0); \
741 }
742
757#define INTPOL_TIME_ALL(time, p, lon, lat) { \
758 intpol_met_time_3d(met0, met0->z, met1, met1->z, time, p, lon, lat, &z, ci, cw, 1); \
759 intpol_met_time_3d(met0, met0->t, met1, met1->t, time, p, lon, lat, &t, ci, cw, 0); \
760 intpol_met_time_3d(met0, met0->u, met1, met1->u, time, p, lon, lat, &u, ci, cw, 0); \
761 intpol_met_time_3d(met0, met0->v, met1, met1->v, time, p, lon, lat, &v, ci, cw, 0); \
762 intpol_met_time_3d(met0, met0->w, met1, met1->w, time, p, lon, lat, &w, ci, cw, 0); \
763 intpol_met_time_3d(met0, met0->pv, met1, met1->pv, time, p, lon, lat, &pv, ci, cw, 0); \
764 intpol_met_time_3d(met0, met0->h2o, met1, met1->h2o, time, p, lon, lat, &h2o, ci, cw, 0); \
765 intpol_met_time_3d(met0, met0->o3, met1, met1->o3, time, p, lon, lat, &o3, ci, cw, 0); \
766 intpol_met_time_3d(met0, met0->lwc, met1, met1->lwc, time, p, lon, lat, &lwc, ci, cw, 0); \
767 intpol_met_time_3d(met0, met0->rwc, met1, met1->rwc, time, p, lon, lat, &rwc, ci, cw, 0); \
768 intpol_met_time_3d(met0, met0->iwc, met1, met1->iwc, time, p, lon, lat, &iwc, ci, cw, 0); \
769 intpol_met_time_3d(met0, met0->swc, met1, met1->swc, time, p, lon, lat, &swc, ci, cw, 0); \
770 intpol_met_time_3d(met0, met0->cc, met1, met1->cc, time, p, lon, lat, &cc, ci, cw, 0); \
771 intpol_met_time_2d(met0, met0->ps, met1, met1->ps, time, lon, lat, &ps, ci, cw, 0); \
772 intpol_met_time_2d(met0, met0->ts, met1, met1->ts, time, lon, lat, &ts, ci, cw, 0); \
773 intpol_met_time_2d(met0, met0->zs, met1, met1->zs, time, lon, lat, &zs, ci, cw, 0); \
774 intpol_met_time_2d(met0, met0->us, met1, met1->us, time, lon, lat, &us, ci, cw, 0); \
775 intpol_met_time_2d(met0, met0->vs, met1, met1->vs, time, lon, lat, &vs, ci, cw, 0); \
776 intpol_met_time_2d(met0, met0->lsm, met1, met1->lsm, time, lon, lat, &lsm, ci, cw, 0); \
777 intpol_met_time_2d(met0, met0->sst, met1, met1->sst, time, lon, lat, &sst, ci, cw, 0); \
778 intpol_met_time_2d(met0, met0->pbl, met1, met1->pbl, time, lon, lat, &pbl, ci, cw, 0); \
779 intpol_met_time_2d(met0, met0->pt, met1, met1->pt, time, lon, lat, &pt, ci, cw, 0); \
780 intpol_met_time_2d(met0, met0->tt, met1, met1->tt, time, lon, lat, &tt, ci, cw, 0); \
781 intpol_met_time_2d(met0, met0->zt, met1, met1->zt, time, lon, lat, &zt, ci, cw, 0); \
782 intpol_met_time_2d(met0, met0->h2ot, met1, met1->h2ot, time, lon, lat, &h2ot, ci, cw, 0); \
783 intpol_met_time_2d(met0, met0->pct, met1, met1->pct, time, lon, lat, &pct, ci, cw, 0); \
784 intpol_met_time_2d(met0, met0->pcb, met1, met1->pcb, time, lon, lat, &pcb, ci, cw, 0); \
785 intpol_met_time_2d(met0, met0->cl, met1, met1->cl, time, lon, lat, &cl, ci, cw, 0); \
786 intpol_met_time_2d(met0, met0->plcl, met1, met1->plcl, time, lon, lat, &plcl, ci, cw, 0); \
787 intpol_met_time_2d(met0, met0->plfc, met1, met1->plfc, time, lon, lat, &plfc, ci, cw, 0); \
788 intpol_met_time_2d(met0, met0->pel, met1, met1->pel, time, lon, lat, &pel, ci, cw, 0); \
789 intpol_met_time_2d(met0, met0->cape, met1, met1->cape, time, lon, lat, &cape, ci, cw, 0); \
790 intpol_met_time_2d(met0, met0->cin, met1, met1->cin, time, lon, lat, &cin, ci, cw, 0); \
791 intpol_met_time_2d(met0, met0->o3c, met1, met1->o3c, time, lon, lat, &o3c, ci, cw, 0); \
792 }
793
808#define LAPSE(p1, t1, p2, t2) \
809 (1e3 * G0 / RA * ((t2) - (t1)) / ((t2) + (t1)) \
810 * ((p2) + (p1)) / ((p2) - (p1)))
811
827#define LIN(x0, y0, x1, y1, x) \
828 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
829
854#define MAX(a,b) \
855 (((a)>(b))?(a):(b))
856
868#define MET_HEADER \
869 fprintf(out, \
870 "# $1 = time [s]\n" \
871 "# $2 = altitude [km]\n" \
872 "# $3 = longitude [deg]\n" \
873 "# $4 = latitude [deg]\n" \
874 "# $5 = pressure [hPa]\n" \
875 "# $6 = temperature [K]\n" \
876 "# $7 = zonal wind [m/s]\n" \
877 "# $8 = meridional wind [m/s]\n" \
878 "# $9 = vertical velocity [hPa/s]\n" \
879 "# $10 = H2O volume mixing ratio [ppv]\n"); \
880 fprintf(out, \
881 "# $11 = O3 volume mixing ratio [ppv]\n" \
882 "# $12 = geopotential height [km]\n" \
883 "# $13 = potential vorticity [PVU]\n" \
884 "# $14 = surface pressure [hPa]\n" \
885 "# $15 = surface temperature [K]\n" \
886 "# $16 = surface geopotential height [km]\n" \
887 "# $17 = surface zonal wind [m/s]\n" \
888 "# $18 = surface meridional wind [m/s]\n" \
889 "# $19 = land-sea mask [1]\n" \
890 "# $20 = sea surface temperature [K]\n"); \
891 fprintf(out, \
892 "# $21 = tropopause pressure [hPa]\n" \
893 "# $22 = tropopause geopotential height [km]\n" \
894 "# $23 = tropopause temperature [K]\n" \
895 "# $24 = tropopause water vapor [ppv]\n" \
896 "# $25 = cloud liquid water content [kg/kg]\n" \
897 "# $26 = cloud rain water content [kg/kg]\n" \
898 "# $27 = cloud ice water content [kg/kg]\n" \
899 "# $28 = cloud snow water content [kg/kg]\n" \
900 "# $29 = cloud cover [1]\n" \
901 "# $30 = total column cloud water [kg/m^2]\n"); \
902 fprintf(out, \
903 "# $31 = cloud top pressure [hPa]\n" \
904 "# $32 = cloud bottom pressure [hPa]\n" \
905 "# $33 = pressure at lifted condensation level (LCL) [hPa]\n" \
906 "# $34 = pressure at level of free convection (LFC) [hPa]\n" \
907 "# $35 = pressure at equilibrium level (EL) [hPa]\n" \
908 "# $36 = convective available potential energy (CAPE) [J/kg]\n" \
909 "# $37 = convective inhibition (CIN) [J/kg]\n" \
910 "# $38 = relative humidity over water [%%]\n" \
911 "# $39 = relative humidity over ice [%%]\n" \
912 "# $40 = dew point temperature [K]\n"); \
913 fprintf(out, \
914 "# $41 = frost point temperature [K]\n" \
915 "# $42 = NAT temperature [K]\n" \
916 "# $43 = HNO3 volume mixing ratio [ppv]\n" \
917 "# $44 = OH volume mixing ratio [ppv]\n" \
918 "# $45 = H2O2 volume mixing ratio [ppv]\n" \
919 "# $46 = HO2 volume mixing ratio [ppv]\n" \
920 "# $47 = O(1D) volume mixing ratio [ppv]\n" \
921 "# $48 = boundary layer pressure [hPa]\n" \
922 "# $49 = total column ozone [DU]\n" \
923 "# $50 = number of data points\n"); \
924 fprintf(out, \
925 "# $51 = number of tropopause data points\n" \
926 "# $52 = number of CAPE data points\n");
927
952#define MIN(a,b) \
953 (((a)<(b))?(a):(b))
954
967#define MOLEC_DENS(p,t) \
968 (AVO * 1e-6 * ((p) * 100) / (RI * (t)))
969
981#define NC(cmd) { \
982 int nc_result=(cmd); \
983 if(nc_result!=NC_NOERR) \
984 ERRMSG("%s", nc_strerror(nc_result)); \
985 }
986
1003#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units) { \
1004 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
1005 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
1006 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
1007 }
1008
1026#define NC_GET_DOUBLE(varname, ptr, force) { \
1027 if(force) { \
1028 NC(nc_inq_varid(ncid, varname, &varid)); \
1029 NC(nc_get_var_double(ncid, varid, ptr)); \
1030 } else { \
1031 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
1032 NC(nc_get_var_double(ncid, varid, ptr)); \
1033 } else \
1034 WARN("netCDF variable %s is missing!", varname); \
1035 } \
1036 }
1037
1054#define NC_INQ_DIM(dimname, ptr, min, max) { \
1055 int dimid; size_t naux; \
1056 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
1057 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
1058 *ptr = (int)naux; \
1059 if ((*ptr) < (min) || (*ptr) > (max)) \
1060 ERRMSG("Dimension %s is out of range!", dimname); \
1061 }
1062
1077#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
1078 NC(nc_inq_varid(ncid, varname, &varid)); \
1079 if(hyperslab) { \
1080 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
1081 } else { \
1082 NC(nc_put_var_double(ncid, varid, ptr)); \
1083 } \
1084 }
1085
1101#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
1102 NC(nc_inq_varid(ncid, varname, &varid)); \
1103 if(hyperslab) { \
1104 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
1105 } else { \
1106 NC(nc_put_var_float(ncid, varid, ptr)); \
1107 } \
1108 }
1109
1124#define NC_PUT_INT(varname, ptr, hyperslab) { \
1125 NC(nc_inq_varid(ncid, varname, &varid)); \
1126 if(hyperslab) { \
1127 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
1128 } else { \
1129 NC(nc_put_var_int(ncid, varid, ptr)); \
1130 } \
1131 }
1132
1146#define NC_PUT_ATT(varname, attname, text) { \
1147 NC(nc_inq_varid(ncid, varname, &varid)); \
1148 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
1149 }
1150
1163#define NC_PUT_ATT_GLOBAL(attname, text) \
1164 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
1165
1183#define NN(x0, y0, x1, y1, x) \
1184 (fabs((x) - (x0)) <= fabs((x) - (x1)) ? (y0) : (y1))
1185
1198#define NORM(a) \
1199 sqrt(DOTP(a, a))
1200
1216#ifdef _OPENACC
1217#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1218 const int ip0_const = ip0; \
1219 const int ip1_const = ip1; \
1220 _Pragma(__VA_ARGS__) \
1221 _Pragma("acc parallel loop independent gang vector") \
1222 for (int ip = ip0_const; ip < ip1_const; ip++) \
1223 if (!check_dt || dt[ip] != 0)
1224#else
1225#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1226 const int ip0_const = ip0; \
1227 const int ip1_const = ip1; \
1228 _Pragma("omp parallel for default(shared)") \
1229 for (int ip = ip0_const; ip < ip1_const; ip++) \
1230 if (!check_dt || dt[ip] != 0)
1231#endif
1232
1255#define P(z) \
1256 (P0 * exp(-(z) / H0))
1257
1279#define PSAT(t) \
1280 (6.112 * exp(17.62 * ((t) - T0) / (243.12 + (t) - T0)))
1281
1303#define PSICE(t) \
1304 (6.112 * exp(22.46 * ((t) - T0) / (272.62 + (t) - T0)))
1305
1330#define PW(p, h2o) \
1331 ((p) * MAX((h2o), 0.1e-6) / (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1332
1360#define RH(p, t, h2o) \
1361 (PW(p, h2o) / PSAT(t) * 100.)
1362
1390#define RHICE(p, t, h2o) \
1391 (PW(p, h2o) / PSICE(t) * 100.)
1392
1415#define RHO(p, t) \
1416 (100. * (p) / (RA * (t)))
1417
1446#define ROETH_PHOTOL(a, b, c, sza) \
1447 ((c)*(sza) < M_PI/2. ? (a) * exp((b) * (1 - 1/cos((c) * (sza)))) : 0)
1448
1465#define SET_ATM(qnt, val) \
1466 if (ctl->qnt >= 0) \
1467 atm->q[ctl->qnt][ip] = val;
1468
1488#define SET_QNT(qnt, name, longname, unit) \
1489 if (strcasecmp(ctl->qnt_name[iq], name) == 0) { \
1490 ctl->qnt = iq; \
1491 sprintf(ctl->qnt_longname[iq], longname); \
1492 sprintf(ctl->qnt_unit[iq], unit); \
1493 } else
1494
1509#define SH(h2o) \
1510 (EPS * MAX((h2o), 0.1e-6))
1511
1522#define SQR(x) \
1523 ((x)*(x))
1524
1536#define SWAP(x, y, type) \
1537 do {type tmp = x; x = y; y = tmp;} while(0);
1538
1560#define TDEW(p, h2o) \
1561 (T0 + 243.12 * log(PW((p), (h2o)) / 6.112) \
1562 / (17.62 - log(PW((p), (h2o)) / 6.112)))
1563
1585#define TICE(p, h2o) \
1586 (T0 + 272.62 * log(PW((p), (h2o)) / 6.112) \
1587 / (22.46 - log(PW((p), (h2o)) / 6.112)))
1588
1609#define THETA(p, t) \
1610 ((t) * pow(1000. / (p), 0.286))
1611
1638#define THETAVIRT(p, t, h2o) \
1639 (TVIRT(THETA((p), (t)), MAX((h2o), 0.1e-6)))
1640
1659#define TOK(line, tok, format, var) { \
1660 if(((tok)=strtok((line), " \t"))) { \
1661 if(sscanf(tok, format, &(var))!=1) continue; \
1662 } else ERRMSG("Error while reading!"); \
1663 }
1664
1684#define TVIRT(t, h2o) \
1685 ((t) * (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1686
1706#define Z(p) \
1707 (H0 * log(P0 / (p)))
1708
1737#define ZDIFF(lnp0, t0, h2o0, lnp1, t1, h2o1) \
1738 (RI / MA / G0 * 0.5 * (TVIRT((t0), (h2o0)) + TVIRT((t1), (h2o1))) \
1739 * ((lnp0) - (lnp1)))
1740
1768#define ZETA(ps, p, t) \
1769 (((p) / (ps) <= 0.3 ? 1. : \
1770 sin(M_PI / 2. * (1. - (p) / (ps)) / (1. - 0.3))) \
1771 * THETA((p), (t)))
1772
1773/* ------------------------------------------------------------
1774 Log messages...
1775 ------------------------------------------------------------ */
1776
1778#ifndef LOGLEV
1779#define LOGLEV 2
1780#endif
1781
1811#define LOG(level, ...) { \
1812 if(level >= 2) \
1813 printf(" "); \
1814 if(level <= LOGLEV) { \
1815 printf(__VA_ARGS__); \
1816 printf("\n"); \
1817 } \
1818 }
1819
1848#define WARN(...) { \
1849 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
1850 LOG(0, __VA_ARGS__); \
1851 }
1852
1881#define ERRMSG(...) { \
1882 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
1883 LOG(0, __VA_ARGS__); \
1884 exit(EXIT_FAILURE); \
1885 }
1886
1916#define PRINT(format, var) \
1917 printf("Print (%s, %s, l%d): %s= "format"\n", \
1918 __FILE__, __func__, __LINE__, #var, var);
1919
1920/* ------------------------------------------------------------
1921 Timers...
1922 ------------------------------------------------------------ */
1923
1925#define NTIMER 100
1926
1940#define PRINT_TIMERS \
1941 timer("END", "END", 1);
1942
1961#define SELECT_TIMER(id, group, color) { \
1962 NVTX_POP; \
1963 NVTX_PUSH(id, color); \
1964 timer(id, group, 0); \
1965 }
1966
1980#define START_TIMERS \
1981 NVTX_PUSH("START", NVTX_CPU);
1982
1995#define STOP_TIMERS \
1996 NVTX_POP;
1997
1998/* ------------------------------------------------------------
1999 NVIDIA Tools Extension (NVTX)...
2000 ------------------------------------------------------------ */
2001
2002#ifdef NVTX
2003#include "nvToolsExt.h"
2004
2006#define NVTX_CPU 0xFFADD8E6
2007
2009#define NVTX_GPU 0xFF00008B
2010
2012#define NVTX_H2D 0xFFFFFF00
2013
2015#define NVTX_D2H 0xFFFF8800
2016
2018#define NVTX_READ 0xFFFFCCCB
2019
2021#define NVTX_WRITE 0xFF8B0000
2022
2024#define NVTX_RECV 0xFFCCFFCB
2025
2027#define NVTX_SEND 0xFF008B00
2028
2058#define NVTX_PUSH(range_title, range_color) { \
2059 nvtxEventAttributes_t eventAttrib = {0}; \
2060 eventAttrib.version = NVTX_VERSION; \
2061 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
2062 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
2063 eventAttrib.colorType = NVTX_COLOR_ARGB; \
2064 eventAttrib.color = range_color; \
2065 eventAttrib.message.ascii = range_title; \
2066 nvtxRangePushEx(&eventAttrib); \
2067 }
2068
2081#define NVTX_POP { \
2082 nvtxRangePop(); \
2083 }
2084#else
2085
2086/* Empty definitions of NVTX_PUSH and NVTX_POP... */
2087#define NVTX_PUSH(range_title, range_color) {}
2088#define NVTX_POP {}
2089#endif
2090
2091/* ------------------------------------------------------------
2092 Thrust...
2093 ------------------------------------------------------------ */
2094
2120 double *__restrict__ c,
2121 int n,
2122 int *__restrict__ index);
2123
2124/* ------------------------------------------------------------
2125 Structs...
2126 ------------------------------------------------------------ */
2127
2135typedef struct {
2136
2137 /* TODO: finally sort ctl parameters once Fortran wrapper is working! */
2138
2142
2145
2148
2151
2154
2155 /* ------------------------------------------------------------
2156 Quantity parameters...
2157 ------------------------------------------------------------ */
2158
2160 int nq;
2161
2163 char qnt_name[NQ][LEN];
2164
2166 char qnt_longname[NQ][LEN];
2167
2169 char qnt_unit[NQ][LEN];
2170
2172 char qnt_format[NQ][LEN];
2173
2176
2179
2182
2185
2188
2191
2194
2197
2200
2203
2206
2209
2212
2215
2218
2221
2224
2227
2230
2233
2236
2239
2242
2245
2248
2251
2254
2257
2260
2263
2266
2269
2272
2275
2278
2281
2284
2287
2290
2293
2296
2299
2302
2305
2308
2311
2314
2317
2320
2323
2326
2329
2332
2335
2338
2341
2344
2347
2350
2353
2356
2359
2362
2365
2368
2371
2374
2377
2380
2383
2386
2389
2392
2395
2398
2401
2404
2407
2410
2413
2416
2419
2422
2425
2428
2431
2434
2437
2440
2442 double t_start;
2443
2445 double t_stop;
2446
2448 double dt_mod;
2449
2450 /* ------------------------------------------------------------
2451 Meteo data parameters...
2452 ------------------------------------------------------------ */
2453
2455 char metbase[LEN];
2456
2458 double dt_met;
2459
2462
2465
2468
2471
2474
2477
2481
2484
2487
2490
2493
2496
2499
2502
2505
2508
2511
2514
2517
2520
2523
2526
2529
2532
2535
2538
2541
2544
2546 double met_p[EP];
2547
2550
2553
2556
2560
2563
2566
2569
2572
2575
2578
2579 /* ------------------------------------------------------------
2580 Geophysical module parameters...
2581 ------------------------------------------------------------ */
2582
2584 double sort_dt;
2585
2589
2591 char balloon[LEN];
2592
2595
2598
2601
2604
2607
2610
2613
2616
2619
2622
2624 double conv_cin;
2625
2627 double conv_dt;
2628
2631
2634
2637
2640
2643
2646
2649
2652
2654 double bound_p0;
2655
2657 double bound_p1;
2658
2661
2664
2667
2670
2672 char species[LEN];
2673
2675 double molmass;
2676
2679
2682
2685
2687 char clim_hno3_filename[LEN];
2688
2690 char clim_oh_filename[LEN];
2691
2693 char clim_h2o2_filename[LEN];
2694
2696 char clim_ho2_filename[LEN];
2697
2699 char clim_o1d_filename[LEN];
2700
2702 char clim_o3_filename[LEN];
2703
2705 char clim_ccl4_timeseries[LEN];
2706
2708 char clim_ccl3f_timeseries[LEN];
2709
2711 char clim_ccl2f2_timeseries[LEN];
2712
2714 char clim_n2o_timeseries[LEN];
2715
2717 char clim_sf6_timeseries[LEN];
2718
2721
2724
2727
2730
2733
2736
2739
2742
2745
2748
2751
2754
2757
2760
2763
2766
2769
2772
2775
2778
2781
2784
2786 double oh_chem[4];
2787
2790
2793
2796
2798 double dt_kpp;
2799
2802
2804 double wet_depo_pre[2];
2805
2808
2811
2814
2817
2819 double wet_depo_ic_h[3];
2820
2822 double wet_depo_bc_h[2];
2823
2826
2829
2832
2835
2837 double psc_h2o;
2838
2840 double psc_hno3;
2841
2842 /* ------------------------------------------------------------
2843 Output parameters...
2844 ------------------------------------------------------------ */
2845
2847 char atm_basename[LEN];
2848
2850 char atm_gpfile[LEN];
2851
2854
2857
2860
2864
2868
2872
2874 char csi_basename[LEN];
2875
2877 char csi_kernel[LEN];
2878
2881
2883 char csi_obsfile[LEN];
2884
2887
2890
2893
2895 double csi_z0;
2896
2898 double csi_z1;
2899
2902
2904 double csi_lon0;
2905
2907 double csi_lon1;
2908
2911
2913 double csi_lat0;
2914
2916 double csi_lat1;
2917
2919 char ens_basename[LEN];
2920
2923
2925 char grid_basename[LEN];
2926
2928 char grid_kernel[LEN];
2929
2931 char grid_gpfile[LEN];
2932
2935
2938
2941
2944
2946 double grid_z0;
2947
2949 double grid_z1;
2950
2953
2956
2959
2962
2965
2968
2971
2973 char prof_basename[LEN];
2974
2976 char prof_obsfile[LEN];
2977
2980
2982 double prof_z0;
2983
2985 double prof_z1;
2986
2989
2992
2995
2998
3001
3004
3006 char sample_basename[LEN];
3007
3009 char sample_kernel[LEN];
3010
3012 char sample_obsfile[LEN];
3013
3016
3019
3021 char stat_basename[LEN];
3022
3024 double stat_lon;
3025
3027 double stat_lat;
3028
3030 double stat_r;
3031
3033 double stat_t0;
3034
3036 double stat_t1;
3037
3039 char vtk_basename[LEN];
3040
3043
3046
3049
3052
3055
3056} ctl_t;
3057
3066typedef struct {
3067
3069 int np;
3070
3072 double time[NP];
3073
3075 double p[NP];
3076
3078 double lon[NP];
3079
3081 double lat[NP];
3082
3084 double q[NQ][NP];
3085
3086} atm_t;
3087
3094typedef struct {
3095
3097 double iso_var[NP];
3098
3100 double iso_ps[NP];
3101
3103 double iso_ts[NP];
3104
3107
3109 float uvwp[NP][3];
3110
3111} cache_t;
3112
3120typedef struct {
3121
3123 int np;
3124
3126 int nsza;
3127
3129 int no3c;
3130
3132 double p[CP];
3133
3135 double sza[CSZA];
3136
3138 double o3c[CO3];
3139
3141 double n2o[CP][CSZA][CO3];
3142
3144 double ccl4[CP][CSZA][CO3];
3145
3147 double ccl3f[CP][CSZA][CO3];
3148
3150 double ccl2f2[CP][CSZA][CO3];
3151
3153 double o2[CP][CSZA][CO3];
3154
3156 double o3_1[CP][CSZA][CO3];
3157
3159 double o3_2[CP][CSZA][CO3];
3160
3162 double h2o2[CP][CSZA][CO3];
3163
3165 double h2o[CP][CSZA][CO3];
3166
3167} clim_photo_t;
3168
3176typedef struct {
3177
3180
3182 double time[CTS];
3183
3185 double vmr[CTS];
3186
3187} clim_ts_t;
3188
3196typedef struct {
3197
3200
3202 int nlat;
3203
3205 int np;
3206
3208 double time[CT];
3209
3211 double lat[CY];
3212
3214 double p[CP];
3215
3217 double vmr[CT][CP][CY];
3218
3219} clim_zm_t;
3220
3228typedef struct {
3229
3232
3235
3237 double tropo_time[12];
3238
3240 double tropo_lat[73];
3241
3243 double tropo[12][73];
3244
3247
3250
3253
3256
3259
3262
3265
3268
3271
3274
3277
3278} clim_t;
3279
3287typedef struct {
3288
3290 double time;
3291
3293 int nx;
3294
3296 int ny;
3297
3299 int np;
3300
3302 int npl;
3303
3305 double lon[EX];
3306
3308 double lat[EY];
3309
3311 double p[EP];
3312
3314 double hybrid[EP];
3315
3317 float ps[EX][EY];
3318
3320 float ts[EX][EY];
3321
3323 float zs[EX][EY];
3324
3326 float us[EX][EY];
3327
3329 float vs[EX][EY];
3330
3332 float lsm[EX][EY];
3333
3335 float sst[EX][EY];
3336
3338 float pbl[EX][EY];
3339
3341 float pt[EX][EY];
3342
3344 float tt[EX][EY];
3345
3347 float zt[EX][EY];
3348
3350 float h2ot[EX][EY];
3351
3353 float pct[EX][EY];
3354
3356 float pcb[EX][EY];
3357
3359 float cl[EX][EY];
3360
3362 float plcl[EX][EY];
3363
3365 float plfc[EX][EY];
3366
3368 float pel[EX][EY];
3369
3371 float cape[EX][EY];
3372
3374 float cin[EX][EY];
3375
3377 float o3c[EX][EY];
3378
3380 float z[EX][EY][EP];
3381
3383 float t[EX][EY][EP];
3384
3386 float u[EX][EY][EP];
3387
3389 float v[EX][EY][EP];
3390
3392 float w[EX][EY][EP];
3393
3395 float pv[EX][EY][EP];
3396
3398 float h2o[EX][EY][EP];
3399
3401 float o3[EX][EY][EP];
3402
3404 float lwc[EX][EY][EP];
3405
3407 float rwc[EX][EY][EP];
3408
3410 float iwc[EX][EY][EP];
3411
3413 float swc[EX][EY][EP];
3414
3416 float cc[EX][EY][EP];
3417
3419 float pl[EX][EY][EP];
3420
3422 float ul[EX][EY][EP];
3423
3425 float vl[EX][EY][EP];
3426
3428 float wl[EX][EY][EP];
3429
3431 float zetal[EX][EY][EP];
3432
3434 float zeta_dotl[EX][EY][EP];
3435
3436} met_t;
3437
3438/* ------------------------------------------------------------
3439 Functions...
3440 ------------------------------------------------------------ */
3441
3464 void *data,
3465 size_t N);
3466
3481void cart2geo(
3482 const double *x,
3483 double *z,
3484 double *lon,
3485 double *lat);
3486
3509double clim_oh(
3510 const ctl_t * ctl,
3511 const clim_t * clim,
3512 const double t,
3513 const double lon,
3514 const double lat,
3515 const double p);
3516
3536 ctl_t * ctl,
3537 clim_t * clim);
3538
3568double clim_photo(
3569 double rate[CP][CSZA][CO3],
3570 clim_photo_t * photo,
3571 double p,
3572 double sza,
3573 double o3c);
3574
3600double clim_tropo(
3601 const clim_t * clim,
3602 const double t,
3603 const double lat);
3604
3623void clim_tropo_init(
3624 clim_t * clim);
3625
3642double clim_ts(
3643 const clim_ts_t * ts,
3644 const double t);
3645
3667double clim_zm(
3668 const clim_zm_t * zm,
3669 const double t,
3670 const double lat,
3671 const double p);
3672
3714 ctl_t * ctl,
3715 char *varname,
3716 float *array,
3717 size_t nx,
3718 size_t ny,
3719 size_t np,
3720 int decompress,
3721 FILE * inout);
3722
3755void compress_pck(
3756 char *varname,
3757 float *array,
3758 size_t nxy,
3759 size_t nz,
3760 int decompress,
3761 FILE * inout);
3762
3802 char *varname,
3803 float *array,
3804 int nx,
3805 int ny,
3806 int nz,
3807 int precision,
3808 double tolerance,
3809 int decompress,
3810 FILE * inout);
3811
3848 char *varname,
3849 float *array,
3850 size_t n,
3851 int decompress,
3852 FILE * inout);
3853
3876void day2doy(
3877 const int year,
3878 const int mon,
3879 const int day,
3880 int *doy);
3881
3903void doy2day(
3904 const int year,
3905 const int doy,
3906 int *mon,
3907 int *day);
3908
3935void fft_help(
3936 double *fcReal,
3937 double *fcImag,
3938 int n);
3939
3966void geo2cart(
3967 const double z,
3968 const double lon,
3969 const double lat,
3970 double *x);
3971
4006void get_met(
4007 ctl_t * ctl,
4008 clim_t * clim,
4009 double t,
4010 met_t ** met0,
4011 met_t ** met1);
4012
4041void get_met_help(
4042 ctl_t * ctl,
4043 double t,
4044 int direct,
4045 char *metbase,
4046 double dt_met,
4047 char *filename);
4048
4072void get_met_replace(
4073 char *orig,
4074 char *search,
4075 char *repl);
4076
4113void get_tropo(
4114 int met_tropo,
4115 ctl_t * ctl,
4116 clim_t * clim,
4117 met_t * met,
4118 double *lons,
4119 int nx,
4120 double *lats,
4121 int ny,
4122 double *pt,
4123 double *zt,
4124 double *tt,
4125 double *qt,
4126 double *o3t,
4127 double *ps,
4128 double *zs);
4129
4172 met_t * met0,
4173 float height0[EX][EY][EP],
4174 float array0[EX][EY][EP],
4175 met_t * met1,
4176 float height1[EX][EY][EP],
4177 float array1[EX][EY][EP],
4178 double ts,
4179 double height,
4180 double lon,
4181 double lat,
4182 double *var,
4183 int *ci,
4184 double *cw,
4185 int init);
4186
4222 met_t * met,
4223 float array[EX][EY][EP],
4224 double p,
4225 double lon,
4226 double lat,
4227 double *var,
4228 int *ci,
4229 double *cw,
4230 int init);
4231
4251 met_t * met,
4252 float array[EX][EY][EP],
4253 double p,
4254 double lon,
4255 double lat,
4256 double *var);
4257
4293 met_t * met,
4294 float array[EX][EY],
4295 double lon,
4296 double lat,
4297 double *var,
4298 int *ci,
4299 double *cw,
4300 int init);
4301
4336 met_t * met0,
4337 float array0[EX][EY][EP],
4338 met_t * met1,
4339 float array1[EX][EY][EP],
4340 double ts,
4341 double p,
4342 double lon,
4343 double lat,
4344 double *var,
4345 int *ci,
4346 double *cw,
4347 int init);
4348
4372 met_t * met0,
4373 float array0[EX][EY][EP],
4374 met_t * met1,
4375 float array1[EX][EY][EP],
4376 double ts,
4377 double p,
4378 double lon,
4379 double lat,
4380 double *var);
4381
4417 met_t * met0,
4418 float array0[EX][EY],
4419 met_t * met1,
4420 float array1[EX][EY],
4421 double ts,
4422 double lon,
4423 double lat,
4424 double *var,
4425 int *ci,
4426 double *cw,
4427 int init);
4428
4466void intpol_tropo_3d(
4467 double time0,
4468 float array0[EX][EY],
4469 double time1,
4470 float array1[EX][EY],
4471 double lons[EX],
4472 double lats[EY],
4473 int nlon,
4474 int nlat,
4475 double time,
4476 double lon,
4477 double lat,
4478 int method,
4479 double *var,
4480 double *sigma);
4481
4508void jsec2time(
4509 const double jsec,
4510 int *year,
4511 int *mon,
4512 int *day,
4513 int *hour,
4514 int *min,
4515 int *sec,
4516 double *remain);
4517
4544double kernel_weight(
4545 const double kz[EP],
4546 const double kw[EP],
4547 const int nk,
4548 const double p);
4549
4588double lapse_rate(
4589 const double t,
4590 const double h2o);
4591
4621 ctl_t * ctl);
4622
4642int locate_irr(
4643 const double *xx,
4644 const int n,
4645 const double x);
4646
4673 const float *xx,
4674 const int n,
4675 const double x,
4676 const int ig);
4677
4700int locate_irr_3d(
4701 float profiles[EX][EY][EP],
4702 int np,
4703 int ind_lon,
4704 int ind_lat,
4705 double x);
4706
4727int locate_reg(
4728 const double *xx,
4729 const int n,
4730 const double x);
4731
4753void locate_vert(
4754 float profiles[EX][EY][EP],
4755 int np,
4756 int lon_ap_ind,
4757 int lat_ap_ind,
4758 double alt_ap,
4759 int *ind);
4760
4807void module_advect(
4808 ctl_t * ctl,
4809 met_t * met0,
4810 met_t * met1,
4811 atm_t * atm,
4812 double *dt);
4813
4836 ctl_t * ctl,
4837 met_t * met0,
4838 met_t * met1,
4839 atm_t * atm);
4840
4878 ctl_t * ctl,
4879 clim_t * clim,
4880 met_t * met0,
4881 met_t * met1,
4882 atm_t * atm,
4883 double *dt);
4884
4902void module_chemgrid(
4903 ctl_t * ctl,
4904 met_t * met0,
4905 met_t * met1,
4906 atm_t * atm,
4907 double t);
4908
4935void module_chem_init(
4936 ctl_t * ctl,
4937 clim_t * clim,
4938 met_t * met0,
4939 met_t * met1,
4940 atm_t * atm);
4941
4970 ctl_t * ctl,
4971 met_t * met0,
4972 met_t * met1,
4973 atm_t * atm,
4974 double *dt,
4975 double *rs);
4976
5003void module_decay(
5004 ctl_t * ctl,
5005 clim_t * clim,
5006 atm_t * atm,
5007 double *dt);
5008
5039 ctl_t * ctl,
5040 met_t * met0,
5041 met_t * met1,
5042 atm_t * atm,
5043 cache_t * cache,
5044 double *dt,
5045 double *rs);
5046
5073 ctl_t * ctl,
5074 clim_t * clim,
5075 atm_t * atm,
5076 double *dt,
5077 double *rs);
5078
5099 ctl_t * ctl,
5100 met_t * met0,
5101 met_t * met1,
5102 atm_t * atm,
5103 double *dt);
5104
5137void module_h2o2_chem(
5138 ctl_t * ctl,
5139 clim_t * clim,
5140 met_t * met0,
5141 met_t * met1,
5142 atm_t * atm,
5143 double *dt);
5144
5165 ctl_t * ctl,
5166 met_t * met0,
5167 met_t * met1,
5168 atm_t * atm,
5169 cache_t * cache);
5170
5189void module_isosurf(
5190 ctl_t * ctl,
5191 met_t * met0,
5192 met_t * met1,
5193 atm_t * atm,
5194 cache_t * cache,
5195 double *dt);
5196
5229 ctl_t * ctl,
5230 clim_t * clim,
5231 met_t * met0,
5232 met_t * met1,
5233 atm_t * atm,
5234 double *dt);
5235
5254void module_meteo(
5255 ctl_t * ctl,
5256 clim_t * clim,
5257 met_t * met0,
5258 met_t * met1,
5259 atm_t * atm,
5260 double *dt);
5261
5279void module_mixing(
5280 ctl_t * ctl,
5281 clim_t * clim,
5282 atm_t * atm,
5283 double t);
5284
5305 ctl_t * ctl,
5306 clim_t * clim,
5307 atm_t * atm,
5308 const int *ixs,
5309 const int *iys,
5310 const int *izs,
5311 int qnt_idx);
5312
5345void module_oh_chem(
5346 ctl_t * ctl,
5347 clim_t * clim,
5348 met_t * met0,
5349 met_t * met1,
5350 atm_t * atm,
5351 double *dt);
5352
5381void module_position(
5382 ctl_t * ctl,
5383 met_t * met0,
5384 met_t * met1,
5385 atm_t * atm,
5386 double *dt);
5387
5412void module_rng_init(
5413 int ntask);
5414
5440void module_rng(
5441 ctl_t * ctl,
5442 double *rs,
5443 size_t n,
5444 int method);
5445
5468void module_sedi(
5469 ctl_t * ctl,
5470 met_t * met0,
5471 met_t * met1,
5472 atm_t * atm,
5473 double *dt);
5474
5499void module_sort(
5500 ctl_t * ctl,
5501 met_t * met0,
5502 atm_t * atm);
5503
5523void module_sort_help(
5524 double *a,
5525 const int *p,
5526 const int np);
5527
5551void module_timesteps(
5552 ctl_t * ctl,
5553 met_t * met0,
5554 atm_t * atm,
5555 double *dt,
5556 double t);
5557
5579 ctl_t * ctl,
5580 atm_t * atm);
5581
5615 ctl_t * ctl,
5616 clim_t * clim,
5617 met_t * met0,
5618 met_t * met1,
5619 atm_t * atm,
5620 double *dt);
5621
5647 ctl_t * ctl,
5648 met_t * met0,
5649 met_t * met1,
5650 atm_t * atm,
5651 double *dt);
5652
5680double nat_temperature(
5681 const double p,
5682 const double h2o,
5683 const double hno3);
5684
5720int read_atm(
5721 const char *filename,
5722 ctl_t * ctl,
5723 atm_t * atm);
5724
5757int read_atm_asc(
5758 const char *filename,
5759 ctl_t * ctl,
5760 atm_t * atm);
5761
5792int read_atm_bin(
5793 const char *filename,
5794 ctl_t * ctl,
5795 atm_t * atm);
5796
5831int read_atm_clams(
5832 const char *filename,
5833 ctl_t * ctl,
5834 atm_t * atm);
5835
5865int read_atm_nc(
5866 const char *filename,
5867 ctl_t * ctl,
5868 atm_t * atm);
5869
5901void read_clim(
5902 ctl_t * ctl,
5903 clim_t * clim);
5904
5933void read_clim_photo(
5934 const char *filename,
5935 clim_photo_t * photo);
5936
5960int read_clim_ts(
5961 const char *filename,
5962 clim_ts_t * ts);
5963
5990void read_clim_zm(
5991 const char *filename,
5992 char *varname,
5993 clim_zm_t * zm);
5994
6024void read_ctl(
6025 const char *filename,
6026 int argc,
6027 char *argv[],
6028 ctl_t * ctl);
6029
6057void read_kernel(
6058 const char *filename,
6059 double kz[EP],
6060 double kw[EP],
6061 int *nk);
6062
6106int read_met(
6107 const char *filename,
6108 ctl_t * ctl,
6109 clim_t * clim,
6110 met_t * met);
6111
6137void read_met_bin_2d(
6138 FILE * in,
6139 met_t * met,
6140 float var[EX][EY],
6141 char *varname);
6142
6180void read_met_bin_3d(
6181 FILE * in,
6182 ctl_t * ctl,
6183 met_t * met,
6184 float var[EX][EY][EP],
6185 char *varname,
6186 float bound_min,
6187 float bound_max);
6188
6215void read_met_cape(
6216 clim_t * clim,
6217 met_t * met);
6218
6241void read_met_cloud(
6242 met_t * met);
6243
6269void read_met_detrend(
6270 ctl_t * ctl,
6271 met_t * met);
6272
6296 met_t * met);
6297
6324void read_met_geopot(
6325 ctl_t * ctl,
6326 met_t * met);
6327
6359void read_met_grid(
6360 const char *filename,
6361 int ncid,
6362 ctl_t * ctl,
6363 met_t * met);
6364
6395void read_met_levels(
6396 int ncid,
6397 ctl_t * ctl,
6398 met_t * met);
6399
6428void read_met_ml2pl(
6429 ctl_t * ctl,
6430 met_t * met,
6431 float var[EX][EY][EP],
6432 char *varname);
6433
6455 met_t * met);
6456
6486int read_met_nc_2d(
6487 int ncid,
6488 char *varname,
6489 char *varname2,
6490 char *varname3,
6491 char *varname4,
6492 ctl_t * ctl,
6493 met_t * met,
6494 float dest[EX][EY],
6495 float scl,
6496 int init);
6497
6526int read_met_nc_3d(
6527 int ncid,
6528 char *varname,
6529 char *varname2,
6530 char *varname3,
6531 char *varname4,
6532 ctl_t * ctl,
6533 met_t * met,
6534 float dest[EX][EY][EP],
6535 float scl);
6536
6565void read_met_pbl(
6566 met_t * met);
6567
6600 met_t * met);
6601
6632 met_t * met);
6633
6664void read_met_pv(
6665 met_t * met);
6666
6689void read_met_ozone(
6690 met_t * met);
6691
6720void read_met_sample(
6721 ctl_t * ctl,
6722 met_t * met);
6723
6764void read_met_surface(
6765 int ncid,
6766 met_t * met,
6767 ctl_t * ctl);
6768
6797void read_met_tropo(
6798 ctl_t * ctl,
6799 clim_t * clim,
6800 met_t * met);
6801
6833void read_obs(
6834 const char *filename,
6835 ctl_t * ctl,
6836 double *rt,
6837 double *rz,
6838 double *rlon,
6839 double *rlat,
6840 double *robs,
6841 int *nobs);
6842
6870void read_obs_asc(
6871 const char *filename,
6872 double *rt,
6873 double *rz,
6874 double *rlon,
6875 double *rlat,
6876 double *robs,
6877 int *nobs);
6878
6905void read_obs_nc(
6906 const char *filename,
6907 double *rt,
6908 double *rz,
6909 double *rlon,
6910 double *rlat,
6911 double *robs,
6912 int *nobs);
6913
6947double scan_ctl(
6948 const char *filename,
6949 int argc,
6950 char *argv[],
6951 const char *varname,
6952 int arridx,
6953 const char *defvalue,
6954 char *value);
6955
6982double sedi(
6983 const double p,
6984 const double T,
6985 const double rp,
6986 const double rhop);
6987
7017void spline(
7018 const double *x,
7019 const double *y,
7020 const int n,
7021 const double *x2,
7022 double *y2,
7023 const int n2,
7024 const int method);
7025
7048float stddev(
7049 const float *data,
7050 const int n);
7051
7071double sza_calc(
7072 const double sec,
7073 const double lon,
7074 const double lat);
7075
7100void time2jsec(
7101 const int year,
7102 const int mon,
7103 const int day,
7104 const int hour,
7105 const int min,
7106 const int sec,
7107 const double remain,
7108 double *jsec);
7109
7138void timer(
7139 const char *name,
7140 const char *group,
7141 int output);
7142
7168double time_from_filename(
7169 const char *filename,
7170 int offset);
7171
7199double tropo_weight(
7200 const clim_t * clim,
7201 const double t,
7202 const double lat,
7203 const double p);
7204
7234void write_atm(
7235 const char *filename,
7236 ctl_t * ctl,
7237 atm_t * atm,
7238 double t);
7239
7262void write_atm_asc(
7263 const char *filename,
7264 ctl_t * ctl,
7265 atm_t * atm,
7266 double t);
7267
7291void write_atm_bin(
7292 const char *filename,
7293 ctl_t * ctl,
7294 atm_t * atm);
7295
7319void write_atm_clams(
7320 const char *filename,
7321 ctl_t * ctl,
7322 atm_t * atm);
7323
7349 const char *dirname,
7350 ctl_t * ctl,
7351 atm_t * atm,
7352 double t);
7353
7377void write_atm_nc(
7378 const char *filename,
7379 ctl_t * ctl,
7380 atm_t * atm);
7381
7410void write_csi(
7411 const char *filename,
7412 ctl_t * ctl,
7413 atm_t * atm,
7414 double t);
7415
7443void write_ens(
7444 const char *filename,
7445 ctl_t * ctl,
7446 atm_t * atm,
7447 double t);
7448
7487void write_grid(
7488 const char *filename,
7489 ctl_t * ctl,
7490 met_t * met0,
7491 met_t * met1,
7492 atm_t * atm,
7493 double t);
7494
7540void write_grid_asc(
7541 const char *filename,
7542 ctl_t * ctl,
7543 double *cd,
7544 double *mean[NQ],
7545 double *sigma[NQ],
7546 double *vmr_impl,
7547 double t,
7548 double *z,
7549 double *lon,
7550 double *lat,
7551 double *area,
7552 double dz,
7553 int *np);
7554
7597void write_grid_nc(
7598 const char *filename,
7599 ctl_t * ctl,
7600 double *cd,
7601 double *mean[NQ],
7602 double *sigma[NQ],
7603 double *vmr_impl,
7604 double t,
7605 double *z,
7606 double *lon,
7607 double *lat,
7608 double *area,
7609 double dz,
7610 int *np);
7611
7644int write_met(
7645 const char *filename,
7646 ctl_t * ctl,
7647 met_t * met);
7648
7676void write_met_bin_2d(
7677 FILE * out,
7678 met_t * met,
7679 float var[EX][EY],
7680 char *varname);
7681
7719void write_met_bin_3d(
7720 FILE * out,
7721 ctl_t * ctl,
7722 met_t * met,
7723 float var[EX][EY][EP],
7724 char *varname,
7725 int precision,
7726 double tolerance);
7727
7761void write_output(
7762 const char *dirname,
7763 ctl_t * ctl,
7764 met_t * met0,
7765 met_t * met1,
7766 atm_t * atm,
7767 double t);
7768
7799void write_prof(
7800 const char *filename,
7801 ctl_t * ctl,
7802 met_t * met0,
7803 met_t * met1,
7804 atm_t * atm,
7805 double t);
7806
7838void write_sample(
7839 const char *filename,
7840 ctl_t * ctl,
7841 met_t * met0,
7842 met_t * met1,
7843 atm_t * atm,
7844 double t);
7845
7872void write_station(
7873 const char *filename,
7874 ctl_t * ctl,
7875 atm_t * atm,
7876 double t);
7877
7906void write_vtk(
7907 const char *filename,
7908 ctl_t * ctl,
7909 atm_t * atm,
7910 double t);
7911
7912/* ------------------------------------------------------------
7913 OpenACC routines...
7914 ------------------------------------------------------------ */
7915
7916#ifdef _OPENACC
7917#pragma acc routine (clim_oh)
7918#pragma acc routine (clim_photo)
7919#pragma acc routine (clim_tropo)
7920#pragma acc routine (clim_ts)
7921#pragma acc routine (clim_zm)
7922#pragma acc routine (intpol_met_4d_coord)
7923#pragma acc routine (intpol_met_space_3d)
7924#pragma acc routine (intpol_met_space_3d_ml)
7925#pragma acc routine (intpol_met_space_2d)
7926#pragma acc routine (intpol_met_time_3d)
7927#pragma acc routine (intpol_met_time_3d_ml)
7928#pragma acc routine (intpol_met_time_2d)
7929#pragma acc routine (kernel_weight)
7930#pragma acc routine (lapse_rate)
7931#pragma acc routine (locate_irr)
7932#pragma acc routine (locate_irr_float)
7933#pragma acc routine (locate_reg)
7934#pragma acc routine (locate_vert)
7935#pragma acc routine (locate_irr_3d)
7936#pragma acc routine (nat_temperature)
7937#pragma acc routine (sedi)
7938#pragma acc routine (stddev)
7939#pragma acc routine (sza_calc)
7940#pragma acc routine (tropo_weight)
7941#endif
7942
7943#endif /* LIBTRAC_H */
void module_mixing_help(ctl_t *ctl, clim_t *clim, atm_t *atm, const int *ixs, const int *iys, const int *izs, int qnt_idx)
Perform interparcel mixing for a specific quantity.
Definition: mptrac.c:3356
int write_met(const char *filename, ctl_t *ctl, met_t *met)
Writes meteorological data to a binary file.
Definition: mptrac.c:9494
void read_met_bin_2d(FILE *in, met_t *met, float var[EX][EY], char *varname)
Reads a 2-dimensional meteorological variable from a binary file and stores it in the provided array.
Definition: mptrac.c:5822
void module_chem_init(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Initializes the chemistry modules by setting atmospheric composition.
Definition: mptrac.c:2579
void intpol_met_time_2d(met_t *met0, float array0[EX][EY], met_t *met1, float array1[EX][EY], double ts, double lon, double lat, double *var, int *ci, double *cw, int init)
Interpolates meteorological data in 2D space and time.
Definition: mptrac.c:1609
#define LEN
Maximum length of ASCII data lines.
Definition: mptrac.h:236
void module_timesteps(ctl_t *ctl, met_t *met0, atm_t *atm, double *dt, double t)
Calculate time steps for air parcels based on specified conditions.
Definition: mptrac.c:3852
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:816
void read_met_extrapolate(met_t *met)
Extrapolates meteorological data.
Definition: mptrac.c:6202
int read_atm_nc(const char *filename, ctl_t *ctl, atm_t *atm)
Reads air parcel data from a generic netCDF file and populates the given atmospheric structure.
Definition: mptrac.c:4372
void write_grid_asc(const char *filename, ctl_t *ctl, double *cd, double *mean[NQ], double *sigma[NQ], double *vmr_impl, double t, double *z, double *lon, double *lat, double *area, double dz, int *np)
Writes grid data to an ASCII file.
Definition: mptrac.c:9266
void module_kpp_chem(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, double *dt)
KPP chemistry module.
void compress_cms(ctl_t *ctl, char *varname, float *array, size_t nx, size_t ny, size_t np, int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats using a custom multiscale compression algorithm.
int read_atm(const char *filename, ctl_t *ctl, atm_t *atm)
Reads air parcel data from a specified file into the given atmospheric structure.
Definition: mptrac.c:4147
void read_met_levels(int ncid, ctl_t *ctl, met_t *met)
Reads meteorological variables at different vertical levels from a NetCDF file.
Definition: mptrac.c:6487
void timer(const char *name, const char *group, int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:8154
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:4465
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:6047
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:7979
void module_sedi(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Simulate sedimentation of particles in the atmosphere.
Definition: mptrac.c:3727
void compress_zstd(char *varname, float *array, size_t n, int decompress, FILE *inout)
Compresses or decompresses an array of floats using the Zstandard (ZSTD) library.
void module_advect_init(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm)
Initializes the advection module by setting up pressure fields.
Definition: mptrac.c:2314
void read_met_grid(const char *filename, int ncid, ctl_t *ctl, met_t *met)
Reads meteorological grid information from a NetCDF file.
Definition: mptrac.c:6369
void write_met_bin_3d(FILE *out, ctl_t *ctl, met_t *met, float var[EX][EY][EP], char *varname, int precision, double tolerance)
Writes a 3-dimensional meteorological variable to a binary file.
Definition: mptrac.c:9646
void read_clim(ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:4405
void module_wet_deposition(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Perform wet deposition calculations for air parcels.
Definition: mptrac.c:3988
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:7850
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:2117
int read_met_nc_2d(int ncid, char *varname, char *varname2, char *varname3, char *varname4, ctl_t *ctl, met_t *met, float dest[EX][EY], float scl, int init)
Reads a 2-dimensional meteorological variable from a NetCDF file.
Definition: mptrac.c:6751
void write_vtk(const char *filename, ctl_t *ctl, atm_t *atm, double t)
Writes VTK (Visualization Toolkit) data to a specified file.
Definition: mptrac.c:10294
void module_sort(ctl_t *ctl, met_t *met0, atm_t *atm)
Sort particles according to box index.
Definition: mptrac.c:3756
int read_atm_asc(const char *filename, ctl_t *ctl, atm_t *atm)
Reads air parcel data from an ASCII file and populates the given atmospheric structure.
Definition: mptrac.c:4218
void module_rng_init(int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:3592
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:4600
void write_atm_asc(const char *filename, ctl_t *ctl, atm_t *atm, double t)
Writes air parcel data to an ASCII file or gnuplot.
Definition: mptrac.c:8341
void write_grid_nc(const char *filename, ctl_t *ctl, double *cd, double *mean[NQ], double *sigma[NQ], double *vmr_impl, double t, double *z, double *lon, double *lat, double *area, double dz, int *np)
Writes grid data to a NetCDF file.
Definition: mptrac.c:9370
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:7118
void module_chemgrid(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double t)
Calculate grid data for chemistry modules.
Definition: mptrac.c:2429
void clim_oh_diurnal_correction(ctl_t *ctl, clim_t *clim)
Applies a diurnal correction to the hydroxyl radical (OH) concentration in climatology data.
Definition: mptrac.c:112
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:394
#define EY
Maximum number of latitudes for meteo data.
Definition: mptrac.h:266
void module_tracer_chem(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Simulate chemical reactions involving long-lived atmospheric tracers.
Definition: mptrac.c:3920
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:193
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:7878
void intpol_met_space_3d_ml(met_t *met, float array[EX][EY][EP], double p, double lon, double lat, double *var)
Interpolates a meteorological variable in 3D space (longitude, latitude, pressure).
Definition: mptrac.c:1430
void intpol_met_time_3d(met_t *met0, float array0[EX][EY][EP], met_t *met1, float array1[EX][EY][EP], double ts, double p, double lon, double lat, double *var, int *ci, double *cw, int init)
Interpolates meteorological data in 3D space and time.
Definition: mptrac.c:1557
void write_met_bin_2d(FILE *out, met_t *met, float var[EX][EY], char *varname)
Writes a 2-dimensional meteorological variable to a binary file.
Definition: mptrac.c:9617
void fft_help(double *fcReal, double *fcImag, int n)
Computes the Fast Fourier Transform (FFT) of a complex sequence.
Definition: mptrac.c:865
void module_rng(ctl_t *ctl, double *rs, size_t n, int method)
Generate random numbers using various methods and distributions.
Definition: mptrac.c:3623
void module_advect(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Performs the advection of atmospheric particles using meteorological data.
Definition: mptrac.c:2156
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:2019
void get_tropo(int met_tropo, ctl_t *ctl, clim_t *clim, met_t *met, double *lons, int nx, double *lats, int ny, double *pt, double *zt, double *tt, double *qt, double *o3t, double *ps, double *zs)
Calculate tropopause data.
Definition: mptrac.c:1154
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:1812
void write_atm_clams_traj(const char *dirname, ctl_t *ctl, atm_t *atm, double t)
Writes CLaMS trajectory data to a NetCDF file.
Definition: mptrac.c:8523
void read_obs(const char *filename, 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:7806
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:8123
void write_grid(const char *filename, ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double t)
Writes grid data to a file in ASCII or netCDF format.
Definition: mptrac.c:9074
void read_clim_zm(const char *filename, char *varname, clim_zm_t *zm)
Reads zonally averaged climatological data from a netCDF file and populates the given structure.
Definition: mptrac.c:4654
void read_met_pbl(met_t *met)
Calculates the planetary boundary layer (PBL) height for each grid point.
Definition: mptrac.c:7047
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:4123
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:8012
#define CP
Maximum number of pressure levels for climatological data.
Definition: mptrac.h:296
void read_met_tropo(ctl_t *ctl, clim_t *clim, met_t *met)
Calculates the tropopause and related meteorological variables based on various methods and stores th...
Definition: mptrac.c:7634
int read_atm_clams(const char *filename, ctl_t *ctl, atm_t *atm)
Reads air parcel data from a CLaMS netCDF file and populates the given atmospheric structure.
Definition: mptrac.c:4316
void write_sample(const char *filename, ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double t)
Writes sample data to a specified file.
Definition: mptrac.c:10045
#define NQ
Maximum number of quantities per data point.
Definition: mptrac.h:246
void module_bound_cond(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Apply boundary conditions to particles based on meteorological and climatological data.
Definition: mptrac.c:2334
void module_timesteps_init(ctl_t *ctl, atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:3889
int read_atm_bin(const char *filename, ctl_t *ctl, atm_t *atm)
Reads air parcel data from a binary file and populates the given atmospheric structure.
Definition: mptrac.c:4260
void read_met_sample(ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:7366
void module_h2o2_chem(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Perform chemical reactions involving H2O2 within cloud particles.
Definition: mptrac.c:2910
void write_station(const char *filename, ctl_t *ctl, atm_t *atm, double t)
Writes station data to a specified file.
Definition: mptrac.c:10208
#define EX
Maximum number of longitudes for meteo data.
Definition: mptrac.h:261
void read_met_monotonize(met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:6672
void write_atm(const char *filename, ctl_t *ctl, atm_t *atm, double t)
Writes air parcel data to a file in various formats.
Definition: mptrac.c:8281
void write_csi(const char *filename, ctl_t *ctl, atm_t *atm, double t)
Writes Critical Success Index (CSI) data to a file.
Definition: mptrac.c:8717
void intpol_tropo_3d(double time0, float array0[EX][EY], double time1, float array1[EX][EY], double lons[EX], double lats[EY], int nlon, int nlat, double time, double lon, double lat, int method, double *var, double *sigma)
Interpolates tropopause data in 3D (latitude, longitude, and time).
Definition: mptrac.c:1642
void read_met_ml2pl(ctl_t *ctl, met_t *met, float var[EX][EY][EP], char *varname)
Interpolates meteorological data to specified pressure levels.
Definition: mptrac.c:6630
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:5534
void module_mixing(ctl_t *ctl, clim_t *clim, atm_t *atm, double t)
Update atmospheric properties through interparcel mixing.
Definition: mptrac.c:3266
void module_position(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Update the positions and pressure levels of atmospheric particles.
Definition: mptrac.c:3533
void module_meteo(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Update atmospheric properties using meteorological data.
Definition: mptrac.c:3166
#define CT
Maximum number of time steps for climatological data.
Definition: mptrac.h:306
void get_met(ctl_t *ctl, clim_t *clim, double t, met_t **met0, met_t **met1)
Retrieves meteorological data for the specified time.
Definition: mptrac.c:919
void module_oh_chem(ctl_t *ctl, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Perform hydroxyl chemistry calculations for atmospheric particles.
Definition: mptrac.c:3451
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:3816
float stddev(const float *data, const int n)
Calculates the standard deviation of a set of data.
Definition: mptrac.c:8061
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:2049
void read_met_bin_3d(FILE *in, ctl_t *ctl, met_t *met, float var[EX][EY][EP], char *varname, float bound_min, float bound_max)
Reads 3D meteorological data from a binary file, potentially using different compression methods.
Definition: mptrac.c:5851
void module_isosurf_init(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, cache_t *cache)
Initialize the isosurface module based on atmospheric data.
Definition: mptrac.c:2990
int read_met_nc_3d(int ncid, char *varname, char *varname2, char *varname3, char *varname4, ctl_t *ctl, met_t *met, float dest[EX][EY][EP], float scl)
Reads a 3-dimensional meteorological variable from a NetCDF file.
Definition: mptrac.c:6901
void read_met_detrend(ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:6098
double time_from_filename(const char *filename, int offset)
Extracts and converts a timestamp from a filename to Julian seconds.
Definition: mptrac.c:8222
void module_dry_deposition(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double *dt)
Simulate dry deposition of atmospheric particles.
Definition: mptrac.c:2847
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:88
#define CTS
Maximum number of data points of climatological time series.
Definition: mptrac.h:311
void read_met_ozone(met_t *met)
Calculates the total column ozone from meteorological ozone data.
Definition: mptrac.c:7338
void intpol_met_time_3d_ml(met_t *met0, float array0[EX][EY][EP], met_t *met1, float array1[EX][EY][EP], double ts, double p, double lon, double lat, double *var)
Interpolates a meteorological variable in time and 3D space (longitude, latitude, pressure).
Definition: mptrac.c:1586
void write_atm_clams(const char *filename, ctl_t *ctl, atm_t *atm)
Writes air parcel data to a NetCDF file in the CLaMS format.
Definition: mptrac.c:8473
void broadcast_large_data(void *data, size_t N)
Broadcasts large data across all processes in an MPI communicator.
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:221
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: mptrac.c:74
#define NP
Maximum number of atmospheric data points.
Definition: mptrac.h:241
double sza_calc(const double sec, const double lon, const double lat)
Calculates the solar zenith angle.
Definition: mptrac.c:8082
void read_met_surface(int ncid, met_t *met, ctl_t *ctl)
Reads surface meteorological data from a netCDF file and stores it in the meteorological data structu...
Definition: mptrac.c:7514
void module_decay(ctl_t *ctl, clim_t *clim, atm_t *atm, double *dt)
Simulate exponential decay processes for atmospheric particles.
Definition: mptrac.c:2688
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:835
void intpol_met_space_3d(met_t *met, float array[EX][EY][EP], double p, double lon, double lat, double *var, int *ci, double *cw, int init)
Interpolates meteorological variables in 3D space.
Definition: mptrac.c:1373
void 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:4753
int locate_irr_3d(float profiles[EX][EY][EP], int np, int ind_lon, int ind_lat, double x)
Locate the index of the interval containing a given value in a 3D irregular grid.
Definition: mptrac.c:2083
int read_met(const char *filename, ctl_t *ctl, clim_t *clim, met_t *met)
Reads meteorological data from a file and populates the provided structures.
Definition: mptrac.c:5575
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:7232
void module_isosurf(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, cache_t *cache, double *dt)
Apply the isosurface module to adjust atmospheric properties.
Definition: mptrac.c:3054
void get_met_replace(char *orig, char *search, char *repl)
Replaces occurrences of a substring in a string with another substring.
Definition: mptrac.c:1130
#define CY
Maximum number of latitudes for climatological data.
Definition: mptrac.h:286
void write_atm_bin(const char *filename, ctl_t *ctl, atm_t *atm)
Writes air parcel data to a binary file.
Definition: mptrac.c:8423
double clim_ts(const clim_ts_t *ts, const double t)
Interpolates a time series of climatological variables.
Definition: mptrac.c:376
void thrustSortWrapper(double *__restrict__ c, int n, int *__restrict__ index)
Wrapper to Thrust sorting function.
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:1735
void intpol_met_4d_coord(met_t *met0, float height0[EX][EY][EP], float array0[EX][EY][EP], met_t *met1, float height1[EX][EY][EP], float array1[EX][EY][EP], double ts, double height, double lon, double lat, double *var, int *ci, double *cw, int init)
Interpolates meteorological variables to a given position and time.
Definition: mptrac.c:1197
double scan_ctl(const char *filename, int argc, char *argv[], const char *varname, int arridx, const char *defvalue, char *value)
Scans a control file or command-line arguments for a specified variable.
Definition: mptrac.c:7907
void write_atm_nc(const char *filename, ctl_t *ctl, atm_t *atm)
Writes air parcel data to a NetCDF file.
Definition: mptrac.c:8672
void module_convection(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double *dt, double *rs)
Simulate convective processes for atmospheric particles.
Definition: mptrac.c:2616
void get_met_help(ctl_t *ctl, double t, int direct, char *metbase, double dt_met, char *filename)
Helper function to generate the filename for meteorological data.
Definition: mptrac.c:1065
void intpol_met_space_2d(met_t *met, float array[EX][EY], double lon, double lat, double *var, int *ci, double *cw, int init)
Interpolates meteorological variables in 2D space.
Definition: mptrac.c:1500
#define EP
Maximum number of pressure levels for meteo data.
Definition: mptrac.h:256
void module_diffusion_meso(ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, cache_t *cache, double *dt, double *rs)
Simulate mesoscale diffusion for atmospheric particles.
Definition: mptrac.c:2727
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:7173
void compress_zfp(char *varname, float *array, int nx, int ny, int nz, int precision, double tolerance, int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats using the ZFP library.
#define CO3
Maximum number of total column ozone data for climatological data.
Definition: mptrac.h:291
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:905
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:1768
void module_diffusion_turb(ctl_t *ctl, clim_t *clim, atm_t *atm, double *dt, double *rs)
Simulate turbulent diffusion for atmospheric particles.
Definition: mptrac.c:2807
void read_met_cape(clim_t *clim, met_t *met)
Calculates Convective Available Potential Energy (CAPE) for each grid point.
Definition: mptrac.c:5937
double tropo_weight(const clim_t *clim, const double t, const double lat, const double p)
Computes the weighting factor for a given pressure with respect to the tropopause.
Definition: mptrac.c:8257
void read_met_geopot(ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:6242
void write_output(const char *dirname, ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double t)
Writes various types of output data to files in a specified directory.
Definition: mptrac.c:9722
void write_prof(const char *filename, ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, double t)
Writes profile data to a specified file.
Definition: mptrac.c:9817
void compress_pck(char *varname, float *array, size_t nxy, size_t nz, int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats.
Definition: mptrac.c:575
void write_ens(const char *filename, ctl_t *ctl, atm_t *atm, double t)
Writes ensemble data to a file.
Definition: mptrac.c:8977
void locate_vert(float profiles[EX][EY][EP], int np, int lon_ap_ind, int lat_ap_ind, double alt_ap, int *ind)
Locate the four vertical indizes of a box for a given height value.
Definition: mptrac.c:2136
#define CSZA
Maximum number of solar zenith angles for climatological data.
Definition: mptrac.h:301
double lapse_rate(const double t, const double h2o)
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
Definition: mptrac.c:1794
double clim_photo(double rate[CP][CSZA][CO3], clim_photo_t *photo, double p, double sza, double o3c)
Calculates the photolysis rate for a given set of atmospheric conditions.
Definition: mptrac.c:142
Air parcel data.
Definition: mptrac.h:3066
int np
Number of air parcels.
Definition: mptrac.h:3069
Cache data structure.
Definition: mptrac.h:3094
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3106
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3120
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3126
int np
Number of pressure levels.
Definition: mptrac.h:3123
int no3c
Number of total ozone columns.
Definition: mptrac.h:3129
Climatological data.
Definition: mptrac.h:3228
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3270
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3246
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3258
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3249
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3231
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3276
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3264
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3267
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3261
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3255
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3234
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3252
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3273
Climatological data in the form of time series.
Definition: mptrac.h:3176
int ntime
Number of timesteps.
Definition: mptrac.h:3179
Climatological data in the form of zonal means.
Definition: mptrac.h:3196
int np
Number of pressure levels.
Definition: mptrac.h:3205
int ntime
Number of timesteps.
Definition: mptrac.h:3199
int nlat
Number of latitudes.
Definition: mptrac.h:3202
Control parameters.
Definition: mptrac.h:2135
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:2946
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2256
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:2916
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2403
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:2813
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2467
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2289
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:2892
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2675
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2235
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2427
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2738
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2762
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2184
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2436
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2193
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2268
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:2886
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2277
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2663
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:2907
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2244
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3024
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2723
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2584
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2735
double stat_r
Search radius around station [km].
Definition: mptrac.h:3030
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:2807
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:2910
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3054
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2759
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2265
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:2777
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2621
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2415
double met_cms_eps_pv
cmultiscale compression epsilon for potential vorticity.
Definition: mptrac.h:2498
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2343
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:2949
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2439
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2421
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2528
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2571
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2307
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2370
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:2901
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:2913
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2609
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2259
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2618
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:2952
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS).
Definition: mptrac.h:2863
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2636
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:2964
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2199
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2334
double met_cms_eps_h2o
cmultiscale compression epsilon for water vapor.
Definition: mptrac.h:2501
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2286
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:2955
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2313
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2568
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2364
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2458
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:2780
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2552
double met_cms_eps_u
cmultiscale compression epsilon for zonal wind.
Definition: mptrac.h:2489
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2606
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2187
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2211
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2355
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2651
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3036
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2603
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:2970
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:2904
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2217
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:2940
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2340
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:2768
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2669
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2325
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2549
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2534
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2196
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2600
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2588
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2657
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2202
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:2979
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:2880
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:2889
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2531
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2771
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2615
double met_cms_eps_iwc
cmultiscale compression epsilon for cloud ice water content.
Definition: mptrac.h:2513
int conv_mix_bot
Lower level for mixing (0=particle pressure, 1=surface).
Definition: mptrac.h:2630
double met_cms_eps_swc
cmultiscale compression epsilon for cloud snow water content.
Definition: mptrac.h:2516
int met_zfp_prec
ZFP compression precision for all variables, except z and T.
Definition: mptrac.h:2470
double met_cms_eps_v
cmultiscale compression epsilon for meridional wind.
Definition: mptrac.h:2492
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:2982
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2250
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2642
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2562
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:2988
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2181
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2559
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2190
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2577
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2726
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2373
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2310
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:2898
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3033
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:2789
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2732
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2331
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=netCDF, 1=binary,...
Definition: mptrac.h:2867
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:2798
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:2831
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2208
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2400
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3042
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2445
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2627
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2301
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2153
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2229
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2349
double met_cms_eps_cc
cmultiscale compression epsilon for cloud cover.
Definition: mptrac.h:2519
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2648
int met_dx
Stride for longitudes.
Definition: mptrac.h:2522
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2747
int met_convention
Meteo data layout (0=[lev, lat, lon], 1 = [lon, lat, lev]).
Definition: mptrac.h:2461
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2361
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:2801
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2448
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2388
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2382
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2232
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3051
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2247
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2328
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2645
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2574
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2304
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2406
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2144
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2783
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2253
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:2997
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2352
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2241
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3018
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2681
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:2871
double met_cms_eps_lwc
cmultiscale compression epsilon for cloud liquid water content.
Definition: mptrac.h:2507
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2205
double met_cms_eps_z
cmultiscale compression epsilon for geopotential height.
Definition: mptrac.h:2483
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:2958
int conv_mix_top
Upper level for mixing (0=particle pressure, 1=EL).
Definition: mptrac.h:2633
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2430
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2424
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2750
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2220
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2280
int advect
Advection scheme (0=off, 1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2594
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:2985
int reflect
Reflection of particles at top and bottom boundary (0=no, 1=yes).
Definition: mptrac.h:2597
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2238
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:2856
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:2795
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2358
int met_vert_coord
Vertical coordinate of input meteo data (0=pressure-level, 1=model-level).
Definition: mptrac.h:2150
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:2895
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2367
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3027
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2409
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:2961
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2433
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2394
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2540
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2660
double met_cms_eps_t
cmultiscale compression epsilon for temperature.
Definition: mptrac.h:2486
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2756
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2292
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2639
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2729
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2298
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2654
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2741
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2397
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2385
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:2943
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:2922
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:2859
int advect_cpl_zeta_and_press_modules
Coupled use of pressure based modules and diabatic advection.
Definition: mptrac.h:2141
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2555
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2753
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:2853
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3003
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:2837
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2537
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:2991
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2765
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2274
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2322
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2337
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3000
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2295
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:2840
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:2994
double met_cms_eps_rwc
cmultiscale compression epsilon for cloud rain water content.
Definition: mptrac.h:2510
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:2792
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2418
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:2828
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2774
double met_cms_eps_o3
cmultiscale compression epsilon for ozone.
Definition: mptrac.h:2504
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:2937
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:2834
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2223
int met_np
Number of target pressure levels.
Definition: mptrac.h:2543
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2178
double met_zfp_tol_t
ZFP compression tolerance for temperature.
Definition: mptrac.h:2473
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2720
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2319
double met_zfp_tol_z
ZFP compression tolerance for geopotential height.
Definition: mptrac.h:2476
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3048
double met_cms_eps_w
cmultiscale compression epsilon for vertical velocity.
Definition: mptrac.h:2495
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2624
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2376
int advect_vert_coord
Vertical coordinate of air parcels (0=pressure, 1=zeta, 2=eta).
Definition: mptrac.h:2147
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2316
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2412
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2214
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2744
int met_cms_heur
cmultiscale coarsening heuristics (0=default, 1=mean diff, 2=median diff, 3=max diff).
Definition: mptrac.h:2480
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:2825
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2346
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:2816
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:2810
int met_dy
Stride for latitudes.
Definition: mptrac.h:2525
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2391
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2612
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2666
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2175
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2565
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2262
double t_start
Start time of simulation [s].
Definition: mptrac.h:2442
int nq
Number of quantities.
Definition: mptrac.h:2160
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2678
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3015
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3045
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:2967
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2226
int met_type
Type of meteo data files (0=netCDF, 1=binary, 2=pck, 3=zfp, 4=zstd).
Definition: mptrac.h:2464
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2271
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2283
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:2934
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2379
Meteo data structure.
Definition: mptrac.h:3287
int nx
Number of longitudes.
Definition: mptrac.h:3293
int ny
Number of latitudes.
Definition: mptrac.h:3296
int np
Number of pressure levels.
Definition: mptrac.h:3299
int npl
Number of model levels.
Definition: mptrac.h:3302
double time
Time [s].
Definition: mptrac.h:3290