JURASSIC
kernel.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
27int main(
28 int argc,
29 char *argv[]) {
30
31 static atm_t atm;
32 static ctl_t ctl;
33 static obs_t obs;
34
35 /* Check arguments... */
36 if (argc < 5)
37 ERRMSG("Give parameters: <ctl> <obs> <atm> <kernel>");
38
39 /* Read control parameters... */
40 read_ctl(argc, argv, &ctl);
41
42 /* Set flags... */
43 ctl.write_matrix = 1;
44
45 /* Read observation geometry... */
46 read_obs(NULL, argv[2], &ctl, &obs);
47
48 /* Read atmospheric data... */
49 read_atm(NULL, argv[3], &ctl, &atm);
50
51 /* Get sizes... */
52 const size_t n = atm2x(&ctl, &atm, NULL, NULL, NULL);
53 const size_t m = obs2y(&ctl, &obs, NULL, NULL, NULL);
54
55 /* Check sizes... */
56 if (n == 0)
57 ERRMSG("No state vector elements!");
58 if (m == 0)
59 ERRMSG("No measurement vector elements!");
60
61 /* Allocate... */
62 gsl_matrix *k = gsl_matrix_alloc(m, n);
63
64 /* Compute kernel matrix... */
65 kernel(&ctl, &atm, &obs, k);
66
67 /* Write matrix to file... */
68 write_matrix(NULL, argv[4], &ctl, k, &atm, &obs, "y", "x", "r");
69
70 /* Free... */
71 gsl_matrix_free(k);
72
73 return EXIT_SUCCESS;
74}
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read forward model control parameters.
Definition: jurassic.c:4547
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm)
Read atmospheric data.
Definition: jurassic.c:4442
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs)
Read observation data.
Definition: jurassic.c:4697
size_t obs2y(const ctl_t *ctl, const obs_t *obs, gsl_vector *y, int *ida, int *ira)
Compose measurement vector.
Definition: jurassic.c:4174
size_t atm2x(const ctl_t *ctl, const atm_t *atm, gsl_vector *x, int *iqa, int *ipa)
Compose state vector or parameter vector.
Definition: jurassic.c:29
void write_matrix(const char *dirname, const char *filename, const ctl_t *ctl, const gsl_matrix *matrix, const atm_t *atm, const obs_t *obs, const char *rowspace, const char *colspace, const char *sort)
Write matrix.
Definition: jurassic.c:5492
void kernel(ctl_t *ctl, atm_t *atm, obs_t *obs, gsl_matrix *k)
Compute Jacobians.
Definition: jurassic.c:4004
JURASSIC library declarations.
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
int main(int argc, char *argv[])
Definition: kernel.c:27
Atmospheric data.
Definition: jurassic.h:488
Forward model control parameters.
Definition: jurassic.h:541
int write_matrix
Write matrix file (0=no, 1=yes).
Definition: jurassic.h:661
Observation geometry and radiance data.
Definition: jurassic.h:734