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 (ctl_t *ctl, 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 ( ctl_t ctl,
const char *  wrkdir,
const char *  obsfile,
const char *  atmfile,
const char *  kernelfile 
)

Perform kernel calculations in a single directory.

Definition at line 96 of file kernel.c.

101 {
102
103 static atm_t atm;
104 static obs_t obs;
105
106 /* Read observation geometry... */
107 read_obs(wrkdir, obsfile, ctl, &obs);
108
109 /* Read atmospheric data... */
110 read_atm(wrkdir, atmfile, ctl, &atm);
111
112 /* Get sizes... */
113 const size_t n = atm2x(ctl, &atm, NULL, NULL, NULL);
114 const size_t m = obs2y(ctl, &obs, NULL, NULL, NULL);
115
116 /* Check sizes... */
117 if (n == 0)
118 ERRMSG("No state vector elements!");
119 if (m == 0)
120 ERRMSG("No measurement vector elements!");
121
122 /* Allocate... */
123 gsl_matrix *k = gsl_matrix_alloc(m, n);
124
125 /* Compute kernel matrix... */
126 kernel(ctl, &atm, &obs, k);
127
128 /* Write matrix to file... */
129 write_matrix(wrkdir, kernelfile, ctl, k, &atm, &obs, "y", "x", "r");
130
131 /* Free... */
132 gsl_matrix_free(k);
133}
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
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
Atmospheric data.
Definition: jurassic.h:488
Observation geometry and radiance data.
Definition: jurassic.h:734
Here is the call graph for this function:

◆ main()

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

Definition at line 43 of file kernel.c.

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