47 static atm_t atm_i, atm_apr;
49 static obs_t obs_i, obs_meas;
53 FILE *proflist = NULL;
61 MPI_Init(&argc, &argv);
62 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
63 MPI_Comm_size(MPI_COMM_WORLD, &size);
71 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
72 "Usage: retrieval <ctl> <dirlist> [KEY VALUE ...]\n\n"
73 "Use -h for full help.");
88 if (argv[2][0] !=
'-') {
89 if (!(dirlist = fopen(argv[2],
"r")))
90 ERRMSG(
"Cannot open directory list!");
94 ERRMSG(
"Cannot open profile list!");
95 if (dirlist == NULL && proflist == NULL)
96 ERRMSG(
"Give a directory list or set SHARED_IO_PROFLIST!");
101 int have_dir = 0, have_profile = 0;
104 have_dir = fscanf(dirlist,
"%4999s", ret.
dir) == 1;
106 sprintf(ret.
dir,
".");
110 if (proflist != NULL)
117 if ((dirlist != NULL && !have_dir) || (proflist != NULL && !have_profile)) {
118 if ((dirlist != NULL && have_dir) || (proflist != NULL && have_profile))
119 ERRMSG(
"DIRLIST and SHARED_IO_PROFLIST have different lengths!");
124 if ((++ntask) % size != rank)
128 if (size > 1 && proflist != NULL && dirlist != NULL) {
130 "\nRetrieve profile %d in directory %s on rank %d of %d...\n",
132 }
else if (size > 1 && proflist != NULL) {
133 LOG(1,
"\nRetrieve profile %d on rank %d of %d...\n",
135 }
else if (size > 1) {
136 LOG(1,
"\nRetrieve in directory %s on rank %d of %d...\n",
137 ret.
dir, rank + 1, size);
138 }
else if (proflist != NULL && dirlist != NULL) {
139 LOG(1,
"\nRetrieve profile %d in directory %s...\n",
141 }
else if (proflist != NULL) {
144 LOG(1,
"\nRetrieve in directory %s...\n", ret.
dir);
150 const char *filename =
153 read_atm(dirname, filename, &ctl, &atm_apr, profile);
159 "obs_meas.tab", &dirname, &profile);
160 read_obs(dirname, filename, &ctl, &obs_meas, profile);
170 LOG(1,
"\nRetrieval done...");
175 if (proflist != NULL)
193 printf(
"\nJURASSIC retrieval tool.\n\n");
194 printf(
"Run optimal-estimation retrievals from measured observations,\n");
195 printf(
"a priori atmospheric input, and control settings.\n\n");
197 printf(
" retrieval <ctl> <dirlist> [KEY VALUE ...]\n\n");
198 printf(
"Arguments:\n");
199 printf(
" <ctl> Control file.\n");
200 printf(
" <dirlist> File containing working directories to process.\n");
201 printf(
" Use '-' together with shared I/O settings such as\n");
202 printf(
" SHARED_IO_PROFLIST for shared-file workflows.\n");
203 printf(
" [KEY VALUE] Optional control parameters.\n\n");
204 printf(
"Tool-specific control parameters:\n");
205 printf(
" KERNEL_RECOMP Kernel recomputation mode.\n");
206 printf(
" CONV_* Convergence settings.\n");
207 printf(
" ERR_* Retrieval error and covariance settings.\n");
209 (
" SHARED_IO_PROFLIST Profile-index file for shared-file retrievals.\n");
210 printf(
" SHARED_IO_* Shared input and output filenames.\n");
212 printf(
"Common control parameters:\n");
214 (
" TBLBASE, TBLFMT Lookup-table base name and format.\n");
215 printf(
" ATMFMT, OBSFMT, MATRIXFMT Input/output file formats.\n");
216 printf(
" NG, EMITTER[i] Active emitters.\n");
217 printf(
" ND, NU[i], NW, WINDOW[i] Spectral channels and windows.\n");
219 (
" NCL, CLNU[i], NSF, SFNU[i] Cloud and surface spectral grids.\n");
220 printf(
" RET*_ZMIN, RET*_ZMAX State-vector altitude limits.\n");
222 (
" WRITE_BBT, FORMOD Output units and forward-model selection.\n");
223 printf(
" CTM_*, REFRAC Continua and refractivity.\n");
225 (
" RAYDS, RAYDZ, FOV Ray tracing and field of view.\n\n");
226 printf(
"Further information:\n");
227 printf(
" Manual: https://slcs-jsc.github.io/jurassic/\n");
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 read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs, int profile)
Read observation data from an input file.
const char * shared_io_input_target(const ret_t *ret, const char *shared_file, const char *legacy_file, const char **dirname, int *profile)
Resolve retrieval input target for legacy-directory and shared-file modes.
void optimal_estimation(ret_t *ret, ctl_t *ctl, tbl_t *tbl, obs_t *obs_meas, obs_t *obs_i, atm_t *atm_apr, atm_t *atm_i, double *chisq)
Perform optimal estimation retrieval using Levenberg–Marquardt minimization.
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm, int profile)
Read atmospheric input data from a file.
void read_ret(int argc, char *argv[], const ctl_t *ctl, ret_t *ret)
Read retrieval configuration and error parameters.
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
JURASSIC library declarations.
#define SELECT_TIMER(id, group)
Switch to a named aggregated timer.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define PRINT_TIMERS
Print aggregated timer statistics.
#define LOG(level,...)
Print a log message with a specified logging level.
int main(int argc, char *argv[])
void usage(void)
Print command-line help.
Atmospheric profile data.
Observation geometry and radiance data.
Retrieval control parameters.
char shared_io_proflist[LEN]
Optional file containing retrieval profile indices.
char shared_io_obs_meas_file[LEN]
Optional shared measured-observation input file.
char shared_io_atm_apr_file[LEN]
Optional shared atmospheric a priori input file.
char dir[LEN]
Working directory.
int shared_io_profile
Profile index used for shared netCDF retrieval inputs and outputs.
Emissivity look-up tables.