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

Improve NetCDF detection and linking #1923

Conversation

rjdave
Copy link
Contributor

@rjdave rjdave commented Oct 12, 2023

TYPE: enhancement

KEYWORDS: NetCDF4, Spack-Stack, gfortran

SOURCE: David Robertson, Rutgers University

DESCRIPTION OF CHANGES:
Problem:

  • NetCDF4 detection and linking is unreliable and impossible if NetCDF-C and NetCDF-Fortran reside in different directories
  • gfortran is intolerant of non-initialized variables in mediation_integrate.F.

Solution:

  • Refactor the detection and configuration of NetCDF dependencies and add the capability to use NetCDF-C and NetCDF-Fortran libraries that don't reside in the same directory by introducing a new variable for the NetCDF-C path.
  • The fname and n2 intent(out) variables are not assigned under certain circumstances so we should initialize them to empty strings.
   ierr = 0
   fname = ""
   n2 = ""

   ! Note that computation of fname and n2 are outside of the oid IF statement

LIST OF MODIFIED FILES: list of changed files (used git diff --name-status release-v4.5.2 to get formatted list)

M       Makefile
M       arch/Config.pl
M       arch/postamble
M       arch/preamble
M       configure
M       share/mediation_integrate.F

TESTS CONDUCTED:

  1. Compiled and ran with several different configurations of NetCDF, including both shared and static versions of both split (NetCDF-C and NetCDF-Fortran in separate directories) and unified library locations. The shared library versions were from Spack-Stack; the static libraries were custom-built for my systems.
  2. Ran the coupled WRF-ROMS standard test case for Hurricane Irene.
  3. The Jenkins tests are all passing.

RELEASE NOTE: This PR improve the detection and linking with shared and static configurations of the NetCDF-4 libraries (split or unified) inside and outside Spack-Stack.

@rjdave rjdave requested a review from a team as a code owner October 12, 2023 19:01
@weiwangncar
Copy link
Collaborator

The results of regression tests:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

@rjdave rjdave requested a review from a team as a code owner October 13, 2023 19:09
@rjdave
Copy link
Contributor Author

rjdave commented Oct 13, 2023

Moved minor variable initialization in share/mediation_integrate.F into this PR from #1924 as requested.

Should I add the notes about share/mediation_integrate.F to the original PR above and remove from #1924?

Hopefully splitting these PRs as requested multiple times will finally get these necessary changes into WRF and help broaden the environments WRF can be compiled under.

@weiwangncar
Copy link
Collaborator

@rjdave Thanks for adding the two line change here. Yes, please add relevant info to this PR.

@weiwangncar
Copy link
Collaborator

@islas Can you review this PR and recommend if it should be included in 4.5.2 release. Thanks!

configure Outdated
@@ -918,7 +882,7 @@ EOF
echo " Fortran compiler is $SFC_arch"
echo " It will build in $netcdf_arch"
echo " "
if [ -e $NETCDF/bin/nc-config ] ; then
if [ -e $NETCDF_C/bin/nc-config ] ; then
echo "NetCDF version: ${ncversion}"
echo "Enabled NetCDF-4/HDF-5: `nc-config --has-nc4`"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will output the results from the wrong nc-config if $NETCDF_C differs from default in PATH

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these changes resolve #1742 and having consistent usage of nf-config and nc-config fall under the aim of this PR

Pinging @wkliao to be aware that this should be the PR that resolves issues noted in #1742

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I missed that one. I will push the appropriate change in a few minutes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these changes resolve #1742 and having consistent usage of nf-config and nc-config fall under the aim of this PR

Pinging @wkliao to be aware that this should be the PR that resolves issues noted in #1742

If this PR #1923 resolved issues raised by PR #1742 and beyond, then #1742 can be closed. Given #1742 was created 1 and 1/2 years ago, I wonder if there is anything it missed, so it could not be merged.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the primary thing #1742 did not have was the ability to use both nf-config and nc-config for different library link info. This probably wasn't a high priority then, but netCDF's shift to split the two programs even further as of v4.9.2 will soon be problematic for WRF's current make builds. (see Unidata/netcdf-c#2619 and Unidata/netcdf-c v4.9.2 release notes)

@islas
Copy link
Collaborator

islas commented Oct 24, 2023

@islas Can you review this PR and recommend if it should be included in 4.5.2 release. Thanks!

Definitely something to include with 4.5.2 as the latest releases of netCDF further separate nc-config and nf-config, thus builds should aim to follow suit

islas
islas previously approved these changes Oct 27, 2023
weiwangncar
weiwangncar previously approved these changes Dec 8, 2023
@weiwangncar
Copy link
Collaborator

@rjdave Can you add weiwangncar as your collaborator? We need to resolve a code conflict when merging your code into the repository. Thanks.

@rjdave
Copy link
Contributor Author

rjdave commented Dec 8, 2023

@rjdave Can you add weiwangncar as your collaborator? We need to resolve a code conflict when merging your code into the repository. Thanks.

I will have to see if we have any spare slots since this is in an organization and not my personal GitHub.

@islas
Copy link
Collaborator

islas commented Dec 8, 2023

I will have to see if we have any spare slots since this is in an organization and not my personal GitHub.

There should be an option on the pull request to "Allow edits by maintainers", if not resolving the merge conflict within your repo should be doable as well. The option should be on the righthand column of the PR below all the reviewers, assignees, labels, and notifications.

@weiwangncar
Copy link
Collaborator

@rjdave If you prefer, you can make the change as it is in PR-1743. It is a one line change for line # 1072 in Makefile.

@rjdave
Copy link
Contributor Author

rjdave commented Dec 11, 2023

I see that adding [ -z "$(USENETCDFPAR)" ] || to my if line will resolve the conflict. However, I'm not entirely sure why I have double quotes around $(NETCDF4_DEP_LIB) for a false USENETCDFPAR but not when USENETCDFPAR is true, Let me see if configure completes without the quotes. If not, they will almost certainly be necessary in the else as well. Is it best to make the necessary "quotes" changes with the "Resolve conflicts" button here in this PR or should I commit the changes to my feature branch?

@weiwangncar
Copy link
Collaborator

@rjdave When you use the 'Resolve Conflicts' button to make a change, the change will be committed to your feature branch.

@rjdave rjdave dismissed stale reviews from weiwangncar and islas via ee2889e December 12, 2023 01:50
@weiwangncar
Copy link
Collaborator

The latest regression test results:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

@weiwangncar
Copy link
Collaborator

weiwangncar commented Dec 12, 2023

@islas Since this PR has been updated, it requires your review again. Specifically it removed quotes from the next line. Thanks.

@weiwangncar
Copy link
Collaborator

@islas Are you ok with this PR? Thanks!

@weiwangncar weiwangncar merged commit bb406d2 into wrf-model:release-v4.5.2 Dec 16, 2023
@rjdave rjdave deleted the feature/improve_netcdf4_detection_and_linking branch January 3, 2024 15:20
vlakshmanan-scala pushed a commit to scala-computing/WRF that referenced this pull request Apr 4, 2024
TYPE: enhancement

KEYWORDS: NetCDF4, Spack-Stack, gfortran

SOURCE: David Robertson, Rutgers University

DESCRIPTION OF CHANGES:
Problem:

- NetCDF4 detection and linking is unreliable and impossible if NetCDF-C and NetCDF-Fortran reside in different directories
- gfortran is intolerant of non-initialized variables in **`mediation_integrate.F`**.

Solution:
- Refactor the detection and configuration of NetCDF dependencies and add the capability to use NetCDF-C and NetCDF-Fortran libraries that don't reside in the same directory by introducing a new variable for the NetCDF-C path.
 -  The **fname** and **n2**  `intent(out)` variables are not assigned under certain circumstances so we should initialize them to empty strings.
``` 
   ierr = 0
   fname = ""
   n2 = ""

   ! Note that computation of fname and n2 are outside of the oid IF statement
```     

LIST OF MODIFIED FILES: list of changed files (used `git diff --name-status release-v4.5.2` to get formatted list)
```
M       Makefile
M       arch/Config.pl
M       arch/postamble
M       arch/preamble
M       configure
M       share/mediation_integrate.F
```
TESTS CONDUCTED: 
1. Compiled and ran with several different configurations of NetCDF, including both shared and static versions of both split (NetCDF-C and NetCDF-Fortran in separate directories) and unified library locations. The shared library versions were from Spack-Stack; the static libraries were custom-built for my systems.
2. Ran the coupled WRF-ROMS standard test case for Hurricane Irene.
3. The Jenkins tests are all passing.

RELEASE NOTE: This PR improve the detection and linking with shared and static configurations of the NetCDF-4 libraries (split or unified) inside and outside Spack-Stack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants