JURASSIC
Loading...
Searching...
No Matches
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 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 /* Loop over time steps... */
76 for (double t = t0; t <= t1 + 0.5 * dt; t += dt) {
77
78 /* Init... */
79 atm.np = 0;
80
81 /* Refine near-surface layer... */
82 if (zsurf) {
83 atm.np = 4;
84 atm.z[0] = z0;
85 atm.z[1] = z0 + 0.01;
86 atm.z[2] = z0 + 0.02;
87 atm.z[3] = z0 + 0.05;
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;
94 if (atm.np >= NP)
95 ERRMSG("Too many atmospheric grid points!");
96 }
97
98 /* Add heights... */
99 for (double z = z0; z <= z1; z += dz)
100 if (atm.np == 0 || z > atm.z[atm.np - 1] + 1e-9) {
101 atm.z[atm.np] = z;
102 if ((++atm.np) >= NP)
103 ERRMSG("Too many atmospheric grid points!");
104 }
105
106 /* Set time and latitude... */
107 for (int ip = 0; ip < atm.np; ip++) {
108 atm.time[ip] = t;
109 atm.lat[ip] = lat;
110 }
111 }
112
113 /* Read JuMACS climatology, if requested... */
114 clim_t *clim = read_clim(&ctl);
115
116 /* Interpolate climatological data... */
117 climatology(&ctl, clim, &atm);
118
119 /* Set cloud layer... */
120 atm.clz = clz;
121 atm.cldz = cldz;
122 for (int icl = 0; icl < ctl.ncl; icl++)
123 atm.clk[icl] = clk[icl];
124
125 /* Set surface layer... */
126 atm.sft = sft;
127 for (int isf = 0; isf < ctl.nsf; isf++)
128 atm.sfeps[isf] = sfeps[isf];
129
130 /* Write data to disk... */
131 write_atm(NULL, argv[2], &ctl, &atm, 0);
132
133 /* Free climatology... */
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.
Definition jurassic.c:8150
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition jurassic.c:6359
void climatology(const ctl_t *ctl, const clim_t *clim, atm_t *atm)
Initializes atmospheric climatology profiles.
Definition jurassic.c:217
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:7455
clim_t * read_clim(const ctl_t *ctl)
Reads a JuMACS climatology file into an allocated climatology structure.
Definition jurassic.c:1363
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition jurassic.h:1451
#define USAGE
Print usage information on -h or --help.
Definition jurassic.h:1332
#define NP
Maximum number of atmospheric data points.
Definition jurassic.h:393
#define NSF
Maximum number of surface layer spectral grid points.
Definition jurassic.h:408
#define NCL
Maximum number of cloud layer spectral grid points.
Definition jurassic.h:351
Atmospheric profile data.
Definition jurassic.h:1501
double time[NP]
Time (seconds since 2000-01-01T00:00Z).
Definition jurassic.h:1507
double sfeps[NSF]
Surface emissivity.
Definition jurassic.h:1543
double lat[NP]
Latitude [deg].
Definition jurassic.h:1516
double clz
Cloud layer height [km].
Definition jurassic.h:1531
int np
Number of data points.
Definition jurassic.h:1504
double cldz
Cloud layer depth [km].
Definition jurassic.h:1534
double sft
Surface temperature [K].
Definition jurassic.h:1540
double z[NP]
Altitude [km].
Definition jurassic.h:1510
double clk[NCL]
Cloud layer extinction [km^-1].
Definition jurassic.h:1537
JuMACS climatology on a fixed grid.
Definition jurassic.h:1553
Control parameters.
Definition jurassic.h:1593
int ncl
Number of cloud layer spectral grid points.
Definition jurassic.h:1626
int nsf
Number of surface layer spectral grid points.
Definition jurassic.h:1632
Here is the call graph for this function: