Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpp_check_field fix for test_mpp_domains2 #1292

Merged
merged 3 commits into from
Aug 8, 2023

Conversation

laurenchilutti
Copy link
Contributor

@laurenchilutti laurenchilutti commented Jul 19, 2023

Description
The test_mpp_domains2 test fails at line 234 in mpp_update_domains.fh with a seg fault. Tracking through the backtrace of this error (you can see the full backtrace in issue #1290) I think I have found the root cause:

In file mpp_domains_misc.inc subroutine mpp_check_field_2d_type2 we call mpp_redistribute at line 426 with the following arguments:

call mpp_redistribute(domain1,field_in,domain2,field1)

Because field1 and field2 are 2D arrays, mpp_redistribute will use the subroutine MPP_REDISTRIBUTE_2D_ from mpp_update_domains2D.fh

field1 in mpp_check_field_2d_type2 is field_out in MPP_REDISTRIBUTE_2D_ and the program fails when we try to set

I think that this is happening because field1 was only allocated on pelist2 but mpp_redistribute is called from all pes . So pes from pelist1 will not have allocated field1.

! Comparison is made on pelist2.
if(any(pelist2 == pe)) then
call mpp_get_data_domain(domain2, isd, ied, jsd, jed)
call mpp_get_compute_domain(domain2, is, ie, js, je)
allocate(field1(isd:ied, jsd:jed),field2(isd:ied, jsd:jed))
if((size(field_in,1) .ne. ied-isd+1) .or. (size(field_in,2) .ne. jed-jsd+1)) &
call mpp_error(FATAL,'mpp_check_field: input field is not on the data domain')
field2(isd:ied, jsd:jed) = field_in(:,:)
endif

The solution I propose in this PR is to allocate field1 outside of the if(any(pelist2 == pe)) condition so that all pes allocate.

Fixes #1290

How Has This Been Tested?
Tested with GCC 13.1.0 on GFDL dev box with openmpi make and make check

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@laurenchilutti laurenchilutti marked this pull request as ready for review July 19, 2023 17:45
mpp/include/mpp_domains_misc.inc Outdated Show resolved Hide resolved
mpp/include/mpp_domains_misc.inc Outdated Show resolved Hide resolved
@laurenchilutti
Copy link
Contributor Author

This also fixes Issue #1101

@rem1776 rem1776 merged commit 01d73fb into NOAA-GFDL:main Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_mpp_domains2 check_parallal fails with GCC 12 and 13
3 participants