41 {
42
45
46 double clk[
NCL], sfeps[
NSF];
47
48
50
51
52 if (argc < 3)
53 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
54 "Usage: climatology <ctl> <atm> [KEY VALUE ...]\n\n"
55 "Use -h for full help.");
56
57
59 const double t0 =
scan_ctl(argc, argv,
"T0", -1,
"0", NULL);
60 const double t1 =
scan_ctl(argc, argv,
"T1", -1,
"0", NULL);
61 const double dt =
scan_ctl(argc, argv,
"DT", -1,
"1", NULL);
62 const double z0 =
scan_ctl(argc, argv,
"Z0", -1,
"0", NULL);
63 const double z1 =
scan_ctl(argc, argv,
"Z1", -1,
"90", NULL);
64 const double dz =
scan_ctl(argc, argv,
"DZ", -1,
"1", NULL);
65 const double lat =
scan_ctl(argc, argv,
"LAT", -1,
"0", NULL);
66 const int zsurf = (int)
scan_ctl(argc, argv,
"ZSURF", -1,
"0", NULL);
67 const double clz =
scan_ctl(argc, argv,
"CLZ", -1,
"0", NULL);
68 const double cldz =
scan_ctl(argc, argv,
"CLDZ", -1,
"0", NULL);
69 for (
int icl = 0; icl < ctl.
ncl; icl++)
70 clk[icl] =
scan_ctl(argc, argv,
"CLK", icl,
"0", NULL);
71 const double sft =
scan_ctl(argc, argv,
"SFT", -1,
"0", NULL);
72 for (
int isf = 0; isf < ctl.
nsf; isf++)
73 sfeps[isf] =
scan_ctl(argc, argv,
"SFEPS", isf,
"1", NULL);
74
75
76 for (double t = t0; t <= t1 + 0.5 * dt; t += dt) {
77
78
80
81
82 if (zsurf) {
88 if (dz > 0.1)
89 for (double z = 0.1; z <= 1.0 + 1e-9; z += 0.1)
90 atm.
z[atm.
np++] = z0 + z;
91 if (dz > 0.2)
92 for (double z = 1.2; z <= 2.0 + 1e-9; z += 0.2)
93 atm.
z[atm.
np++] = z0 + z;
95 ERRMSG(
"Too many atmospheric grid points!");
96 }
97
98
99 for (double z = z0; z <= z1; z += dz)
100 if (atm.
np == 0 || z > atm.
z[atm.
np - 1] + 1e-9) {
102 if ((++atm.
np) >=
NP)
103 ERRMSG(
"Too many atmospheric grid points!");
104 }
105
106
107 for (
int ip = 0; ip < atm.
np; ip++) {
110 }
111 }
112
113
115
116
118
119
122 for (
int icl = 0; icl < ctl.
ncl; icl++)
123 atm.
clk[icl] = clk[icl];
124
125
127 for (
int isf = 0; isf < ctl.
nsf; isf++)
128 atm.
sfeps[isf] = sfeps[isf];
129
130
132
133
134 free(clim);
135
136 return EXIT_SUCCESS;
137}
void write_atm(const char *dirname, const char *filename, const ctl_t *ctl, const atm_t *atm, int profile)
Write atmospheric data to a file.
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
void climatology(const ctl_t *ctl, const clim_t *clim, atm_t *atm)
Initializes atmospheric climatology profiles.
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.
clim_t * read_clim(const ctl_t *ctl)
Reads a JuMACS climatology file into an allocated climatology structure.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define NP
Maximum number of atmospheric data points.
#define NSF
Maximum number of surface layer spectral grid points.
#define NCL
Maximum number of cloud layer spectral grid points.
Atmospheric profile data.
double time[NP]
Time (seconds since 2000-01-01T00:00Z).
double sfeps[NSF]
Surface emissivity.
double lat[NP]
Latitude [deg].
double clz
Cloud layer height [km].
int np
Number of data points.
double cldz
Cloud layer depth [km].
double sft
Surface temperature [K].
double z[NP]
Altitude [km].
double clk[NCL]
Cloud layer extinction [km^-1].
JuMACS climatology on a fixed grid.
int ncl
Number of cloud layer spectral grid points.
int nsf
Number of surface layer spectral grid points.