Skip to content

Conversation

@hyeoksu-lee
Copy link
Contributor

@hyeoksu-lee hyeoksu-lee commented May 15, 2025

Description

In the subroutine s_initialize_mpi_proxy_module in post_process, q_cons_buffer_in and q_cons_buffer_out are allocated with the size buff_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) that buff_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.

  • Bug fix (non-breaking change which fixes an issue)

Scope

  • This PR comprises a set of related changes with a common goal

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?

  • Large 3D simulation (1023 x 1023 x 511, sys_size = 29)
  • What computers and compilers did you use to test this: Carpenter

Checklist

  • I ran ./mfc.sh format before committing my code
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

@hyeoksu-lee hyeoksu-lee requested a review from a team as a code owner May 15, 2025 05:53
@sbryngelson
Copy link
Member

Good find. There's actually a "better" way of doing this by making them floating point additions/multiplies then turning the result into the nearest integer. @wilfonba can you incorporate this fix into your MPI PR?

@codecov
Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 43.09%. Comparing base (40164cf) to head (518a645).

Files with missing lines Patch % Lines
src/post_process/m_mpi_proxy.fpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #837      +/-   ##
==========================================
- Coverage   43.15%   43.09%   -0.07%     
==========================================
  Files          68       68              
  Lines       20262    20262              
  Branches     2424     2427       +3     
==========================================
- Hits         8745     8731      -14     
- Misses      10054    10071      +17     
+ Partials     1463     1460       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wilfonba
Copy link
Collaborator

wilfonba commented May 15, 2025

A fix for this problem is already in the MPI refactor PR (and this code in post-process is removed in favor of a common module) .https://github.com/wilfonba/MFC-Wilfong/blob/6448b3701fa44700b99955107ddb27f961ce5749/src/common/m_mpi_common.fpp#L54-L81
I'll hopefully have time to finish up the necessary manual checks for that PR this weekend once I get back to Atlanta.

@hyeoksu-lee
Copy link
Contributor Author

@sbryngelson @wilfonba Sounds great. I will close this PR then. Thanks!

@hyeoksu-lee hyeoksu-lee deleted the post-mpi-buffer branch May 16, 2025 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants