MPTRAC
met_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-2023 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 clim_t *clim;
34
35 met_t *met;
36
37 /* Check arguments... */
38 if (argc < 6)
39 ERRMSG("Give parameters: <ctl> <met_in> <met_in_type>"
40 " <met_out> <met_out_type>");
41
42 /* Allocate... */
43 ALLOC(clim, clim_t, 1);
44 ALLOC(met, met_t, 1);
45
46 /* Start timers... */
48
49 /* Read control parameters... */
50 read_ctl(argv[1], argc, argv, &ctl);
51
52 /* Read climatological data... */
53 read_clim(&ctl, clim);
54
55 /* Read meteo data... */
56 ctl.met_type = atoi(argv[3]);
57 if (!read_met(argv[2], &ctl, clim, met))
58 ERRMSG("Cannot open file!");
59
60 /* Write meteo data... */
61 ctl.met_type = atoi(argv[5]);
62 write_met(argv[4], &ctl, met);
63
64 /* Report timers... */
67
68 /* Free... */
69 free(clim);
70 free(met);
71
72 return EXIT_SUCCESS;
73}
int main(int argc, char *argv[])
Definition: met_conv.c:27
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.
Definition: mptrac.c:9708
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_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.
Definition: mptrac.c:5655
void read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:4473
MPTRAC library declarations.
#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
#define START_TIMERS
Starts a timer for tracking.
Definition: mptrac.h:2000
#define PRINT_TIMERS
Print the current state of all timers.
Definition: mptrac.h:1960
#define STOP_TIMERS
Stop the current timer.
Definition: mptrac.h:2015
Climatological data.
Definition: mptrac.h:3282
Control parameters.
Definition: mptrac.h:2155
int met_type
Type of meteo data files (0=netCDF, 1=binary, 2=pck, 3=zfp, 4=zstd, 5=cms).
Definition: mptrac.h:2485
Meteo data structure.
Definition: mptrac.h:3341