60 {
62
63
64 if (argc < 6)
65 ERRMSG(
"tblrdc: Give parameters: <ctl> <tblbase_in> <tblfmt_in>"
66 " <tblbase_out> <tblfmt_out>");
67
68
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
74 sprintf(ctl.
tblbase,
"%s", argv[2]);
75 ctl.
tblfmt = atoi(argv[3]);
77
78
79 for (
int id = 0;
id < ctl.
nd;
id++)
80 for (
int ig = 0; ig < ctl.
ng; ig++) {
81
82
83 int total_input = 0;
84 int total_output = 0;
85
86
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
93 int write_idx = 1;
94
95
96 if (num_points > 2)
97 reduction(tbl, id, ig, ip, it, 0, num_points - 1, &write_idx,
98 atol, rtol);
99
100
101 if (num_points > 1) {
102 copy_density(tbl, id, ig, ip, it, write_idx, num_points - 1);
103 write_idx++;
104 }
105
106
107 tbl->
nu[id][ig][ip][it] = write_idx;
108 total_input += num_points;
109 total_output += write_idx;
110 }
111 }
112
113
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
121 sprintf(ctl.
tblbase,
"%s", argv[4]);
122 ctl.
tblfmt = atoi(argv[5]);
124
125
127
128 return EXIT_SUCCESS;
129}
void tbl_free(const ctl_t *ctl, tbl_t *tbl)
Free lookup table and all internally allocated memory.
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
void write_tbl(const ctl_t *ctl, const tbl_t *tbl)
Write emissivity lookup tables to disk.
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.
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define LOG(level,...)
Print a log message with a specified logging level.
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
char tblbase[LEN]
Basename for table files and filter function files.
int ng
Number of emitters.
int nd
Number of radiance channels.
char emitter[NG][LEN]
Name of each emitter.
int tblfmt
Look-up table file format (1=ASCII, 2=binary, 3=netCDF).
Emissivity look-up tables.
int nu[ND][NG][TBLNP][TBLNT]
Number of column densities.
int nt[ND][NG][TBLNP]
Number of temperatures.
int np[ND][NG]
Number of pressure levels.