JURASSIC
Functions
climatology.c File Reference

Prepare atmospheric data file from climatological data. More...

#include "jurassic.h"

Go to the source code of this file.

Functions

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

Detailed Description

Prepare atmospheric data file from climatological data.

Definition in file climatology.c.

Function Documentation

◆ main()

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

Definition at line 39 of file climatology.c.

41 {
42
43 static atm_t atm;
44 static ctl_t ctl;
45
46 double clk[NCL], sfeps[NSF];
47
48 /* Print usage information... */
49 USAGE;
50
51 /* Check arguments... */
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 /* Read control parameters... */
58 read_ctl(argc, argv, &ctl);
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 int zsurf = (int) scan_ctl(argc, argv, "ZSURF", -1, "0", NULL);
66 const double clz = scan_ctl(argc, argv, "CLZ", -1, "0", NULL);
67 const double cldz = scan_ctl(argc, argv, "CLDZ", -1, "0", NULL);
68 for (int icl = 0; icl < ctl.ncl; icl++)
69 clk[icl] = scan_ctl(argc, argv, "CLK", icl, "0", NULL);
70 const double sft = scan_ctl(argc, argv, "SFT", -1, "0", NULL);
71 for (int isf = 0; isf < ctl.nsf; isf++)
72 sfeps[isf] = scan_ctl(argc, argv, "SFEPS", isf, "1", NULL);
73
74 /* Loop over time steps... */
75 for (double t = t0; t <= t1 + 0.5 * dt; t += dt) {
76
77 /* Init... */
78 atm.np = 0;
79
80 /* Refine near-surface layer... */
81 if (zsurf) {
82 atm.np = 4;
83 atm.z[0] = z0;
84 atm.z[1] = z0 + 0.01;
85 atm.z[2] = z0 + 0.02;
86 atm.z[3] = z0 + 0.05;
87 if (dz > 0.1)
88 for (double z = 0.1; z <= 1.0 + 1e-9; z += 0.1)
89 atm.z[atm.np++] = z0 + z;
90 if (dz > 0.2)
91 for (double z = 1.2; z <= 2.0 + 1e-9; z += 0.2)
92 atm.z[atm.np++] = z0 + z;
93 if (atm.np >= NP)
94 ERRMSG("Too many atmospheric grid points!");
95 }
96
97 /* Add heights... */
98 for (double z = z0; z <= z1; z += dz)
99 if (atm.np == 0 || z > atm.z[atm.np - 1] + 1e-9) {
100 atm.z[atm.np] = z;
101 if ((++atm.np) >= NP)
102 ERRMSG("Too many atmospheric grid points!");
103 }
104
105 /* Set time... */
106 for (int ip = 0; ip < atm.np; ip++)
107 atm.time[ip] = t;
108 }
109
110 /* Interpolate climatological data... */
111 climatology(&ctl, &atm);
112
113 /* Set cloud layer... */
114 atm.clz = clz;
115 atm.cldz = cldz;
116 for (int icl = 0; icl < ctl.ncl; icl++)
117 atm.clk[icl] = clk[icl];
118
119 /* Set surface layer... */
120 atm.sft = sft;
121 for (int isf = 0; isf < ctl.nsf; isf++)
122 atm.sfeps[isf] = sfeps[isf];
123
124 /* Write data to disk... */
125 write_atm(NULL, argv[2], &ctl, &atm, 0);
126
127 return EXIT_SUCCESS;
128}
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.
Definition: jurassic.c:7307
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5516
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
void climatology(const ctl_t *ctl, atm_t *atm)
Initializes atmospheric climatology profiles.
Definition: jurassic.c:215
#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 NP
Maximum number of atmospheric data points.
Definition: jurassic.h:308
#define NSF
Maximum number of surface layer spectral grid points.
Definition: jurassic.h:323
#define NCL
Maximum number of cloud layer spectral grid points.
Definition: jurassic.h:283
Atmospheric profile data.
Definition: jurassic.h:1375
double time[NP]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:1381
double sfeps[NSF]
Surface emissivity.
Definition: jurassic.h:1417
double clz
Cloud layer height [km].
Definition: jurassic.h:1405
int np
Number of data points.
Definition: jurassic.h:1378
double cldz
Cloud layer depth [km].
Definition: jurassic.h:1408
double sft
Surface temperature [K].
Definition: jurassic.h:1414
double z[NP]
Altitude [km].
Definition: jurassic.h:1384
double clk[NCL]
Cloud layer extinction [km^-1].
Definition: jurassic.h:1411
Control parameters.
Definition: jurassic.h:1428
int ncl
Number of cloud layer spectral grid points.
Definition: jurassic.h:1461
int nsf
Number of surface layer spectral grid points.
Definition: jurassic.h:1467
Here is the call graph for this function: