JURASSIC
Functions
tblrdc.c File Reference

Reduce look-up table size using recursive, error-controlled interpolation. More...

#include "jurassic.h"

Go to the source code of this file.

Functions

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

Detailed Description

Reduce look-up table size using recursive, error-controlled interpolation.

Definition in file tblrdc.c.

Function Documentation

◆ main()

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

Definition at line 62 of file tblrdc.c.

64 {
65 ctl_t ctl;
66
67 /* Print usage information... */
68 USAGE;
69
70 /* Check arguments... */
71 if (argc < 6)
72 ERRMSG("Missing or invalid command-line arguments.\n\n"
73 "Usage: tblrdc <ctl> <tblbase_in> <tblfmt_in> <tblbase_out> <tblfmt_out> [KEY VALUE ...]\n\n"
74 "Use -h for full help.");
75
76 /* Read control parameters... */
77 read_ctl(argc, argv, &ctl);
78 const double atol = scan_ctl(argc, argv, "ATOL", -1, "1e-9", NULL);
79 const double rtol = scan_ctl(argc, argv, "RTOL", -1, "0.01", NULL);
80
81 /* Read tables... */
82 sprintf(ctl.tblbase, "%s", argv[2]);
83 ctl.tblfmt = atoi(argv[3]);
84 tbl_t *tbl = read_tbl(&ctl);
85
86 /* Loop over trace gases and channels... */
87 for (int id = 0; id < ctl.nd; id++)
88 for (int ig = 0; ig < ctl.ng; ig++) {
89
90 /* Init counters... */
91 int total_input = 0;
92 int total_output = 0;
93
94 /* Loop over (p, T) combinations... */
95 for (int ip = 0; ip < tbl->np[id][ig]; ip++) {
96 for (int it = 0; it < tbl->nt[id][ig][ip]; it++) {
97
98 const int num_points = tbl->nu[id][ig][ip][it];
99
100 /* First entry is implicitly kept (in-place reduction)... */
101 int write_idx = 1;
102
103 /* Reduce Middle-Entries if more than 2 entries... */
104 if (num_points > 2)
105 reduction(tbl, id, ig, ip, it, 0, num_points - 1, &write_idx,
106 atol, rtol);
107
108 /* Keep last entry if more than 1 entry... */
109 if (num_points > 1) {
110 copy_density(tbl, id, ig, ip, it, write_idx, num_points - 1);
111 write_idx++;
112 }
113
114 /* Update number of kept points... */
115 tbl->nu[id][ig][ip][it] = write_idx;
116 total_input += num_points;
117 total_output += write_idx;
118 }
119 }
120
121 /* Write info... */
122 LOG(1, "Reduction: %s | %.4f cm^-1 | n= %d | CR= %g", ctl.emitter[ig],
123 ctl.nu[id], total_input,
124 total_output > 0 ? (double) total_input / total_output : NAN);
125
126 }
127
128 /* Write tables... */
129 sprintf(ctl.tblbase, "%s", argv[4]);
130 ctl.tblfmt = atoi(argv[5]);
131 write_tbl(&ctl, tbl);
132
133 /* Free... */
134 tbl_free(&ctl, tbl);
135
136 return EXIT_SUCCESS;
137}
void tbl_free(const ctl_t *ctl, tbl_t *tbl)
Free lookup table and all internally allocated memory.
Definition: jurassic.c:7002
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5516
void write_tbl(const ctl_t *ctl, const tbl_t *tbl)
Write emissivity lookup tables to disk.
Definition: jurassic.c:8722
double scan_ctl(int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scan control file or command-line arguments for a configuration variable.
Definition: jurassic.c:6612
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
Definition: jurassic.c:6332
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1325
#define USAGE
Print usage information on -h or --help.
Definition: jurassic.h:1206
#define LOG(level,...)
Print a log message with a specified logging level.
Definition: jurassic.h:1255
Control parameters.
Definition: jurassic.h:1428
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
Definition: jurassic.h:1452
char tblbase[LEN]
Basename for table files and filter function files.
Definition: jurassic.h:1479
int ng
Number of emitters.
Definition: jurassic.h:1431
int nd
Number of radiance channels.
Definition: jurassic.h:1449
char emitter[NG][LEN]
Name of each emitter.
Definition: jurassic.h:1434
int tblfmt
Look-up table file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1482
Emissivity look-up tables.
Definition: jurassic.h:1842
int nu[ND][NG][TBLNP][TBLNT]
Number of column densities.
Definition: jurassic.h:1851
int nt[ND][NG][TBLNP]
Number of temperatures.
Definition: jurassic.h:1848
int np[ND][NG]
Number of pressure levels.
Definition: jurassic.h:1845
Here is the call graph for this function: