Skip to content

xuzhenwu/APPA

Repository files navigation

Automatic Partition-based Parallel Algorithm

Automatic partition-based parallel algorithm (APPA) is a parallel algorithm that helps maximize the performance of parallelization of grid-based distributed models. To use it, you may need an explicit understanding of the grid-based hydrological model that needs parallelization. APPA is still developing. If any question arises, please feel free to contact the developer at xuzhw5@mail2.sysu.edu.cn for further guidance/communication.

Parallelization

Since the current APPA does not support importing local flow direction, users can only use the single flow routing (D8 algorithm) with the first three CPP files to get the flow table generated by the D8 algorithm. Further, we will change the I/O of APPA to make it suitable for other produced single flow direction images. Meanwhile, the source code is now compiled in VS2019. Later, we will move the source code to a single directory.

According to the reference, there are four parameters in APPA, D, xita_s, xita_g, and Tcg. You can keep the parameters or try to modify them.

We also preparing to publish an R package of APPA (in the plan, depending on responses from the community).

Coding practice in modeling

The output of APPA is stored in ".sthread " and ".cthread" files (txt file) to indicate the sub-basin ID and channel unit ID. Specifically, the channel units ID needs to be parsed, as it is composed of layer ID and 3-digit unit ID in that layer. For example, 12056 stands for "layer 12 unit 056". In specific, you can get the two IDs by following equations.

unitID  = inputChannelID % 1000 // get remainder
layerID = (inputChannelID - unitID) / 1000

Here we provide a C++ version of pseudo-code to illustrate the coding practice for models. You can simulate the grid one by one in ithread_grid_array, jlayer_ithread_grid_array in each time scale. For example, recursively run it for daily simulations.

// start of daily simulation
import_grid_array();
import_parallel_images();
    
// hillslope processes 
#pragma omp parallel for schedule (static, 1) num_threads(nthread) 
for (ithread = 0; ithread < nthread; ithread ++) {//nthread is the number of threads
	parallel_hillslope_daily (ithread_grid_array); // grid array that stores addresses of grids
}
// channel processes
for (jlayer = 0; jlayer < nlayer; jlayer++){//nlayer is the number of layers
	#pragma omp parallel for schedule (static, 1) num_threads(nthread) 
	for (ithread = 0; ithread < nthread; ithread ++) {//nthread is the number of threads
		parallel_channel_daily(jlayer_ithread_grid_array);// grid array that stores addresses of grids
	} 
}
// end of daily simluation

References

Xu, Z., Tang, G., Jiang, T., Chen, X., Chen, T., & Niu, X. (2021). An automatic partition-based parallel algorithm for grid-based distributed hydrological models. Environmental Modelling & Software, 144, 105142. https://doi.org/10.1016/j.envsoft.2021.105142

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published