MPTRAC
atm_conv.c
Go to the documentation of this file.
1/*
2 This file is part of MPTRAC.
3
4 MPTRAC is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 MPTRAC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2013-2025 Forschungszentrum Juelich GmbH
18*/
19
25#include "mptrac.h"
26
27int main(
28 int argc,
29 char *argv[]) {
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 mptrac_read_ctl(argv[1], argc, argv, &ctl);
45
46 /* Read atmospheric data... */
47 ctl.atm_type = atoi(argv[3]);
48 if (!mptrac_read_atm(argv[2], &ctl, atm))
49 ERRMSG("Cannot open file!");
50
51 /* Write atmospheric data... */
52 if (ctl.atm_type_out == 3) {
53
54 /* For CLaMS trajectory files... */
55 ctl.t_start = ctl.t_stop;
56 ctl.atm_type_out = atoi(argv[5]);
57 mptrac_write_atm(argv[4], &ctl, atm, ctl.t_stop);
58
59 } else {
60
61 /* Otherwise... */
62 ctl.atm_type_out = atoi(argv[5]);
63 mptrac_write_atm(argv[4], &ctl, atm, 0);
64 }
65
66 /* Free... */
67 free(atm);
68
69 return EXIT_SUCCESS;
70}
int main(int argc, char *argv[])
Definition: atm_conv.c:27
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:5667
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:4400
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:4531
MPTRAC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: mptrac.h:1904
#define ALLOC(ptr, type, n)
Allocate memory for a pointer with error handling.
Definition: mptrac.h:349
Air parcel data.
Definition: mptrac.h:3146
Control parameters.
Definition: mptrac.h:2158
int atm_type
Type of atmospheric data files (0=ASCII, 1=binary, 2=netCDF, 3=CLaMS_traj, 4=CLaMS_pos).
Definition: mptrac.h:2931
int atm_type_out
Type of atmospheric data files for output (-1=same as ATM_TYPE, 0=ASCII, 1=binary,...
Definition: mptrac.h:2936
double t_stop
Stop time of simulation [s].
Definition: mptrac.h:2459
double t_start
Start time of simulation [s].
Definition: mptrac.h:2456