JURASSIC
climatology.c
Go to the documentation of this file.
1/*
2 This file is part of JURASSIC.
3
4 JURASSIC is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 JURASSIC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with JURASSIC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2003-2026 Forschungszentrum Juelich GmbH
18*/
19
25#include "jurassic.h"
26
27int main(
28 int argc,
29 char *argv[]) {
30
31 static atm_t atm;
32 static ctl_t ctl;
33
34 double clk[NCL], sfeps[NSF];
35
36 /* Check arguments... */
37 if (argc < 3)
38 ERRMSG("Give parameters: <ctl> <atm>");
39
40 /* Read control parameters... */
41 read_ctl(argc, argv, &ctl);
42 const double t0 = scan_ctl(argc, argv, "T0", -1, "0", NULL);
43 const double t1 = scan_ctl(argc, argv, "T1", -1, "0", NULL);
44 const double dt = scan_ctl(argc, argv, "DT", -1, "1", NULL);
45 const double z0 = scan_ctl(argc, argv, "Z0", -1, "0", NULL);
46 const double z1 = scan_ctl(argc, argv, "Z1", -1, "90", NULL);
47 const double dz = scan_ctl(argc, argv, "DZ", -1, "1", NULL);
48 const int zsurf = (int) scan_ctl(argc, argv, "ZSURF", -1, "0", NULL);
49 const double clz = scan_ctl(argc, argv, "CLZ", -1, "0", NULL);
50 const double cldz = scan_ctl(argc, argv, "CLDZ", -1, "0", NULL);
51 for (int icl = 0; icl < ctl.ncl; icl++)
52 clk[icl] = scan_ctl(argc, argv, "CLK", icl, "0", NULL);
53 const double sft = scan_ctl(argc, argv, "SFT", -1, "0", NULL);
54 for (int isf = 0; isf < ctl.nsf; isf++)
55 sfeps[isf] = scan_ctl(argc, argv, "SFEPS", isf, "1", NULL);
56
57 /* Loop over time steps... */
58 for (double t = t0; t <= t1 + 0.5 * dt; t += dt) {
59
60 /* Init... */
61 atm.np = 0;
62
63 /* Refine near-surface layer... */
64 if (zsurf) {
65 atm.np = 4;
66 atm.z[0] = z0;
67 atm.z[1] = z0 + 0.01;
68 atm.z[2] = z0 + 0.02;
69 atm.z[3] = z0 + 0.05;
70 if (dz > 0.1)
71 for (double z = 0.1; z <= 1.0 + 1e-9; z += 0.1)
72 atm.z[atm.np++] = z0 + z;
73 if (dz > 0.2)
74 for (double z = 1.2; z <= 2.0 + 1e-9; z += 0.2)
75 atm.z[atm.np++] = z0 + z;
76 if (atm.np >= NP)
77 ERRMSG("Too many atmospheric grid points!");
78 }
79
80 /* Add heights... */
81 for (double z = z0; z <= z1; z += dz)
82 if (atm.np == 0 || z > atm.z[atm.np - 1] + 1e-9) {
83 atm.z[atm.np] = z;
84 if ((++atm.np) >= NP)
85 ERRMSG("Too many atmospheric grid points!");
86 }
87
88 /* Set time... */
89 for (int ip = 0; ip < atm.np; ip++)
90 atm.time[ip] = t;
91 }
92
93 /* Interpolate climatological data... */
94 climatology(&ctl, &atm);
95
96 /* Set cloud layer... */
97 atm.clz = clz;
98 atm.cldz = cldz;
99 for (int icl = 0; icl < ctl.ncl; icl++)
100 atm.clk[icl] = clk[icl];
101
102 /* Set surface layer... */
103 atm.sft = sft;
104 for (int isf = 0; isf < ctl.nsf; isf++)
105 atm.sfeps[isf] = sfeps[isf];
106
107 /* Write data to disk... */
108 write_atm(NULL, argv[2], &ctl, &atm);
109
110 return EXIT_SUCCESS;
111}
int main(int argc, char *argv[])
Definition: climatology.c:27
void write_atm(const char *dirname, const char *filename, const ctl_t *ctl, const atm_t *atm)
Write atmospheric data to a file.
Definition: jurassic.c:6953
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5477
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:6413
void climatology(const ctl_t *ctl, atm_t *atm)
Initializes atmospheric climatology profiles.
Definition: jurassic.c:200
JURASSIC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1193
#define NP
Maximum number of atmospheric data points.
Definition: jurassic.h:248
#define NSF
Maximum number of surface layer spectral grid points.
Definition: jurassic.h:258
#define NCL
Maximum number of cloud layer spectral grid points.
Definition: jurassic.h:233
Atmospheric profile data.
Definition: jurassic.h:1243
double time[NP]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:1249
double sfeps[NSF]
Surface emissivity.
Definition: jurassic.h:1285
double clz
Cloud layer height [km].
Definition: jurassic.h:1273
int np
Number of data points.
Definition: jurassic.h:1246
double cldz
Cloud layer depth [km].
Definition: jurassic.h:1276
double sft
Surface temperature [K].
Definition: jurassic.h:1282
double z[NP]
Altitude [km].
Definition: jurassic.h:1252
double clk[NCL]
Cloud layer extinction [km^-1].
Definition: jurassic.h:1279
Control parameters.
Definition: jurassic.h:1296
int ncl
Number of cloud layer spectral grid points.
Definition: jurassic.h:1329
int nsf
Number of surface layer spectral grid points.
Definition: jurassic.h:1335