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

Fix test_read_input_nml2 failure and test_diag_update_buffer.F90 seg fault : Cray #1302

Merged
merged 4 commits into from
Aug 4, 2023

Conversation

laurenchilutti
Copy link
Contributor

@laurenchilutti laurenchilutti commented Jul 26, 2023

Description

Cray uses an IOSTAT of -4001 for end of file while other compilers typically use -1. Because of this, the do loop (shown below) will not exit on the condition if (stat.eq.-1) at Line 71

n = 1
do
read(1, '(A)', iostat=stat) line
if (stat.eq.-1) then
exit
end if
if (input_nml_file(n).ne.line) then
call mpp_error(FATAL, "data resident in ./input.nml does not match&
& that read into input_nml_file by read_input_nml")
end if
n = n + 1
end do

To fix: I took the approach seen in fortran standards (section 12.11.5 in the J3/23-007draft spec) and replaced if (stat.eq.-1) with if (stat < 0) to check for end of file and exit loop.

I also noticed that the tests were not matching the description here:

! Test 1: Tests the subroutine on a valid input nml full of data,
! with no arguments passed to read_input_nml()
! Test 2: Tests the subroutine on a valid input nml full of data,
! with a string passed to read_input_nml() in order to read a different nml
! Test 4: Tests the subroutine on a valid empty input nml,
! with no arguments passed to read_input_nml()

Previously, test 1 was reading a blank input.nml and test 2 was reading a blank input_alternate.nml. I have modified this so that there is data inside of input.nml and input_alternate.nml. Test 4 still tests a blank nml with the name input_blank.nml

Cray was failing to compile test_diag_update_buffer.F90 because of the 1 at the beginning of line 289

field(i,j,k,l) = get_array_index_from_4D(i,j,k,l,NX,NY,NZ)
1 TYPE IS (integer(kind=i8_kind))
field(i,j,k,l) = get_array_index_from_4D(i,j,k,l,NX,NY,NZ)

I have removed the 1 and refactored the code a little bit - I am open to feedback on the changes I made and will undo if they are not helpful.

Fixes #1300

How Has This Been Tested?
make and make check on
C5
cce/15.0.1
cray-hdf5/1.12.2.3
cray-netcdf/4.9.0.3

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 changed the title Fix MPP test_read_input_nml2 test for Cray Fix MPP test_read_input_nml2 failure and test_diag_update_buffer.F90 - Seg fault during build: Cray Jul 26, 2023
@laurenchilutti laurenchilutti changed the title Fix MPP test_read_input_nml2 failure and test_diag_update_buffer.F90 - Seg fault during build: Cray Fix test_read_input_nml2 failure and test_diag_update_buffer.F90 seg fault : Cray Jul 26, 2023
@rem1776 rem1776 merged commit 6b699a1 into NOAA-GFDL:main Aug 4, 2023
18 checks passed
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_read_input_nml2 fail and test_diag_update_buffer.F90 segfault : Cray
4 participants