MPTRAC
Functions
atm_conv.c File Reference

Convert file format of air parcel data files. More...

#include "mptrac.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Convert file format of air parcel data files.

Definition in file atm_conv.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file atm_conv.c.

29 {
30
31 ctl_t ctl;
32
33 atm_t *atm;
34
35 /* Check arguments... */
36 if (argc < 6)
37 ERRMSG("Give parameters: <ctl> <atm_in> <atm_in_type>"
38 " <atm_out> <atm_out_type>");
39
40 /* Allocate... */
41 ALLOC(atm, atm_t, 1);
42
43 /* Read control parameters... */
44 read_ctl(argv[1], argc, argv, &ctl);
45
46 /* Read atmospheric data... */
47 ctl.atm_type = atoi(argv[3]);
48 if (!read_atm(argv[2], &ctl, atm))
49 ERRMSG("Cannot open file!");
50
51 /* Write atmospheric data... */
52 if (ctl.atm_type_out == 3) {
53 /* For CLaMS trajectory files... */
54 ctl.t_start = ctl.t_stop;
55 ctl.atm_type_out = atoi(argv[5]);
56 write_atm(argv[4], &ctl, atm, ctl.t_stop);
57 } else {
58 /* Otherwise... */
59 ctl.atm_type_out = atoi(argv[5]);
60 write_atm(argv[4], &ctl, atm, 0);
61 }
62
63 /* Free... */
64 free(atm);
65
66 return EXIT_SUCCESS;
67}
void write_atm(const char *filename, const ctl_t *ctl, const atm_t *atm, const double t)
Writes air parcel data to a file in various formats.
Definition: mptrac.c:8472
void read_ctl(const char *filename, int argc, char *argv[], ctl_t *ctl)
Reads control parameters from a configuration file and populates the given structure.
Definition: mptrac.c:4805
int read_atm(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a specified file into the given atmospheric structure.
Definition: mptrac.c:4215
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: mptrac.h:1901
#define ALLOC(ptr, type, n)
Allocate memory for a pointer with error handling.
Definition: mptrac.h:347
Air parcel data.
Definition: mptrac.h:3120
Control parameters.
Definition: mptrac.h:2155
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:2905
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:2910
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2465
double t_start
Start time of simulation [s].
Definition: mptrac.h:2462
Here is the call graph for this function: