JURASSIC
hydrostatic.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) 2003-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 static atm_t atm;
44 static ctl_t ctl;
45
46 /* Print usage information... */
47 USAGE;
48
49 /* Check arguments... */
50 if (argc < 4)
51 ERRMSG("Missing or invalid command-line arguments.\n\n"
52 "Usage: hydrostatic <ctl> <atm_in> <atm_hyd> [KEY VALUE ...]\n\n"
53 "Use -h for full help.");
54
55 /* Read control parameters... */
56 read_ctl(argc, argv, &ctl);
57
58 /* Check reference height... */
59 if (ctl.hydz < 0)
60 ERRMSG("Set HYDZ>=0!");
61
62 /* Read atmospheric data... */
63 read_atm(NULL, argv[2], &ctl, &atm, 0);
64
65 /* Build atmosphere based on hydrostatic equilibrium... */
66 hydrostatic(&ctl, &atm);
67
68 /* Write atmospheric data... */
69 write_atm(NULL, argv[3], &ctl, &atm, 0);
70
71 return EXIT_SUCCESS;
72}
73
74/*****************************************************************************/
75
76static void usage(
77 void) {
78 printf("\nJURASSIC hydrostatic tool.\n\n");
79 printf("Recalculate pressure from hydrostatic equilibrium for an\n");
80 printf("existing atmospheric profile.\n\n");
81 printf("Usage:\n");
82 printf(" hydrostatic <ctl> <atm_in> <atm_hyd> [KEY VALUE ...]\n\n");
83 printf("Arguments:\n");
84 printf(" <ctl> Control file.\n");
85 printf(" <atm_in> Input atmospheric data file.\n");
86 printf
87 (" <atm_hyd> Output atmospheric data file with hydrostatic pressure.\n");
88 printf(" [KEY VALUE] Optional control parameters.\n\n");
89 printf("Notes:\n");
90 printf(" HYDZ must be set to a non-negative reference height.\n");
91 printf("\n");
92 printf("Common control parameters:\n");
93 printf(" ATMFMT Atmospheric file format.\n");
94 printf(" NG, EMITTER[i] Active emitters.\n");
95 printf(" NW, WINDOW[i] Extinction-window layout.\n");
96 printf(" NCL, CLNU[i] Cloud spectral grid.\n");
97 printf(" NSF, SFNU[i] Surface spectral grid.\n\n");
98 printf("Further information:\n");
99 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
100}
void usage(void)
Print command-line help.
Definition: formod.c:163
int main(int argc, char *argv[])
Definition: hydrostatic.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
void hydrostatic(const ctl_t *ctl, atm_t *atm)
Adjust pressure profile using the hydrostatic equation.
Definition: jurassic.c:3903
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
double hydz
Reference height for hydrostatic pressure profile (-999 to skip) [km].
Definition: jurassic.h:1494