JURASSIC
tblfmt.c
Go to the documentation of this file.
1/*
2 This file is part of JURASSIC.
3
4 JURASSIC 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 JURASSIC 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 JURASSIC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2013-2026 Forschungszentrum Juelich GmbH
18*/
19
25#include "jurassic.h"
26
27/* ------------------------------------------------------------
28 Functions...
29 ------------------------------------------------------------ */
30
32static void usage(
33 void);
34
35/* ------------------------------------------------------------
36 Main...
37 ------------------------------------------------------------ */
38
39int main(
40 int argc,
41 char *argv[]) {
42
43 ctl_t ctl;
44
45 /* Print usage information... */
46 USAGE;
47
48 /* Check arguments... */
49 if (argc < 6)
50 ERRMSG("Missing or invalid command-line arguments.\n\n"
51 "Usage: tblfmt <ctl> <tblbase_in> <tblfmt_in> <tblbase_out> <tblfmt_out> [KEY VALUE ...]\n\n"
52 "Use -h for full help.");
53
54 /* Read control parameters... */
55 read_ctl(argc, argv, &ctl);
56
57 /* Read tables... */
58 sprintf(ctl.tblbase, "%s", argv[2]);
59 ctl.tblfmt = atoi(argv[3]);
60 tbl_t *tbl = read_tbl(&ctl);
61
62 /* Write tables... */
63 sprintf(ctl.tblbase, "%s", argv[4]);
64 ctl.tblfmt = atoi(argv[5]);
65 write_tbl(&ctl, tbl);
66
67 /* Free... */
68 tbl_free(&ctl, tbl);
69
70 return EXIT_SUCCESS;
71}
72
73/*****************************************************************************/
74
75static void usage(
76 void) {
77 printf("\nJURASSIC lookup-table format converter.\n\n");
78 printf("Convert look-up tables between supported TBLFMT formats.\n\n");
79 printf("Usage:\n");
80 printf
81 (" tblfmt <ctl> <tblbase_in> <tblfmt_in> <tblbase_out> <tblfmt_out>\n");
82 printf(" [KEY VALUE ...]\n\n");
83 printf("Arguments:\n");
84 printf(" <ctl> Control file.\n");
85 printf(" <tblbase_in> Input table base name.\n");
86 printf(" <tblfmt_in> Input table format identifier.\n");
87 printf(" <tblbase_out> Output table base name.\n");
88 printf(" <tblfmt_out> Output table format identifier.\n");
89 printf(" [KEY VALUE] Optional control parameters.\n\n");
90 printf("Common control parameters:\n");
91 printf(" NG, EMITTER[i] Active emitters.\n");
92 printf(" ND, NU[i] Spectral channels.\n\n");
93 printf("Further information:\n");
94 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
95}
void usage(void)
Print command-line help.
Definition: formod.c:163
void tbl_free(const ctl_t *ctl, tbl_t *tbl)
Free lookup table and all internally allocated memory.
Definition: jurassic.c:7002
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5516
void write_tbl(const ctl_t *ctl, const tbl_t *tbl)
Write emissivity lookup tables to disk.
Definition: jurassic.c:8722
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
Definition: jurassic.c:6332
JURASSIC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1325
#define USAGE
Print usage information on -h or --help.
Definition: jurassic.h:1206
Control parameters.
Definition: jurassic.h:1428
char tblbase[LEN]
Basename for table files and filter function files.
Definition: jurassic.h:1479
int tblfmt
Look-up table file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1482
Emissivity look-up tables.
Definition: jurassic.h:1842
int main(int argc, char *argv[])
Definition: tblfmt.c:39