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 58 of file tblrdc.c.

60 {
61 ctl_t ctl;
62
63 /* Check arguments... */
64 if (argc < 6)
65 ERRMSG("tblrdc: Give parameters: <ctl> <tblbase_in> <tblfmt_in>"
66 " <tblbase_out> <tblfmt_out>");
67
68 /* Read control parameters... */
69 read_ctl(argc, argv, &ctl);
70 const double atol = scan_ctl(argc, argv, "ATOL", -1, "1e-9", NULL);
71 const double rtol = scan_ctl(argc, argv, "RTOL", -1, "0.01", NULL);
72
73 /* Read tables... */
74 sprintf(ctl.tblbase, "%s", argv[2]);
75 ctl.tblfmt = atoi(argv[3]);
76 tbl_t *tbl = read_tbl(&ctl);
77
78 /* Loop over trace gases and channels... */
79 for (int id = 0; id < ctl.nd; id++)
80 for (int ig = 0; ig < ctl.ng; ig++) {
81
82 /* Init counters... */
83 int total_input = 0;
84 int total_output = 0;
85
86 /* Loop over (p, T) combinations... */
87 for (int ip = 0; ip < tbl->np[id][ig]; ip++) {
88 for (int it = 0; it < tbl->nt[id][ig][ip]; it++) {
89
90 const int num_points = tbl->nu[id][ig][ip][it];
91
92 /* First entry is implicitly kept (in-place reduction)... */
93 int write_idx = 1;
94
95 /* Reduce Middle-Entries if more than 2 entries... */
96 if (num_points > 2)
97 reduction(tbl, id, ig, ip, it, 0, num_points - 1, &write_idx,
98 atol, rtol);
99
100 /* Keep last entry if more than 1 entry... */
101 if (num_points > 1) {
102 copy_density(tbl, id, ig, ip, it, write_idx, num_points - 1);
103 write_idx++;
104 }
105
106 /* Update number of kept points... */
107 tbl->nu[id][ig][ip][it] = write_idx;
108 total_input += num_points;
109 total_output += write_idx;
110 }
111 }
112
113 /* Write info... */
114 LOG(1, "Reduction: %s | %.4f cm^-1 | n= %d | CR= %g", ctl.emitter[ig],
115 ctl.nu[id], total_input,
116 total_output > 0 ? (double) total_input / total_output : NAN);
117
118 }
119
120 /* Write tables... */
121 sprintf(ctl.tblbase, "%s", argv[4]);
122 ctl.tblfmt = atoi(argv[5]);
123 write_tbl(&ctl, tbl);
124
125 /* Free... */
126 tbl_free(&ctl, tbl);
127
128 return EXIT_SUCCESS;
129}
void tbl_free(const ctl_t *ctl, tbl_t *tbl)
Free lookup table and all internally allocated memory.
Definition: jurassic.c:6648
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5450
void write_tbl(const ctl_t *ctl, const tbl_t *tbl)
Write emissivity lookup tables to disk.
Definition: jurassic.c:7976
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:6380
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
Definition: jurassic.c:6106
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1194
#define LOG(level,...)
Print a log message with a specified logging level.
Definition: jurassic.h:1124
Control parameters.
Definition: jurassic.h:1297
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
Definition: jurassic.h:1321
char tblbase[LEN]
Basename for table files and filter function files.
Definition: jurassic.h:1348
int ng
Number of emitters.
Definition: jurassic.h:1300
int nd
Number of radiance channels.
Definition: jurassic.h:1318
char emitter[NG][LEN]
Name of each emitter.
Definition: jurassic.h:1303
int tblfmt
Look-up table file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1351
Emissivity look-up tables.
Definition: jurassic.h:1657
int nu[ND][NG][TBLNP][TBLNT]
Number of column densities.
Definition: jurassic.h:1666
int nt[ND][NG][TBLNP]
Number of temperatures.
Definition: jurassic.h:1663
int np[ND][NG]
Number of pressure levels.
Definition: jurassic.h:1660
Here is the call graph for this function: