JURASSIC
Functions
kernel.c File Reference

Calculate kernel functions. More...

#include "jurassic.h"

Go to the source code of this file.

Functions

void call_kernel (const ctl_t *ctl, const tbl_t *tbl, const char *wrkdir, const char *obsfile, const char *atmfile, const char *kernelfile)
 Perform kernel calculations in a single directory. More...
 
int main (int argc, char *argv[])
 

Detailed Description

Calculate kernel functions.

Definition in file kernel.c.

Function Documentation

◆ call_kernel()

void call_kernel ( const ctl_t ctl,
const tbl_t tbl,
const char *  wrkdir,
const char *  obsfile,
const char *  atmfile,
const char *  kernelfile 
)

Perform kernel calculations in a single directory.

Definition at line 103 of file kernel.c.

109 {
110
111 static atm_t atm;
112 static obs_t obs;
113
114 /* Read observation geometry... */
115 read_obs(wrkdir, obsfile, ctl, &obs);
116
117 /* Read atmospheric data... */
118 read_atm(wrkdir, atmfile, ctl, &atm);
119
120 /* Get sizes... */
121 const size_t n = atm2x(ctl, &atm, NULL, NULL, NULL);
122 const size_t m = obs2y(ctl, &obs, NULL, NULL, NULL);
123
124 /* Check sizes... */
125 if (n == 0)
126 ERRMSG("No state vector elements!");
127 if (m == 0)
128 ERRMSG("No measurement vector elements!");
129
130 /* Allocate... */
131 gsl_matrix *k = gsl_matrix_alloc(m, n);
132
133 /* Compute kernel matrix... */
134 kernel(ctl, tbl, &atm, &obs, k);
135
136 /* Write matrix to file... */
137 write_matrix(wrkdir, kernelfile, ctl, k, &atm, &obs, "y", "x", "r");
138
139 /* Free... */
140 gsl_matrix_free(k);
141}
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm)
Read atmospheric data.
Definition: jurassic.c:4581
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs)
Read observation data.
Definition: jurassic.c:4842
void kernel(const ctl_t *ctl, const tbl_t *tbl, atm_t *atm, obs_t *obs, gsl_matrix *k)
Compute Jacobians.
Definition: jurassic.c:4142
size_t obs2y(const ctl_t *ctl, const obs_t *obs, gsl_vector *y, int *ida, int *ira)
Compose measurement vector.
Definition: jurassic.c:4312
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:5656
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:238
Atmospheric data.
Definition: jurassic.h:494
Observation geometry and radiance data.
Definition: jurassic.h:761
Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 44 of file kernel.c.

46 {
47
48 static ctl_t ctl;
49
50 char dirlist[LEN];
51
52 /* Check arguments... */
53 if (argc < 5)
54 ERRMSG("Give parameters: <ctl> <obs> <atm> <kernel>");
55
56 /* Read control parameters... */
57 read_ctl(argc, argv, &ctl);
58
59 /* Initialize look-up tables... */
60 tbl_t *tbl = read_tbl(&ctl);
61
62 /* Get dirlist... */
63 scan_ctl(argc, argv, "DIRLIST", -1, "-", dirlist);
64
65 /* Set flags... */
66 ctl.write_matrix = 1;
67
68 /* Single kernel calculation... */
69 if (dirlist[0] == '-')
70 call_kernel(&ctl, tbl, NULL, argv[2], argv[3], argv[4]);
71
72 /* Work on directory list... */
73 else {
74
75 /* Open directory list... */
76 FILE *in;
77 if (!(in = fopen(dirlist, "r")))
78 ERRMSG("Cannot open directory list!");
79
80 /* Loop over directories... */
81 char wrkdir[LEN];
82 while (fscanf(in, "%4999s", wrkdir) != EOF) {
83
84 /* Write info... */
85 LOG(1, "\nWorking directory: %s", wrkdir);
86
87 /* Call forward model... */
88 call_kernel(&ctl, tbl, wrkdir, argv[2], argv[3], argv[4]);
89 }
90
91 /* Close dirlist... */
92 fclose(in);
93 }
94
95 /* Free... */
96 free(tbl);
97
98 return EXIT_SUCCESS;
99}
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read forward model control parameters.
Definition: jurassic.c:4686
double scan_ctl(int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Search control parameter file for variable entry.
Definition: jurassic.c:5278
tbl_t * read_tbl(const ctl_t *ctl)
Read look-up table data.
Definition: jurassic.c:5104
#define LEN
Maximum length of ASCII data lines.
Definition: jurassic.h:394
#define LOG(level,...)
Print log message.
Definition: jurassic.h:222
void call_kernel(const ctl_t *ctl, const tbl_t *tbl, const char *wrkdir, const char *obsfile, const char *atmfile, const char *kernelfile)
Perform kernel calculations in a single directory.
Definition: kernel.c:103
Forward model control parameters.
Definition: jurassic.h:547
int write_matrix
Write matrix file (0=no, 1=yes).
Definition: jurassic.h:688
Emissivity look-up tables.
Definition: jurassic.h:805
Here is the call graph for this function: