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

void usage (void)
 Print command-line help. More...
 
int main (int argc, char *argv[])
 

Detailed Description

Convert file format of air parcel data files.

Definition in file atm_conv.c.

Function Documentation

◆ usage()

void usage ( void  )

Print command-line help.

Definition at line 91 of file atm_conv.c.

92 {
93
94 printf("\nMPTRAC atm_conv tool.\n\n");
95 printf("Convert atmospheric particle data between file formats.\n");
96 printf("\n");
97 printf("Usage:\n");
98 printf
99 (" atm_conv <ctl> <atm_in> <atm_in_type> <atm_out> <atm_out_type>\n");
100 printf("\n");
101 printf("Arguments:\n");
102 printf(" <ctl> Control file.\n");
103 printf(" <atm_in> Atmospheric input file.\n");
104 printf(" <atm_in_type> Input format: 0=ASCII, 1=binary, 2=netCDF,\n");
105 printf
106 (" 3=CLaMS trajectory/position netCDF, 4=CLaMS position netCDF.\n");
107 printf(" <atm_out> Atmospheric output file.\n");
108 printf(" <atm_out_type> Output format: 0=ASCII, 1=binary, 2=netCDF,\n");
109 printf
110 (" 3=CLaMS trajectory/position netCDF, 4=CLaMS position netCDF.\n");
111 printf("\nFurther information:\n");
112 printf(" Manual: https://slcs-jsc.github.io/mptrac/\n");
113}

◆ main()

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

Definition at line 39 of file atm_conv.c.

41 {
42
43 ctl_t ctl;
44
45 atm_t *atm;
46
47 /* Print usage information... */
48 USAGE;
49
50 /* Check arguments... */
51 if (argc < 6)
52 ERRMSG("Missing or invalid command-line arguments.\n\n"
53 "Usage: atm_conv <ctl> <atm_in> <atm_in_type> <atm_out> <atm_out_type>\n\n"
54 "Use -h for full help.");
55
56 /* Allocate... */
57 ALLOC(atm, atm_t, 1);
58
59 /* Read control parameters... */
60 mptrac_read_ctl(argv[1], argc, argv, &ctl);
61
62 /* Read atmospheric data... */
63 ctl.atm_type = atoi(argv[3]);
64 if (!mptrac_read_atm(argv[2], &ctl, atm))
65 ERRMSG("Cannot open file!");
66
67 /* Write atmospheric data... */
68 if (ctl.atm_type_out == 3) {
69
70 /* For CLaMS trajectory files... */
71 ctl.t_start = ctl.t_stop;
72 ctl.atm_type_out = atoi(argv[5]);
73 mptrac_write_atm(argv[4], &ctl, atm, ctl.t_stop);
74
75 } else {
76
77 /* Otherwise... */
78 ctl.atm_type_out = atoi(argv[5]);
79 mptrac_write_atm(argv[4], &ctl, atm, 0);
80 }
81
82 /* Free... */
83 free(atm);
84
85 return EXIT_SUCCESS;
86}
void mptrac_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:6526
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.
Definition: mptrac.c:5117
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.
Definition: mptrac.c:5248
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: mptrac.h:2102
#define USAGE
Print usage information on -h or --help.
Definition: mptrac.h:1909
#define ALLOC(ptr, type, n)
Allocate memory for a pointer with error handling.
Definition: mptrac.h:453
Air parcel data.
Definition: mptrac.h:3241
Control parameters.
Definition: mptrac.h:2190
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:3007
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:3012
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2524
double t_start
Start time of simulation [s].
Definition: mptrac.h:2521
Here is the call graph for this function: