JURASSIC
retrieval.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-2025 Forschungszentrum Juelich GmbH
18*/
19
25#include "jurassic.h"
26
27/* ------------------------------------------------------------
28 Main...
29 ------------------------------------------------------------ */
30
31int main(
32 int argc,
33 char *argv[]) {
34
35 static atm_t atm_i, atm_apr;
36 static ctl_t ctl;
37 static obs_t obs_i, obs_meas;
38 static ret_t ret;
39
40 FILE *dirlist;
41
42 /* Check arguments... */
43 if (argc < 3)
44 ERRMSG("Give parameters: <ctl> <dirlist>");
45
46 /* Measure CPU-time... */
47 TIMER("total", 1);
48
49 /* Read control parameters... */
50 read_ctl(argc, argv, &ctl);
51 read_ret(argc, argv, &ctl, &ret);
52
53 /* Initialize look-up tables... */
54 tbl_t *tbl = read_tbl(&ctl);
55
56 /* Open directory list... */
57 if (!(dirlist = fopen(argv[2], "r")))
58 ERRMSG("Cannot open directory list!");
59
60 /* Loop over directories... */
61 while (fscanf(dirlist, "%4999s", ret.dir) != EOF) {
62
63 /* Write info... */
64 LOG(1, "\nRetrieve in directory %s...\n", ret.dir);
65
66 /* Read atmospheric data... */
67 read_atm(ret.dir, "atm_apr.tab", &ctl, &atm_apr);
68
69 /* Read observation data... */
70 read_obs(ret.dir, "obs_meas.tab", &ctl, &obs_meas);
71
72 /* Run retrieval... */
73 double chisq;
74 optimal_estimation(&ret, &ctl, tbl, &obs_meas, &obs_i, &atm_apr, &atm_i,
75 &chisq);
76
77 /* Measure CPU-time... */
78 TIMER("total", 2);
79 }
80
81 /* Write info... */
82 LOG(1, "\nRetrieval done...");
83
84 /* Measure CPU-time... */
85 TIMER("total", 3);
86
87 /* Free... */
88 free(tbl);
89
90 return EXIT_SUCCESS;
91}
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5322
void optimal_estimation(ret_t *ret, ctl_t *ctl, tbl_t *tbl, obs_t *obs_meas, obs_t *obs_i, atm_t *atm_apr, atm_t *atm_i, double *chisq)
Perform optimal estimation retrieval using Levenberg–Marquardt minimization.
Definition: jurassic.c:4601
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm)
Read atmospheric input data from a file.
Definition: jurassic.c:5109
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs)
Read observation data from an input file.
Definition: jurassic.c:5480
void read_ret(int argc, char *argv[], const ctl_t *ctl, ret_t *ret)
Read retrieval configuration and error parameters.
Definition: jurassic.c:5731
tbl_t * read_tbl(const ctl_t *ctl)
Read all emissivity lookup tables for all gases and frequencies.
Definition: jurassic.c:5887
JURASSIC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:948
#define TIMER(name, mode)
Start or stop a named timer.
Definition: jurassic.h:813
#define LOG(level,...)
Print a log message with a specified logging level.
Definition: jurassic.h:878
int main(int argc, char *argv[])
Definition: retrieval.c:31
Atmospheric profile data.
Definition: jurassic.h:998
Control parameters.
Definition: jurassic.h:1051
Observation geometry and radiance data.
Definition: jurassic.h:1277
Retrieval control parameters.
Definition: jurassic.h:1329
char dir[LEN]
Working directory.
Definition: jurassic.h:1332
Emissivity look-up tables.
Definition: jurassic.h:1411