45 {
46
48
50
52
54
56
58
60
61 FILE *dirlist;
62
63 char dirname[
LEN], filename[2 *
LEN];
64
66
67
69
70
71#ifdef MPI
72 MPI_Init(&argc, &argv);
73 MPI_Comm_rank(MPI_COMM_WORLD, &
rank);
74 MPI_Comm_size(MPI_COMM_WORLD, &
size);
75#ifdef _OPENACC
76 const int num_devices = acc_get_num_devices(acc_device_nvidia);
77 if (num_devices <= 0)
78 ERRMSG(
"Not running on a GPU device!");
79 acc_set_device_num(
rank % num_devices, acc_device_nvidia);
80#endif
81#endif
82
83
84 if (argc < 4)
85 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
86 "Usage: trac <dirlist> <ctl> <atm_in> [KEY VALUE ...]\n\n"
87 "Use -h for full help.");
88
89
90 if (!(dirlist = fopen(argv[1], "r")))
91 ERRMSG(
"Cannot open directory list!");
92
93
94 while (fscanf(dirlist, "%4999s", dirname) != EOF) {
95
96
98 continue;
99
100
101 LOG(1,
"Parallelization: ntask= %d | rank= %d | size= %d",
103
104
105
106
107
108
109 mptrac_alloc(&ctl, &cache, &clim, &met0, &met1, &atm, &depo, &dd);
110
111
112 sprintf(filename, "%s/%s", dirname, argv[2]);
114
115
117
118
120
121
122 sprintf(filename, "%s/%s", dirname, argv[3]);
124 ERRMSG(
"Cannot open file!");
125
126
128#ifdef DD
129 int peak_np = atm->
np;
130#endif
131
132
133
134
135
136
140
141
144
145
147
148
150 double dt_rec;
152 dt_rec = fabs(met0->
lon[1] - met0->
lon[0]) * 111132. / 150.;
153 else {
154 double spacing = INFINITY;
155 for (
int ix = 1; ix < met0->
nx; ix++) {
156 const double dx = fabs(met0->
lon[ix] - met0->
lon[ix - 1]);
157 if (!isfinite(dx) || dx <= 0) {
158 spacing = NAN;
159 break;
160 }
161 spacing =
MIN(spacing, dx);
162 }
163 if (isfinite(spacing))
164 for (
int iy = 1; iy < met0->
ny; iy++) {
165 const double dy = fabs(met0->
lat[iy] - met0->
lat[iy - 1]);
166 if (!isfinite(dy) || dy <= 0) {
167 spacing = NAN;
168 break;
169 }
170 spacing =
MIN(spacing, dy);
171 }
172 dt_rec = spacing / 50.;
173 }
174 if (!isfinite(dt_rec) || dt_rec <= 0) {
176 ("Cannot recommend DT_MOD: invalid horizontal meteo grid spacing!");
177 }
else if (ctl->
dt_mod > dt_rec) {
179 ("DT_MOD=%g s may be too large for accurate trajectory integration; "
180 "recommended maximum from horizontal meteo grid resolution is %g s.",
182 }
183 }
184#ifdef DD
185
188#else
189
193 ("Model configured for domain decomposition, but not compiled for it!");
194#endif
195
196
198#ifdef DD
199 if (ctl->
dd && atm->
np > peak_np)
201#endif
202
203
205 }
206
207
208
209
210
211
212 fflush(NULL);
213
214
215 LOG(1,
"SIZE_NP = %d", atm->
np);
216#ifdef DD
218 LOG(1,
"SIZE_NP_PEAK = %d", peak_np);
219#endif
220 LOG(1,
"SIZE_MPI_TASKS = %d",
size);
221 LOG(1,
"SIZE_OMP_THREADS = %d", omp_get_max_threads());
222
223
224 LOG(1,
"MEMORY_ATM = %g MByte",
sizeof(
atm_t) / 1024. / 1024.);
225 LOG(1,
"MEMORY_CACHE = %g MByte",
sizeof(
cache_t) / 1024. / 1024.);
226 LOG(1,
"MEMORY_DEPO = %g MByte",
sizeof(
depo_t) / 1024. / 1024.);
227 LOG(1,
"MEMORY_CLIM = %g MByte",
sizeof(
clim_t) / 1024. / 1024.);
228 LOG(1,
"MEMORY_METEO = %g MByte",
sizeof(
met_t) / 1024. / 1024.);
229
230
231 mptrac_free(ctl, cache, clim, met0, met1, atm, depo, dd);
232
233
235 }
236
237
238#ifdef MPI
239 MPI_Finalize();
240#endif
241
242 return EXIT_SUCCESS;
243}
void dd_init(const ctl_t *ctl, dd_t *dd, atm_t *atm)
Initialize the domain decomposition infrastructure.
void mptrac_free(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm, depo_t *depo, dd_t *dd)
Frees memory resources allocated for MPTRAC.
void mptrac_write_output(const char *dirname, const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, depo_t *depo, const double t)
Writes various types of output data to files in a specified directory.
void mptrac_get_met(ctl_t *ctl, clim_t *clim, const double t, met_t **met0, met_t **met1, dd_t *dd)
Retrieves meteorological data for the specified time.
void mptrac_read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
void mptrac_init(ctl_t *ctl, cache_t *cache, clim_t *clim, atm_t *atm, depo_t *depo, const int ntask)
Initializes the MPTRAC model and its associated components.
int mptrac_read_atm(const char *filename, const ctl_t *ctl, atm_t *atm)
Reads air parcel data from a specified file into the given atmospheric structure.
void mptrac_alloc(ctl_t **ctl, cache_t **cache, clim_t **clim, met_t **met0, met_t **met1, atm_t **atm, depo_t **depo, dd_t **dd)
Allocates and initializes memory resources for MPTRAC.
void mptrac_run_timestep(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t **met0, met_t **met1, atm_t *atm, depo_t *depo, double t, dd_t *dd)
Executes a single timestep of the MPTRAC model simulation.
void mptrac_read_ctl(const char *filename, int argc, char *argv[], ctl_t *ctl)
Reads control parameters from a configuration file and populates the given structure.
#define LEN
Maximum length of ASCII data lines.
#define MIN(a, b)
Macro to determine the minimum of two values.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define WARN(...)
Print a warning message with contextual information.
#define PRINT_TIMERS
Print the current state of all timers.
#define LOG(level,...)
Print a log message with a specified logging level.
int np
Number of air parcels.
int direction
Direction flag (1=forward calculation, -1=backward calculation).
int dd_supported
Whether the executable implements the domain decomposition.
int dd
Domain decomposition (0=no, 1=yes).
double t_stop
Stop time of simulation [s].
double dt_mod
Time step of simulation [s].
int dd_subdomains_zonal
Domain decomposition zonal subdomain number (defaults to 2 if domain decomposition is used,...
double t_start
Start time of simulation [s].
int dd_subdomains_meridional
Domain decomposition meridional subdomain number (defaults to 2 if domain decomposition is used,...
Domain decomposition data structure.
Ground inventories of deposited radionuclides.
int nx
Number of longitudes.
int ny
Number of latitudes.
double lon[EX]
Longitudes [deg].
double lat[EY]
Latitudes [deg].