MPTRAC
|
MPTRAC library definitions. More...
#include "mptrac.h"
Go to the source code of this file.
Functions | |
void | cart2geo (const double *x, double *z, double *lon, double *lat) |
State variables of cuRAND random number generator. More... | |
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 correction based on solar zenith angle. More... | |
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. More... | |
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. More... | |
double | clim_tropo (const clim_t *clim, const double t, const double lat) |
Calculates the tropopause pressure based on climatological data. More... | |
void | clim_tropo_init (clim_t *clim) |
Initializes the tropopause data in the climatology structure. More... | |
double | clim_ts (const clim_ts_t *ts, const double t) |
Interpolates a time series of climatological variables. More... | |
double | clim_zm (const clim_zm_t *zm, const double t, const double lat, const double p) |
Interpolates monthly mean zonal mean climatological variables. More... | |
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. More... | |
void | day2doy (const int year, const int mon, const int day, int *doy) |
Get day of year from date. More... | |
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). More... | |
void | fft_help (double *fcReal, double *fcImag, const int n) |
Computes the Fast Fourier Transform (FFT) of a complex sequence. More... | |
void | geo2cart (const double z, const double lon, const double lat, double *x) |
Converts geographic coordinates (longitude, latitude, altitude) to Cartesian coordinates. More... | |
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. More... | |
void | get_met_help (const ctl_t *ctl, const double t, const int direct, const char *metbase, const double dt_met, char *filename) |
void | get_met_replace (char *orig, char *search, char *repl) |
Replaces occurrences of a substring in a string with another substring. More... | |
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. More... | |
void | intpol_met_4d_coord (const met_t *met0, float heights0[EX][EY][EP], float array0[EX][EY][EP], const met_t *met1, float heights1[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. More... | |
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. More... | |
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). More... | |
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. More... | |
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. More... | |
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). More... | |
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. More... | |
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). More... | |
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. More... | |
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. More... | |
double | lapse_rate (const double t, const double h2o) |
Calculates the moist adiabatic lapse rate in Kelvin per kilometer. More... | |
void | level_definitions (ctl_t *ctl) |
Defines pressure levels for meteorological data. More... | |
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. More... | |
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. More... | |
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. More... | |
void | locate_vert (float profiles[EX][EY][EP], const int np, const int lon_ap_ind, const int lat_ap_ind, const double height_ap, int *ind) |
Locate the four vertical indizes of a box for a given height value. More... | |
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. More... | |
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. More... | |
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. More... | |
void | module_chemgrid (const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double tt) |
Calculate grid data for chemistry modules. More... | |
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. More... | |
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. More... | |
void | module_decay (const ctl_t *ctl, const clim_t *clim, atm_t *atm, const double *dt) |
Simulate exponential decay processes for atmospheric particles. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | module_mixing (const ctl_t *ctl, const clim_t *clim, atm_t *atm, const double t) |
Update atmospheric properties through interparcel mixing. More... | |
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. More... | |
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. More... | |
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. More... | |
void | module_rng_init (const int ntask) |
Initialize random number generators for parallel tasks. More... | |
void | module_rng (const ctl_t *ctl, double *rs, const size_t n, const int method) |
Generate random numbers using various methods and distributions. More... | |
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. More... | |
void | module_sort (const ctl_t *ctl, met_t *met0, atm_t *atm) |
Sort particles according to box index. More... | |
void | module_sort_help (double *a, const int *p, const int np) |
Reorder an array based on a given permutation. More... | |
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. More... | |
void | module_timesteps_init (ctl_t *ctl, const atm_t *atm) |
Initialize start time and time interval for time-stepping. More... | |
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. More... | |
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. More... | |
double | nat_temperature (const double p, const double h2o, const double hno3) |
Calculates the nitric acid trihydrate (NAT) temperature. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | read_clim (const ctl_t *ctl, clim_t *clim) |
Reads various climatological data and populates the given climatology structure. More... | |
void | read_clim_photo (const char *filename, clim_photo_t *photo) |
Reads photolysis rates from a NetCDF file and populates the given photolysis structure. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | read_met_bin (const char *filename, ctl_t *ctl, met_t *met) |
Reads meteorological data from a binary file. More... | |
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. More... | |
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. More... | |
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. More... | |
void | read_met_cloud (met_t *met) |
Calculates cloud-related variables for each grid point. More... | |
void | read_met_detrend (const ctl_t *ctl, met_t *met) |
Detrends meteorological data. More... | |
void | read_met_extrapolate (met_t *met) |
Extrapolates meteorological data. More... | |
void | read_met_geopot (const ctl_t *ctl, met_t *met) |
Calculates geopotential heights from meteorological data. More... | |
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. More... | |
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. More... | |
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. More... | |
void | read_met_monotonize (met_t *met) |
Makes zeta and pressure profiles monotone. More... | |
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. More... | |
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. More... | |
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. More... | |
void | read_met_pbl (const ctl_t *ctl, met_t *met) |
Computes the planetary boundary layer (PBL) height based on meteorological data. More... | |
void | read_met_periodic (met_t *met) |
Applies periodic boundary conditions to meteorological data along longitudinal axis. More... | |
void | read_met_polar_winds (met_t *met) |
Applies a fix for polar winds in meteorological data. More... | |
void | read_met_pv (met_t *met) |
Calculates potential vorticity (PV) from meteorological data. More... | |
void | read_met_ozone (met_t *met) |
Calculates the total column ozone from meteorological ozone data. More... | |
void | read_met_sample (const ctl_t *ctl, met_t *met) |
Downsamples meteorological data based on specified parameters. More... | |
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 structure. More... | |
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 the results in the meteorological data structure. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
double | sedi (const double p, const double T, const double rp, const double rhop) |
Calculates the sedimentation velocity of a particle in air. More... | |
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. More... | |
float | stddev (const float *data, const int n) |
Calculates the standard deviation of a set of data. More... | |
double | sza_calc (const double sec, const double lon, const double lat) |
Calculates the solar zenith angle. More... | |
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. More... | |
void | timer (const char *name, const char *group, const int output) |
Measures and reports elapsed time for named and grouped timers. More... | |
double | time_from_filename (const char *filename, const int offset) |
Extracts and converts a timestamp from a filename to Julian seconds. More... | |
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. More... | |
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. More... | |
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. More... | |
void | write_atm_bin (const char *filename, const ctl_t *ctl, const atm_t *atm) |
Writes air parcel data to a binary file. More... | |
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. More... | |
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. More... | |
void | write_atm_nc (const char *filename, const ctl_t *ctl, const atm_t *atm) |
Writes air parcel data to a NetCDF file. More... | |
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. More... | |
void | write_ens (const char *filename, const ctl_t *ctl, const atm_t *atm, const double t) |
Writes ensemble data to a file. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | write_met_bin (const char *filename, const ctl_t *ctl, met_t *met) |
Writes meteorological data in binary format to a specified file. More... | |
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. More... | |
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. More... | |
void | write_met_nc (const char *filename, const ctl_t *ctl, met_t *met) |
Writes meteorological data to a NetCDF file. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | write_station (const char *filename, const ctl_t *ctl, atm_t *atm, const double t) |
Writes station data to a specified file. More... | |
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. More... | |
MPTRAC library definitions.
Definition in file mptrac.c.
void cart2geo | ( | const double * | x, |
double * | z, | ||
double * | lon, | ||
double * | lat | ||
) |
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 correction based on solar zenith angle.
This function retrieves OH data from a given climatology and applies a diurnal correction if the correction factor (oh_chem_beta) is greater than zero. The diurnal correction accounts for the variation in OH concentration due to changes in the solar zenith angle.
ctl | Pointer to the control structure containing configuration parameters. |
clim | Pointer to the climatology structure containing OH data. |
t | Time at which the OH concentration is to be calculated. |
lon | Longitude at which the OH concentration is to be calculated. |
lat | Latitude at which the OH concentration is to be calculated. |
p | Pressure level at which the OH concentration is to be calculated. |
Definition at line 89 of file mptrac.c.
Applies a diurnal correction to the hydroxyl radical (OH) concentration in climatology data.
This function iterates over the climatology data points for OH concentration and integrates the day/night correction factor over longitude. The correction factor is based on the solar zenith angle, and it adjusts the OH data to account for diurnal variations. The corrected OH data is scaled accordingly.
ctl | Pointer to the control structure containing configuration parameters, including the correction factor (oh_chem_beta). |
clim | Pointer to the climatology structure containing OH data that will be corrected. |
Definition at line 116 of file mptrac.c.
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.
This function computes the photolysis rate based on provided climatology data and input parameters such as pressure, solar zenith angle (SZA), and ozone column. It ensures that the input parameters are within the valid range of the climatology data and interpolates the photolysis rate accordingly.
rate | 3D array containing the photolysis rates for different combinations of pressure, SZA, and ozone column. |
photo | Pointer to the climatology data structure containing arrays of valid pressure levels, SZAs, and ozone columns. |
p | Pressure at which the photolysis rate is to be calculated. |
sza | Solar zenith angle at which the photolysis rate is to be calculated. |
o3c | Ozone column at which the photolysis rate is to be calculated. |
This function performs the following steps:
Definition at line 149 of file mptrac.c.
double clim_tropo | ( | const clim_t * | clim, |
const double | t, | ||
const double | lat | ||
) |
Calculates the tropopause pressure based on climatological data.
This function computes the tropopause pressure using climatological data for different times and latitudes. It interpolates the tropopause pressure based on the input time and latitude parameters.
clim | Pointer to the climatology structure containing tropopause pressure data. |
t | Time for which the tropopause pressure is to be calculated, in seconds since the beginning of the year. |
lat | Latitude at which the tropopause pressure is to be calculated. |
This function performs the following steps:
Definition at line 200 of file mptrac.c.
void clim_tropo_init | ( | clim_t * | clim | ) |
Initializes the tropopause data in the climatology structure.
This function initializes the tropopause data in the climatology structure. It sets the time steps, latitudes, and tropopause pressure values based on predefined arrays.
clim | Pointer to the climatology structure to be initialized. |
This function performs the following steps:
Definition at line 228 of file mptrac.c.
double clim_ts | ( | const clim_ts_t * | ts, |
const double | t | ||
) |
Interpolates a time series of climatological variables.
This function interpolates a time series of climatological variables based on the input time and the provided data points.
ts | Pointer to the time series structure containing data points. |
t | Time at which to interpolate the climatological variable (in seconds). |
This function performs linear interpolation between the closest data points to the input time t
. If t
is outside the range of the provided time series, the value at the nearest boundary is returned.
Definition at line 383 of file mptrac.c.
double clim_zm | ( | const clim_zm_t * | zm, |
const double | t, | ||
const double | lat, | ||
const double | p | ||
) |
Interpolates monthly mean zonal mean climatological variables.
This function interpolates climatological variables based on pressure, latitude, and time. The climatological data is provided in the form of monthly mean zonal mean values.
zm | Pointer to the climatological zonal mean structure containing data points. |
t | Time at which to interpolate the climatological variable (in seconds since the beginning of the year). |
lat | Latitude at which to interpolate the climatological variable (in degrees). |
p | Pressure at which to interpolate the climatological variable (in hPa). |
This function performs trilinear interpolation between the nearest data points to the input time t
, latitude lat
, and pressure or altitude p
. If the input values are outside the range of the provided data, the function extrapolates by using the nearest boundary values.
Definition at line 401 of file mptrac.c.
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.
This function either compresses or decompresses a 3D array of floats based on the value of the decompress
parameter. Compression reduces the storage size by converting float values (4 bytes) to unsigned short values (2 bytes) with scaling and offset. Decompression restores the original float values from the compressed unsigned short representation.
varname | The name of the variable being processed. |
array | Pointer to the 3D array of floats to be compressed or decompressed. |
nxy | The number of elements in the first two dimensions of the array. |
nz | The number of elements in the third dimension of the array. |
decompress | If non-zero, the function will decompress the data; otherwise, it will compress the data. |
inout | File pointer for input or output operations. It is used for reading compressed data during decompression and writing compressed data during compression. |
The function performs the following steps:
array
.The function allocates memory for the compressed data array and frees it before returning.
Definition at line 657 of file mptrac.c.
void day2doy | ( | const int | year, |
const int | mon, | ||
const int | day, | ||
int * | doy | ||
) |
Get day of year from date.
Converts a given date to the day of the year (DOY).
This function computes the day of the year (DOY) for a given date specified by the year, month, and day. It takes into account whether the given year is a leap year or not.
year | The year of the date. |
mon | The month of the date (1-12). |
day | The day of the month (1-31). |
doy | Pointer to an integer where the computed day of the year will be stored. |
The function uses two arrays, d0
and d0l
, which contain the cumulative number of days at the start of each month for non-leap years and leap years respectively. It checks if the year is a leap year and calculates the day of the year accordingly.
Definition at line 897 of file mptrac.c.
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).
This function computes the month and day for a given day of the year (DOY) and year. It accounts for whether the given year is a leap year or not.
year | The year corresponding to the DOY. |
doy | The day of the year (1-365 or 1-366). |
mon | Pointer to an integer where the computed month will be stored. |
day | Pointer to an integer where the computed day of the month will be stored. |
The function uses two arrays, d0
and d0l
, which contain the cumulative number of days at the start of each month for non-leap years and leap years respectively. It checks if the year is a leap year and calculates the month and day of the month accordingly.
Definition at line 916 of file mptrac.c.
void fft_help | ( | double * | fcReal, |
double * | fcImag, | ||
const int | n | ||
) |
Computes the Fast Fourier Transform (FFT) of a complex sequence.
This function calculates the FFT of a complex sequence represented by separate arrays for the real and imaginary parts. The input arrays fcReal
and fcImag
are modified in place to contain the transformed data.
fcReal | Pointer to an array of doubles representing the real part of the input sequence. The array should have at least n elements. |
fcImag | Pointer to an array of doubles representing the imaginary part of the input sequence. The array should have at least n elements. |
n | The number of complex data points in the input sequence. This value should not exceed PMAX. |
fcReal
and fcImag
must point to arrays of at least n
elements. n
must be less than or equal to PMAX.fcReal
and fcImag
will contain the real and imaginary parts of the FFT result, respectively.n
exceeds PMAX, the function will trigger an error message and terminate.Definition at line 946 of file mptrac.c.
void geo2cart | ( | const double | z, |
const double | lon, | ||
const double | lat, | ||
double * | x | ||
) |
Converts geographic coordinates (longitude, latitude, altitude) to Cartesian coordinates.
This function converts geographic coordinates specified by longitude, latitude, and altitude into Cartesian coordinates. The Earth is approximated as a sphere with radius defined by the constant RE
.
z | The altitude above the Earth's surface in kilometers. |
lon | The longitude in degrees. |
lat | The latitude in degrees. |
x | Pointer to an array of three doubles where the computed Cartesian coordinates (x, y, z) will be stored. |
The function computes the Cartesian coordinates using the given altitude, longitude, and latitude. It assumes the Earth is a perfect sphere and uses the following formulas:
RE
is defined as the Earth's radius in kilometers. Retrieves meteorological data for the specified time.
This function retrieves meteorological data for the given time t
and updates the provided pointers to the met0 and met1 structures accordingly. It handles both the initialization and subsequent updates of the meteorological data based on the direction of time integration.
ctl | Pointer to the control structure containing configuration settings. |
clim | Pointer to the climate structure. |
t | The current time for which meteorological data is to be retrieved. |
met0 | Pointer to the pointer of the first meteorological data structure. |
met1 | Pointer to the pointer of the second meteorological data structure. |
The function performs the following steps:
ctl
, clim
, met0
, and met1
are properly initialized before calling this function.Definition at line 1004 of file mptrac.c.
void get_met_help | ( | const ctl_t * | ctl, |
const double | t, | ||
const int | direct, | ||
const char * | metbase, | ||
const double | dt_met, | ||
char * | filename | ||
) |
Definition at line 1150 of file mptrac.c.
void get_met_replace | ( | char * | orig, |
char * | search, | ||
char * | repl | ||
) |
Replaces occurrences of a substring in a string with another substring.
This function replaces occurrences of the substring search
in the string orig
with the substring repl
. The replacement is performed in-place.
orig | The original string where replacements are to be made. |
search | The substring to be replaced. |
repl | The substring to replace occurrences of search . |
The function iterates over the original string orig
and replaces each occurrence of the substring search
with the substring repl
. It performs the replacement operation up to three times to ensure multiple occurrences are replaced.
YYYY
, MM
, and DD
by year, month, and day in filenames. orig
, search
, and repl
are properly initialized and have sufficient memory allocated before calling this function.Definition at line 1215 of file mptrac.c.
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.
This function reads and interpolates various meteorological parameters such as tropopause pressure, temperature, and ozone concentration at specified latitudes and longitudes. The interpolated data is stored in the provided arrays.
met_tropo | An integer specifying the type of meteorological data to use. |
ctl | Pointer to a ctl_t structure that controls the meteorological data processing. |
clim | Pointer to a clim_t structure containing climatological data. |
met | Pointer to a met_t structure containing meteorological data. |
lons | Array of longitudes at which to interpolate data. The array should have nx elements. |
nx | Number of longitude points. |
lats | Array of latitudes at which to interpolate data. The array should have ny elements. |
ny | Number of latitude points. |
pt | Pointer to an array where the interpolated pressure values will be stored. The array should have nx * ny elements. |
zt | Pointer to an array where the interpolated height values will be stored. The array should have nx * ny elements. |
tt | Pointer to an array where the interpolated temperature values will be stored. The array should have nx * ny elements. |
qt | Pointer to an array where the interpolated specific humidity values will be stored. The array should have nx * ny elements. |
o3t | Pointer to an array where the interpolated ozone concentration values will be stored. The array should have nx * ny elements. |
ps | Pointer to an array where the interpolated surface pressure values will be stored. The array should have nx * ny elements. |
zs | Pointer to an array where the interpolated surface height values will be stored. The array should have nx * ny elements. |
lons
must have at least nx
elements. lats
must have at least ny
elements. pt
, zt
, tt
, qt
, o3t
, ps
, and zs
must have at least nx * ny
elements.pt
, zt
, tt
, qt
, o3t
, ps
, and zs
will contain the interpolated meteorological data.read_met_tropo
, intpol_met_space_2d
, and intpol_met_space_3d
for reading and interpolating the tropopause data.Definition at line 1239 of file mptrac.c.
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.
This function interpolates meteorological variables to a specified position and time. It calculates the interpolated value based on the values provided at two time steps and performs interpolation in time, longitude, latitude, and altitude dimensions.
met0 | Pointer to the meteorological data at the first time step. |
height0 | Array containing heights at the first time step. |
array0 | Array containing meteorological variable values at the first time step. |
met1 | Pointer to the meteorological data at the second time step. |
height1 | Array containing heights at the second time step. |
array1 | Array containing meteorological variable values at the second time step. |
ts | Interpolation time (fractional time between met0 and met1). |
height | Altitude at which to interpolate. |
lon | Longitude at which to interpolate. |
lat | Latitude at which to interpolate. |
var | Pointer to store the interpolated variable value. |
ci | Array to store the calculated indices. |
cw | Array to store the weighting factors. |
init | Flag indicating if it's the first call (1) or not (0). |
The function first restricts the longitude within the range [0, 360) degrees. It then calculates the horizontal indices (ci[0]
and ci[1]
) based on the provided longitude and latitude. Next, it locates the vertical indices for each edge of the column based on the provided height.
The function then calculates the weighting factors for time, longitude, latitude, and altitude. It iterates over the interpolation process to determine the altitude weighting factor. After initializing the interpolation parameters, it calculates the interpolated variable value and stores it in the memory location pointed to by var
.
height0
, array0
, height1
, array1
, ci
, cw
) have sufficient memory allocated before calling this function.Definition at line 1282 of file mptrac.c.
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.
This function interpolates meteorological variables at a specified pressure level and geographic position. It calculates the interpolated value based on the values provided at neighboring grid points and performs interpolation in pressure, longitude, and latitude dimensions.
met | Pointer to the meteorological data. |
array | Array containing meteorological variable values. |
p | Pressure level at which to interpolate. |
lon | Longitude at which to interpolate. |
lat | Latitude at which to interpolate. |
var | Pointer to store the interpolated variable value. |
ci | Array to store the calculated indices. |
cw | Array to store the weighting factors. |
init | Flag indicating if it's the first call (1) or not (0). |
The function first checks the longitude and adjusts it if necessary to ensure it falls within the valid range. It then calculates the interpolation indices based on the provided pressure level, longitude, and latitude. Next, it computes the interpolation weights for pressure, longitude, and latitude.
The function interpolates vertically first and then horizontally. The interpolated value is stored in the memory location pointed to by var
.
array
, ci
, and cw
arrays have sufficient memory allocated before calling this function.Definition at line 1460 of file mptrac.c.
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).
This function performs trilinear interpolation of a meteorological variable based on the provided longitude, latitude, and pressure coordinates. The meteorological data is given in a 3D array, and the function calculates the interpolated value and stores it in the variable pointed to by var
. The function operates on model level data.
[in] | met | Pointer to a met_t structure containing the meteorological data. |
[in] | array | 3D array of meteorological data with dimensions [EX][EY][EP]. |
[in] | p | Pressure coordinate at which to interpolate. |
[in] | lon | Longitude coordinate at which to interpolate. |
[in] | lat | Latitude coordinate at which to interpolate. |
[out] | var | Pointer to a double where the interpolated value will be stored. |
Definition at line 1520 of file mptrac.c.
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.
This function interpolates meteorological variables at a specified geographic position. It calculates the interpolated value based on the values provided at neighboring grid points and performs interpolation in longitude and latitude dimensions.
met | Pointer to the meteorological data. |
array | Array containing meteorological variable values. |
lon | Longitude at which to interpolate. |
lat | Latitude at which to interpolate. |
var | Pointer to store the interpolated variable value. |
ci | Array to store the calculated indices. |
cw | Array to store the weighting factors. |
init | Flag indicating if it's the first call (1) or not (0). |
The function first checks the longitude and adjusts it if necessary to ensure it falls within the valid range. It then calculates the interpolation indices based on the provided longitude and latitude. Next, it computes the interpolation weights for longitude and latitude.
The function interpolates horizontally and stores the interpolated value in the memory location pointed to by var
. If any of the data values used in interpolation are not finite, the function handles this situation by choosing a valid value or performing a simple interpolation.
array
, ci
, and cw
arrays have sufficient memory allocated before calling this function.Definition at line 1593 of file mptrac.c.
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.
This function interpolates meteorological data in three dimensions (longitude, latitude, and pressure) and time. It calculates the interpolated value based on the values provided at neighboring grid points and performs interpolation both spatially and temporally.
met0 | Pointer to the meteorological data at time t0. |
array0 | 3D array of meteorological data at time t0. |
met1 | Pointer to the meteorological data at time t1. |
array1 | 3D array of meteorological data at time t1. |
ts | Time stamp at which to interpolate. |
p | Pressure level at which to interpolate. |
lon | Longitude at which to interpolate. |
lat | Latitude at which to interpolate. |
var | Pointer to store the interpolated value. |
ci | Array to store the calculated indices. |
cw | Array to store the weighting factors. |
init | Flag indicating if it's the first call (1) or not (0). |
The function first performs spatial interpolation for both time instances (t0 and t1) using the intpol_met_space_3d
function. It then calculates the weighting factor wt
based on the time stamp ts
. Finally, it performs temporal interpolation using the interpolated values at t0 and t1 along with the weighting factor to compute the final interpolated value stored in var
.
ci
and cw
arrays have sufficient memory allocated before calling this function.Definition at line 1653 of file mptrac.c.
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).
This function performs spatiotemporal interpolation of a meteorological variable based on the provided longitude, latitude, pressure, and timestamp. The meteorological data is given in two 3D arrays corresponding to two different time steps, and the function calculates the interpolated value and stores it in the variable pointed to by var
. The function operates on model level data.
[in] | met0 | Pointer to a met_t structure containing the meteorological data for the first time step. |
[in] | array0 | 3D array of meteorological data for the first time step with dimensions [EX][EY][EP]. |
[in] | met1 | Pointer to a met_t structure containing the meteorological data for the second time step. |
[in] | array1 | 3D array of meteorological data for the second time step with dimensions [EX][EY][EP]. |
[in] | ts | Timestamp at which to interpolate. |
[in] | p | Pressure coordinate at which to interpolate. |
[in] | lon | Longitude coordinate at which to interpolate. |
[in] | lat | Latitude coordinate at which to interpolate. |
[out] | var | Pointer to a double where the interpolated value will be stored. |
Definition at line 1682 of file mptrac.c.
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.
This function interpolates meteorological data in two dimensions (longitude and latitude) and time. It calculates the interpolated value based on the values provided at neighboring grid points and performs interpolation both spatially and temporally.
met0 | Pointer to the meteorological data at time t0. |
array0 | 2D array of meteorological data at time t0. |
met1 | Pointer to the meteorological data at time t1. |
array1 | 2D array of meteorological data at time t1. |
ts | Time stamp at which to interpolate. |
lon | Longitude at which to interpolate. |
lat | Latitude at which to interpolate. |
var | Pointer to store the interpolated value. |
ci | Array to store the calculated indices. |
cw | Array to store the weighting factors. |
init | Flag indicating if it's the first call (1) or not (0). |
The function first performs spatial interpolation for both time instances (t0 and t1) using the intpol_met_space_2d
function. It then calculates the weighting factor wt
based on the time stamp ts
. Finally, it performs temporal interpolation using the interpolated values at t0 and t1 along with the weighting factor to compute the final interpolated value stored in var
. If one of the interpolated values is not finite, it selects the valid value based on the weighting factor wt
.
ci
and cw
arrays have sufficient memory allocated before calling this function.Definition at line 1705 of file mptrac.c.
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).
This function performs interpolation of tropopause data at a given latitude, longitude, and time. The interpolation can be performed using either linear interpolation or nearest neighbor interpolation. The standard deviation of the data points used in the interpolation is also computed.
time0 | Time corresponding to the first data array array0 . |
array0 | A 2D array of tropopause data at time0 . The dimensions are EX by EY . |
time1 | Time corresponding to the second data array array1 . |
array1 | A 2D array of tropopause data at time1 . The dimensions are EX by EY . |
lons | Array of longitudes with EX elements. |
lats | Array of latitudes with EY elements. |
nlon | Number of longitudes. |
nlat | Number of latitudes. |
time | The specific time at which to interpolate the data. |
lon | The specific longitude at which to interpolate the data. |
lat | The specific latitude at which to interpolate the data. |
method | Interpolation method: 1 for linear interpolation, otherwise nearest neighbor interpolation is used. |
var | Pointer to the variable where the interpolated value will be stored. |
sigma | Pointer to the variable where the standard deviation of the data points will be stored. |
array0
and array1
must be 2D arrays of size EX
by EY
. lons
must have at least nlon
elements and lats
must have at least nlat
elements.var
will contain the interpolated value. sigma
will contain the standard deviation of the data points used in the interpolation.lons
. locate_reg
, LIN
, and NN
for locating indices and performing interpolation.EX
and EY
are defined appropriately to match the dimensions of array0
and array1
.Definition at line 1738 of file mptrac.c.
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.
This function converts Julian seconds to calendar date and time components, including year, month, day, hour, minute, and second. It also calculates the fractional part of the seconds.
jsec | Julian seconds to convert. |
year | Pointer to store the year. |
mon | Pointer to store the month. |
day | Pointer to store the day. |
hour | Pointer to store the hour. |
min | Pointer to store the minute. |
sec | Pointer to store the second. |
remain | Pointer to store the fractional part of seconds. |
The function initializes a time structure t0
with a fixed starting date and time. It then converts the Julian seconds to a time_t type by adding the seconds to the epoch time. Next, it converts the time_t value to a UTC time structure t1
. Finally, it extracts the year, month, day, hour, minute, and second components from t1
and calculates the fractional part of seconds, which is stored in remain
.
Definition at line 1832 of file mptrac.c.
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.
This function calculates the kernel weight based on altitude and given kernel data. It takes arrays of altitudes (kz
) and corresponding weights (kw
), the number of data points (nk
), and the current altitude (p
) as input.
kz | Array of altitudes. |
kw | Array of corresponding weights. |
nk | Number of data points. |
p | Current altitude. |
If the number of data points is less than 2 (nk < 2
), the function returns a default weight of 1.0.
The function first computes the altitude z
based on the current altitude p
. Then it checks whether z
is outside the range of altitudes in the kernel data. If so, it returns the corresponding weight at the nearest altitude boundary. Otherwise, it interpolates linearly between the two closest altitudes in the kernel data to determine the weight at altitude z
.
Definition at line 1865 of file mptrac.c.
double lapse_rate | ( | const double | t, |
const double | h2o | ||
) |
Calculates the moist adiabatic lapse rate in Kelvin per kilometer.
This function calculates the moist adiabatic lapse rate in Kelvin per kilometer from the given temperature (t
) in Kelvin and water vapor volume mixing ratio (h2o
).
t | Temperature in Kelvin. |
h2o | Water vapor volume mixing ratio. |
The moist adiabatic lapse rate is calculated using the formula:
\[ \Gamma = \frac{{1000 \times g \times \left(a + L_v \times r \times T\right)}} {{C_{pd} \times a + L_v^2 \times r \times \epsilon}} \]
where:
The constants used in the calculation are defined externally:
Definition at line 1891 of file mptrac.c.
void level_definitions | ( | ctl_t * | ctl | ) |
Defines pressure levels for meteorological data.
This function defines pressure levels for meteorological data based on the given control structure (ctl
). Pressure levels are defined differently based on the value of press_level_def
in ctl
.
ctl | Control structure containing information about pressure level definitions. |
The function determines the number of pressure levels (met_np
) and the corresponding pressure values (met_p
) based on the value of press_level_def
in the control structure ctl
. It initializes the met_np
and met_p
fields accordingly.
press_level_def
are:press_level_def
will result in an error message.Definition at line 1909 of file mptrac.c.
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.
This function locates the index of the interval containing a given value in a sorted array. It uses a binary search algorithm to efficiently find the interval.
xx | Pointer to the sorted array. |
n | Size of the array. |
x | Value to be located. |
x
.The function assumes that the array xx
is sorted in ascending order. It returns the index of the interval where the value x
is located. If the value x
is outside the range of the array, the function returns the index of the closest interval.
Definition at line 2116 of file mptrac.c.
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.
This function performs a binary search to locate the interval in the array xx
such that xx[ig] <= x < xx[ig + 1]
. If the value x
lies within the interval specified by the initial guess index ig
, the function returns ig
. Otherwise, it searches the array to find the correct interval.
xx | Pointer to the array of floats representing the irregularly spaced intervals. The array must be of size n . |
n | The number of elements in the array xx . |
x | The value to locate within the intervals of the array xx . |
ig | The initial guess index. If the interval [xx[ig], xx[ig+1]) contains x , the function returns ig directly. |
i
such that xx[i] <= x < xx[i + 1]
. If x
is out of bounds, it returns the index of the closest interval.xx
contains at least two elements. xx
.xx
is not sorted in either increasing or decreasing order, or if it contains less than two elements.Definition at line 2146 of file mptrac.c.
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.
This function locates the index of the interval containing a given value in a regular grid. It calculates the index based on the spacing between grid points and the value to be located.
xx | Pointer to the array representing the regular grid. |
n | Size of the grid (number of grid points). |
x | Value to be located. |
x
.The function assumes that the array xx
represents a regular grid with equally spaced points. It calculates the index of the interval where the value x
is located based on the spacing between grid points. If the value x
is outside the range of the grid, the function returns the index of the closest interval.
Definition at line 2180 of file mptrac.c.
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.
This function locates the vertical indices corresponding to a given height in a 3D irregular grid. It calculates the indices based on the specified longitude and latitude indices of the grid.
profiles | 3D array representing the irregular grid. |
np | Size of the profile (number of data points). |
lon_ap_ind | Index of the longitude. |
lat_ap_ind | Index of the latitude. |
alt_ap | Height value. |
ind | Pointer to an array to store the resulting indices. |
The function calculates the indices corresponding to the specified height in the 3D irregular grid. It stores the resulting indices in the array pointed to by ind
. The indices are calculated based on the specified longitude and latitude indices of the grid.
Definition at line 2199 of file mptrac.c.
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.
This function advects particles in the atmosphere using meteorological data from two time steps, updating their positions and interpolating necessary data. It supports both pressure and zeta vertical coordinate systems.
ctl | Pointer to the control structure containing configuration flags. |
met0 | Pointer to the initial meteorological data structure. |
met1 | Pointer to the final meteorological data structure. |
atm | Pointer to the air parcel data structure. |
dt | Array of time step values for each particle. |
The function performs the following operations:
Definition at line 2219 of file mptrac.c.
Initializes the advection module by setting up pressure fields.
This function initializes the advection module, setting up the air parcel pressure to be consistent with the given zeta vertical coordinate. It utilizes meteorological data from two time steps and interpolates the pressure values accordingly.
ctl | Pointer to the control structure containing configuration flags. |
met0 | Pointer to the initial meteorological data structure. |
met1 | Pointer to the final meteorological data structure. |
atm | Pointer to the air parcel data structure. |
The function performs the following operations:
Definition at line 2377 of file mptrac.c.
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.
This function applies boundary conditions to particles based on specified criteria, including latitude, pressure, surface layer parameters, and climatological data. It loops over each particle and checks whether it satisfies the specified boundary conditions. If a particle satisfies the conditions, its properties such as mass, volume mixing ratio, and age of air are updated accordingly.
It checks for quantity flags to determine which properties need to be updated. If the latitude or pressure of a particle falls outside the specified ranges, it skips the particle. It also considers surface layer parameters such as surface pressure, height, zeta range, and planetary boundary layer. If a particle is within the specified surface layer boundaries, its properties are updated accordingly.
The function updates properties such as mass and volume mixing ratio if the corresponding flags are set. It retrieves volume mixing ratio values for various trace gases (e.g., CFC-10, CFC-11, N2O, SF6) from climatological time series data and updates the particle properties accordingly. Additionally, it updates the age of air for each particle based on the current simulation time.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climatological data structure containing time series data. |
met0 | Pointer to the meteorological data structure at the initial time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to the time step value. |
Definition at line 2403 of file mptrac.c.
Calculate grid data for chemistry modules.
This function initializes and updates chemical grid quantities based on atmospheric data and interpolation of meteorological variables.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climate data structure containing climatological data. |
met0 | Pointer to the first meteorological data structure. |
met1 | Pointer to the second meteorological data structure. |
atm | Pointer to the atmospheric data structure containing particle information. |
t | Time for which chemical grid is updated. |
Definition at line 2498 of file mptrac.c.
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.
This function initializes various chemical components of the atmosphere using meteorological data and climatological information. It interpolates and sets values for water vapor (H2O), ozone (O3), and several radical species such as OH, HO2, H2O2, and O1D for each air parcel.
ctl | Pointer to the control structure containing quantity flags. |
clim | Pointer to the climatology structure containing climatological data. |
met0 | Pointer to the initial meteorological data structure. |
met1 | Pointer to the final meteorological data structure. |
atm | Pointer to the air parcel data structure. |
The function uses OpenMP for parallel processing, iterating over each point in the atmosphere (atm->np) to initialize chemical species concentrations. It performs the following steps:
Definition at line 2646 of file mptrac.c.
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.
This function simulates convective processes for atmospheric particles based on convective available potential energy (CAPE) and convective inhibition (CIN). It loops over each particle and checks whether the CAPE exceeds a specified threshold. If CAPE is above the threshold and meets the conditions, it performs convective mixing to update the particle's pressure based on random numbers generated for each particle.
The function interpolates CAPE and CIN from meteorological data and checks whether the particle is above the cloud top level. If the conditions are met, it determines the pressure range for vertical mixing and calculates the density range based on temperature at different pressure levels. It then calculates the new density based on random numbers and updates the particle's pressure accordingly.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the meteorological data structure at the initial time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to the time step value. |
rs | Pointer to an array of random numbers generated for each particle. |
Definition at line 2687 of file mptrac.c.
Simulate exponential decay processes for atmospheric particles.
This function simulates decay processes for atmospheric particles based on their mass or volume mixing ratio. It loops over each particle and calculates the decay rate using weighting factors for tropospheric and stratospheric lifetimes. Exponential decay is then calculated, and the mass or volume mixing ratio of particles is updated accordingly. Loss rates can also be calculated and updated based on the decay process.
The function checks for quantity flags to ensure that mass or volume mixing ratio data is available. It then calculates the weighting factor based on the particle's location in the atmosphere and sets the lifetime accordingly. Exponential decay is calculated using the time step and the lifetime, and the particle's mass or volume mixing ratio is updated. Loss rates can also be updated based on the decay process.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climate data structure containing atmospheric data. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to the time step value. |
Definition at line 2759 of file mptrac.c.
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.
This function simulates mesoscale diffusion for atmospheric particles, including horizontal and vertical wind fluctuations. It calculates standard deviations of local wind data and temporal correlations for mesoscale fluctuations. Mesoscale wind fluctuations are then calculated based on the provided random numbers and turbulence parameters. The particle positions are updated accordingly.
The function loops over each particle and calculates indices for interpolation of wind data. It then computes standard deviations of local wind data and temporal correlations for mesoscale fluctuations. Based on the turbulence parameters and provided random numbers, it calculates horizontal and vertical mesoscale wind fluctuations. Finally, it updates the particle positions based on the calculated wind fluctuations.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the meteorological data structure at the current time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
cache | Pointer to the cache structure for temporary storage. |
dt | Pointer to the time step value. |
rs | Pointer to the array of random numbers. |
Definition at line 2799 of file mptrac.c.
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.
This function simulates turbulent diffusion for atmospheric particles, including horizontal and vertical diffusion. It calculates diffusivity based on the provided weighting factor and turbulence parameters. The diffusion coefficients are then used to calculate horizontal and vertical displacements of particles based on the provided random numbers and time step.
The function loops over each particle and calculates the weighting factor based on the atmospheric properties. It then computes diffusivity for horizontal and vertical diffusion. Based on the diffusivity values and provided random numbers, it calculates horizontal and vertical displacements of particles and updates their positions accordingly.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climatological data structure containing atmospheric properties. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to the time step value. |
rs | Pointer to the array of random numbers. |
Definition at line 2879 of file mptrac.c.
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.
This function simulates the dry deposition of atmospheric particles, including both particulate matter and gases. It calculates the sedimentation velocity for particles based on the atmospheric properties and applies it to determine the loss of mass or volume mixing ratio due to deposition. The function loops over each particle and calculates the loss of mass or volume mixing ratio based on the deposition velocity and time step.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the meteorological data structure at the current time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to the time step value. |
Definition at line 2920 of file mptrac.c.
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.
This function simulates chemical reactions involving hydrogen peroxide (H2O2) within cloud particles. It calculates the change in H2O2 concentration over time due to chemical reactions. The reaction rates are determined based on temperature and cloud properties such as liquid water content.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climatological data structure. |
met0 | Pointer to the first meteorological data structure. |
met1 | Pointer to the second meteorological data structure. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to an array containing the time step for each particle. |
Definition at line 2983 of file mptrac.c.
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.
This function initializes the isosurface module based on the atmospheric data provided. It calculates the necessary variables required for generating the isosurface, such as pressure, density, or potential temperature. Additionally, it can read balloon pressure data from a file if specified in the control structure. The initialized data is stored in the cache for later use.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the meteorological data structure at the current time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
cache | Pointer to the cache structure for storing initialized data. |
Definition at line 3063 of file mptrac.c.
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.
This function applies the isosurface module to adjust atmospheric properties based on the initialized data stored in the cache. It interpolates and restores atmospheric pressure, density, or potential temperature according to the specified isosurface mode in the control structure.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the meteorological data structure at the current time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
cache | Pointer to the cache structure containing initialized data. |
dt | Array of time step values for each particle. |
Definition at line 3127 of file mptrac.c.
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.
This function updates atmospheric properties based on meteorological data interpolated between two time steps. It calculates various atmospheric quantities such as pressure, temperature, wind speed, humidity, etc., and updates the corresponding fields in the atmospheric data structure.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climate data structure containing climatological data. |
met0 | Pointer to the meteorological data structure at the current time step. |
met1 | Pointer to the meteorological data structure at the next time step. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Array of time step values for each particle. |
Definition at line 3232 of file mptrac.c.
Update atmospheric properties through interparcel mixing.
This function updates atmospheric properties by performing interparcel mixing based on the given meteorological and climatological data. It calculates the indices of grid boxes and performs mixing for various quantities such as mass, volume mixing ratio, and other chemical species concentrations.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climate data structure containing climatological data. |
atm | Pointer to the atmospheric data structure containing particle information. |
t | Time at which mixing is performed. |
Definition at line 3332 of file mptrac.c.
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.
This function performs interparcel mixing for a specific quantity based on the given indices of grid boxes. It calculates the mean concentration within each grid box and adjusts the quantity for each particle accordingly.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climate data structure containing climatological data. |
atm | Pointer to the atmospheric data structure containing particle information. |
ixs | Pointer to the array of grid box indices along the longitude direction. |
iys | Pointer to the array of grid box indices along the latitude direction. |
izs | Pointer to the array of grid box indices along the vertical direction. |
qnt_idx | Index of the quantity for which mixing is performed. |
Definition at line 3422 of file mptrac.c.
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.
This function calculates the OH chemistry for each atmospheric particle based on the specified reaction mechanism and updates the particle quantities accordingly. The OH chemistry includes bimolecular and termolecular reactions, and the reaction rates are calculated based on the provided climatological data and atmospheric conditions. The function supports both mass and volume mixing ratio quantities for the particles.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climate data structure containing climatological data. |
met0 | Pointer to the first meteorological data structure. |
met1 | Pointer to the second meteorological data structure. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Array of time steps for each particle. |
Definition at line 3517 of file mptrac.c.
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.
This function updates the positions and pressure levels of atmospheric particles based on the meteorological data and the specified time step. It loops over each particle in the atmospheric data structure and performs the following operations:
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the first meteorological data structure. |
met1 | Pointer to the second meteorological data structure. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to an array containing the time step for each particle. |
Definition at line 3600 of file mptrac.c.
void module_rng_init | ( | const int | ntask | ) |
Initialize random number generators for parallel tasks.
This function initializes random number generators for parallel tasks using both GSL (GNU Scientific Library) and cuRAND (NVIDIA CUDA Random Number Generation Library) if available. It sets up GSL random number generators for each OpenMP thread and initializes them with unique seeds. For cuRAND, it creates a pseudo-random number generator and sets its seed. The initialization ensures that each task or thread has its own independent random number generator to prevent interference between parallel executions.
ntask | The number of tasks or parallel threads for which random number generators are initialized. |
Definition at line 3659 of file mptrac.c.
void module_rng | ( | const ctl_t * | ctl, |
double * | rs, | ||
const size_t | n, | ||
const int | method | ||
) |
Generate random numbers using various methods and distributions.
This function generates random numbers using different methods and distributions based on the specified method and random number generator type. It supports uniform and normal distributions and can utilize GSL, Squares (Widynski, 2022), or cuRAND random number generators.
ctl | Pointer to the control structure containing parameters and settings. |
rs | Pointer to the array where the generated random numbers will be stored. |
n | The number of random numbers to generate. |
method | The method for generating random numbers:
|
Definition at line 3690 of file mptrac.c.
Simulate sedimentation of particles in the atmosphere.
This function calculates the sedimentation velocity of particles based on atmospheric pressure, temperature, and particle properties such as radius and density. It then updates the pressure of each particle based on the sedimentation velocity and the specified time step.
ctl | Pointer to the control structure containing parameters and settings. |
met0 | Pointer to the meteorological data at the current time step. |
met1 | Pointer to the meteorological data at the next time step. |
atm | Pointer to the atmospheric data containing particle information. |
dt | Pointer to the array of time steps for each particle. |
sedi
function, which takes atmospheric pressure, temperature, particle radius, and particle density as inputs. DZ2DP
function.Definition at line 3794 of file mptrac.c.
Sort particles according to box index.
This function sorts particles within the atmosphere data structure based on their geographical coordinates (longitude and latitude) and pressure level. It allocates temporary arrays to store indices and auxiliary data for sorting, then performs the sorting operation. After sorting, it updates the order of particles in the atmosphere data structure.
ctl | Pointer to the control structure containing parameters and settings. |
met0 | Pointer to the meteorological data at the current time step. |
atm | Pointer to the atmospheric data containing particle information. |
locate_reg
and locate_irr
functions to determine the appropriate index for sorting particles based on their longitude, latitude, and pressure level. Definition at line 3823 of file mptrac.c.
void module_sort_help | ( | double * | a, |
const int * | p, | ||
const int | np | ||
) |
Reorder an array based on a given permutation.
This function reorders the elements of a given array based on a specified permutation array. It allocates temporary memory to store the reordered elements, performs the reordering operation, and then updates the original array with the reordered elements.
a | Pointer to the array to be reordered. |
p | Pointer to the permutation array defining the order of elements. |
np | The number of elements in the array. |
p
, which defines the new order of elements in the array a
.Definition at line 3883 of file mptrac.c.
Calculate time steps for air parcels based on specified conditions.
This function calculates the time steps for air parcels based on specified conditions, including the direction of simulation, start and stop times, and a given target time. It adjusts the time step for each air parcel accordingly and checks for horizontal boundary conditions of local meteorological data.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the initial meteorological data structure. |
atm | Pointer to the atmospheric data structure containing air parcel information. |
dt | Pointer to the array storing the calculated time steps for air parcels. |
t | The target time for which time steps are calculated. |
t
. Definition at line 3919 of file mptrac.c.
Initialize start time and time interval for time-stepping.
This function initializes the start time and time interval for time-stepping based on the direction of simulation and the provided atmospheric data. It sets the start time according to the minimum or maximum time in the atmospheric data, depending on the simulation direction. Additionally, it checks the time interval and adjusts the start time accordingly for rounding purposes.
ctl | Pointer to the control structure containing simulation parameters. |
atm | Pointer to the atmospheric data structure containing air parcel information. |
Definition at line 3956 of file mptrac.c.
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.
This function simulates chemical reactions involving atmospheric tracers, such as CFC-10, CFC-11, CFC-12, and N2O. It calculates the change in tracer concentrations over time based on reaction rates and environmental factors such as temperature, ozone concentration, solar zenith angle, and O(1D) volume mixing ratio.
ctl | Pointer to the control structure containing simulation parameters. |
clim | Pointer to the climatological data structure. |
met0 | Pointer to the first meteorological data structure. |
met1 | Pointer to the second meteorological data structure. |
atm | Pointer to the atmospheric data structure containing particle information. |
dt | Pointer to an array containing the time step for each particle. |
Definition at line 3987 of file mptrac.c.
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.
This function calculates the wet deposition process for each air parcel based on provided atmospheric and meteorological data. It estimates the precipitation rate and scavenging coefficients for particles and gases inside and below cloud layers. The scavenging coefficients are used to calculate the exponential decay of mass or volume mixing ratio over time due to wet deposition.
ctl | Pointer to the control structure containing simulation parameters. |
met0 | Pointer to the initial meteorological data structure. |
met1 | Pointer to the updated meteorological data structure. |
atm | Pointer to the atmospheric data structure containing air parcel information. |
dt | Array containing the time step for each air parcel. |
Definition at line 4056 of file mptrac.c.
double nat_temperature | ( | const double | p, |
const double | h2o, | ||
const double | hno3 | ||
) |
Calculates the nitric acid trihydrate (NAT) temperature.
This function computes the temperature at which nitric acid trihydrate (NAT) can form given the partial pressures of water vapor and nitric acid in the atmosphere.
p | The total atmospheric pressure (in hPa). |
h2o | The volume mixing ratio of water vapor (H2O). |
hno3 | The volume mixing ratio of nitric acid (HNO3). |
This function follows these steps:
The calculations are based on empirical relationships involving logarithms of the partial pressures of H2O and HNO3.
Definition at line 4191 of file mptrac.c.
Reads air parcel data from a specified file into the given atmospheric structure.
This function reads air parcel data from a file and populates the provided atm_t
structure based on the type of data specified in the ctl_t
control structure. It supports various data formats including ASCII, binary, netCDF, and CLaMS.
filename | The name of the file containing the atmospheric data. |
ctl | A pointer to the control structure (ctl_t ) that specifies the type of data. |
atm | A pointer to the atmospheric structure (atm_t ) that will be populated with the data. |
This function performs the following steps:
ctl->atm_type
):0
for ASCII data1
for binary data2
for netCDF data3
or 4
for CLaMS dataThe function utilizes several helper functions and macros:
SELECT_TIMER
for setting the timer.LOG
for logging information.ERRMSG
for handling error messages.gsl_stats_minmax
for calculating minimum and maximum values.Z
for converting altitude.Definition at line 4215 of file mptrac.c.
Reads air parcel data from an ASCII file and populates the given atmospheric structure.
This function reads air parcel data from an ASCII file and stores the data in the provided atm_t
structure. It reads each line of the file, extracts the necessary data fields, and converts the altitude to pressure.
filename | The name of the ASCII file containing the atmospheric data. |
ctl | A pointer to the control structure (ctl_t ) that specifies the number of quantities. |
atm | A pointer to the atmospheric structure (atm_t ) that will be populated with the data. |
This function performs the following steps:
NP
) and logs an error message if so.The function utilizes several macros and helper functions:
WARN
for logging warnings.ERRMSG
for handling error messages.TOK
for tokenizing and reading values from the line.P
for converting altitude to pressure.Definition at line 4286 of file mptrac.c.
Reads air parcel data from a binary file and populates the given atmospheric structure.
This function reads air parcel data from a binary file and stores the data in the provided atm_t
structure. It checks the version of the binary data, reads the data values, and verifies the integrity of the data read.
filename | The name of the binary file containing the atmospheric data. |
ctl | A pointer to the control structure (ctl_t ) that specifies the number of quantities. |
atm | A pointer to the atmospheric structure (atm_t ) that will be populated with the data. |
This function performs the following steps:
np
).The function utilizes several macros and helper functions:
ERRMSG
for handling error messages.FREAD
for reading data from the binary file.Definition at line 4328 of file mptrac.c.
Reads air parcel data from a CLaMS netCDF file and populates the given atmospheric structure.
This function reads air parcel data from a CLaMS (Chemical Lagrangian Model of the Stratosphere) netCDF file and stores the data in the provided atm_t
structure. It handles various coordinate systems and ensures the necessary data is correctly read and stored.
filename | The name of the netCDF file containing the atmospheric data. |
ctl | A pointer to the control structure (ctl_t ) that specifies the vertical coordinate system and quantities. |
atm | A pointer to the atmospheric structure (atm_t ) that will be populated with the data. |
This function performs the following steps:
np
) from the "NPARTS" dimension.TIME_INIT
) if available, otherwise uses the "time" variable.vert_coord_ap
):vert_coord_ap
is 1, reads "ZETA" and optionally "PRESS".The function utilizes several macros and helper functions:
NC_INQ_DIM
for inquiring about dimensions in the netCDF file.NC_GET_DOUBLE
for reading double values from the netCDF file.NC
for checking netCDF function return values.WARN
for logging warnings.Definition at line 4384 of file mptrac.c.
Reads air parcel data from a generic netCDF file and populates the given atmospheric structure.
This function reads air parcel data from a netCDF file and stores the data in the provided atm_t
structure. It retrieves the dimensions, geolocations (time, pressure, longitude, latitude), and specified variables from the file.
filename | The name of the netCDF file containing the atmospheric data. |
ctl | A pointer to the control structure (ctl_t ) that specifies the number of quantities and their names. |
atm | A pointer to the atmospheric structure (atm_t ) that will be populated with the data. |
This function performs the following steps:
np
) from the "obs" dimension.atm_t
structure.The function utilizes several macros and helper functions:
NC_INQ_DIM
for inquiring about dimensions in the netCDF file.NC_GET_DOUBLE
for reading double values from the netCDF file.NC
for checking netCDF function return values.Definition at line 4440 of file mptrac.c.
Reads various climatological data and populates the given climatology structure.
This function reads a range of climatological datasets based on the specified control settings and stores the data in the provided clim_t
structure. It handles initialization of tropopause climatology, photolysis rates, and multiple gas species' climatologies and time series.
ctl | A pointer to the control structure (ctl_t ) that specifies file names and parameters for climatology data. |
clim | A pointer to the climatology structure (clim_t ) that will be populated with the data. |
This function performs the following steps:
ctl
.ctl
.ctl
and applies a diurnal correction if specified.ctl
.ctl
.The function utilizes several helper functions:
clim_tropo_init
for initializing tropopause climatology.read_clim_photo
for reading photolysis rates.read_clim_zm
for reading zonal mean climatologies.clim_oh_diurnal_correction
for applying diurnal correction to OH climatology.read_clim_ts
for reading time series data.Definition at line 4473 of file mptrac.c.
void read_clim_photo | ( | const char * | filename, |
clim_photo_t * | photo | ||
) |
Reads photolysis rates from a NetCDF file and populates the given photolysis structure.
This function opens a NetCDF file specified by the filename, reads various dimensions and data related to photolysis rates, and stores this data in the provided clim_photo_t
structure. It includes checks for data consistency and logs detailed information about the loaded data.
filename | A string containing the path to the NetCDF file containing photolysis rate data. |
photo | A pointer to the photolysis structure (clim_photo_t ) that will be populated with the data. |
The function performs the following steps:
clim_photo_t
structure.Definition at line 4533 of file mptrac.c.
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.
This function reads a variable from a NetCDF file into a 3D array based on the dimensions provided by the clim_photo_t
structure.
[in] | ncid | NetCDF file ID. |
[in] | varname | Name of the variable to read from the NetCDF file. |
[in] | photo | Pointer to a structure defining the data dimensions (np, nsza, no3c). |
[out] | var | 3D array to store the read data, with dimensions [CP][CSZA][CO3]. |
Definition at line 4624 of file mptrac.c.
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.
This function reads time and volume mixing ratio (VMR) data from a specified file, processes the data, and stores it in the provided clim_ts_t
structure. It also includes checks for data consistency and logs detailed information about the loaded data.
filename | A string containing the path to the file containing the climatological time series data. |
ts | A pointer to the time series structure (clim_ts_t ) that will be populated with the data. |
The function performs the following steps:
Definition at line 4652 of file mptrac.c.
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.
This function reads data from a specified netCDF file, including pressure levels, latitudes, and volume mixing ratios (VMR) for a specified variable. It performs necessary checks and logs detailed information about the loaded data.
filename | A string containing the path to the netCDF file. |
varname | A string containing the name of the variable to be read from the netCDF file. |
zm | A pointer to the structure (clim_zm_t ) that will be populated with the data. |
The function performs the following steps:
Definition at line 4706 of file mptrac.c.
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.
This function reads control parameters from a specified configuration file and command line arguments, populating the provided ctl_t
structure with the parsed data. It handles a wide range of parameters, performing necessary checks and providing default values where applicable.
filename | A string containing the path to the configuration file. |
argc | An integer representing the number of command line arguments. |
argv | An array of strings containing the command line arguments. |
ctl | A pointer to the structure (ctl_t ) that will be populated with the control parameters. |
The function performs the following steps:
Definition at line 4805 of file mptrac.c.
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.
This function reads kernel function data from a specified file, populating the provided arrays kz
and kw
with the parsed data. It also updates the variable pointed to by nk
with the number of data points read. The function ensures that the height levels are in ascending order and performs checks for the number of height levels read.
filename | A string containing the path to the file containing kernel function data. |
kz | A double array to store the height levels of the kernel function. |
kw | A double array to store the weights corresponding to the height levels. |
nk | A pointer to an integer variable representing the number of data points read. |
The function performs the following steps:
nk
with the number of data points read.Definition at line 5614 of file mptrac.c.
Reads meteorological data from a file, supporting multiple formats and MPI broadcasting.
This function reads meteorological data from a file specified by the filename
parameter. It supports both NetCDF and binary formats based on the met_type
field in the ctl_t
structure. The function can also handle parallel processing with MPI, broadcasting the data across ranks if required by the configuration.
filename | A constant character pointer representing the name of the file to read the meteorological data from. |
ctl | A pointer to a ctl_t structure, which holds control parameters including the type of meteorological data, MPI sharing flags, and configuration details. |
clim | A pointer to a clim_t structure, which contains climatological data to be used in the process, if applicable. |
met | A pointer to a met_t structure that will store the meteorological data read from the file. |
met_mpi_share
flag is set in the control structure.ctl->met_type
is 0, the data is read from a NetCDF file using the read_met_nc
function.ctl->met_type
is between 1 and 5, the data is read from a binary file using the read_met_bin
function.met_type
is not recognized, an error message is generated.Definition at line 5655 of file mptrac.c.
Reads meteorological data from a binary file.
This function reads meteorological data from a binary file and populates the provided met_t
structure with the data. It checks the binary file's format version and met_type
, ensuring compatibility with the control structure (ctl_t
). The function reads time, grid, surface data, and multi-level data, and supports different binary file versions.
filename | A constant character pointer representing the name of the binary file to read the meteorological data from. |
ctl | A pointer to a ctl_t structure that holds control parameters such as the expected met_type and other configuration options. |
met | A pointer to a met_t structure that will store the meteorological data read from the binary file. |
FREAD
macro for safe binary reading operations, which checks the integrity of the read operation.met_type
and binary file version to ensure compatibility.LSM
, SST
, RWC
, SWC
, and CC
).met_type
in the file does not match the ctl->met_type
.Definition at line 5710 of file mptrac.c.
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.
This function reads a 2-dimensional meteorological variable from a binary file, which is assumed to be uncompressed, and stores it in the provided 2-dimensional array var
. The variable name is used for logging purposes to identify the data being read.
in | A pointer to the FILE structure representing the binary file to read from. |
met | A pointer to a structure containing meteorological data. |
var | A 2-dimensional array to store the read variable. |
varname | A string containing the name of the variable being read. |
The function performs the following steps:
Definition at line 5859 of file mptrac.c.
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.
This function reads 3-dimensional meteorological data from a binary file into a specified variable array. The data can be read in uncompressed form or using one of several supported compression methods. The data is then clamped to specified minimum and maximum bounds.
[in] | in | Pointer to the input file from which to read the data. |
[in] | ctl | Pointer to the control structure that contains metadata about the type of data and how it is stored. |
[in] | met | Pointer to the meteorological structure that contains the dimensions of the data. |
[out] | var | 3D array to store the read data, with dimensions [EX][EY][EP]. |
[in] | varname | Name of the variable being read, used for logging and debugging. |
[in] | bound_min | Minimum bound to which data values should be clamped. |
[in] | bound_max | Maximum bound to which data values should be clamped. |
The function supports the following types of data:
Depending on the compression type specified in the control structure, the appropriate reading and decompression function is used. The data is read into a temporary buffer, then copied into the output array, applying the specified bounds to each value.
met
structure. Definition at line 5888 of file mptrac.c.
Calculates Convective Available Potential Energy (CAPE) for each grid point.
This function calculates the Convective Available Potential Energy (CAPE) at each grid point based on the provided meteorological data. CAPE is a measure of the energy available for deep convection, which is essential for severe weather development.
clim | A pointer to a structure containing climatological data. |
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 5974 of file mptrac.c.
void read_met_cloud | ( | met_t * | met | ) |
Calculates cloud-related variables for each grid point.
This function calculates cloud-related variables, such as cloud cover, cloud top pressure, cloud bottom pressure, and total cloud water content, based on the provided meteorological data.
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 6089 of file mptrac.c.
Detrends meteorological data.
This function detrends meteorological data by removing spatially varying backgrounds from each grid point. Detrending helps in removing systematic biases and trends from the data, enabling better analysis and modeling.
ctl | A pointer to a structure containing control parameters. |
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 6146 of file mptrac.c.
void read_met_extrapolate | ( | met_t * | met | ) |
Extrapolates meteorological data.
This function extrapolates meteorological data by filling missing or invalid data points with values from the nearest valid point above. Extrapolation is performed column-wise, ensuring that missing data points are replaced with valid values.
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 6250 of file mptrac.c.
Calculates geopotential heights from meteorological data.
This function calculates geopotential heights from provided meteorological data using the hydrostatic equation. Geopotential heights are computed column-wise for each grid point based on the temperature, pressure, and surface height information. Optionally, the calculated geopotential heights can be smoothed horizontally using a weighted averaging scheme.
ctl | A pointer to a structure containing control parameters. |
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 6290 of file mptrac.c.
Reads meteorological grid information from a NetCDF file.
This function reads meteorological grid information from a NetCDF file, including time, spatial dimensions, and pressure levels. It also extracts longitudes, latitudes, and pressure levels from the NetCDF file based on the specified control parameters. The function determines the time information either from the filename or from the data file, depending on the file type.
filename | The filename of the NetCDF file. |
ncid | The NetCDF file identifier. |
ctl | A pointer to a structure containing control parameters. |
met | A pointer to a structure to store meteorological data. |
The function performs the following steps:
Definition at line 6418 of file mptrac.c.
Reads meteorological variables at different vertical levels from a NetCDF file.
This function reads meteorological variables such as temperature, wind components, specific humidity, ozone data, cloud parameters, and cloud cover at various vertical levels from a NetCDF file. The function supports reading meteorological data from both MPTRAC and CLaMS formats. Depending on the file format, it reads specific variables and performs necessary conversions or interpolations.
ncid | The NetCDF file identifier. |
ctl | A pointer to a structure containing control parameters. |
met | A pointer to a structure to store meteorological data. |
The function performs the following steps:
Definition at line 6536 of file mptrac.c.
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.
This function interpolates meteorological data from model levels to pressure levels. The interpolation is performed in parallel over the spatial grid defined in the meteorological data structure.
[in] | ctl | A pointer to a control structure containing the number of pressure levels (met_np ) and the pressure levels themselves (met_p ). |
[in] | met | A pointer to a meteorological data structure containing the grid dimensions (nx , ny ) and the pressure profile (pl ). |
[in,out] | var | A 3D array containing the meteorological variable to be interpolated. On output, this array will contain the interpolated values at the specified pressure levels. |
[in] | varname | A string representing the name of the meteorological variable being interpolated. |
This function performs the following steps:
var
array.Definition at line 6672 of file mptrac.c.
void read_met_monotonize | ( | met_t * | met | ) |
Makes zeta and pressure profiles monotone.
This function ensures that zeta and pressure profiles are monotone increasing and decreasing with altitude. It iterates over each grid point and each level to identify inversions and linearly interpolate between them to maintain monotonicity. The interpolation is performed for both zeta and pressure profiles.
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 6714 of file mptrac.c.
Reads meteorological data from a NetCDF file and processes it.
This function reads meteorological data from a NetCDF file specified by the filename
parameter, using the NetCDF library. It reads grid, surface, and vertical level data, processes the data (including extrapolation, boundary conditions, and downsampling), and calculates various derived meteorological fields such as geopotential heights, potential vorticity, cloud properties, and convective available potential energy (CAPE).
filename | A constant character pointer representing the name of the NetCDF file to read the meteorological data from. |
ctl | A pointer to a ctl_t structure, which contains control parameters for reading and processing the meteorological data. |
clim | A pointer to a clim_t structure that holds climatological data, used in the calculation of derived properties such as CAPE and tropopause data. |
met | A pointer to a met_t structure that will store the meteorological data read and processed from the NetCDF file. |
nc_open
and handles any errors during the file opening process.Definition at line 6794 of file mptrac.c.
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.
This function reads a 2-dimensional meteorological variable from a NetCDF file and stores it in a specified destination array. It supports both packed and unpacked data formats and handles missing values and scaling factors accordingly. The function also checks the meteorological data layout to ensure correct data copying.
ncid | The NetCDF file ID. |
varname | The name of the variable to read. |
varname2 | An alternative name of the variable to read (in case varname is not found). |
varname3 | An alternative name of the variable to read (in case varname2 is not found). |
varname4 | An alternative name of the variable to read (in case varname3 is not found). |
ctl | A pointer to a structure containing control parameters. |
met | A pointer to a structure containing meteorological data. |
dest | The destination array to store the read data. |
scl | A scaling factor to apply to the read data. |
init | Flag indicating whether to initialize the destination array before reading. |
The function performs the following steps:
Definition at line 6866 of file mptrac.c.
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.
This function reads a 3-dimensional meteorological variable from a NetCDF file and stores it in a specified destination array. It supports both packed and unpacked data formats and handles missing values and scaling factors accordingly. The function also checks the meteorological data layout to ensure correct data copying.
ncid | The NetCDF file ID. |
varname | The name of the variable to read. |
varname2 | An alternative name of the variable to read (in case varname is not found). |
varname3 | An alternative name of the variable to read (in case varname2 is not found). |
varname4 | An alternative name of the variable to read (in case varname3 is not found). |
varname5 | An alternative name of the variable to read (in case varname4 is not found). |
varname6 | An alternative name of the variable to read (in case varname5 is not found). |
ctl | A pointer to a structure containing control parameters. |
met | A pointer to a structure containing meteorological data. |
dest | The destination array to store the read data. |
scl | A scaling factor to apply to the read data. |
The function performs the following steps:
Definition at line 7024 of file mptrac.c.
Computes the planetary boundary layer (PBL) height based on meteorological data.
This function calculates the PBL height for each grid point using one of three methods:
[in] | ctl | Pointer to the control structure (ctl_t ), which contains parameters controlling the PBL calculation. |
[in,out] | met | Pointer to the meteorological data structure (met_t ), which contains grid and atmospheric data. The met->pbl array is updated with the calculated PBL heights. |
Method 0 (Precomputed PBL height from file):
Method 1 (Richardson number criterion):
Method 2 (Potential temperature difference):
Final Adjustments:
Definition at line 7170 of file mptrac.c.
void read_met_periodic | ( | met_t * | met | ) |
Applies periodic boundary conditions to meteorological data along longitudinal axis.
This function applies periodic boundary conditions to meteorological data along the longitudinal axis. It checks if the difference between the last and first longitudes and the difference between the second and first longitudes are approximately equal to 360 degrees, indicating periodicity. If the condition is met, the function increases the longitude counter, sets the longitude value for the new grid point, and copies meteorological data from the first grid point to the last grid point to ensure periodicity.
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 7316 of file mptrac.c.
void read_met_polar_winds | ( | met_t * | met | ) |
Applies a fix for polar winds in meteorological data.
This function applies a fix for polar winds in meteorological data, particularly focusing on the u and v wind components. It checks if the latitudes at the top and bottom of the grid are close to the poles. If so, it transforms the winds at 89-degree latitude into Cartesian coordinates, takes their mean, and replaces the winds at 90-degree latitude with this mean, effectively fixing the unrealistic behavior of winds at the poles.
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 7371 of file mptrac.c.
void read_met_pv | ( | met_t * | met | ) |
Calculates potential vorticity (PV) from meteorological data.
This function calculates the potential vorticity (PV) from the provided meteorological data. It employs finite difference methods to estimate gradients of temperature, wind components, and pressure in longitude, latitude, and pressure dimensions. These gradients are then used to compute PV at each grid point. Additionally, a fix for polar regions is applied to ensure smoothness of PV values in these regions.
met | A pointer to a structure containing meteorological data. |
The function performs the following steps:
Definition at line 7430 of file mptrac.c.
void read_met_ozone | ( | met_t * | met | ) |
Calculates the total column ozone from meteorological ozone data.
This function calculates the total column ozone from the provided meteorological ozone data. It integrates ozone concentrations over altitude to obtain the column ozone density. The result is then converted to Dobson units, which represent the thickness of the ozone layer if compressed into one layer at standard temperature and pressure.
met | A pointer to a structure containing meteorological ozone data. |
The function performs the following steps:
Definition at line 7536 of file mptrac.c.
Downsamples meteorological data based on specified parameters.
This function downsamples meteorological data based on the provided control parameters. It reduces the resolution of meteorological data by averaging over specified intervals in longitude, latitude, and altitude.
ctl | A pointer to a structure containing control parameters for downsampling. |
met | A pointer to a structure containing meteorological data to be downsampled. |
The function performs the following steps:
Definition at line 7565 of file mptrac.c.
Reads surface meteorological data from a netCDF file and stores it in the meteorological data structure.
This function reads various surface meteorological variables from a netCDF file and stores them in the provided meteorological data structure. Depending on the configuration, it may read data for surface pressure, geopotential height, temperature, zonal and meridional wind components, land-sea mask, and sea surface temperature.
ncid | NetCDF file identifier. |
met | A pointer to the meteorological data structure to store the read data. |
ctl | A pointer to a structure containing control parameters. |
The function performs the following steps:
Definition at line 7713 of file mptrac.c.
Calculates the tropopause and related meteorological variables based on various methods and stores the results in the meteorological data structure.
This function calculates the tropopause and related meteorological variables using different methods specified by the control parameters. The calculated tropopause pressure is stored in the provided meteorological data structure.
ctl | A pointer to a structure containing control parameters. |
clim | A pointer to the climatological data structure. |
met | A pointer to the meteorological data structure to store the calculated tropopause pressure and related variables. |
The function performs the following steps:
Definition at line 7825 of file mptrac.c.
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.
This function reads observation data from a specified file in either ASCII or NetCDF format, depending on the value of the OBS_TYPE control parameter. It stores the time, altitude, longitude, latitude, and observation values in the provided arrays.
filename | The path to the observation data file. |
ctl | A pointer to a structure containing control parameters. |
rt | An array to store the time values of the observations. |
rz | An array to store the altitude values of the observations. |
rlon | An array to store the longitude values of the observations. |
rlat | An array to store the latitude values of the observations. |
robs | An array to store the observation values. |
nobs | A pointer to an integer variable to store the number of observations read. |
The function performs the following steps:
Definition at line 7997 of file mptrac.c.
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.
This function reads observation data from a specified ASCII file. It extracts time, altitude, longitude, latitude, and observation values from each line of the file and stores them in the provided arrays.
filename | The path to the ASCII file containing the observation data. |
rt | An array to store the time values of the observations. |
rz | An array to store the altitude values of the observations. |
rlon | An array to store the longitude values of the observations. |
rlat | An array to store the latitude values of the observations. |
robs | An array to store the observation values. |
nobs | A pointer to an integer variable to store the number of observations read. |
The function performs the following steps:
Definition at line 8041 of file mptrac.c.
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.
This function reads observation data from a specified NetCDF file. It extracts time, altitude, longitude, latitude, and observation values from the variables in the NetCDF file and stores them in the provided arrays.
filename | The path to the NetCDF file containing the observation data. |
rt | An array to store the time values of the observations. |
rz | An array to store the altitude values of the observations. |
rlon | An array to store the longitude values of the observations. |
rlat | An array to store the latitude values of the observations. |
robs | An array to store the observation values. |
nobs | A pointer to an integer variable to store the number of observations read. |
The function performs the following steps:
Definition at line 8069 of file mptrac.c.
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.
This function scans either a control file or command-line arguments for a specified variable name and retrieves its value. It searches for the variable name in the control file or command-line arguments and returns its corresponding value. If the variable is not found, it returns a default value specified by the user.
filename | The name of the control file to be scanned. If NULL, only command-line arguments will be scanned. |
argc | The number of command-line arguments. |
argv | An array of command-line arguments. |
varname | The name of the variable to be searched. |
arridx | The index of the variable array, if applicable. Set to -1 if not an array. |
defvalue | The default value to be returned if the variable is not found. |
value | A pointer to a character array to store the retrieved value. |
The function performs the following steps:
Definition at line 8098 of file mptrac.c.
double sedi | ( | const double | p, |
const double | T, | ||
const double | rp, | ||
const double | rhop | ||
) |
Calculates the sedimentation velocity of a particle in air.
This function calculates the sedimentation velocity of a particle in air using the given parameters.
p | The atmospheric pressure [hPa]. |
T | The temperature [K]. |
rp | The radius of the particle [microns]. |
rhop | The density of the particle [kg/m^3]. |
The function performs the following steps:
Definition at line 8170 of file mptrac.c.
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.
This function interpolates a set of data points using either cubic spline interpolation or linear interpolation, depending on the specified method.
x | The array of x-coordinates of the data points. |
y | The array of y-coordinates of the data points. |
n | The number of data points. |
x2 | The array of x-coordinates where interpolation is required. |
y2 | The array to store the interpolated y-values. |
n2 | The number of points to interpolate. |
method | The interpolation method: 1 for cubic spline, 0 for linear interpolation. |
If the method is set to 1 (cubic spline interpolation):
If the method is set to 0 (linear interpolation):
Definition at line 8203 of file mptrac.c.
float stddev | ( | const float * | data, |
const int | n | ||
) |
Calculates the standard deviation of a set of data.
This function calculates the standard deviation of a set of floating-point data values.
data | Pointer to the array of data values. |
n | Number of data values in the array. |
The standard deviation is calculated using the formula:
\[ \sigma = \sqrt{\frac{\sum_{i=1}^{n} (x_i - \bar{x})^2}{n}} \]
where:
double sza_calc | ( | const double | sec, |
const double | lon, | ||
const double | lat | ||
) |
Calculates the solar zenith angle.
This function calculates the solar zenith angle, which is the angle between the zenith (straight up) and the line connecting the observer to the center of the sun.
sec | Seconds elapsed since 2000-01-01T12:00Z. |
lon | Observer's longitude in degrees. |
lat | Observer's latitude in degrees. |
The solar zenith angle is calculated based on the observer's position (longitude and latitude) and the time specified in seconds elapsed since 2000-01-01T12:00Z.
Definition at line 8273 of file mptrac.c.
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.
This function calculates the number of seconds elapsed since January 1, 2000, 12:00:00 UTC, based on the provided year, month, day, hour, minute, and second. It also includes a fractional part to represent the remaining seconds.
year | The year. |
mon | The month (1-12). |
day | The day of the month (1-31). |
hour | The hour of the day (0-23). |
min | The minute (0-59). |
sec | The second (0-59). |
remain | The fractional part of seconds. |
jsec | Pointer to store the calculated number of seconds since January 1, 2000, 12:00:00 UTC. |
The function calculates the time elapsed since January 1, 2000, 12:00:00 UTC, up to the specified time and includes any fractional seconds indicated by the "remain" parameter.
Definition at line 8314 of file mptrac.c.
void timer | ( | const char * | name, |
const char * | group, | ||
const int | output | ||
) |
Measures and reports elapsed time for named and grouped timers.
The timer
function measures elapsed time for a specified named timer and an optional group of timers, accumulating time statistics such as minimum, maximum, and mean elapsed times. It also provides an option to log the timing statistics to an output.
name | A string representing the name of the timer. |
group | A string representing the group to which the timer belongs. |
output | An integer flag indicating whether to report the timing statistics (non-zero to report). |
The function keeps track of multiple timers and groups. When called, it:
output
parameter is non-zero.name
and group
.name
and group
are new, and if so, initializes them.omp_get_wtime()
to get the current wall time. NTIMER
macro.NTIMER
, the function will trigger an error message.Definition at line 8345 of file mptrac.c.
double time_from_filename | ( | const char * | filename, |
const int | offset | ||
) |
Extracts and converts a timestamp from a filename to Julian seconds.
The time_from_filename
function parses a given filename to extract a timestamp and converts it to Julian seconds. The timestamp is expected to follow a specific format and position within the filename, defined by the offset
parameter.
filename | A string representing the filename containing the timestamp. |
offset | An integer indicating the position from the end of the filename where the timestamp starts. |
The function performs the following steps:
time2jsec
function.YYYY-MM-DD_HH-MM
(e.g., "2023-05-27_14-45").Definition at line 8413 of file mptrac.c.
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.
The tropo_weight
function calculates a weighting factor that indicates how much a given pressure p
is influenced by the tropopause based on climatological data.
clim | A pointer to a clim_t structure containing climatological tropopause data. |
t | The time parameter, typically representing the time of year or specific temporal context. |
lat | The latitude for which the weighting factor is being calculated. |
p | The pressure for which the weighting factor is to be computed. |
The function performs the following steps:
pt
using the clim_tropo
function.p1
(lower bound) and p0
(upper bound).p
:1
if p
is greater than p0
(troposphere).0
if p
is less than p1
(stratosphere).1
and 0
for pressures between p0
and p1
.clim_tropo
function is assumed to provide the tropopause pressure based on climatological data. 0.866877899
and its reciprocal) are specific to the function's logic.Definition at line 8448 of file mptrac.c.
Writes air parcel data to a file in various formats.
The write_atm
function writes the air parcel data stored in the atm
structure to a file specified by filename
. The format of the output file is determined by the atm_type_out
field in the ctl
control structure.
filename | A string representing the name of the file to write the data to. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
t | The current time, used for certain output formats. |
The function performs the following steps:
SELECT_TIMER
macro.atm_type_out
value in the ctl
structure, writes the data in one of the following formats:atm_type_out == 0
): Calls write_atm_asc
.atm_type_out == 1
): Calls write_atm_bin
.atm_type_out == 2
): Calls write_atm_nc
.atm_type_out == 3
): Calls write_atm_clams_traj
.atm_type_out == 4
): Calls write_atm_clams
.atm_type_out
value is not supported, triggers an error message.ctl
structure.Definition at line 8472 of file mptrac.c.
Writes air parcel data to an ASCII file or gnuplot.
The write_atm_asc
function writes the atmospheric data stored in the atm
structure to an ASCII file specified by filename
or to pipe to gnuplot if requested.
filename | A string representing the name of the file to write the data to. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
t | The current time used for filtering and timestamping. |
The function performs the following steps:
atm
structure, filtering by time if specified, and writes the data to the output file.Definition at line 8532 of file mptrac.c.
Writes air parcel data to a binary file.
The write_atm_bin
function writes the air parcel data stored in the atm
structure to a binary file specified by filename
. The function includes versioning information and ensures that all relevant data arrays are written in a consistent binary format.
filename | A string representing the name of the file to write the data to. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
The function performs the following steps:
ctl
structure and writes each quantity array to the file.Definition at line 8614 of file mptrac.c.
Writes air parcel data to a NetCDF file in the CLaMS format.
The write_atm_clams
function creates a NetCDF file and writes air parcel data into it. The data includes time, latitude, longitude, pressure, and other specified quantities. The function defines the dimensions and variables, sets global attributes, and writes the data to the file.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
The function performs the following steps:
Definition at line 8664 of file mptrac.c.
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.
The write_atm_clams_traj
function writes trajectory data for the CLaMS model to a NetCDF file. The file is created and populated with data including time, latitude, longitude, pressure, and other quantities. The function also handles the creation of a final initialization file at the last time step.
dirname | A string representing the directory name where the file will be created. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
t | The current time in seconds since a reference epoch. |
The function performs the following steps:
Definition at line 8717 of file mptrac.c.
Writes air parcel data to a NetCDF file.
The write_atm_nc
function creates a NetCDF file and writes air parcel data into it. The data includes time, pressure, longitude, latitude, and other specified quantities. The function defines the dimensions and variables, sets global attributes, and writes the data to the file.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
The function performs the following steps:
Definition at line 8875 of file mptrac.c.
Writes Critical Success Index (CSI) data to a file.
The write_csi
function processes air parcel and observation data to calculate and write various verification statistics, including the Critical Success Index (CSI), to a specified output file at regular intervals. The statistics include measures such as the number of hits, misses, and false alarms, bias, probability of detection, false alarm rate, equitable threat score, and correlation coefficients.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
t | A double representing the current time. |
The function performs the following steps:
Definition at line 8924 of file mptrac.c.
Writes ensemble data to a file.
The write_ens
function processes air parcel data to calculate ensemble means and standard deviations for various quantities and writes them to a specified output file. It handles ensemble members and calculates statistics such as means and standard deviations for each ensemble, along with latitude, longitude, altitude, and time information.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure containing atmospheric data. |
t | A double representing the current time. |
The function performs the following steps:
Definition at line 9186 of file mptrac.c.
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.
The write_grid
function processes air parcel data to calculate various grid-based statistics such as column density, mean, and standard deviation for specified quantities. It then writes this data to a specified output file either in ASCII or netCDF format based on the configuration parameters provided in the ctl
structure.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
met0 | A pointer to a met_t structure containing meteorological data for the initial time step. |
met1 | A pointer to a met_t structure containing meteorological data for the final time step. |
atm | A pointer to an atm_t structure containing atmospheric data. |
t | A double representing the current time. |
The function performs the following steps:
grid_type
in the control parameters.Definition at line 9283 of file mptrac.c.
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.
The write_grid_asc
function writes gridded air parcel data, including column density, mean and standard deviation for specified quantities, and volume mixing ratio (if available), to an ASCII file. The function also supports writing gnuplot commands to generate plots if requested in the control parameters.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
cd | An array of doubles representing column density values. |
mean | An array of arrays of doubles representing the mean values for specified quantities. |
sigma | An array of arrays of doubles representing the standard deviation values for specified quantities. |
vmr_impl | An array of doubles representing the volume mixing ratio (implicit) values. |
t | A double representing the current time. |
z | An array of doubles representing vertical coordinates (altitude). |
lon | An array of doubles representing longitudinal coordinates. |
lat | An array of doubles representing latitudinal coordinates. |
area | An array of doubles representing surface area values. |
dz | A double representing the layer depth. |
np | An array of integers representing the number of particles. |
The function performs the following steps:
Definition at line 9474 of file mptrac.c.
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.
The write_grid_nc
function writes gridded air parcel data, including column density, mean and standard deviation for specified quantities, and volume mixing ratio (if available), to a NetCDF file. NetCDF is a self-describing, machine-independent data format for storing scientific data.
filename | A string representing the name of the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
cd | An array of doubles representing column density values. |
mean | An array of arrays of doubles representing the mean values for specified quantities. |
sigma | An array of arrays of doubles representing the standard deviation values for specified quantities. |
vmr_impl | An array of doubles representing the volume mixing ratio (implicit) values. |
t | A double representing the current time. |
z | An array of doubles representing vertical coordinates (altitude). |
lon | An array of doubles representing longitudinal coordinates. |
lat | An array of doubles representing latitudinal coordinates. |
area | An array of doubles representing surface area values. |
dz | A double representing the layer depth. |
np | An array of integers representing the number of particles. |
The function performs the following steps:
Definition at line 9578 of file mptrac.c.
Writes meteorological data to a file, supporting multiple formats and compression options.
This function handles writing meteorological data based on the specified control (ctl_t
) and meteorological data (met_t
) structures. The file format and compression type are determined by the met_type
in the control structure. The function supports netCDF, binary output, and various compression methods (ZFP, ZSTD, CMS), while providing error handling for unsupported configurations.
filename | A constant character pointer representing the name of the file to write the meteorological data to. |
ctl | A pointer to a ctl_t structure, which holds the configuration and control parameters for the output, including the type of meteorological data and compression method. |
met | A pointer to a met_t structure that holds the meteorological data to be written to the file. |
ctl->met_type
is 3, ZFP compression is required, and the function will generate an error if compiled without ZFP support.ctl->met_type
is 4, ZSTD compression is required, and the function will generate an error if compiled without ZSTD support.ctl->met_type
is 5, CMS compression is required, and the function will generate an error if compiled without CMS support.ctl->met_type
is 0, the function writes data in netCDF format via write_met_nc
.ctl->met_type
is between 1 and 5, the function writes data in binary format via write_met_bin
.ctl->met_type
is not recognized, an error message is generated.Definition at line 9708 of file mptrac.c.
Writes meteorological data in binary format to a specified file.
This function writes meteorological data from the met_t
structure to a binary file. The data includes grid and surface data, as well as multi-level data such as temperature, velocity components, and atmospheric properties. The compression options for multi-level data (ZFP) are controlled via the ctl_t
structure. The function supports multiple variables, such as surface pressure, temperature, wind components, and cloud properties.
filename | A constant character pointer representing the name of the file to write the binary data to. |
ctl | A pointer to a ctl_t structure, which holds control parameters including the type of meteorological data, compression settings, and grid dimensions. |
met | A pointer to a met_t structure that contains the meteorological data to be written to the binary file. |
ctl->met_type
) and the version of the binary format are written at the beginning of the file.write_met_bin_2d
helper function.write_met_bin_3d
function with optional ZFP compression settings.Definition at line 9748 of file mptrac.c.
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.
The write_met_bin_2d
function writes a 2-dimensional meteorological variable to a binary file specified by the out
parameter. The variable data is provided in a 2-dimensional array var
with maximum dimensions EX
by EY
. The variable name is provided as a string in the varname
parameter.
out | A pointer to a FILE structure representing the output file. |
met | A pointer to a met_t structure containing meteorological data. |
var | An array of floats representing the 2-dimensional variable data. |
varname | A string containing the name of the variable being written. |
The function performs the following steps:
var
to the temporary buffer help
.out
.Definition at line 9845 of file mptrac.c.
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.
The write_met_bin_3d
function writes a 3-dimensional meteorological variable to a binary file specified by the out
parameter. The variable data is provided in a 3-dimensional array var
with maximum dimensions EX
by EY
by EP
. The variable name is provided as a string in the varname
parameter. Additionally, the function takes parameters for specifying the compression precision and tolerance.
out | A pointer to a FILE structure representing the output file. |
ctl | A pointer to a ctl_t structure containing control parameters. |
met | A pointer to a met_t structure containing meteorological data. |
var | An array of floats representing the 3-dimensional variable data. |
varname | A string containing the name of the variable being written. |
precision | An integer specifying the precision of compression (for certain compression methods). |
tolerance | A double specifying the tolerance for compression (for certain compression methods). |
The function performs the following steps:
var
to the temporary buffer help
.out
using the specified compression method (uncompressed, packed, zfp, zstd, cmultiscale).ctl->met_type
, the function writes the variable data using different compression methods. If ctl->met_type
is not supported, an error message is logged.Definition at line 9874 of file mptrac.c.
Writes meteorological data to a NetCDF file.
This function creates and writes meteorological data to a NetCDF file in the NetCDF-4 format. It defines the required dimensions, grid, surface variables, and level data within the NetCDF structure and writes the corresponding values from the met_t
structure. The function uses helper functions to write 2D surface and 3D level data.
filename | A constant character pointer representing the name of the NetCDF file to create and write the data to. |
ctl | A pointer to a ctl_t structure that contains control parameters, such as the NetCDF level and quantization settings. |
met | A pointer to a met_t structure that contains the meteorological data to be written to the NetCDF file. |
Definition at line 9950 of file mptrac.c.
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.
This function writes a 2D meteorological variable, stored in the array var
, to a NetCDF file with the specified variable name. The data is scaled by a factor scl
before being written. The function handles memory allocation for the data copy, scaling, and freeing the allocated memory after writing the data to the NetCDF file.
ncid | The NetCDF file ID. This is an integer that identifies the NetCDF file where the data will be written. It is assumed that this file has already been opened for writing. |
varname | A pointer to a string containing the name of the variable in the NetCDF file where the data will be stored. |
met | A pointer to a structure of type met_t that contains metadata about the meteorological field, including the dimensions nx (number of points in x-direction) and ny (number of points in y-direction). |
var | A 2D array of dimensions EX x EY containing the meteorological data to be written. The data is provided in the format var[ix][iy] , where ix is the index in the x-direction and iy is the index in the y-direction. |
scl | A scaling factor applied to each element in the var array before writing to the NetCDF file. |
Definition at line 10056 of file mptrac.c.
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.
This function writes a 3D meteorological variable, stored in the array var
, to a NetCDF file with the specified variable name. The data is scaled by a factor scl
before being written. The function handles memory allocation for the data copy, scaling, and freeing the allocated memory after writing the data to the NetCDF file.
ncid | The NetCDF file ID. This is an integer that identifies the NetCDF file where the data will be written. It is assumed that this file has already been opened for writing. |
varname | A pointer to a string containing the name of the variable in the NetCDF file where the data will be stored. |
met | A pointer to a structure of type met_t that contains metadata about the meteorological field, including the dimensions nx (number of points in the x-direction), ny (number of points in the y-direction), and np (number of points in the third dimension, e.g., pressure levels). |
var | A 3D array of dimensions EX x EY x EP containing the meteorological data to be written. The data is provided in the format var[ix][iy][ip] , where ix is the index in the x-direction, iy is the index in the y-direction, and ip is the index in the third dimension (e.g., vertical levels). |
scl | A scaling factor applied to each element in the var array before writing to the NetCDF file. |
Definition at line 10085 of file mptrac.c.
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.
The write_output
function writes various types of output data to files in the directory specified by the dirname
parameter. The function takes control parameters (ctl
), two meteorological data structures (met0
and met1
), an atmospheric data structure (atm
), and a time value (t
) as input.
dirname | A string representing the directory path where output files will be written. |
ctl | A pointer to a ctl_t structure containing control parameters. |
met0 | A pointer to a met_t structure representing the first set of meteorological data. |
met1 | A pointer to a met_t structure representing the second set of meteorological data. |
atm | A pointer to an atm_t structure representing atmospheric data. |
t | A double value representing the time at which the output is being written. |
The function performs the following steps:
t
) to extract year, month, day, hour, minute, and second.Definition at line 10115 of file mptrac.c.
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.
The write_prof
function writes profile data to a file specified by the filename
parameter. It takes control parameters (ctl
), two meteorological data structures (met0
and met1
), an atmospheric data structure (atm
), and a time value (t
) as input.
filename | A string representing the filename where the profile data will be written. |
ctl | A pointer to a ctl_t structure containing control parameters. |
met0 | A pointer to a met_t structure representing the first set of meteorological data. |
met1 | A pointer to a met_t structure representing the second set of meteorological data. |
atm | A pointer to an atm_t structure representing atmospheric data. |
t | A double value representing the time at which the profile data is being written. |
The function performs the following steps:
Definition at line 10210 of file mptrac.c.
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.
The write_sample
function writes sample data to a file specified by the filename
parameter. It takes control parameters (ctl
), two meteorological data structures (met0
and met1
), an atmospheric data structure (atm
), and a time value (t
) as input.
filename | A string representing the filename where the sample data will be written. |
ctl | A pointer to a ctl_t structure containing control parameters. |
met0 | A pointer to a met_t structure representing the first set of meteorological data. |
met1 | A pointer to a met_t structure representing the second set of meteorological data. |
atm | A pointer to an atm_t structure representing atmospheric data. |
t | A double value representing the time at which the sample data is being written. |
The function performs the following steps:
Definition at line 10437 of file mptrac.c.
Writes station data to a specified file.
The write_station
function writes station data to a file specified by the filename
parameter. It takes control parameters (ctl
), an atmospheric data structure (atm
), and a time value (t
) as input.
filename | A string representing the filename where the station data will be written. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure representing atmospheric data. |
t | A double value representing the time at which the station data is being written. |
The function performs the following steps:
Definition at line 10600 of file mptrac.c.
Writes VTK (Visualization Toolkit) data to a specified file.
The write_vtk
function writes VTK data to a file specified by the filename
parameter. It takes control parameters (ctl
), an atmospheric data structure (atm
), and a time value (t
) as input.
filename | A string representing the filename where the VTK data will be written. |
ctl | A pointer to a ctl_t structure containing control parameters. |
atm | A pointer to an atm_t structure representing atmospheric data. |
t | A double value representing the time at which the VTK data is being written. |
The function performs the following steps:
Definition at line 10686 of file mptrac.c.