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