JURASSIC
interpolate.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_in, atm_pts;
44 static ctl_t ctl;
45
46 double k[NW], q[NG];
47
48 /* Print usage information... */
49 USAGE;
50
51 /* Interpolate atmospheric data... */
52
53 /* Check arguments... */
54 if (argc < 5)
55 ERRMSG("Missing or invalid command-line arguments.\n\n"
56 "Usage: interpolate <ctl> <atm_in> <atm_pts> <atm_out> [KEY VALUE ...]\n\n"
57 "Use -h for full help.");
58
59 /* Read control parameters... */
60 read_ctl(argc, argv, &ctl);
61
62 /* Read atmospheric data... */
63 read_atm(NULL, argv[2], &ctl, &atm_in, 0);
64 read_atm(NULL, argv[3], &ctl, &atm_pts, 0);
65
66 /* Interpolate atmospheric data... */
67 for (int ip = 0; ip < atm_pts.np; ip++) {
68 intpol_atm(&ctl, &atm_in, atm_pts.z[ip],
69 &atm_pts.p[ip], &atm_pts.t[ip], q, k);
70 for (int ig = 0; ig < ctl.ng; ig++)
71 atm_pts.q[ig][ip] = q[ig];
72 for (int iw = 0; iw < ctl.nw; iw++)
73 atm_pts.k[iw][ip] = k[iw];
74 }
75
76 /* Save interpolated data... */
77 write_atm(NULL, argv[4], &ctl, &atm_pts, 0);
78
79 return EXIT_SUCCESS;
80}
81
82/*****************************************************************************/
83
84static void usage(
85 void) {
86 printf("\nJURASSIC interpolation tool.\n\n");
87 printf("Interpolate atmospheric state variables from one atmospheric\n");
88 printf("profile to the grid defined by another profile.\n\n");
89 printf("Usage:\n");
90 printf
91 (" interpolate <ctl> <atm_in> <atm_pts> <atm_out> [KEY VALUE ...]\n\n");
92 printf("Arguments:\n");
93 printf(" <ctl> Control file.\n");
94 printf(" <atm_in> Input atmospheric data file.\n");
95 printf(" <atm_pts> Atmospheric file defining interpolation points.\n");
96 printf(" <atm_out> Output atmospheric data file.\n");
97 printf(" [KEY VALUE] Optional control parameters.\n\n");
98 printf("Common control parameters:\n");
99 printf(" ATMFMT Atmospheric file format.\n");
100 printf(" NG, EMITTER[i] Active emitters.\n");
101 printf(" NW, WINDOW[i] Extinction-window layout.\n");
102 printf(" NCL, CLNU[i] Cloud spectral grid.\n");
103 printf(" NSF, SFNU[i] Surface spectral grid.\n\n");
104 printf("Further information:\n");
105 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
106}
void usage(void)
Print command-line help.
Definition: formod.c:163
int main(int argc, char *argv[])
Definition: interpolate.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 intpol_atm(const ctl_t *ctl, const atm_t *atm, const double z, double *p, double *t, double *q, double *k)
Interpolate atmospheric state variables at a given altitude.
Definition: jurassic.c:4049
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
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
#define NG
Maximum number of emitters.
Definition: jurassic.h:298
#define NW
Maximum number of spectral windows.
Definition: jurassic.h:338
Atmospheric profile data.
Definition: jurassic.h:1375
double k[NW][NP]
Extinction [km^-1].
Definition: jurassic.h:1402
double t[NP]
Temperature [K].
Definition: jurassic.h:1396
int np
Number of data points.
Definition: jurassic.h:1378
double z[NP]
Altitude [km].
Definition: jurassic.h:1384
double q[NG][NP]
Volume mixing ratio [ppv].
Definition: jurassic.h:1399
double p[NP]
Pressure [hPa].
Definition: jurassic.h:1393
Control parameters.
Definition: jurassic.h:1428
int nw
Number of spectral windows.
Definition: jurassic.h:1455
int ng
Number of emitters.
Definition: jurassic.h:1431