47 char dirname[
LEN], filename[2 *
LEN];
49 int ntask = -1, rank = 0, size = 1;
57 MPI_Init(&argc, &argv);
58 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
59 MPI_Comm_size(MPI_COMM_WORLD, &size);
64 ERRMSG(
"Give parameters: <dirlist> <ctl> <atm_in>");
67 if (!(dirlist = fopen(argv[1],
"r")))
68 ERRMSG(
"Cannot open directory list!");
71 while (fscanf(dirlist,
"%4999s", dirname) != EOF) {
74 if ((++ntask) % size != rank)
86 acc_device_t device_type = acc_get_device_type();
87 LOG(1,
"Parallelization: ntask= %d | rank= %d | size= %d | acc_dev= %d",
88 ntask, rank, size, acc_get_device_num(device_type));
90 LOG(1,
"Parallelization: ntask= %d | rank= %d | size= %d | acc_dev= nan",
95 sprintf(filename,
"%s/%s", dirname, argv[2]);
102 sprintf(filename,
"%s/%s", dirname, argv[3]);
104 ERRMSG(
"Cannot open file!");
116 if (ctl->
dt_mod > fabs(met0->
lon[1] - met0->
lon[0]) * 111132. / 150.)
117 WARN(
"Violation of CFL criterion! Check DT_MOD!");
132#pragma acc update device(atm[:1], cache[:1], clim[:1], ctl[:1])
163 LOG(1,
"SIZE_NP = %d", atm->
np);
164 LOG(1,
"SIZE_MPI_TASKS = %d", size);
165 LOG(1,
"SIZE_OMP_THREADS = %d", omp_get_max_threads());
167 LOG(1,
"SIZE_ACC_DEVICES = %d", acc_get_num_devices(acc_device_nvidia));
169 LOG(1,
"SIZE_ACC_DEVICES = %d", 0);
173 LOG(1,
"MEMORY_ATM = %g MByte",
sizeof(
atm_t) / 1024. / 1024.);
174 LOG(1,
"MEMORY_CACHE = %g MByte",
sizeof(
cache_t) / 1024. / 1024.);
175 LOG(1,
"MEMORY_CLIM = %g MByte",
sizeof(
clim_t) / 1024. / 1024.);
176 LOG(1,
"MEMORY_METEO = %g MByte",
sizeof(
met_t) / 1024. / 1024.);
void mptrac_alloc(ctl_t **ctl, cache_t **cache, clim_t **clim, met_t **met0, met_t **met1, atm_t **atm)
Allocates and initializes memory resources for MPTRAC.
void get_met(ctl_t *ctl, clim_t *clim, const double t, met_t **met0, met_t **met1)
Retrieves meteorological data for the specified time.
void module_chem_init(const ctl_t *ctl, const clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Initializes the chemistry modules by setting atmospheric composition.
void module_timesteps_init(ctl_t *ctl, const atm_t *atm)
Initialize start time and time interval for time-stepping.
void module_isosurf_init(const ctl_t *ctl, cache_t *cache, met_t *met0, met_t *met1, atm_t *atm)
Initialize the isosurface module based on atmospheric data.
void module_advect_init(const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm)
Initializes the advection module by setting up pressure fields.
void module_rng_init(const int ntask)
Initialize random number generators for parallel tasks.
void mptrac_free(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t *met0, met_t *met1, atm_t *atm)
Frees memory resources allocated for MPTRAC.
void write_output(const char *dirname, const ctl_t *ctl, met_t *met0, met_t *met1, atm_t *atm, const double t)
Writes various types of output data to files in a specified directory.
void read_ctl(const char *filename, int argc, char *argv[], ctl_t *ctl)
Reads control parameters from a configuration file and populates the given structure.
void mptrac_run_timestep(ctl_t *ctl, cache_t *cache, clim_t *clim, met_t **met0, met_t **met1, atm_t *atm, double t)
Executes a single timestep of the MPTRAC model simulation.
int 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 read_clim(const ctl_t *ctl, clim_t *clim)
Reads various climatological data and populates the given climatology structure.
MPTRAC library declarations.
#define LEN
Maximum length of ASCII data lines.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define WARN(...)
Print a warning message with contextual information.
#define START_TIMERS
Starts a timer for tracking.
#define SELECT_TIMER(id, group, color)
Select and start a timer with specific attributes.
#define PRINT_TIMERS
Print the current state of all timers.
#define LOG(level,...)
Print a log message with a specified logging level.
#define STOP_TIMERS
Stop the current timer.
int np
Number of air parcels.
int direction
Direction flag (1=forward calculation, -1=backward calculation).
int isosurf
Isosurface parameter (0=none, 1=pressure, 2=density, 3=theta, 4=balloon).
double t_stop
Stop time of simulation [s].
double dt_mod
Time step of simulation [s].
double t_start
Start time of simulation [s].
double lon[EX]
Longitude [deg].
int main(int argc, char *argv[])