47 met_t *met0 = NULL, *met1 = NULL;
57 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
58 "Usage: atm2grid <ctl> <atm_in> [KEY VALUE ...]\n\n"
59 "Use -h for full help.");
66 ERRMSG(
"You need to specify GRID_BASENAME!");
70 ERRMSG(
"Cannot open file!");
73 int year, mon, day, hour, min, sec;
75 jsec2time(t, &year, &mon, &day, &hour, &min, &sec, &r);
78 char filename[3 *
LEN];
79 sprintf(filename,
"%s_%04d_%02d_%02d_%02d_%02d.%s",
84 write_grid(filename, &ctl, met0, met1, atm, t);
98 printf(
"\nMPTRAC atm2grid tool.\n\n");
100 (
"Convert an atmospheric particle data file to gridded output data.\n");
103 printf(
" atm2grid <ctl> <atm_in> [KEY VALUE ...]\n");
105 printf(
"Arguments:\n");
106 printf(
" <ctl> Control file.\n");
107 printf(
" <atm_in> Atmospheric input file.\n");
108 printf(
" [KEY VALUE] Optional control parameters.\n");
111 printf(
" GRID_BASENAME must be set in the control parameters.\n");
112 printf(
"\nFurther information:\n");
113 printf(
" Manual: https://slcs-jsc.github.io/mptrac/\n");
int main(int argc, char *argv[])
void usage(void)
Print command-line help.
double time_from_filename(const char *filename, const int offset)
Extracts and converts a timestamp from a filename to Julian seconds.
int mptrac_read_atm(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a specified file into the given atmospheric structure.
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.
void mptrac_read_ctl(const char *filename, int argc, char *argv[], ctl_t *ctl)
Reads control parameters from a configuration file and populates the given structure.
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.
MPTRAC library declarations.
#define LEN
Maximum length of ASCII data lines.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define ALLOC(ptr, type, n)
Allocate memory for a pointer with error handling.
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
int grid_type
Type of grid data files (0=ASCII, 1=netCDF).
char grid_basename[LEN]
Basename of grid data files.