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 60 */
257#define EP 140
258#endif
259
261#ifndef EX
262#define EX 1202
263/* #define EX 481 */
264#endif
265
267#ifndef EY
268/* #define EY 241 */
269#define EY 602
270#endif
271
273#ifndef NENS
274#define NENS 2000
275#endif
276
278#ifndef NOBS
279#define NOBS 10000000
280#endif
281
283#ifndef NTHREADS
284#define NTHREADS 512
285#endif
286
288#ifndef CY
289#define CY 250
290#endif
291
293#ifndef CO3
294#define CO3 30
295#endif
296
298#ifndef CP
299#define CP 70
300#endif
301
303#ifndef CSZA
304#define CSZA 50
305#endif
306
308#ifndef CT
309#define CT 12
310#endif
311
313#ifndef CTS
314#define CTS 1000
315#endif
316
317/* ------------------------------------------------------------
318 Macros...
319 ------------------------------------------------------------ */
320
340#ifdef _OPENACC
341#define ALLOC(ptr, type, n) \
342 if(acc_get_num_devices(acc_device_nvidia) <= 0) \
343 ERRMSG("Not running on a GPU device!"); \
344 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
345 ERRMSG("Out of memory!");
346#else
347#define ALLOC(ptr, type, n) \
348 if((ptr=calloc((size_t)(n), sizeof(type)))==NULL) \
349 ERRMSG("Out of memory!");
350#endif
351
370#define ARRAY_2D(ix, iy, ny) \
371 ((ix) * (ny) + (iy))
372
389#define ARRAY_3D(ix, iy, ny, iz, nz) \
390 (((ix)*(ny) + (iy)) * (nz) + (iz))
391
414#define ARRHENIUS(a, b, t) \
415 ((a) * exp( -(b) / (t)))
416
438#define DEG2DX(dlon, lat) \
439 (RE * DEG2RAD(dlon) * cos(DEG2RAD(lat)))
440
459#define DEG2DY(dlat) \
460 (RE * DEG2RAD(dlat))
461
476#define DEG2RAD(deg) \
477 ((deg) * (M_PI / 180.0))
478
499#define DP2DZ(dp, p) \
500 (- (dp) * H0 / (p))
501
521#define DX2DEG(dx, lat) \
522 (((lat) < -89.999 || (lat) > 89.999) ? 0 \
523 : (dx) * 180. / (M_PI * RE * cos(DEG2RAD(lat))))
524
539#define DY2DEG(dy) \
540 ((dy) * 180. / (M_PI * RE))
541
556#define DZ2DP(dz, p) \
557 (-(dz) * (p) / H0)
558
572#define DIST(a, b) \
573 sqrt(DIST2(a, b))
574
588#define DIST2(a, b) \
589 ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]))
590
604#define DOTP(a, b) \
605 (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])
606
623#define FMOD(x, y) \
624 ((x) - (int) ((x) / (y)) * (y))
625
641#define FREAD(ptr, type, size, in) { \
642 if(fread(ptr, sizeof(type), size, in)!=size) \
643 ERRMSG("Error while reading!"); \
644 }
645
661#define FWRITE(ptr, type, size, out) { \
662 if(fwrite(ptr, sizeof(type), size, out)!=size) \
663 ERRMSG("Error while writing!"); \
664 }
665
676#define INTPOL_INIT \
677 double cw[4] = {0.0, 0.0, 0.0, 0.0}; int ci[3] = {0, 0, 0};
678
690#define INTPOL_2D(var, init) \
691 intpol_met_time_2d(met0, met0->var, met1, met1->var, \
692 atm->time[ip], atm->lon[ip], atm->lat[ip], \
693 &var, ci, cw, init);
694
707#define INTPOL_3D(var, init) \
708 intpol_met_time_3d(met0, met0->var, met1, met1->var, \
709 atm->time[ip], atm->p[ip], \
710 atm->lon[ip], atm->lat[ip], \
711 &var, ci, cw, init);
712
726#define INTPOL_SPACE_ALL(p, lon, lat) { \
727 intpol_met_space_3d(met, met->z, p, lon, lat, &z, ci, cw, 1); \
728 intpol_met_space_3d(met, met->t, p, lon, lat, &t, ci, cw, 0); \
729 intpol_met_space_3d(met, met->u, p, lon, lat, &u, ci, cw, 0); \
730 intpol_met_space_3d(met, met->v, p, lon, lat, &v, ci, cw, 0); \
731 intpol_met_space_3d(met, met->w, p, lon, lat, &w, ci, cw, 0); \
732 intpol_met_space_3d(met, met->pv, p, lon, lat, &pv, ci, cw, 0); \
733 intpol_met_space_3d(met, met->h2o, p, lon, lat, &h2o, ci, cw, 0); \
734 intpol_met_space_3d(met, met->o3, p, lon, lat, &o3, ci, cw, 0); \
735 intpol_met_space_3d(met, met->lwc, p, lon, lat, &lwc, ci, cw, 0); \
736 intpol_met_space_3d(met, met->rwc, p, lon, lat, &rwc, ci, cw, 0); \
737 intpol_met_space_3d(met, met->iwc, p, lon, lat, &iwc, ci, cw, 0); \
738 intpol_met_space_3d(met, met->swc, p, lon, lat, &swc, ci, cw, 0); \
739 intpol_met_space_3d(met, met->cc, p, lon, lat, &cc, ci, cw, 0); \
740 intpol_met_space_2d(met, met->ps, lon, lat, &ps, ci, cw, 0); \
741 intpol_met_space_2d(met, met->ts, lon, lat, &ts, ci, cw, 0); \
742 intpol_met_space_2d(met, met->zs, lon, lat, &zs, ci, cw, 0); \
743 intpol_met_space_2d(met, met->us, lon, lat, &us, ci, cw, 0); \
744 intpol_met_space_2d(met, met->vs, lon, lat, &vs, ci, cw, 0); \
745 intpol_met_space_2d(met, met->lsm, lon, lat, &lsm, ci, cw, 0); \
746 intpol_met_space_2d(met, met->sst, lon, lat, &sst, ci, cw, 0); \
747 intpol_met_space_2d(met, met->pbl, lon, lat, &pbl, ci, cw, 0); \
748 intpol_met_space_2d(met, met->pt, lon, lat, &pt, ci, cw, 0); \
749 intpol_met_space_2d(met, met->tt, lon, lat, &tt, ci, cw, 0); \
750 intpol_met_space_2d(met, met->zt, lon, lat, &zt, ci, cw, 0); \
751 intpol_met_space_2d(met, met->h2ot, lon, lat, &h2ot, ci, cw, 0); \
752 intpol_met_space_2d(met, met->pct, lon, lat, &pct, ci, cw, 0); \
753 intpol_met_space_2d(met, met->pcb, lon, lat, &pcb, ci, cw, 0); \
754 intpol_met_space_2d(met, met->cl, lon, lat, &cl, ci, cw, 0); \
755 intpol_met_space_2d(met, met->plcl, lon, lat, &plcl, ci, cw, 0); \
756 intpol_met_space_2d(met, met->plfc, lon, lat, &plfc, ci, cw, 0); \
757 intpol_met_space_2d(met, met->pel, lon, lat, &pel, ci, cw, 0); \
758 intpol_met_space_2d(met, met->cape, lon, lat, &cape, ci, cw, 0); \
759 intpol_met_space_2d(met, met->cin, lon, lat, &cin, ci, cw, 0); \
760 intpol_met_space_2d(met, met->o3c, lon, lat, &o3c, ci, cw, 0); \
761 }
762
777#define INTPOL_TIME_ALL(time, p, lon, lat) { \
778 intpol_met_time_3d(met0, met0->z, met1, met1->z, time, p, lon, lat, &z, ci, cw, 1); \
779 intpol_met_time_3d(met0, met0->t, met1, met1->t, time, p, lon, lat, &t, ci, cw, 0); \
780 intpol_met_time_3d(met0, met0->u, met1, met1->u, time, p, lon, lat, &u, ci, cw, 0); \
781 intpol_met_time_3d(met0, met0->v, met1, met1->v, time, p, lon, lat, &v, ci, cw, 0); \
782 intpol_met_time_3d(met0, met0->w, met1, met1->w, time, p, lon, lat, &w, ci, cw, 0); \
783 intpol_met_time_3d(met0, met0->pv, met1, met1->pv, time, p, lon, lat, &pv, ci, cw, 0); \
784 intpol_met_time_3d(met0, met0->h2o, met1, met1->h2o, time, p, lon, lat, &h2o, ci, cw, 0); \
785 intpol_met_time_3d(met0, met0->o3, met1, met1->o3, time, p, lon, lat, &o3, ci, cw, 0); \
786 intpol_met_time_3d(met0, met0->lwc, met1, met1->lwc, time, p, lon, lat, &lwc, ci, cw, 0); \
787 intpol_met_time_3d(met0, met0->rwc, met1, met1->rwc, time, p, lon, lat, &rwc, ci, cw, 0); \
788 intpol_met_time_3d(met0, met0->iwc, met1, met1->iwc, time, p, lon, lat, &iwc, ci, cw, 0); \
789 intpol_met_time_3d(met0, met0->swc, met1, met1->swc, time, p, lon, lat, &swc, ci, cw, 0); \
790 intpol_met_time_3d(met0, met0->cc, met1, met1->cc, time, p, lon, lat, &cc, ci, cw, 0); \
791 intpol_met_time_2d(met0, met0->ps, met1, met1->ps, time, lon, lat, &ps, ci, cw, 0); \
792 intpol_met_time_2d(met0, met0->ts, met1, met1->ts, time, lon, lat, &ts, ci, cw, 0); \
793 intpol_met_time_2d(met0, met0->zs, met1, met1->zs, time, lon, lat, &zs, ci, cw, 0); \
794 intpol_met_time_2d(met0, met0->us, met1, met1->us, time, lon, lat, &us, ci, cw, 0); \
795 intpol_met_time_2d(met0, met0->vs, met1, met1->vs, time, lon, lat, &vs, ci, cw, 0); \
796 intpol_met_time_2d(met0, met0->lsm, met1, met1->lsm, time, lon, lat, &lsm, ci, cw, 0); \
797 intpol_met_time_2d(met0, met0->sst, met1, met1->sst, time, lon, lat, &sst, ci, cw, 0); \
798 intpol_met_time_2d(met0, met0->pbl, met1, met1->pbl, time, lon, lat, &pbl, ci, cw, 0); \
799 intpol_met_time_2d(met0, met0->pt, met1, met1->pt, time, lon, lat, &pt, ci, cw, 0); \
800 intpol_met_time_2d(met0, met0->tt, met1, met1->tt, time, lon, lat, &tt, ci, cw, 0); \
801 intpol_met_time_2d(met0, met0->zt, met1, met1->zt, time, lon, lat, &zt, ci, cw, 0); \
802 intpol_met_time_2d(met0, met0->h2ot, met1, met1->h2ot, time, lon, lat, &h2ot, ci, cw, 0); \
803 intpol_met_time_2d(met0, met0->pct, met1, met1->pct, time, lon, lat, &pct, ci, cw, 0); \
804 intpol_met_time_2d(met0, met0->pcb, met1, met1->pcb, time, lon, lat, &pcb, ci, cw, 0); \
805 intpol_met_time_2d(met0, met0->cl, met1, met1->cl, time, lon, lat, &cl, ci, cw, 0); \
806 intpol_met_time_2d(met0, met0->plcl, met1, met1->plcl, time, lon, lat, &plcl, ci, cw, 0); \
807 intpol_met_time_2d(met0, met0->plfc, met1, met1->plfc, time, lon, lat, &plfc, ci, cw, 0); \
808 intpol_met_time_2d(met0, met0->pel, met1, met1->pel, time, lon, lat, &pel, ci, cw, 0); \
809 intpol_met_time_2d(met0, met0->cape, met1, met1->cape, time, lon, lat, &cape, ci, cw, 0); \
810 intpol_met_time_2d(met0, met0->cin, met1, met1->cin, time, lon, lat, &cin, ci, cw, 0); \
811 intpol_met_time_2d(met0, met0->o3c, met1, met1->o3c, time, lon, lat, &o3c, ci, cw, 0); \
812 }
813
828#define LAPSE(p1, t1, p2, t2) \
829 (1e3 * G0 / RA * ((t2) - (t1)) / ((t2) + (t1)) \
830 * ((p2) + (p1)) / ((p2) - (p1)))
831
847#define LIN(x0, y0, x1, y1, x) \
848 ((y0)+((y1)-(y0))/((x1)-(x0))*((x)-(x0)))
849
874#define MAX(a,b) \
875 (((a)>(b))?(a):(b))
876
888#define MET_HEADER \
889 fprintf(out, \
890 "# $1 = time [s]\n" \
891 "# $2 = altitude [km]\n" \
892 "# $3 = longitude [deg]\n" \
893 "# $4 = latitude [deg]\n" \
894 "# $5 = pressure [hPa]\n" \
895 "# $6 = temperature [K]\n" \
896 "# $7 = zonal wind [m/s]\n" \
897 "# $8 = meridional wind [m/s]\n" \
898 "# $9 = vertical velocity [hPa/s]\n" \
899 "# $10 = H2O volume mixing ratio [ppv]\n"); \
900 fprintf(out, \
901 "# $11 = O3 volume mixing ratio [ppv]\n" \
902 "# $12 = geopotential height [km]\n" \
903 "# $13 = potential vorticity [PVU]\n" \
904 "# $14 = surface pressure [hPa]\n" \
905 "# $15 = surface temperature [K]\n" \
906 "# $16 = surface geopotential height [km]\n" \
907 "# $17 = surface zonal wind [m/s]\n" \
908 "# $18 = surface meridional wind [m/s]\n" \
909 "# $19 = land-sea mask [1]\n" \
910 "# $20 = sea surface temperature [K]\n"); \
911 fprintf(out, \
912 "# $21 = tropopause pressure [hPa]\n" \
913 "# $22 = tropopause geopotential height [km]\n" \
914 "# $23 = tropopause temperature [K]\n" \
915 "# $24 = tropopause water vapor [ppv]\n" \
916 "# $25 = cloud liquid water content [kg/kg]\n" \
917 "# $26 = cloud rain water content [kg/kg]\n" \
918 "# $27 = cloud ice water content [kg/kg]\n" \
919 "# $28 = cloud snow water content [kg/kg]\n" \
920 "# $29 = cloud cover [1]\n" \
921 "# $30 = total column cloud water [kg/m^2]\n"); \
922 fprintf(out, \
923 "# $31 = cloud top pressure [hPa]\n" \
924 "# $32 = cloud bottom pressure [hPa]\n" \
925 "# $33 = pressure at lifted condensation level (LCL) [hPa]\n" \
926 "# $34 = pressure at level of free convection (LFC) [hPa]\n" \
927 "# $35 = pressure at equilibrium level (EL) [hPa]\n" \
928 "# $36 = convective available potential energy (CAPE) [J/kg]\n" \
929 "# $37 = convective inhibition (CIN) [J/kg]\n" \
930 "# $38 = relative humidity over water [%%]\n" \
931 "# $39 = relative humidity over ice [%%]\n" \
932 "# $40 = dew point temperature [K]\n"); \
933 fprintf(out, \
934 "# $41 = frost point temperature [K]\n" \
935 "# $42 = NAT temperature [K]\n" \
936 "# $43 = HNO3 volume mixing ratio [ppv]\n" \
937 "# $44 = OH volume mixing ratio [ppv]\n" \
938 "# $45 = H2O2 volume mixing ratio [ppv]\n" \
939 "# $46 = HO2 volume mixing ratio [ppv]\n" \
940 "# $47 = O(1D) volume mixing ratio [ppv]\n" \
941 "# $48 = boundary layer pressure [hPa]\n" \
942 "# $49 = total column ozone [DU]\n" \
943 "# $50 = number of data points\n"); \
944 fprintf(out, \
945 "# $51 = number of tropopause data points\n" \
946 "# $52 = number of CAPE data points\n");
947
972#define MIN(a,b) \
973 (((a)<(b))?(a):(b))
974
987#define MOLEC_DENS(p,t) \
988 (AVO * 1e-6 * ((p) * 100) / (RI * (t)))
989
1001#define NC(cmd) { \
1002 int nc_result=(cmd); \
1003 if(nc_result!=NC_NOERR) \
1004 ERRMSG("%s", nc_strerror(nc_result)); \
1005 }
1006
1030#define NC_DEF_VAR(varname, type, ndims, dims, long_name, units, level, quant) { \
1031 NC(nc_def_var(ncid, varname, type, ndims, dims, &varid)); \
1032 NC(nc_put_att_text(ncid, varid, "long_name", strnlen(long_name, LEN), long_name)); \
1033 NC(nc_put_att_text(ncid, varid, "units", strnlen(units, LEN), units)); \
1034 if((quant) > 0) \
1035 NC(nc_def_var_quantize(ncid, varid, NC_QUANTIZE_GRANULARBR, quant)); \
1036 if((level) != 0) { \
1037 NC(nc_def_var_deflate(ncid, varid, 1, 1, level)); \
1038 /* unsigned int ulevel = (unsigned int)level; */ \
1039 /* NC(nc_def_var_filter(ncid, varid, 32015, 1, (unsigned int[]){ulevel})); */ \
1040 } \
1041 }
1042
1060#define NC_GET_DOUBLE(varname, ptr, force) { \
1061 if(force) { \
1062 NC(nc_inq_varid(ncid, varname, &varid)); \
1063 NC(nc_get_var_double(ncid, varid, ptr)); \
1064 } else { \
1065 if(nc_inq_varid(ncid, varname, &varid) == NC_NOERR) { \
1066 NC(nc_get_var_double(ncid, varid, ptr)); \
1067 } else \
1068 WARN("netCDF variable %s is missing!", varname); \
1069 } \
1070 }
1071
1088#define NC_INQ_DIM(dimname, ptr, min, max) { \
1089 int dimid; size_t naux; \
1090 NC(nc_inq_dimid(ncid, dimname, &dimid)); \
1091 NC(nc_inq_dimlen(ncid, dimid, &naux)); \
1092 *ptr = (int)naux; \
1093 if ((*ptr) < (min) || (*ptr) > (max)) \
1094 ERRMSG("Dimension %s is out of range!", dimname); \
1095 }
1096
1111#define NC_PUT_DOUBLE(varname, ptr, hyperslab) { \
1112 NC(nc_inq_varid(ncid, varname, &varid)); \
1113 if(hyperslab) { \
1114 NC(nc_put_vara_double(ncid, varid, start, count, ptr)); \
1115 } else { \
1116 NC(nc_put_var_double(ncid, varid, ptr)); \
1117 } \
1118 }
1119
1135#define NC_PUT_FLOAT(varname, ptr, hyperslab) { \
1136 NC(nc_inq_varid(ncid, varname, &varid)); \
1137 if(hyperslab) { \
1138 NC(nc_put_vara_float(ncid, varid, start, count, ptr)); \
1139 } else { \
1140 NC(nc_put_var_float(ncid, varid, ptr)); \
1141 } \
1142 }
1143
1158#define NC_PUT_INT(varname, ptr, hyperslab) { \
1159 NC(nc_inq_varid(ncid, varname, &varid)); \
1160 if(hyperslab) { \
1161 NC(nc_put_vara_int(ncid, varid, start, count, ptr)); \
1162 } else { \
1163 NC(nc_put_var_int(ncid, varid, ptr)); \
1164 } \
1165 }
1166
1180#define NC_PUT_ATT(varname, attname, text) { \
1181 NC(nc_inq_varid(ncid, varname, &varid)); \
1182 NC(nc_put_att_text(ncid, varid, attname, strnlen(text, LEN), text)); \
1183 }
1184
1197#define NC_PUT_ATT_GLOBAL(attname, text) \
1198 NC(nc_put_att_text(ncid, NC_GLOBAL, attname, strnlen(text, LEN), text));
1199
1217#define NN(x0, y0, x1, y1, x) \
1218 (fabs((x) - (x0)) <= fabs((x) - (x1)) ? (y0) : (y1))
1219
1232#define NORM(a) \
1233 sqrt(DOTP(a, a))
1234
1250#ifdef _OPENACC
1251#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1252 const int ip0_const = ip0; \
1253 const int ip1_const = ip1; \
1254 _Pragma(__VA_ARGS__) \
1255 _Pragma("acc parallel loop independent gang vector") \
1256 for (int ip = ip0_const; ip < ip1_const; ip++) \
1257 if (!check_dt || dt[ip] != 0)
1258#else
1259#define PARTICLE_LOOP(ip0, ip1, check_dt, ...) \
1260 const int ip0_const = ip0; \
1261 const int ip1_const = ip1; \
1262 _Pragma("omp parallel for default(shared)") \
1263 for (int ip = ip0_const; ip < ip1_const; ip++) \
1264 if (!check_dt || dt[ip] != 0)
1265#endif
1266
1289#define P(z) \
1290 (P0 * exp(-(z) / H0))
1291
1313#define PSAT(t) \
1314 (6.112 * exp(17.62 * ((t) - T0) / (243.12 + (t) - T0)))
1315
1337#define PSICE(t) \
1338 (6.112 * exp(22.46 * ((t) - T0) / (272.62 + (t) - T0)))
1339
1364#define PW(p, h2o) \
1365 ((p) * MAX((h2o), 0.1e-6) / (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1366
1381#define RAD2DEG(rad) \
1382 ((rad) * (180.0 / M_PI))
1383
1411#define RH(p, t, h2o) \
1412 (PW(p, h2o) / PSAT(t) * 100.)
1413
1441#define RHICE(p, t, h2o) \
1442 (PW(p, h2o) / PSICE(t) * 100.)
1443
1466#define RHO(p, t) \
1467 (100. * (p) / (RA * (t)))
1468
1485#define SET_ATM(qnt, val) \
1486 if (ctl->qnt >= 0) \
1487 atm->q[ctl->qnt][ip] = val;
1488
1508#define SET_QNT(qnt, name, longname, unit) \
1509 if (strcasecmp(ctl->qnt_name[iq], name) == 0) { \
1510 ctl->qnt = iq; \
1511 sprintf(ctl->qnt_longname[iq], longname); \
1512 sprintf(ctl->qnt_unit[iq], unit); \
1513 } else
1514
1529#define SH(h2o) \
1530 (EPS * MAX((h2o), 0.1e-6))
1531
1542#define SQR(x) \
1543 ((x)*(x))
1544
1556#define SWAP(x, y, type) \
1557 do {type tmp = x; x = y; y = tmp;} while(0);
1558
1580#define TDEW(p, h2o) \
1581 (T0 + 243.12 * log(PW((p), (h2o)) / 6.112) \
1582 / (17.62 - log(PW((p), (h2o)) / 6.112)))
1583
1605#define TICE(p, h2o) \
1606 (T0 + 272.62 * log(PW((p), (h2o)) / 6.112) \
1607 / (22.46 - log(PW((p), (h2o)) / 6.112)))
1608
1629#define THETA(p, t) \
1630 ((t) * pow(1000. / (p), 0.286))
1631
1658#define THETAVIRT(p, t, h2o) \
1659 (TVIRT(THETA((p), (t)), MAX((h2o), 0.1e-6)))
1660
1679#define TOK(line, tok, format, var) { \
1680 if(((tok)=strtok((line), " \t"))) { \
1681 if(sscanf(tok, format, &(var))!=1) continue; \
1682 } else ERRMSG("Error while reading!"); \
1683 }
1684
1704#define TVIRT(t, h2o) \
1705 ((t) * (1. + (1. - EPS) * MAX((h2o), 0.1e-6)))
1706
1726#define Z(p) \
1727 (H0 * log(P0 / (p)))
1728
1757#define ZDIFF(lnp0, t0, h2o0, lnp1, t1, h2o1) \
1758 (RI / MA / G0 * 0.5 * (TVIRT((t0), (h2o0)) + TVIRT((t1), (h2o1))) \
1759 * ((lnp0) - (lnp1)))
1760
1788#define ZETA(ps, p, t) \
1789 (((p) / (ps) <= 0.3 ? 1. : \
1790 sin(M_PI / 2. * (1. - (p) / (ps)) / (1. - 0.3))) \
1791 * THETA((p), (t)))
1792
1793/* ------------------------------------------------------------
1794 Log messages...
1795 ------------------------------------------------------------ */
1796
1798#ifndef LOGLEV
1799#define LOGLEV 2
1800#endif
1801
1831#define LOG(level, ...) { \
1832 if(level >= 2) \
1833 printf(" "); \
1834 if(level <= LOGLEV) { \
1835 printf(__VA_ARGS__); \
1836 printf("\n"); \
1837 } \
1838 }
1839
1868#define WARN(...) { \
1869 printf("\nWarning (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
1870 LOG(0, __VA_ARGS__); \
1871 }
1872
1901#define ERRMSG(...) { \
1902 printf("\nError (%s, %s, l%d): ", __FILE__, __func__, __LINE__); \
1903 LOG(0, __VA_ARGS__); \
1904 exit(EXIT_FAILURE); \
1905 }
1906
1936#define PRINT(format, var) \
1937 printf("Print (%s, %s, l%d): %s= "format"\n", \
1938 __FILE__, __func__, __LINE__, #var, var);
1939
1940/* ------------------------------------------------------------
1941 Timers...
1942 ------------------------------------------------------------ */
1943
1945#define NTIMER 100
1946
1960#define PRINT_TIMERS \
1961 timer("END", "END", 1);
1962
1981#define SELECT_TIMER(id, group, color) { \
1982 NVTX_POP; \
1983 NVTX_PUSH(id, color); \
1984 timer(id, group, 0); \
1985 }
1986
2000#define START_TIMERS \
2001 NVTX_PUSH("START", NVTX_CPU);
2002
2015#define STOP_TIMERS \
2016 NVTX_POP;
2017
2018/* ------------------------------------------------------------
2019 NVIDIA Tools Extension (NVTX)...
2020 ------------------------------------------------------------ */
2021
2022#ifdef NVTX
2023#include "nvToolsExt.h"
2024
2026#define NVTX_CPU 0xFFADD8E6
2027
2029#define NVTX_GPU 0xFF00008B
2030
2032#define NVTX_H2D 0xFFFFFF00
2033
2035#define NVTX_D2H 0xFFFF8800
2036
2038#define NVTX_READ 0xFFFFCCCB
2039
2041#define NVTX_WRITE 0xFF8B0000
2042
2044#define NVTX_RECV 0xFFCCFFCB
2045
2047#define NVTX_SEND 0xFF008B00
2048
2078#define NVTX_PUSH(range_title, range_color) { \
2079 nvtxEventAttributes_t eventAttrib = {0}; \
2080 eventAttrib.version = NVTX_VERSION; \
2081 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
2082 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
2083 eventAttrib.colorType = NVTX_COLOR_ARGB; \
2084 eventAttrib.color = range_color; \
2085 eventAttrib.message.ascii = range_title; \
2086 nvtxRangePushEx(&eventAttrib); \
2087 }
2088
2101#define NVTX_POP { \
2102 nvtxRangePop(); \
2103 }
2104#else
2105
2106/* Empty definitions of NVTX_PUSH and NVTX_POP... */
2107#define NVTX_PUSH(range_title, range_color) {}
2108#define NVTX_POP {}
2109#endif
2110
2111/* ------------------------------------------------------------
2112 Thrust...
2113 ------------------------------------------------------------ */
2114
2140 double *__restrict__ c,
2141 int n,
2142 int *__restrict__ index);
2143
2144/* ------------------------------------------------------------
2145 Structs...
2146 ------------------------------------------------------------ */
2147
2155typedef struct {
2156
2157 /* TODO: finally sort ctl parameters once Fortran wrapper is working! */
2158
2162
2165
2168
2171
2174
2175 /* ------------------------------------------------------------
2176 Quantity parameters...
2177 ------------------------------------------------------------ */
2178
2180 int nq;
2181
2183 char qnt_name[NQ][LEN];
2184
2186 char qnt_longname[NQ][LEN];
2187
2189 char qnt_unit[NQ][LEN];
2190
2192 char qnt_format[NQ][LEN];
2193
2196
2199
2202
2205
2208
2211
2214
2217
2220
2223
2226
2229
2232
2235
2238
2241
2244
2247
2250
2253
2256
2259
2262
2265
2268
2271
2274
2277
2280
2283
2286
2289
2292
2295
2298
2301
2304
2307
2310
2313
2316
2319
2322
2325
2328
2331
2334
2337
2340
2343
2346
2349
2352
2355
2358
2361
2364
2367
2370
2373
2376
2379
2382
2385
2388
2391
2394
2397
2400
2403
2406
2409
2412
2415
2418
2421
2424
2427
2430
2433
2436
2439
2442
2445
2448
2451
2454
2457
2460
2462 double t_start;
2463
2465 double t_stop;
2466
2468 double dt_mod;
2469
2470 /* ------------------------------------------------------------
2471 Meteo data parameters...
2472 ------------------------------------------------------------ */
2473
2475 char metbase[LEN];
2476
2478 double dt_met;
2479
2482
2486
2489
2492
2495
2498
2501
2504
2507
2511
2514
2517
2520
2523
2526
2529
2532
2535
2538
2541
2544
2547
2550
2553
2556
2559
2562
2565
2568
2571
2574
2576 double met_p[EP];
2577
2580
2583
2586
2589
2592
2595
2598
2602
2605
2608
2611
2614
2617
2620
2621 /* ------------------------------------------------------------
2622 Geophysical module parameters...
2623 ------------------------------------------------------------ */
2624
2626 double sort_dt;
2627
2631
2633 char balloon[LEN];
2634
2637
2640
2643
2646
2649
2652
2655
2658
2661
2664
2666 double conv_cin;
2667
2669 double conv_dt;
2670
2673
2676
2679
2682
2685
2688
2691
2694
2696 double bound_p0;
2697
2699 double bound_p1;
2700
2703
2706
2709
2712
2714 char species[LEN];
2715
2717 double molmass;
2718
2721
2724
2727
2729 char clim_hno3_filename[LEN];
2730
2732 char clim_oh_filename[LEN];
2733
2735 char clim_h2o2_filename[LEN];
2736
2738 char clim_ho2_filename[LEN];
2739
2741 char clim_o1d_filename[LEN];
2742
2744 char clim_o3_filename[LEN];
2745
2747 char clim_ccl4_timeseries[LEN];
2748
2750 char clim_ccl3f_timeseries[LEN];
2751
2753 char clim_ccl2f2_timeseries[LEN];
2754
2756 char clim_n2o_timeseries[LEN];
2757
2759 char clim_sf6_timeseries[LEN];
2760
2763
2766
2769
2772
2775
2778
2781
2784
2787
2790
2793
2796
2799
2802
2805
2808
2811
2814
2817
2820
2823
2826
2828 double oh_chem[4];
2829
2832
2835
2838
2840 double dt_kpp;
2841
2844
2846 double wet_depo_pre[2];
2847
2850
2853
2856
2859
2861 double wet_depo_ic_h[3];
2862
2864 double wet_depo_bc_h[2];
2865
2868
2871
2874
2877
2879 double psc_h2o;
2880
2882 double psc_hno3;
2883
2884 /* ------------------------------------------------------------
2885 Output parameters...
2886 ------------------------------------------------------------ */
2887
2889 char atm_basename[LEN];
2890
2892 char atm_gpfile[LEN];
2893
2896
2899
2902
2906
2911
2914
2916 int atm_nc_quant[NQ];
2917
2920
2922 char csi_basename[LEN];
2923
2925 char csi_kernel[LEN];
2926
2929
2931 char csi_obsfile[LEN];
2932
2935
2938
2941
2943 double csi_z0;
2944
2946 double csi_z1;
2947
2950
2952 double csi_lon0;
2953
2955 double csi_lon1;
2956
2959
2961 double csi_lat0;
2962
2964 double csi_lat1;
2965
2967 char ens_basename[LEN];
2968
2971
2973 char grid_basename[LEN];
2974
2976 char grid_kernel[LEN];
2977
2979 char grid_gpfile[LEN];
2980
2983
2986
2989
2991 int grid_nc_quant[NQ];
2992
2995
2998
3000 double grid_z0;
3001
3003 double grid_z1;
3004
3007
3010
3013
3016
3019
3022
3025
3027 char prof_basename[LEN];
3028
3030 char prof_obsfile[LEN];
3031
3034
3036 double prof_z0;
3037
3039 double prof_z1;
3040
3043
3046
3049
3052
3055
3058
3060 char sample_basename[LEN];
3061
3063 char sample_kernel[LEN];
3064
3066 char sample_obsfile[LEN];
3067
3070
3073
3075 char stat_basename[LEN];
3076
3078 double stat_lon;
3079
3081 double stat_lat;
3082
3084 double stat_r;
3085
3087 double stat_t0;
3088
3090 double stat_t1;
3091
3093 char vtk_basename[LEN];
3094
3097
3100
3103
3106
3109
3110} ctl_t;
3111
3120typedef struct {
3121
3123 int np;
3124
3126 double time[NP];
3127
3129 double p[NP];
3130
3132 double lon[NP];
3133
3135 double lat[NP];
3136
3138 double q[NQ][NP];
3139
3140} atm_t;
3141
3148typedef struct {
3149
3151 double iso_var[NP];
3152
3154 double iso_ps[NP];
3155
3157 double iso_ts[NP];
3158
3161
3163 float uvwp[NP][3];
3164
3165} cache_t;
3166
3174typedef struct {
3175
3177 int np;
3178
3180 int nsza;
3181
3183 int no3c;
3184
3186 double p[CP];
3187
3189 double sza[CSZA];
3190
3192 double o3c[CO3];
3193
3195 double n2o[CP][CSZA][CO3];
3196
3198 double ccl4[CP][CSZA][CO3];
3199
3201 double ccl3f[CP][CSZA][CO3];
3202
3204 double ccl2f2[CP][CSZA][CO3];
3205
3207 double o2[CP][CSZA][CO3];
3208
3210 double o3_1[CP][CSZA][CO3];
3211
3213 double o3_2[CP][CSZA][CO3];
3214
3216 double h2o2[CP][CSZA][CO3];
3217
3219 double h2o[CP][CSZA][CO3];
3220
3221} clim_photo_t;
3222
3230typedef struct {
3231
3234
3236 double time[CTS];
3237
3239 double vmr[CTS];
3240
3241} clim_ts_t;
3242
3250typedef struct {
3251
3254
3256 int nlat;
3257
3259 int np;
3260
3262 double time[CT];
3263
3265 double lat[CY];
3266
3268 double p[CP];
3269
3271 double vmr[CT][CP][CY];
3272
3273} clim_zm_t;
3274
3282typedef struct {
3283
3286
3289
3291 double tropo_time[12];
3292
3294 double tropo_lat[73];
3295
3297 double tropo[12][73];
3298
3301
3304
3307
3310
3313
3316
3319
3322
3325
3328
3331
3332} clim_t;
3333
3341typedef struct {
3342
3344 double time;
3345
3347 int nx;
3348
3350 int ny;
3351
3353 int np;
3354
3356 int npl;
3357
3359 double lon[EX];
3360
3362 double lat[EY];
3363
3365 double p[EP];
3366
3368 double hybrid[EP];
3369
3371 float ps[EX][EY];
3372
3374 float ts[EX][EY];
3375
3377 float zs[EX][EY];
3378
3380 float us[EX][EY];
3381
3383 float vs[EX][EY];
3384
3386 float lsm[EX][EY];
3387
3389 float sst[EX][EY];
3390
3392 float pbl[EX][EY];
3393
3395 float pt[EX][EY];
3396
3398 float tt[EX][EY];
3399
3401 float zt[EX][EY];
3402
3404 float h2ot[EX][EY];
3405
3407 float pct[EX][EY];
3408
3410 float pcb[EX][EY];
3411
3413 float cl[EX][EY];
3414
3416 float plcl[EX][EY];
3417
3419 float plfc[EX][EY];
3420
3422 float pel[EX][EY];
3423
3425 float cape[EX][EY];
3426
3428 float cin[EX][EY];
3429
3431 float o3c[EX][EY];
3432
3434 float z[EX][EY][EP];
3435
3437 float t[EX][EY][EP];
3438
3440 float u[EX][EY][EP];
3441
3443 float v[EX][EY][EP];
3444
3446 float w[EX][EY][EP];
3447
3449 float pv[EX][EY][EP];
3450
3452 float h2o[EX][EY][EP];
3453
3455 float o3[EX][EY][EP];
3456
3458 float lwc[EX][EY][EP];
3459
3461 float rwc[EX][EY][EP];
3462
3464 float iwc[EX][EY][EP];
3465
3467 float swc[EX][EY][EP];
3468
3470 float cc[EX][EY][EP];
3471
3473 float pl[EX][EY][EP];
3474
3476 float ul[EX][EY][EP];
3477
3479 float vl[EX][EY][EP];
3480
3482 float wl[EX][EY][EP];
3483
3485 float zetal[EX][EY][EP];
3486
3488 float zeta_dotl[EX][EY][EP];
3489
3490} met_t;
3491
3492/* ------------------------------------------------------------
3493 Functions...
3494 ------------------------------------------------------------ */
3495
3518 void *data,
3519 size_t N);
3520
3535void cart2geo(
3536 const double *x,
3537 double *z,
3538 double *lon,
3539 double *lat);
3540
3563double clim_oh(
3564 const ctl_t * ctl,
3565 const clim_t * clim,
3566 const double t,
3567 const double lon,
3568 const double lat,
3569 const double p);
3570
3590 const ctl_t * ctl,
3591 clim_t * clim);
3592
3622double clim_photo(
3623 const double rate[CP][CSZA][CO3],
3624 const clim_photo_t * photo,
3625 const double p,
3626 const double sza,
3627 const double o3c);
3628
3654double clim_tropo(
3655 const clim_t * clim,
3656 const double t,
3657 const double lat);
3658
3677void clim_tropo_init(
3678 clim_t * clim);
3679
3696double clim_ts(
3697 const clim_ts_t * ts,
3698 const double t);
3699
3721double clim_zm(
3722 const clim_zm_t * zm,
3723 const double t,
3724 const double lat,
3725 const double p);
3726
3768 const ctl_t * ctl,
3769 const char *varname,
3770 float *array,
3771 const size_t nx,
3772 const size_t ny,
3773 const size_t np,
3774 const int decompress,
3775 FILE * inout);
3776
3809void compress_pck(
3810 const char *varname,
3811 float *array,
3812 const size_t nxy,
3813 const size_t nz,
3814 const int decompress,
3815 FILE * inout);
3816
3856 const char *varname,
3857 float *array,
3858 const int nx,
3859 const int ny,
3860 const int nz,
3861 const int precision,
3862 const double tolerance,
3863 const int decompress,
3864 FILE * inout);
3865
3902 const char *varname,
3903 float *array,
3904 const size_t n,
3905 const int decompress,
3906 FILE * inout);
3907
3930void day2doy(
3931 const int year,
3932 const int mon,
3933 const int day,
3934 int *doy);
3935
3957void doy2day(
3958 const int year,
3959 const int doy,
3960 int *mon,
3961 int *day);
3962
3989void fft_help(
3990 double *fcReal,
3991 double *fcImag,
3992 const int n);
3993
4020void geo2cart(
4021 const double z,
4022 const double lon,
4023 const double lat,
4024 double *x);
4025
4060void get_met(
4061 ctl_t * ctl,
4062 clim_t * clim,
4063 const double t,
4064 met_t ** met0,
4065 met_t ** met1);
4066
4067void get_met_help(
4068 const ctl_t * ctl,
4069 const double t,
4070 const int direct,
4071 const char *metbase,
4072 const double dt_met,
4073 char *filename);
4074
4098void get_met_replace(
4099 char *orig,
4100 char *search,
4101 char *repl);
4102
4139void get_tropo(
4140 const int met_tropo,
4141 ctl_t * ctl,
4142 clim_t * clim,
4143 met_t * met,
4144 const double *lons,
4145 const int nx,
4146 const double *lats,
4147 const int ny,
4148 double *pt,
4149 double *zt,
4150 double *tt,
4151 double *qt,
4152 double *o3t,
4153 double *ps,
4154 double *zs);
4155
4198 const met_t * met0,
4199 float height0[EX][EY][EP],
4200 float array0[EX][EY][EP],
4201 const met_t * met1,
4202 float height1[EX][EY][EP],
4203 float array1[EX][EY][EP],
4204 const double ts,
4205 const double height,
4206 const double lon,
4207 const double lat,
4208 double *var,
4209 int *ci,
4210 double *cw,
4211 const int init);
4212
4248 const met_t * met,
4249 float array[EX][EY][EP],
4250 const double p,
4251 const double lon,
4252 const double lat,
4253 double *var,
4254 int *ci,
4255 double *cw,
4256 const int init);
4257
4277 const met_t * met,
4278 float array[EX][EY][EP],
4279 const double p,
4280 const double lon,
4281 const double lat,
4282 double *var);
4283
4319 const met_t * met,
4320 float array[EX][EY],
4321 const double lon,
4322 const double lat,
4323 double *var,
4324 int *ci,
4325 double *cw,
4326 const int init);
4327
4362 const met_t * met0,
4363 float array0[EX][EY][EP],
4364 const met_t * met1,
4365 float array1[EX][EY][EP],
4366 const double ts,
4367 const double p,
4368 const double lon,
4369 const double lat,
4370 double *var,
4371 int *ci,
4372 double *cw,
4373 const int init);
4374
4398 const met_t * met0,
4399 float array0[EX][EY][EP],
4400 const met_t * met1,
4401 float array1[EX][EY][EP],
4402 const double ts,
4403 const double p,
4404 const double lon,
4405 const double lat,
4406 double *var);
4407
4443 const met_t * met0,
4444 float array0[EX][EY],
4445 const met_t * met1,
4446 float array1[EX][EY],
4447 const double ts,
4448 const double lon,
4449 const double lat,
4450 double *var,
4451 int *ci,
4452 double *cw,
4453 const int init);
4454
4492void intpol_tropo_3d(
4493 const double time0,
4494 float array0[EX][EY],
4495 const double time1,
4496 float array1[EX][EY],
4497 const double lons[EX],
4498 const double lats[EY],
4499 const int nlon,
4500 const int nlat,
4501 const double time,
4502 const double lon,
4503 const double lat,
4504 const int method,
4505 double *var,
4506 double *sigma);
4507
4534void jsec2time(
4535 const double jsec,
4536 int *year,
4537 int *mon,
4538 int *day,
4539 int *hour,
4540 int *min,
4541 int *sec,
4542 double *remain);
4543
4570double kernel_weight(
4571 const double kz[EP],
4572 const double kw[EP],
4573 const int nk,
4574 const double p);
4575
4614double lapse_rate(
4615 const double t,
4616 const double h2o);
4617
4647 ctl_t * ctl);
4648
4668int locate_irr(
4669 const double *xx,
4670 const int n,
4671 const double x);
4672
4699 const float *xx,
4700 const int n,
4701 const double x,
4702 const int ig);
4703
4724int locate_reg(
4725 const double *xx,
4726 const int n,
4727 const double x);
4728
4750void locate_vert(
4751 float profiles[EX][EY][EP],
4752 const int np,
4753 const int lon_ap_ind,
4754 const int lat_ap_ind,
4755 const double alt_ap,
4756 int *ind);
4757
4804void module_advect(
4805 const ctl_t * ctl,
4806 met_t * met0,
4807 met_t * met1,
4808 atm_t * atm,
4809 const double *dt);
4810
4833 const ctl_t * ctl,
4834 met_t * met0,
4835 met_t * met1,
4836 atm_t * atm);
4837
4875 const ctl_t * ctl,
4876 const clim_t * clim,
4877 met_t * met0,
4878 met_t * met1,
4879 atm_t * atm,
4880 const double *dt);
4881
4899void module_chemgrid(
4900 const ctl_t * ctl,
4901 met_t * met0,
4902 met_t * met1,
4903 atm_t * atm,
4904 const double t);
4905
4932void module_chem_init(
4933 const ctl_t * ctl,
4934 const clim_t * clim,
4935 met_t * met0,
4936 met_t * met1,
4937 atm_t * atm);
4938
4967 const ctl_t * ctl,
4968 met_t * met0,
4969 met_t * met1,
4970 atm_t * atm,
4971 const double *dt,
4972 double *rs);
4973
5000void module_decay(
5001 const ctl_t * ctl,
5002 const clim_t * clim,
5003 atm_t * atm,
5004 const double *dt);
5005
5036 const ctl_t * ctl,
5037 met_t * met0,
5038 met_t * met1,
5039 atm_t * atm,
5040 cache_t * cache,
5041 const double *dt,
5042 double *rs);
5043
5070 const ctl_t * ctl,
5071 const clim_t * clim,
5072 atm_t * atm,
5073 const double *dt,
5074 double *rs);
5075
5096 const ctl_t * ctl,
5097 met_t * met0,
5098 met_t * met1,
5099 atm_t * atm,
5100 const double *dt);
5101
5134void module_h2o2_chem(
5135 const ctl_t * ctl,
5136 const clim_t * clim,
5137 met_t * met0,
5138 met_t * met1,
5139 atm_t * atm,
5140 const double *dt);
5141
5162 const ctl_t * ctl,
5163 met_t * met0,
5164 met_t * met1,
5165 atm_t * atm,
5166 cache_t * cache);
5167
5186void module_isosurf(
5187 const ctl_t * ctl,
5188 met_t * met0,
5189 met_t * met1,
5190 atm_t * atm,
5191 cache_t * cache,
5192 const double *dt);
5193
5226 ctl_t * ctl,
5227 clim_t * clim,
5228 met_t * met0,
5229 met_t * met1,
5230 atm_t * atm,
5231 double *dt);
5232
5251void module_meteo(
5252 const ctl_t * ctl,
5253 const clim_t * clim,
5254 met_t * met0,
5255 met_t * met1,
5256 atm_t * atm,
5257 const double *dt);
5258
5276void module_mixing(
5277 const ctl_t * ctl,
5278 const clim_t * clim,
5279 atm_t * atm,
5280 const double t);
5281
5302 const ctl_t * ctl,
5303 const clim_t * clim,
5304 atm_t * atm,
5305 const int *ixs,
5306 const int *iys,
5307 const int *izs,
5308 const int qnt_idx);
5309
5342void module_oh_chem(
5343 const ctl_t * ctl,
5344 const clim_t * clim,
5345 met_t * met0,
5346 met_t * met1,
5347 atm_t * atm,
5348 const double *dt);
5349
5378void module_position(
5379 const ctl_t * ctl,
5380 met_t * met0,
5381 met_t * met1,
5382 atm_t * atm,
5383 const double *dt);
5384
5409void module_rng_init(
5410 const int ntask);
5411
5437void module_rng(
5438 const ctl_t * ctl,
5439 double *rs,
5440 const size_t n,
5441 const int method);
5442
5465void module_sedi(
5466 const ctl_t * ctl,
5467 met_t * met0,
5468 met_t * met1,
5469 atm_t * atm,
5470 const double *dt);
5471
5496void module_sort(
5497 const ctl_t * ctl,
5498 met_t * met0,
5499 atm_t * atm);
5500
5520void module_sort_help(
5521 double *a,
5522 const int *p,
5523 const int np);
5524
5548void module_timesteps(
5549 const ctl_t * ctl,
5550 met_t * met0,
5551 atm_t * atm,
5552 double *dt,
5553 const double t);
5554
5576 ctl_t * ctl,
5577 const atm_t * atm);
5578
5612 const ctl_t * ctl,
5613 const clim_t * clim,
5614 met_t * met0,
5615 met_t * met1,
5616 atm_t * atm,
5617 const double *dt);
5618
5644 const ctl_t * ctl,
5645 met_t * met0,
5646 met_t * met1,
5647 atm_t * atm,
5648 const double *dt);
5649
5677double nat_temperature(
5678 const double p,
5679 const double h2o,
5680 const double hno3);
5681
5717int read_atm(
5718 const char *filename,
5719 const ctl_t * ctl,
5720 atm_t * atm);
5721
5754int read_atm_asc(
5755 const char *filename,
5756 const ctl_t * ctl,
5757 atm_t * atm);
5758
5789int read_atm_bin(
5790 const char *filename,
5791 const ctl_t * ctl,
5792 atm_t * atm);
5793
5828int read_atm_clams(
5829 const char *filename,
5830 const ctl_t * ctl,
5831 atm_t * atm);
5832
5862int read_atm_nc(
5863 const char *filename,
5864 const ctl_t * ctl,
5865 atm_t * atm);
5866
5898void read_clim(
5899 const ctl_t * ctl,
5900 clim_t * clim);
5901
5930void read_clim_photo(
5931 const char *filename,
5932 clim_photo_t * photo);
5933
5951 const int ncid,
5952 const char *varname,
5953 const clim_photo_t * photo,
5954 double var[CP][CSZA][CO3]);
5955
5979int read_clim_ts(
5980 const char *filename,
5981 clim_ts_t * ts);
5982
6009void read_clim_zm(
6010 const char *filename,
6011 const char *varname,
6012 clim_zm_t * zm);
6013
6043void read_ctl(
6044 const char *filename,
6045 int argc,
6046 char *argv[],
6047 ctl_t * ctl);
6048
6076void read_kernel(
6077 const char *filename,
6078 double kz[EP],
6079 double kw[EP],
6080 int *nk);
6081
6110int read_met(
6111 const char *filename,
6112 ctl_t * ctl,
6113 clim_t * clim,
6114 met_t * met);
6115
6147int read_met_bin(
6148 const char *filename,
6149 ctl_t * ctl,
6150 met_t * met);
6151
6177void read_met_bin_2d(
6178 FILE * in,
6179 const met_t * met,
6180 float var[EX][EY],
6181 const char *varname);
6182
6220void read_met_bin_3d(
6221 FILE * in,
6222 const ctl_t * ctl,
6223 const met_t * met,
6224 float var[EX][EY][EP],
6225 const char *varname,
6226 const float bound_min,
6227 const float bound_max);
6228
6255void read_met_cape(
6256 const ctl_t * ctl,
6257 const clim_t * clim,
6258 met_t * met);
6259
6282void read_met_cloud(
6283 met_t * met);
6284
6310void read_met_detrend(
6311 const ctl_t * ctl,
6312 met_t * met);
6313
6337 met_t * met);
6338
6365void read_met_geopot(
6366 const ctl_t * ctl,
6367 met_t * met);
6368
6400void read_met_grid(
6401 const char *filename,
6402 const int ncid,
6403 const ctl_t * ctl,
6404 met_t * met);
6405
6436void read_met_levels(
6437 const int ncid,
6438 const ctl_t * ctl,
6439 met_t * met);
6440
6469void read_met_ml2pl(
6470 const ctl_t * ctl,
6471 const met_t * met,
6472 float var[EX][EY][EP],
6473 const char *varname);
6474
6496 met_t * met);
6497
6529int read_met_nc(
6530 const char *filename,
6531 ctl_t * ctl,
6532 clim_t * clim,
6533 met_t * met);
6534
6564int read_met_nc_2d(
6565 const int ncid,
6566 const char *varname,
6567 const char *varname2,
6568 const char *varname3,
6569 const char *varname4,
6570 const char *varname5,
6571 const char *varname6,
6572 const ctl_t * ctl,
6573 const met_t * met,
6574 float dest[EX][EY],
6575 const float scl,
6576 const int init);
6577
6608int read_met_nc_3d(
6609 const int ncid,
6610 const char *varname,
6611 const char *varname2,
6612 const char *varname3,
6613 const char *varname4,
6614 const ctl_t * ctl,
6615 const met_t * met,
6616 float dest[EX][EY][EP],
6617 const float scl);
6618
6659void read_met_pbl(
6660 const ctl_t * ctl,
6661 met_t * met);
6662
6695 met_t * met);
6696
6727 met_t * met);
6728
6759void read_met_pv(
6760 met_t * met);
6761
6784void read_met_ozone(
6785 met_t * met);
6786
6815void read_met_sample(
6816 const ctl_t * ctl,
6817 met_t * met);
6818
6859void read_met_surface(
6860 const int ncid,
6861 const ctl_t * ctl,
6862 met_t * met);
6863
6892void read_met_tropo(
6893 const ctl_t * ctl,
6894 const clim_t * clim,
6895 met_t * met);
6896
6928void read_obs(
6929 const char *filename,
6930 const ctl_t * ctl,
6931 double *rt,
6932 double *rz,
6933 double *rlon,
6934 double *rlat,
6935 double *robs,
6936 int *nobs);
6937
6965void read_obs_asc(
6966 const char *filename,
6967 double *rt,
6968 double *rz,
6969 double *rlon,
6970 double *rlat,
6971 double *robs,
6972 int *nobs);
6973
7000void read_obs_nc(
7001 const char *filename,
7002 double *rt,
7003 double *rz,
7004 double *rlon,
7005 double *rlat,
7006 double *robs,
7007 int *nobs);
7008
7042double scan_ctl(
7043 const char *filename,
7044 int argc,
7045 char *argv[],
7046 const char *varname,
7047 const int arridx,
7048 const char *defvalue,
7049 char *value);
7050
7077double sedi(
7078 const double p,
7079 const double T,
7080 const double rp,
7081 const double rhop);
7082
7112void spline(
7113 const double *x,
7114 const double *y,
7115 const int n,
7116 const double *x2,
7117 double *y2,
7118 const int n2,
7119 const int method);
7120
7143float stddev(
7144 const float *data,
7145 const int n);
7146
7166double sza_calc(
7167 const double sec,
7168 const double lon,
7169 const double lat);
7170
7195void time2jsec(
7196 const int year,
7197 const int mon,
7198 const int day,
7199 const int hour,
7200 const int min,
7201 const int sec,
7202 const double remain,
7203 double *jsec);
7204
7233void timer(
7234 const char *name,
7235 const char *group,
7236 const int output);
7237
7263double time_from_filename(
7264 const char *filename,
7265 const int offset);
7266
7294double tropo_weight(
7295 const clim_t * clim,
7296 const double t,
7297 const double lat,
7298 const double p);
7299
7329void write_atm(
7330 const char *filename,
7331 const ctl_t * ctl,
7332 const atm_t * atm,
7333 const double t);
7334
7357void write_atm_asc(
7358 const char *filename,
7359 const ctl_t * ctl,
7360 const atm_t * atm,
7361 const double t);
7362
7386void write_atm_bin(
7387 const char *filename,
7388 const ctl_t * ctl,
7389 const atm_t * atm);
7390
7414void write_atm_clams(
7415 const char *filename,
7416 const ctl_t * ctl,
7417 const atm_t * atm);
7418
7444 const char *dirname,
7445 const ctl_t * ctl,
7446 const atm_t * atm,
7447 const double t);
7448
7472void write_atm_nc(
7473 const char *filename,
7474 const ctl_t * ctl,
7475 const atm_t * atm);
7476
7505void write_csi(
7506 const char *filename,
7507 const ctl_t * ctl,
7508 const atm_t * atm,
7509 const double t);
7510
7538void write_ens(
7539 const char *filename,
7540 const ctl_t * ctl,
7541 const atm_t * atm,
7542 const double t);
7543
7582void write_grid(
7583 const char *filename,
7584 const ctl_t * ctl,
7585 met_t * met0,
7586 met_t * met1,
7587 const atm_t * atm,
7588 const double t);
7589
7635void write_grid_asc(
7636 const char *filename,
7637 const ctl_t * ctl,
7638 const double *cd,
7639 double *mean[NQ],
7640 double *sigma[NQ],
7641 const double *vmr_impl,
7642 const double t,
7643 const double *z,
7644 const double *lon,
7645 const double *lat,
7646 const double *area,
7647 const double dz,
7648 const int *np);
7649
7692void write_grid_nc(
7693 const char *filename,
7694 const ctl_t * ctl,
7695 const double *cd,
7696 double *mean[NQ],
7697 double *sigma[NQ],
7698 const double *vmr_impl,
7699 const double t,
7700 const double *z,
7701 const double *lon,
7702 const double *lat,
7703 const double *area,
7704 const double dz,
7705 const int *np);
7706
7742void write_met(
7743 const char *filename,
7744 const ctl_t * ctl,
7745 met_t * met);
7746
7776void write_met_bin(
7777 const char *filename,
7778 const ctl_t * ctl,
7779 met_t * met);
7780
7808void write_met_bin_2d(
7809 FILE * out,
7810 met_t * met,
7811 float var[EX][EY],
7812 const char *varname);
7813
7851void write_met_bin_3d(
7852 FILE * out,
7853 const ctl_t * ctl,
7854 met_t * met,
7855 float var[EX][EY][EP],
7856 const char *varname,
7857 const int precision,
7858 const double tolerance);
7859
7887void write_met_nc(
7888 const char *filename,
7889 const ctl_t * ctl,
7890 met_t * met);
7891
7916void write_met_nc_2d(
7917 int ncid,
7918 const char *varname,
7919 met_t * met,
7920 float var[EX][EY],
7921 float scl);
7922
7948void write_met_nc_3d(
7949 int ncid,
7950 const char *varname,
7951 met_t * met,
7952 float var[EX][EY][EP],
7953 float scl);
7954
7988void write_output(
7989 const char *dirname,
7990 const ctl_t * ctl,
7991 met_t * met0,
7992 met_t * met1,
7993 atm_t * atm,
7994 const double t);
7995
8026void write_prof(
8027 const char *filename,
8028 const ctl_t * ctl,
8029 met_t * met0,
8030 met_t * met1,
8031 const atm_t * atm,
8032 const double t);
8033
8065void write_sample(
8066 const char *filename,
8067 const ctl_t * ctl,
8068 met_t * met0,
8069 met_t * met1,
8070 const atm_t * atm,
8071 const double t);
8072
8099void write_station(
8100 const char *filename,
8101 const ctl_t * ctl,
8102 atm_t * atm,
8103 const double t);
8104
8133void write_vtk(
8134 const char *filename,
8135 const ctl_t * ctl,
8136 const atm_t * atm,
8137 const double t);
8138
8139/* ------------------------------------------------------------
8140 OpenACC routines...
8141 ------------------------------------------------------------ */
8142
8143#ifdef _OPENACC
8144#pragma acc routine (clim_oh)
8145#pragma acc routine (clim_photo)
8146#pragma acc routine (clim_tropo)
8147#pragma acc routine (clim_ts)
8148#pragma acc routine (clim_zm)
8149#pragma acc routine (intpol_met_4d_coord)
8150#pragma acc routine (intpol_met_space_3d)
8151#pragma acc routine (intpol_met_space_3d_ml)
8152#pragma acc routine (intpol_met_space_2d)
8153#pragma acc routine (intpol_met_time_3d)
8154#pragma acc routine (intpol_met_time_3d_ml)
8155#pragma acc routine (intpol_met_time_2d)
8156#pragma acc routine (kernel_weight)
8157#pragma acc routine (lapse_rate)
8158#pragma acc routine (locate_irr)
8159#pragma acc routine (locate_irr_float)
8160#pragma acc routine (locate_reg)
8161#pragma acc routine (locate_vert)
8162#pragma acc routine (nat_temperature)
8163#pragma acc routine (sedi)
8164#pragma acc routine (stddev)
8165#pragma acc routine (sza_calc)
8166#pragma acc routine (tropo_weight)
8167#endif
8168
8169#endif /* LIBTRAC_H */
void read_met_geopot(const ctl_t *ctl, met_t *met)
Calculates geopotential heights from meteorological data.
Definition: mptrac.c:6290
#define LEN
Maximum length of ASCII data lines.
Definition: mptrac.h:236
void day2doy(const int year, const int mon, const int day, int *doy)
Get day of year from date.
Definition: mptrac.c:897
void read_met_extrapolate(met_t *met)
Extrapolates meteorological data.
Definition: mptrac.c:6250
void read_met_levels(const int ncid, const ctl_t *ctl, met_t *met)
Reads meteorological variables at different vertical levels from a NetCDF file.
Definition: mptrac.c:6536
void write_atm_clams_traj(const char *dirname, const ctl_t *ctl, const atm_t *atm, const double t)
Writes CLaMS trajectory data to a NetCDF file.
Definition: mptrac.c:8717
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 read_met_sample(const ctl_t *ctl, met_t *met)
Downsamples meteorological data based on specified parameters.
Definition: mptrac.c:7565
void write_met_bin_3d(FILE *out, const ctl_t *ctl, met_t *met, float var[EX][EY][EP], const char *varname, const int precision, const double tolerance)
Writes a 3-dimensional meteorological variable to a binary file.
Definition: mptrac.c:9874
void read_obs(const char *filename, const ctl_t *ctl, double *rt, double *rz, double *rlon, double *rlat, double *robs, int *nobs)
Reads observation data from a file and stores it in arrays.
Definition: mptrac.c:7997
void get_met(ctl_t *ctl, clim_t *clim, const double t, met_t **met0, met_t **met1)
Retrieves meteorological data for the specified time.
Definition: mptrac.c:1004
void module_advect(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Performs the advection of atmospheric particles using meteorological data.
Definition: mptrac.c:2219
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:4533
void read_met_cloud(met_t *met)
Calculates cloud-related variables for each grid point.
Definition: mptrac.c:6089
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:8170
void intpol_met_space_2d(const met_t *met, float array[EX][EY], const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological variables in 2D space.
Definition: mptrac.c:1593
void intpol_met_time_3d_ml(const met_t *met0, float array0[EX][EY][EP], const met_t *met1, float array1[EX][EY][EP], const double ts, const double p, const double lon, const double lat, double *var)
Interpolates a meteorological variable in time and 3D space (longitude, latitude, pressure).
Definition: mptrac.c:1682
int read_atm_nc(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a generic netCDF file and populates the given atmospheric structure.
Definition: mptrac.c:4440
void read_met_pbl(const ctl_t *ctl, met_t *met)
Computes the planetary boundary layer (PBL) height based on meteorological data.
Definition: mptrac.c:7170
void read_met_detrend(const ctl_t *ctl, met_t *met)
Detrends meteorological data.
Definition: mptrac.c:6146
int read_met_nc_2d(const int ncid, const char *varname, const char *varname2, const char *varname3, const char *varname4, const char *varname5, const char *varname6, const ctl_t *ctl, const met_t *met, float dest[EX][EY], const float scl, const int init)
Reads a 2-dimensional meteorological variable from a NetCDF file.
Definition: mptrac.c:6866
void read_met_tropo(const ctl_t *ctl, const clim_t *clim, met_t *met)
Calculates the tropopause and related meteorological variables based on various methods and stores th...
Definition: mptrac.c:7825
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:8041
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:2180
void get_tropo(const int met_tropo, ctl_t *ctl, clim_t *clim, met_t *met, const double *lons, const int nx, const double *lats, const int ny, double *pt, double *zt, double *tt, double *qt, double *o3t, double *ps, double *zs)
Calculate tropopause data.
Definition: mptrac.c:1239
void locate_vert(float profiles[EX][EY][EP], const int np, const int lon_ap_ind, const int lat_ap_ind, const double alt_ap, int *ind)
Locate the four vertical indizes of a box for a given height value.
Definition: mptrac.c:2199
void module_chem_init(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Initializes the chemistry modules by setting atmospheric composition.
Definition: mptrac.c:2646
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:4652
void module_convection(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double *dt, double *rs)
Simulate convective processes for atmospheric particles.
Definition: mptrac.c:2687
void read_met_periodic(met_t *met)
Applies periodic boundary conditions to meteorological data along longitudinal axis.
Definition: mptrac.c:7316
void module_diffusion_meso(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, cache_t *cache, const double *dt, double *rs)
Simulate mesoscale diffusion for atmospheric particles.
Definition: mptrac.c:2799
void module_sedi(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Simulate sedimentation of particles in the atmosphere.
Definition: mptrac.c:3794
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
Definition: mptrac.c:3956
void write_ens(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes ensemble data to a file.
Definition: mptrac.c:9186
void compress_cms(const ctl_t *ctl, const char *varname, float *array, const size_t nx, const size_t ny, const size_t np, const int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats using a custom multiscale compression algorithm.
void module_mixing(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const double t)
Update atmospheric properties through interparcel mixing.
Definition: mptrac.c:3332
void compress_zfp(const char *varname, float *array, const int nx, const int ny, const int nz, const int precision, const double tolerance, const int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats using the ZFP library.
double clim_zm(const clim_zm_t *zm, const double t, const double lat, const double p)
Interpolates monthly mean zonal mean climatological variables.
Definition: mptrac.c:401
#define EY
Maximum number of latitudes for meteo data.
Definition: mptrac.h:269
void module_oh_chem(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Perform hydroxyl chemistry calculations for atmospheric particles.
Definition: mptrac.c:3517
void read_clim_photo_help(const int ncid, const char *varname, const clim_photo_t *photo, double var[CP][CSZA][CO3])
Reads a 3D climatological photochemistry variable from a NetCDF file.
Definition: mptrac.c:4624
void read_met_ml2pl(const ctl_t *ctl, const met_t *met, float var[EX][EY][EP], const char *varname)
Interpolates meteorological data to specified pressure levels.
Definition: mptrac.c:6672
double clim_tropo(const clim_t *clim, const double t, const double lat)
Calculates the tropopause pressure based on climatological data.
Definition: mptrac.c:200
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:8069
void read_met_grid(const char *filename, const int ncid, const ctl_t *ctl, met_t *met)
Reads meteorological grid information from a NetCDF file.
Definition: mptrac.c:6418
void read_met_bin_2d(FILE *in, const met_t *met, float var[EX][EY], const char *varname)
Reads a 2-dimensional meteorological variable from a binary file and stores it in the provided array.
Definition: mptrac.c:5859
void module_isosurf(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, cache_t *cache, const double *dt)
Apply the isosurface module to adjust atmospheric properties.
Definition: mptrac.c:3127
void module_timesteps(const ctl_t *ctl, met_t *met0, atm_t *atm, double *dt, const double t)
Calculate time steps for air parcels based on specified conditions.
Definition: mptrac.c:3919
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:2116
void level_definitions(ctl_t *ctl)
Defines pressure levels for meteorological data.
Definition: mptrac.c:1909
void write_grid_asc(const char *filename, const ctl_t *ctl, const double *cd, double *mean[NQ], double *sigma[NQ], const double *vmr_impl, const double t, const double *z, const double *lon, const double *lat, const double *area, const double dz, const int *np)
Writes grid data to an ASCII file.
Definition: mptrac.c:9474
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:8314
void intpol_met_time_3d(const met_t *met0, float array0[EX][EY][EP], const met_t *met1, float array1[EX][EY][EP], const double ts, const double p, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological data in 3D space and time.
Definition: mptrac.c:1653
void write_atm(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes air parcel data to a file in various formats.
Definition: mptrac.c:8472
void fft_help(double *fcReal, double *fcImag, const int n)
Computes the Fast Fourier Transform (FFT) of a complex sequence.
Definition: mptrac.c:946
int read_met_bin(const char *filename, ctl_t *ctl, met_t *met)
Reads meteorological data from a binary file.
Definition: mptrac.c:5710
void compress_pck(const char *varname, float *array, const size_t nxy, const size_t nz, const int decompress, FILE *inout)
Compresses or decompresses a 3D array of floats.
Definition: mptrac.c:657
double nat_temperature(const double p, const double h2o, const double hno3)
Calculates the nitric acid trihydrate (NAT) temperature.
Definition: mptrac.c:4191
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:8203
void module_isosurf_init(const 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:3063
void module_chemgrid(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double t)
Calculate grid data for chemistry modules.
Definition: mptrac.c:2498
#define CP
Maximum number of pressure levels for climatological data.
Definition: mptrac.h:299
#define NQ
Maximum number of quantities per data point.
Definition: mptrac.h:246
double clim_photo(const double rate[CP][CSZA][CO3], const clim_photo_t *photo, const double p, const double sza, const double o3c)
Calculates the photolysis rate for a given set of atmospheric conditions.
Definition: mptrac.c:149
void read_clim_zm(const char *filename, const char *varname, clim_zm_t *zm)
Reads zonally averaged climatological data from a netCDF file and populates the given structure.
Definition: mptrac.c:4706
#define EX
Maximum number of longitudes for meteo data.
Definition: mptrac.h:262
void module_position(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Update the positions and pressure levels of atmospheric particles.
Definition: mptrac.c:3600
void timer(const char *name, const char *group, const int output)
Measures and reports elapsed time for named and grouped timers.
Definition: mptrac.c:8345
void read_met_monotonize(met_t *met)
Makes zeta and pressure profiles monotone.
Definition: mptrac.c:6714
void write_atm_asc(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes air parcel data to an ASCII file or gnuplot.
Definition: mptrac.c:8532
void module_diffusion_turb(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const double *dt, double *rs)
Simulate turbulent diffusion for atmospheric particles.
Definition: mptrac.c:2879
void intpol_met_space_3d(const met_t *met, float array[EX][EY][EP], const double p, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological variables in 3D space.
Definition: mptrac.c:1460
void read_met_surface(const int ncid, const ctl_t *ctl, met_t *met)
Reads surface meteorological data from a netCDF file and stores it in the meteorological data structu...
Definition: mptrac.c:7713
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:5614
void module_advect_init(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm)
Initializes the advection module by setting up pressure fields.
Definition: mptrac.c:2377
double scan_ctl(const char *filename, int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scans a control file or command-line arguments for a specified variable.
Definition: mptrac.c:8098
#define CT
Maximum number of time steps for climatological data.
Definition: mptrac.h:309
void module_sort_help(double *a, const int *p, const int np)
Reorder an array based on a given permutation.
Definition: mptrac.c:3883
float stddev(const float *data, const int n)
Calculates the standard deviation of a set of data.
Definition: mptrac.c:8252
void write_met(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a file, supporting multiple formats and compression options.
Definition: mptrac.c:9708
void intpol_tropo_3d(const double time0, float array0[EX][EY], const double time1, float array1[EX][EY], const double lons[EX], const double lats[EY], const int nlon, const int nlat, const double time, const double lon, const double lat, const int method, double *var, double *sigma)
Interpolates tropopause data in 3D (latitude, longitude, and time).
Definition: mptrac.c:1738
int read_met_nc_3d(const int ncid, const char *varname, const char *varname2, const char *varname3, const char *varname4, const ctl_t *ctl, const met_t *met, float dest[EX][EY][EP], const float scl)
Reads a 3-dimensional meteorological variable from a NetCDF file.
Definition: mptrac.c:7024
void read_met_bin_3d(FILE *in, const ctl_t *ctl, const met_t *met, float var[EX][EY][EP], const char *varname, const float bound_min, const float bound_max)
Reads 3D meteorological data from a binary file, potentially using different compression methods.
Definition: mptrac.c:5888
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:2146
double time_from_filename(const char *filename, const int offset)
Extracts and converts a timestamp from a filename to Julian seconds.
Definition: mptrac.c:8413
void write_prof(const char *filename, const ctl_t *ctl, met_t *met0, met_t *met1, const atm_t *atm, const double t)
Writes profile data to a specified file.
Definition: mptrac.c:10210
void write_met_nc(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data to a NetCDF file.
Definition: mptrac.c:9950
void module_decay(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const double *dt)
Simulate exponential decay processes for atmospheric particles.
Definition: mptrac.c:2759
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
Definition: mptrac.c:3659
void intpol_met_4d_coord(const met_t *met0, float height0[EX][EY][EP], float array0[EX][EY][EP], const met_t *met1, float height1[EX][EY][EP], float array1[EX][EY][EP], const double ts, const double height, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological variables to a given position and time.
Definition: mptrac.c:1282
double clim_oh(const ctl_t *ctl, const clim_t *clim, const double t, const double lon, const double lat, const double p)
Calculates the hydroxyl radical (OH) concentration from climatology data, with an optional diurnal co...
Definition: mptrac.c:89
#define CTS
Maximum number of data points of climatological time series.
Definition: mptrac.h:314
void read_met_ozone(met_t *met)
Calculates the total column ozone from meteorological ozone data.
Definition: mptrac.c:7536
void broadcast_large_data(void *data, size_t N)
Broadcasts large data across all processes in an MPI communicator.
void module_wet_deposition(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Perform wet deposition calculations for air parcels.
Definition: mptrac.c:4056
void module_h2o2_chem(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Perform chemical reactions involving H2O2 within cloud particles.
Definition: mptrac.c:2983
void clim_tropo_init(clim_t *clim)
Initializes the tropopause data in the climatology structure.
Definition: mptrac.c:228
void module_rng(const ctl_t *ctl, double *rs, const size_t n, const int method)
Generate random numbers using various methods and distributions.
Definition: mptrac.c:3690
void module_meteo(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Update atmospheric properties using meteorological data.
Definition: mptrac.c:3232
void get_met_help(const ctl_t *ctl, const double t, const int direct, const char *metbase, const double dt_met, char *filename)
Definition: mptrac.c:1150
void write_station(const char *filename, const ctl_t *ctl, atm_t *atm, const double t)
Writes station data to a specified file.
Definition: mptrac.c:10600
void cart2geo(const double *x, double *z, double *lon, double *lat)
Converts Cartesian coordinates to geographic coordinates.
Definition: mptrac.c:74
void write_output(const char *dirname, const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double t)
Writes various types of output data to files in a specified directory.
Definition: mptrac.c:10115
#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:8273
void module_mixing_help(const ctl_t *ctl, const clim_t *clim, atm_t *atm, const int *ixs, const int *iys, const int *izs, const int qnt_idx)
Perform interparcel mixing for a specific quantity.
Definition: mptrac.c:3422
void write_met_nc_2d(int ncid, const char *varname, met_t *met, float var[EX][EY], float scl)
Writes a 2D meteorological variable to a NetCDF file.
Definition: mptrac.c:10056
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:916
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:4805
void intpol_met_time_2d(const met_t *met0, float array0[EX][EY], const met_t *met1, float array1[EX][EY], const double ts, const double lon, const double lat, double *var, int *ci, double *cw, const int init)
Interpolates meteorological data in 2D space and time.
Definition: mptrac.c:1705
void module_bound_cond(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Apply boundary conditions to particles based on meteorological and climatological data.
Definition: mptrac.c:2403
void clim_oh_diurnal_correction(const ctl_t *ctl, clim_t *clim)
Applies a diurnal correction to the hydroxyl radical (OH) concentration in climatology data.
Definition: mptrac.c:116
void module_tracer_chem(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Simulate chemical reactions involving long-lived atmospheric tracers.
Definition: mptrac.c:3987
int read_met(const char *filename, ctl_t *ctl, clim_t *clim, met_t *met)
Reads meteorological data from a file, supporting multiple formats and MPI broadcasting.
Definition: mptrac.c:5655
void write_met_bin_2d(FILE *out, met_t *met, float var[EX][EY], const char *varname)
Writes a 2-dimensional meteorological variable to a binary file.
Definition: mptrac.c:9845
void read_met_pv(met_t *met)
Calculates potential vorticity (PV) from meteorological data.
Definition: mptrac.c:7430
int read_atm_bin(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a binary file and populates the given atmospheric structure.
Definition: mptrac.c:4328
void get_met_replace(char *orig, char *search, char *repl)
Replaces occurrences of a substring in a string with another substring.
Definition: mptrac.c:1215
#define CY
Maximum number of latitudes for climatological data.
Definition: mptrac.h:289
void module_sort(const ctl_t *ctl, met_t *met0, atm_t *atm)
Sort particles according to box index.
Definition: mptrac.c:3823
double clim_ts(const clim_ts_t *ts, const double t)
Interpolates a time series of climatological variables.
Definition: mptrac.c:383
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:1832
void write_atm_clams(const char *filename, const ctl_t *ctl, const atm_t *atm)
Writes air parcel data to a NetCDF file in the CLaMS format.
Definition: mptrac.c:8664
int read_atm_clams(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a CLaMS netCDF file and populates the given atmospheric structure.
Definition: mptrac.c:4384
int read_atm(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a specified file into the given atmospheric structure.
Definition: mptrac.c:4215
void write_vtk(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes VTK (Visualization Toolkit) data to a specified file.
Definition: mptrac.c:10686
#define EP
Maximum number of pressure levels for meteo data.
Definition: mptrac.h:257
void read_met_polar_winds(met_t *met)
Applies a fix for polar winds in meteorological data.
Definition: mptrac.c:7371
void compress_zstd(const char *varname, float *array, const size_t n, const int decompress, FILE *inout)
Compresses or decompresses an array of floats using the Zstandard (ZSTD) library.
void write_grid_nc(const char *filename, const ctl_t *ctl, const double *cd, double *mean[NQ], double *sigma[NQ], const double *vmr_impl, const double t, const double *z, const double *lon, const double *lat, const double *area, const double dz, const int *np)
Writes grid data to a NetCDF file.
Definition: mptrac.c:9578
void read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:4473
#define CO3
Maximum number of total column ozone data for climatological data.
Definition: mptrac.h:294
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:986
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:1865
void intpol_met_space_3d_ml(const met_t *met, float array[EX][EY][EP], const double p, const double lon, const double lat, double *var)
Interpolates a meteorological variable in 3D space (longitude, latitude, pressure).
Definition: mptrac.c:1520
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:8448
int read_atm_asc(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from an ASCII file and populates the given atmospheric structure.
Definition: mptrac.c:4286
void write_sample(const char *filename, const ctl_t *ctl, met_t *met0, met_t *met1, const atm_t *atm, const double t)
Writes sample data to a specified file.
Definition: mptrac.c:10437
void write_grid(const char *filename, const ctl_t *ctl, met_t *met0, met_t *met1, const atm_t *atm, const double t)
Writes grid data to a file in ASCII or netCDF format.
Definition: mptrac.c:9283
void write_met_nc_3d(int ncid, const char *varname, met_t *met, float var[EX][EY][EP], float scl)
Writes a 3D meteorological variable to a NetCDF file.
Definition: mptrac.c:10085
void module_dry_deposition(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double *dt)
Simulate dry deposition of atmospheric particles.
Definition: mptrac.c:2920
void write_met_bin(const char *filename, const ctl_t *ctl, met_t *met)
Writes meteorological data in binary format to a specified file.
Definition: mptrac.c:9748
void write_atm_bin(const char *filename, const ctl_t *ctl, const atm_t *atm)
Writes air parcel data to a binary file.
Definition: mptrac.c:8614
int read_met_nc(const char *filename, ctl_t *ctl, clim_t *clim, met_t *met)
Reads meteorological data from a NetCDF file and processes it.
Definition: mptrac.c:6794
void read_met_cape(const ctl_t *ctl, const clim_t *clim, met_t *met)
Calculates Convective Available Potential Energy (CAPE) for each grid point.
Definition: mptrac.c:5974
#define CSZA
Maximum number of solar zenith angles for climatological data.
Definition: mptrac.h:304
double lapse_rate(const double t, const double h2o)
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
Definition: mptrac.c:1891
void write_csi(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes Critical Success Index (CSI) data to a file.
Definition: mptrac.c:8924
void write_atm_nc(const char *filename, const ctl_t *ctl, const atm_t *atm)
Writes air parcel data to a NetCDF file.
Definition: mptrac.c:8875
Air parcel data.
Definition: mptrac.h:3120
int np
Number of air parcels.
Definition: mptrac.h:3123
Cache data structure.
Definition: mptrac.h:3148
int iso_n
Isosurface balloon number of data points.
Definition: mptrac.h:3160
Climatological data in the form of photolysis rates.
Definition: mptrac.h:3174
int nsza
Number of solar zenith angles.
Definition: mptrac.h:3180
int np
Number of pressure levels.
Definition: mptrac.h:3177
int no3c
Number of total ozone columns.
Definition: mptrac.h:3183
Climatological data.
Definition: mptrac.h:3282
clim_ts_t ccl2f2
CFC-12 time series.
Definition: mptrac.h:3324
clim_photo_t photo
Photolysis rates.
Definition: mptrac.h:3300
clim_zm_t ho2
HO2 zonal means.
Definition: mptrac.h:3312
clim_zm_t hno3
HNO3 zonal means.
Definition: mptrac.h:3303
int tropo_ntime
Number of tropopause timesteps.
Definition: mptrac.h:3285
clim_ts_t sf6
SF6 time series.
Definition: mptrac.h:3330
clim_ts_t ccl4
CFC-10 time series.
Definition: mptrac.h:3318
clim_ts_t ccl3f
CFC-11 time series.
Definition: mptrac.h:3321
clim_zm_t o1d
O(1D) zonal means.
Definition: mptrac.h:3315
clim_zm_t h2o2
H2O2 zonal means.
Definition: mptrac.h:3309
int tropo_nlat
Number of tropopause latitudes.
Definition: mptrac.h:3288
clim_zm_t oh
OH zonal means.
Definition: mptrac.h:3306
clim_ts_t n2o
N2O time series.
Definition: mptrac.h:3327
Climatological data in the form of time series.
Definition: mptrac.h:3230
int ntime
Number of timesteps.
Definition: mptrac.h:3233
Climatological data in the form of zonal means.
Definition: mptrac.h:3250
int np
Number of pressure levels.
Definition: mptrac.h:3259
int ntime
Number of timesteps.
Definition: mptrac.h:3253
int nlat
Number of latitudes.
Definition: mptrac.h:3256
Control parameters.
Definition: mptrac.h:2155
double grid_z0
Lower altitude of gridded data [km].
Definition: mptrac.h:3000
int qnt_o3
Quantity array index for ozone volume mixing ratio.
Definition: mptrac.h:2276
double csi_lat1
Upper latitude of gridded CSI data [deg].
Definition: mptrac.h:2964
int qnt_Coh
Quantity array index for OH volume mixing ratio (chemistry code).
Definition: mptrac.h:2423
double wet_depo_ic_a
Coefficient A for wet deposition in cloud (exponential form).
Definition: mptrac.h:2855
int met_nc_scale
Check netCDF scaling factors (0=no, 1=yes).
Definition: mptrac.h:2488
int qnt_pel
Quantity array index for pressure at equilibrium level (EL).
Definition: mptrac.h:2309
int csi_nz
Number of altitudes of gridded CSI data.
Definition: mptrac.h:2940
double molmass
Molar mass [g/mol].
Definition: mptrac.h:2717
int qnt_p
Quantity array index for pressure.
Definition: mptrac.h:2255
int qnt_Cccl2f2
Quantity array index for CFC-12 volume mixing ratio (chemistry code).
Definition: mptrac.h:2447
int mixing_nx
Number of longitudes of mixing grid.
Definition: mptrac.h:2780
double chemgrid_z1
Upper altitude of chemistry grid [km].
Definition: mptrac.h:2804
int qnt_m
Quantity array index for mass.
Definition: mptrac.h:2204
int qnt_aoa
Quantity array index for age of air.
Definition: mptrac.h:2456
int qnt_rhop
Quantity array index for particle density.
Definition: mptrac.h:2213
int qnt_swc
Quantity array index for cloud snow water content.
Definition: mptrac.h:2288
double csi_obsmin
Minimum observation index to trigger detection.
Definition: mptrac.h:2934
int qnt_pcb
Quantity array index for cloud bottom pressure.
Definition: mptrac.h:2297
double bound_dzs
Boundary conditions surface layer depth [km].
Definition: mptrac.h:2705
double csi_lon1
Upper longitude of gridded CSI data [deg].
Definition: mptrac.h:2955
int qnt_u
Quantity array index for zonal wind.
Definition: mptrac.h:2264
double stat_lon
Longitude of station [deg].
Definition: mptrac.h:3078
double mixing_trop
Interparcel exchange parameter for mixing in the troposphere.
Definition: mptrac.h:2765
double sort_dt
Time step for sorting of particle data [s].
Definition: mptrac.h:2626
double mixing_z1
Upper altitude of mixing grid [km].
Definition: mptrac.h:2777
double stat_r
Search radius around station [km].
Definition: mptrac.h:3084
double wet_depo_bc_a
Coefficient A for wet deposition below cloud (exponential form).
Definition: mptrac.h:2849
int csi_ny
Number of latitudes of gridded CSI data.
Definition: mptrac.h:2958
int vtk_sphere
Spherical projection for VTK data (0=no, 1=yes).
Definition: mptrac.h:3108
double chemgrid_z0
Lower altitude of chemistry grid [km].
Definition: mptrac.h:2801
double met_pbl_min
Minimum depth of planetary boundary layer [km].
Definition: mptrac.h:2594
int qnt_iwc
Quantity array index for cloud ice water content.
Definition: mptrac.h:2285
double chemgrid_lat0
Lower latitude of chemistry grid [deg].
Definition: mptrac.h:2819
double conv_cape
CAPE threshold for convection module [J/kg].
Definition: mptrac.h:2663
int qnt_Co1d
Quantity array index for O(1D) volume mixing ratio (chemistry code).
Definition: mptrac.h:2435
double met_cms_eps_pv
cmultiscale compression epsilon for potential vorticity.
Definition: mptrac.h:2528
int qnt_pw
Quantity array index for partial water vapor pressure.
Definition: mptrac.h:2363
double grid_z1
Upper altitude of gridded data [km].
Definition: mptrac.h:3003
int direction
Direction flag (1=forward calculation, -1=backward calculation).
Definition: mptrac.h:2459
int qnt_Cccl4
Quantity array index for CFC-10 volume mixing ratio (chemistry code).
Definition: mptrac.h:2441
int met_dp
Stride for pressure levels.
Definition: mptrac.h:2558
double met_dt_out
Time step for sampling of meteo data along trajectories [s].
Definition: mptrac.h:2613
int qnt_h2o2
Quantity array index for H2O2 volume mixing ratio (climatology).
Definition: mptrac.h:2327
int qnt_vh
Quantity array index for horizontal wind.
Definition: mptrac.h:2390
int csi_nx
Number of longitudes of gridded CSI data.
Definition: mptrac.h:2949
double csi_lat0
Lower latitude of gridded CSI data [deg].
Definition: mptrac.h:2961
double turb_dz_trop
Vertical turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2651
int met_pbl
Planetary boundary layer data (0=file, 1=Richardson, 2=theta).
Definition: mptrac.h:2591
int qnt_lwc
Quantity array index for cloud liquid water content.
Definition: mptrac.h:2279
double turb_mesoz
Vertical scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2660
int grid_nc_level
zlib compression level of netCDF grid data files (0=off).
Definition: mptrac.h:2988
int grid_nx
Number of longitudes of gridded data.
Definition: mptrac.h:3006
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:2905
double bound_mass
Boundary conditions mass per particle [kg].
Definition: mptrac.h:2678
double grid_lat0
Lower latitude of gridded data [deg].
Definition: mptrac.h:3018
int qnt_ts
Quantity array index for surface temperature.
Definition: mptrac.h:2219
int qnt_loss_rate
Quantity array index for total loss rate.
Definition: mptrac.h:2354
double met_cms_eps_h2o
cmultiscale compression epsilon for water vapor.
Definition: mptrac.h:2531
int qnt_plfc
Quantity array index for pressure at level of free convection (LCF).
Definition: mptrac.h:2306
double grid_lon0
Lower longitude of gridded data [deg].
Definition: mptrac.h:3009
int qnt_o1d
Quantity array index for O(1D) volume mixing ratio (climatology).
Definition: mptrac.h:2333
int met_tropo_spline
Tropopause interpolation method (0=linear, 1=spline).
Definition: mptrac.h:2610
int qnt_tvirt
Quantity array index for virtual temperature.
Definition: mptrac.h:2384
double dt_met
Time step of meteo data [s].
Definition: mptrac.h:2478
double chemgrid_lat1
Upper latitude of chemistry grid [deg].
Definition: mptrac.h:2822
int met_geopot_sy
Latitudinal smoothing of geopotential heights.
Definition: mptrac.h:2582
double met_cms_eps_u
cmultiscale compression epsilon for zonal wind.
Definition: mptrac.h:2519
double turb_dx_strat
Horizontal turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2648
int qnt_vmr
Quantity array index for volume mixing ratio.
Definition: mptrac.h:2207
int qnt_lsm
Quantity array index for land-sea mask.
Definition: mptrac.h:2231
int qnt_theta
Quantity array index for potential temperature.
Definition: mptrac.h:2375
double bound_lat1
Boundary conditions maximum longitude [deg].
Definition: mptrac.h:2693
double stat_t1
Stop time for station output [s].
Definition: mptrac.h:3090
double turb_dx_trop
Horizontal turbulent diffusion coefficient (troposphere) [m^2/s].
Definition: mptrac.h:2645
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:3024
double csi_lon0
Lower longitude of gridded CSI data [deg].
Definition: mptrac.h:2952
int qnt_pbl
Quantity array index for boundary layer pressure.
Definition: mptrac.h:2237
int grid_stddev
Include standard deviations in grid output (0=no, 1=yes).
Definition: mptrac.h:2994
int qnt_psice
Quantity array index for saturation pressure over ice.
Definition: mptrac.h:2360
double chemgrid_lon0
Lower longitude of chemistry grid [deg].
Definition: mptrac.h:2810
int bound_pbl
Boundary conditions planetary boundary layer (0=no, 1=yes).
Definition: mptrac.h:2711
int qnt_mloss_wet
Quantity array index for total mass loss due to wet deposition.
Definition: mptrac.h:2345
int met_geopot_sx
Longitudinal smoothing of geopotential heights.
Definition: mptrac.h:2579
int met_sy
Smoothing for latitudes.
Definition: mptrac.h:2564
int qnt_ps
Quantity array index for surface pressure.
Definition: mptrac.h:2216
int rng_type
Random number generator (0=GSL, 1=Squares, 2=cuRAND).
Definition: mptrac.h:2642
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
Definition: mptrac.h:2630
double bound_p1
Boundary conditions top pressure [hPa].
Definition: mptrac.h:2699
int qnt_zs
Quantity array index for surface geopotential height.
Definition: mptrac.h:2222
int prof_nz
Number of altitudes of gridded profile data.
Definition: mptrac.h:3033
double csi_dt_out
Time step for CSI output [s].
Definition: mptrac.h:2928
int met_cape
Convective available potential energy data (0=file, 1=calculate).
Definition: mptrac.h:2588
double csi_modmin
Minimum column density to trigger detection [kg/m^2].
Definition: mptrac.h:2937
int met_sx
Smoothing for longitudes.
Definition: mptrac.h:2561
double chemgrid_lon1
Upper longitude of chemistry grid [deg].
Definition: mptrac.h:2813
double turb_mesox
Horizontal scaling factor for mesoscale wind fluctuations.
Definition: mptrac.h:2657
double met_cms_eps_iwc
cmultiscale compression epsilon for cloud ice water content.
Definition: mptrac.h:2543
int conv_mix_bot
Lower level for mixing (0=particle pressure, 1=surface).
Definition: mptrac.h:2672
double met_cms_eps_swc
cmultiscale compression epsilon for cloud snow water content.
Definition: mptrac.h:2546
int met_zfp_prec
ZFP compression precision for all variables, except z and T.
Definition: mptrac.h:2497
double met_cms_eps_v
cmultiscale compression epsilon for meridional wind.
Definition: mptrac.h:2522
double prof_z0
Lower altitude of gridded profile data [km].
Definition: mptrac.h:3036
int qnt_w
Quantity array index for vertical velocity.
Definition: mptrac.h:2270
double bound_vmr
Boundary conditions volume mixing ratio [ppv].
Definition: mptrac.h:2684
double met_tropo_pv
Dynamical tropopause potential vorticity threshold [PVU].
Definition: mptrac.h:2604
int prof_nx
Number of longitudes of gridded profile data.
Definition: mptrac.h:3042
int qnt_stat
Quantity array index for station flag.
Definition: mptrac.h:2201
int met_tropo
Tropopause definition (0=none, 1=clim, 2=cold point, 3=WMO_1st, 4=WMO_2nd, 5=dynamical).
Definition: mptrac.h:2601
int qnt_rp
Quantity array index for particle radius.
Definition: mptrac.h:2210
int met_mpi_share
Use MPI to share meteo (0=no, 1=yes).
Definition: mptrac.h:2619
double mixing_strat
Interparcel exchange parameter for mixing in the stratosphere.
Definition: mptrac.h:2768
int qnt_vz
Quantity array index for vertical velocity.
Definition: mptrac.h:2393
int qnt_ho2
Quantity array index for HO2 volume mixing ratio (climatology).
Definition: mptrac.h:2330
double csi_z1
Upper altitude of gridded CSI data [km].
Definition: mptrac.h:2946
double stat_t0
Start time for station output [s].
Definition: mptrac.h:3087
double oh_chem_beta
Beta parameter for diurnal variablity of OH.
Definition: mptrac.h:2831
double mixing_z0
Lower altitude of mixing grid [km].
Definition: mptrac.h:2774
int qnt_mloss_decay
Quantity array index for total mass loss due to exponential decay.
Definition: mptrac.h:2351
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:2910
double dt_kpp
Time step for KPP chemistry [s].
Definition: mptrac.h:2840
double dry_depo_dp
Dry deposition surface layer [hPa].
Definition: mptrac.h:2873
int qnt_vs
Quantity array index for surface meridional wind.
Definition: mptrac.h:2228
int qnt_Cco
Quantity array index for CO volume mixing ratio (chemistry code).
Definition: mptrac.h:2420
double vtk_dt_out
Time step for VTK data output [s].
Definition: mptrac.h:3096
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2465
double conv_dt
Time interval for convection module [s].
Definition: mptrac.h:2669
int qnt_hno3
Quantity array index for HNO3 volume mixing ratio (climatology).
Definition: mptrac.h:2321
int met_clams
Read MPTRAC or CLaMS meteo data (0=MPTRAC, 1=CLaMS).
Definition: mptrac.h:2173
int qnt_h2ot
Quantity array index for tropopause water vapor volume mixing ratio.
Definition: mptrac.h:2249
int qnt_rh
Quantity array index for relative humidity over water.
Definition: mptrac.h:2369
double met_cms_eps_cc
cmultiscale compression epsilon for cloud cover.
Definition: mptrac.h:2549
double bound_lat0
Boundary conditions minimum longitude [deg].
Definition: mptrac.h:2690
double met_pbl_max
Maximum depth of planetary boundary layer [km].
Definition: mptrac.h:2597
int met_dx
Stride for longitudes.
Definition: mptrac.h:2552
int mixing_ny
Number of latitudes of mixing grid.
Definition: mptrac.h:2789
int met_convention
Meteo data layout (0=[lev, lat, lon], 1 = [lon, lat, lev]).
Definition: mptrac.h:2481
int qnt_zeta_d
Quantity array index for diagnosed zeta vertical coordinate.
Definition: mptrac.h:2381
int tracer_chem
Switch for first order tracer chemistry module (0=off, 1=on).
Definition: mptrac.h:2843
double dt_mod
Time step of simulation [s].
Definition: mptrac.h:2468
int qnt_tnat
Quantity array index for T_NAT.
Definition: mptrac.h:2408
int qnt_tice
Quantity array index for T_ice.
Definition: mptrac.h:2402
int qnt_zg
Quantity array index for geopotential height.
Definition: mptrac.h:2252
double vtk_offset
Vertical offset for VTK data [km].
Definition: mptrac.h:3105
int qnt_v
Quantity array index for meridional wind.
Definition: mptrac.h:2267
int qnt_mloss_dry
Quantity array index for total mass loss due to dry deposition.
Definition: mptrac.h:2348
double bound_vmr_trend
Boundary conditions volume mixing ratio trend [ppv/s].
Definition: mptrac.h:2687
int met_cache
Preload meteo data into disk cache (0=no, 1=yes).
Definition: mptrac.h:2616
int qnt_oh
Quantity array index for OH volume mixing ratio (climatology).
Definition: mptrac.h:2324
int qnt_Ch
Quantity array index for H volume mixing ratio (chemistry code).
Definition: mptrac.h:2426
int met_press_level_def
Use predefined pressure levels or not.
Definition: mptrac.h:2164
int oh_chem_reaction
Reaction type for OH chemistry (0=none, 2=bimolecular, 3=termolecular).
Definition: mptrac.h:2825
int qnt_h2o
Quantity array index for water vapor volume mixing ratio.
Definition: mptrac.h:2273
int prof_ny
Number of latitudes of gridded profile data.
Definition: mptrac.h:3051
int qnt_rhice
Quantity array index for relative humidity over ice.
Definition: mptrac.h:2372
int qnt_rho
Quantity array index for density of air.
Definition: mptrac.h:2261
double sample_dz
Layer depth for sample output [km].
Definition: mptrac.h:3072
double tdec_strat
Life time of particles in the stratosphere [s].
Definition: mptrac.h:2723
int obs_type
Type of observation data files (0=ASCII, 1=netCDF).
Definition: mptrac.h:2919
double met_cms_eps_lwc
cmultiscale compression epsilon for cloud liquid water content.
Definition: mptrac.h:2537
int qnt_us
Quantity array index for surface zonal wind.
Definition: mptrac.h:2225
double met_cms_eps_z
cmultiscale compression epsilon for geopotential height.
Definition: mptrac.h:2513
double grid_lon1
Upper longitude of gridded data [deg].
Definition: mptrac.h:3012
int conv_mix_top
Upper level for mixing (0=particle pressure, 1=EL).
Definition: mptrac.h:2675
int qnt_Cn2o
Quantity array index for N2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2450
int qnt_Cccl3f
Quantity array index for CFC-11 volume mixing ratio (chemistry code).
Definition: mptrac.h:2444
double mixing_lat0
Lower latitude of mixing grid [deg].
Definition: mptrac.h:2792
int qnt_pt
Quantity array index for tropopause pressure.
Definition: mptrac.h:2240
int qnt_cl
Quantity array index for total column cloud water.
Definition: mptrac.h:2300
int advect
Advection scheme (0=off, 1=Euler, 2=midpoint, 4=Runge-Kutta).
Definition: mptrac.h:2636
double prof_z1
Upper altitude of gridded profile data [km].
Definition: mptrac.h:3039
int reflect
Reflection of particles at top and bottom boundary (0=no, 1=yes).
Definition: mptrac.h:2639
int qnt_t
Quantity array index for temperature.
Definition: mptrac.h:2258
int atm_filter
Time filter for atmospheric data output (0=none, 1=missval, 2=remove).
Definition: mptrac.h:2898
int kpp_chem
Switch for KPP chemistry module (0=off, 1=on).
Definition: mptrac.h:2837
int qnt_zeta
Quantity array index for zeta vertical coordinate.
Definition: mptrac.h:2378
int met_vert_coord
Vertical coordinate of input meteo data (0=pressure-level, 1=model-level).
Definition: mptrac.h:2170
double csi_z0
Lower altitude of gridded CSI data [km].
Definition: mptrac.h:2943
int qnt_lapse
Quantity array index for lapse rate.
Definition: mptrac.h:2387
double stat_lat
Latitude of station [deg].
Definition: mptrac.h:3081
int qnt_Cho2
Quantity array index for HO2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2429
int grid_ny
Number of latitudes of gridded data.
Definition: mptrac.h:3015
int qnt_Csf6
Quantity array index for SF6 volume mixing ratio (chemistry code).
Definition: mptrac.h:2453
int qnt_Ch2o
Quantity array index for H2O volume mixing ratio (chemistry code).
Definition: mptrac.h:2414
double met_detrend
FWHM of horizontal Gaussian used for detrending [km].
Definition: mptrac.h:2570
double bound_dps
Boundary conditions surface layer depth [hPa].
Definition: mptrac.h:2702
double met_cms_eps_t
cmultiscale compression epsilon for temperature.
Definition: mptrac.h:2516
int chemgrid_nz
Number of altitudes of chemistry grid.
Definition: mptrac.h:2798
int qnt_cape
Quantity array index for convective available potential energy (CAPE).
Definition: mptrac.h:2312
double bound_mass_trend
Boundary conditions mass per particle trend [kg/s].
Definition: mptrac.h:2681
int mixing_nz
Number of altitudes of mixing grid.
Definition: mptrac.h:2771
int qnt_o3c
Quantity array index for total column ozone.
Definition: mptrac.h:2318
double bound_p0
Boundary conditions bottom pressure [hPa].
Definition: mptrac.h:2696
double mixing_lon0
Lower longitude of mixing grid [deg].
Definition: mptrac.h:2783
int qnt_Co3
Quantity array index for O3 volume mixing ratio (chemistry code).
Definition: mptrac.h:2417
int qnt_tsts
Quantity array index for T_STS.
Definition: mptrac.h:2405
int grid_nz
Number of altitudes of gridded data.
Definition: mptrac.h:2997
double ens_dt_out
Time step for ensemble output [s].
Definition: mptrac.h:2970
int atm_stride
Particle index stride for atmospheric data files.
Definition: mptrac.h:2901
int advect_cpl_zeta_and_press_modules
Coupled use of pressure based modules and diabatic advection.
Definition: mptrac.h:2161
int met_relhum
Try to read relative humidity (0=no, 1=yes).
Definition: mptrac.h:2585
double mixing_lat1
Upper latitude of mixing grid [deg].
Definition: mptrac.h:2795
double atm_dt_out
Time step for atmospheric data output [s].
Definition: mptrac.h:2895
double prof_lat1
Upper latitude of gridded profile data [deg].
Definition: mptrac.h:3057
int met_cms_batch
cmultiscale batch size.
Definition: mptrac.h:2506
double psc_h2o
H2O volume mixing ratio for PSC analysis.
Definition: mptrac.h:2879
int met_sp
Smoothing for pressure levels.
Definition: mptrac.h:2567
double prof_lon0
Lower longitude of gridded profile data [deg].
Definition: mptrac.h:3045
int chemgrid_nx
Number of longitudes of chemistry grid.
Definition: mptrac.h:2807
int qnt_pct
Quantity array index for cloud top pressure.
Definition: mptrac.h:2294
int qnt_mloss_kpp
Quantity array index for total mass loss due to KPP chemistry.
Definition: mptrac.h:2342
int qnt_psat
Quantity array index for saturation pressure over water.
Definition: mptrac.h:2357
double prof_lat0
Lower latitude of gridded profile data [deg].
Definition: mptrac.h:3054
int qnt_cin
Quantity array index for convective inhibition (CIN).
Definition: mptrac.h:2315
double psc_hno3
HNO3 volume mixing ratio for PSC analysis.
Definition: mptrac.h:2882
double prof_lon1
Upper longitude of gridded profile data [deg].
Definition: mptrac.h:3048
double met_cms_eps_rwc
cmultiscale compression epsilon for cloud rain water content.
Definition: mptrac.h:2540
int met_nc_quant
Number of digits for quantization of netCDF meteo files (0=off).
Definition: mptrac.h:2494
int h2o2_chem_reaction
Reaction type for H2O2 chemistry (0=none, 1=SO2).
Definition: mptrac.h:2834
int qnt_Co3p
Quantity array index for O(3P) volume mixing ratio (chemistry code).
Definition: mptrac.h:2438
double wet_depo_bc_ret_ratio
Coefficients for wet deposition below cloud: retention ratio.
Definition: mptrac.h:2870
int chemgrid_ny
Number of latitudes of chemistry grid.
Definition: mptrac.h:2816
double met_cms_eps_o3
cmultiscale compression epsilon for ozone.
Definition: mptrac.h:2534
int grid_sparse
Sparse output in grid data files (0=no, 1=yes).
Definition: mptrac.h:2985
double dry_depo_vdep
Dry deposition velocity [m/s].
Definition: mptrac.h:2876
int qnt_tt
Quantity array index for tropopause temperature.
Definition: mptrac.h:2243
int met_np
Number of target pressure levels.
Definition: mptrac.h:2573
int qnt_ens
Quantity array index for ensemble IDs.
Definition: mptrac.h:2198
int met_nc_level
zlib compression level of netCDF meteo files (0=off).
Definition: mptrac.h:2491
double met_zfp_tol_t
ZFP compression tolerance for temperature.
Definition: mptrac.h:2500
double mixing_dt
Time interval for mixing [s].
Definition: mptrac.h:2762
int qnt_mloss_h2o2
Quantity array index for total mass loss due to H2O2 chemistry.
Definition: mptrac.h:2339
double met_zfp_tol_z
ZFP compression tolerance for geopotential height.
Definition: mptrac.h:2503
double vtk_scale
Vertical scaling factor for VTK data.
Definition: mptrac.h:3102
double met_cms_eps_w
cmultiscale compression epsilon for vertical velocity.
Definition: mptrac.h:2525
double conv_cin
CIN threshold for convection module [J/kg].
Definition: mptrac.h:2666
int qnt_pv
Quantity array index for potential vorticity.
Definition: mptrac.h:2396
int advect_vert_coord
Vertical coordinate of air parcels (0=pressure, 1=zeta, 2=eta).
Definition: mptrac.h:2167
int qnt_mloss_oh
Quantity array index for total mass loss due to OH chemistry.
Definition: mptrac.h:2336
int qnt_Ch2o2
Quantity array index for H2O2 volume mixing ratio (chemistry code).
Definition: mptrac.h:2432
int qnt_sst
Quantity array index for sea surface temperature.
Definition: mptrac.h:2234
double mixing_lon1
Upper longitude of mixing grid [deg].
Definition: mptrac.h:2786
int atm_nc_level
zlib compression level of netCDF atmospheric data files (0=off).
Definition: mptrac.h:2913
int met_cms_heur
cmultiscale coarsening heuristics (0=default, 1=mean diff, 2=median diff, 3=max diff).
Definition: mptrac.h:2510
double wet_depo_ic_ret_ratio
Coefficients for wet deposition in cloud: retention ratio.
Definition: mptrac.h:2867
int qnt_sh
Quantity array index for specific humidity.
Definition: mptrac.h:2366
double wet_depo_ic_b
Coefficient B for wet deposition in cloud (exponential form).
Definition: mptrac.h:2858
double wet_depo_bc_b
Coefficient B for wet deposition below cloud (exponential form).
Definition: mptrac.h:2852
int met_dy
Stride for latitudes.
Definition: mptrac.h:2555
int qnt_Cx
Quantity array index for trace species x volume mixing ratio (chemistry code).
Definition: mptrac.h:2411
double turb_dz_strat
Vertical turbulent diffusion coefficient (stratosphere) [m^2/s].
Definition: mptrac.h:2654
double bound_zetas
Boundary conditions surface layer zeta [K].
Definition: mptrac.h:2708
int qnt_idx
Quantity array index for air parcel IDs.
Definition: mptrac.h:2195
double met_tropo_theta
Dynamical tropopause potential temperature threshold [K].
Definition: mptrac.h:2607
int qnt_rwc
Quantity array index for cloud rain water content.
Definition: mptrac.h:2282
double t_start
Start time of simulation [s].
Definition: mptrac.h:2462
int nq
Number of quantities.
Definition: mptrac.h:2180
double tdec_trop
Life time of particles in the troposphere [s].
Definition: mptrac.h:2720
double sample_dx
Horizontal radius for sample output [km].
Definition: mptrac.h:3069
int vtk_stride
Particle index stride for VTK data.
Definition: mptrac.h:3099
double grid_lat1
Upper latitude of gridded data [deg].
Definition: mptrac.h:3021
int qnt_zt
Quantity array index for tropopause geopotential height.
Definition: mptrac.h:2246
int met_type
Type of meteo data files (0=netCDF, 1=binary, 2=pck, 3=zfp, 4=zstd, 5=cms).
Definition: mptrac.h:2485
int qnt_cc
Quantity array index for cloud cover.
Definition: mptrac.h:2291
int qnt_plcl
Quantity array index for pressure at lifted condensation level (LCL).
Definition: mptrac.h:2303
double grid_dt_out
Time step for gridded data output [s].
Definition: mptrac.h:2982
int qnt_tdew
Quantity array index for dew point temperature.
Definition: mptrac.h:2399
Meteo data structure.
Definition: mptrac.h:3341
int nx
Number of longitudes.
Definition: mptrac.h:3347
int ny
Number of latitudes.
Definition: mptrac.h:3350
int np
Number of pressure levels.
Definition: mptrac.h:3353
int npl
Number of model levels.
Definition: mptrac.h:3356
double time
Time [s].
Definition: mptrac.h:3344