MPTRAC
Functions
met_conv.c File Reference

Convert file format of meteo 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 meteo data files.

Definition in file met_conv.c.

Function Documentation

◆ main()

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

Definition at line 27 of file met_conv.c.

29 {
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 /* Read control parameters... */
47 read_ctl(argv[1], argc, argv, &ctl);
48
49 /* Read climatological data... */
50 read_clim(&ctl, clim);
51
52 /* Read meteo data... */
53 ctl.met_type = atoi(argv[3]);
54 if (!read_met(argv[2], &ctl, clim, met))
55 ERRMSG("Cannot open file!");
56
57 /* Write meteo data... */
58 ctl.met_type = atoi(argv[5]);
59 write_met(argv[4], &ctl, met);
60
61 /* Free... */
62 free(clim);
63 free(met);
64
65 return EXIT_SUCCESS;
66}
int write_met(const char *filename, ctl_t *ctl, met_t *met)
Writes meteorological data to a binary file.
Definition: mptrac.c:9529
void read_clim(ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:4441
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:4789
int read_met(const char *filename, ctl_t *ctl, clim_t *clim, met_t *met)
Reads meteorological data from a file and populates the provided structures.
Definition: mptrac.c:5611
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: mptrac.h:1881
#define ALLOC(ptr, type, n)
Allocate memory for a pointer with error handling.
Definition: mptrac.h:344
Climatological data.
Definition: mptrac.h:3230
Control parameters.
Definition: mptrac.h:2135
int met_type
Type of meteo data files (0=netCDF, 1=binary, 2=pck, 3=zfp, 4=zstd, 5=cms).
Definition: mptrac.h:2465
Meteo data structure.
Definition: mptrac.h:3289
Here is the call graph for this function: