JURASSIC
atmfmt.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 static atm_t atm;
46
47 /* Print usage information... */
48 USAGE;
49
50 /* Check arguments... */
51 if (argc < 6)
52 ERRMSG("Missing or invalid command-line arguments.\n\n"
53 "Usage: atmfmt <ctl> <atm_in> <atmfmt_in> <atm_out> <atmfmt_out> [KEY VALUE ...]\n\n"
54 "Use -h for full help.");
55
56 /* Read control parameters... */
57 read_ctl(argc, argv, &ctl);
58
59 /* Read profile indices... */
60 int prof_in = (int) scan_ctl(argc, argv, "PROF_IN", -1, "0", NULL);
61 int prof_out = (int) scan_ctl(argc, argv, "PROF_OUT", -1, "0", NULL);
62
63 /* Read atmospheric data... */
64 ctl.atmfmt = atoi(argv[3]);
65 read_atm(NULL, argv[2], &ctl, &atm, prof_in);
66
67 /* Write atmospheric data... */
68 ctl.atmfmt = atoi(argv[5]);
69 write_atm(NULL, argv[4], &ctl, &atm, prof_out);
70
71 return EXIT_SUCCESS;
72}
73
74/*****************************************************************************/
75
76static void usage(
77 void) {
78 printf("\nJURASSIC atmospheric-format converter.\n\n");
79 printf
80 ("Convert atmospheric input files between supported ATMFMT formats.\n\n");
81 printf("Usage:\n");
82 printf(" atmfmt <ctl> <atm_in> <atmfmt_in> <atm_out> <atmfmt_out>\n");
83 printf(" [KEY VALUE ...]\n\n");
84 printf("Arguments:\n");
85 printf(" <ctl> Control file.\n");
86 printf(" <atm_in> Input atmospheric data file.\n");
87 printf(" <atmfmt_in> Input atmospheric file format identifier.\n");
88 printf(" <atm_out> Output atmospheric data file.\n");
89 printf(" <atmfmt_out> Output atmospheric file format identifier.\n");
90 printf(" [KEY VALUE] Optional control parameters.\n\n");
91 printf("Tool-specific control parameters:\n");
92 printf(" PROF_IN <n> Read profile index <n> from the input file.\n");
93 printf(" PROF_OUT <n> Write output as profile index <n>.\n\n");
94 printf("Common control parameters:\n");
95 printf(" NG, EMITTER[i] Active emitters in atmospheric files.\n");
96 printf(" NW, WINDOW[i] Extinction-window layout.\n");
97 printf(" NCL, CLNU[i] Cloud spectral grid.\n");
98 printf(" NSF, SFNU[i] Surface spectral grid.\n\n");
99 printf("Further information:\n");
100 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
101}
int main(int argc, char *argv[])
Definition: atmfmt.c:39
void write_atm(const char *dirname, const char *filename, const ctl_t *ctl, const atm_t *atm, int profile)
Write atmospheric data to a file.
Definition: jurassic.c:7307
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 read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm, int profile)
Read atmospheric input data from a file.
Definition: jurassic.c:5193
double scan_ctl(int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scan control file or command-line arguments for a configuration variable.
Definition: jurassic.c:6612
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
Atmospheric profile data.
Definition: jurassic.h:1375
Control parameters.
Definition: jurassic.h:1428
int atmfmt
Atmospheric data file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1485