Improve mpi buffer allocation in post_process #837
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In the subroutine
s_initialize_mpi_proxy_modulein post_process,q_cons_buffer_inandq_cons_buffer_outare allocated with the sizebuff_size*sys_size*(m + 2*buff_size + 1)*(n + 2*buff_size + 1)*(p + 2*buff_size + 1)/(min(m, n, p)+ 2*buff_size + 1). However, as the Fortran computes the operations sequentially, it could be too large before dividing by(min(m, n, p)+ 2*buff_size + 1).For example, I noticed in a 3D simulation (1023 x 1023 x 511) with method of classes bubbles (
nb = 11) thatbuff_size*sys_size*(m + 2*buff_size + 1)*(n + 2*buff_size + 1)*(p + 2*buff_size + 1)is 6.4242e+10, which is greater than the max value of integer 2^31 - 1 =2.1475e+09. Therefore, it becomes a wrong negative integer value, -2528337, and thus it throws an error.Therefore, I made a quick fix to this by changing the order of operations.
Type of change
Please delete options that are not relevant.
Scope
If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.
How Has This Been Tested?
Checklist
./mfc.sh formatbefore committing my code