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

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

Detailed Description

Convert file format of meteo data files.

Definition in file met_conv.c.

Function Documentation

◆ usage()

void usage ( void  )

Print command-line help.

Definition at line 94 of file met_conv.c.

95 {
96
97 printf("\nMPTRAC met_conv tool.\n\n");
98 printf("Convert meteorological data between file formats.\n");
99 printf("\n");
100 printf("Usage:\n");
101 printf
102 (" met_conv <ctl> <met_in> <met_in_type> <met_out> <met_out_type>\n");
103 printf("\n");
104 printf("Arguments:\n");
105 printf(" <ctl> Control file.\n");
106 printf(" <met_in> Meteorological input file.\n");
107 printf
108 (" <met_in_type> Input format: 0=netCDF, 1=binary, 2=pck, 3=zfp,\n");
109 printf(" 4=zstd, 5=cms, 6=GRIB, 7=SZ3.\n");
110 printf(" <met_out> Meteorological output file.\n");
111 printf
112 (" <met_out_type> Output format: 0=netCDF, 1=binary, 2=pck, 3=zfp,\n");
113 printf(" 4=zstd, 5=cms, 6=GRIB, 7=SZ3.\n");
114 printf("\nFurther information:\n");
115 printf(" Manual: https://slcs-jsc.github.io/mptrac/\n");
116}

◆ main()

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

Definition at line 39 of file met_conv.c.

41 {
42
43 ctl_t ctl;
44
45 clim_t *clim;
46
47 met_t *met;
48
49 dd_t *dd;
50
51 /* Print usage information... */
52 USAGE;
53
54 /* Check arguments... */
55 if (argc < 6)
56 ERRMSG("Missing or invalid command-line arguments.\n\n"
57 "Usage: met_conv <ctl> <met_in> <met_in_type> <met_out> <met_out_type>\n\n"
58 "Use -h for full help.");
59
60 /* Allocate... */
61 ALLOC(clim, clim_t, 1);
62 ALLOC(met, met_t, 1);
63 ALLOC(dd, dd_t, 1);
64
65 /* Read control parameters... */
66 mptrac_read_ctl(argv[1], argc, argv, &ctl);
67
68 /* Read climatological data... */
69 mptrac_read_clim(&ctl, clim);
70
71 /* Read meteo data... */
72 ctl.met_type = atoi(argv[3]);
73 if (!mptrac_read_met(argv[2], &ctl, clim, met, dd))
74 ERRMSG("Cannot open file!");
75
76 /* Write meteo data... */
77 ctl.met_type = atoi(argv[5]);
78 mptrac_write_met(argv[4], &ctl, met);
79
80 /* Report timers... */
82
83 /* Free... */
84 free(clim);
85 free(met);
86 free(dd);
87
88 return EXIT_SUCCESS;
89}
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
Definition: mptrac.c:5188
int mptrac_read_met(const char *filename, const ctl_t *ctl, const clim_t *clim, met_t *met, dd_t *dd)
Reads meteorological data from a file, supporting multiple formats and MPI broadcasting.
Definition: mptrac.c:6151
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
void mptrac_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:6586
#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
#define PRINT_TIMERS
Print the current state of all timers.
Definition: mptrac.h:2161
Climatological data.
Definition: mptrac.h:3436
Control parameters.
Definition: mptrac.h:2190
int met_type
Type of meteo data files (0=netCDF, 1=binary, 2=pck, 3=ZFP, 4=ZSTD, 5=cms, 6=grib,...
Definition: mptrac.h:2548
Domain decomposition data structure.
Definition: mptrac.h:3669
Meteo data structure.
Definition: mptrac.h:3495
Here is the call graph for this function: