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

Allow using the SMIOL I/O library when building with cmake. #1254

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jim-p-w
Copy link
Contributor

@jim-p-w jim-p-w commented Dec 19, 2024

This PR removes the restriction of only using the PIO I/O library when building with cmake.

The default behavior will build using PIO.
In order to build and use the SMIOL I/O library provide -DMPAS_USE_SMIOL=1 on the command line when running cmake.

Test run include the mpasjedi ctests, as well as the MPAS-Workflow cylc tests:
3dvar_OIE120km_WarmStart_TEST/
3dvar_OIE120km_ColdStart_TEST/
3dvar_O30kmIE60km_ColdStart_TEST/
3denvar_O30kmIE60km_WarmStart_TEST/
4denvar_OIE120km_WarmStart_TEST/
4dhybrid_OIE120km_WarmStart_TEST/
eda_OIE120km_WarmStart_TEST/
getkf_OIE120km_WarmStart_TEST/
ForecastFromGFSAnalysesMPT_TEST/
3denvar_OIE120km_IAU_WarmStart_TEST/

  • this test fail with:
ERROR: SMIOLf_open_file failed with error -5
ERROR: NetCDF: Attempt to use feature that was not turned on when netCDF was built.

because the test tries to read an HDF5 data file.

@amstokely
Copy link
Contributor

Have you run any tests, that are easily reproducible, to test these changes? It would be interesting to see if the same problem in PR 1234 occurs when using SMIOL.

@@ -59,7 +61,9 @@ find_package(OpenMP COMPONENTS Fortran)
find_package(MPI REQUIRED COMPONENTS Fortran)
find_package(NetCDF REQUIRED COMPONENTS Fortran C)
find_package(PnetCDF REQUIRED COMPONENTS Fortran)
find_package(PIO REQUIRED COMPONENTS Fortran C)
if(NOT MPAS_USE_SMIOL)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't seem to work. When I build with -DMPAS_USE_SMIOL=1 the cmake output still has:

-- Found PIO: /glade/work/epicufsrt/contrib/spack-stack/derecho/spack-stack-1.6.0/envs/unified-env/install/gcc/12.2.0/parallelio-2.5.10-ysh2ljm  found components: Fortran C 
-- FindPIO:
--   - PIO_PREFIX [/glade/work/epicufsrt/contrib/spack-stack/derecho/spack-stack-1.6.0/envs/unified-env/install/gcc/12.2.0/parallelio-2.5.10-ysh2ljm]
--   - PIO Components Found: Fortran;C;SHARED

as well as

-- The following REQUIRED packages have been found:
...
 * PIO

@mgduda mgduda requested review from amstokely, mgduda and islas December 19, 2024 18:47
@jim-p-w jim-p-w changed the base branch from hotfix-v8.2.3 to develop December 19, 2024 20:38
)
if(MPAS_USE_SMIOL)
set(MPAS_FORTRAN_TARGET_COMPILE_DEFINITIONS
_MPI=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we might want to split out common defines and only set relevant ones within the respective if() check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the common defines out of this if/then clauses.

@@ -0,0 +1,32 @@

cmake_minimum_required(VERSION 3.10)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is necessary, especially as parts of this file inherently rely on early parts of the CMake build so this wouldn't be able to be run standalone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the cmake_minimum_required.

find_package(PnetCDF REQUIRED COMPONENTS Fortran C)

# Specify the library source files
set(SMIOL_C_SOURCES smiol.c smiol_utils.c)
Copy link
Contributor

Choose a reason for hiding this comment

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

SMIOL_C_SOURCES and SMIOLF_SOURCES don't quite follow the same naming convention. Doesn't matter too much, but it might be nice to align the two. My understanding is SMIOLF_SOURCES is meant to be effectively, <TARGET_NAME>_SOURCES and follow the Makefile target name. SMIOL_SOURCES for the C sources follows that same convention, though it does look more ambiguous than the _C_ one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean change SMIOLF_SOURCES to SMIOL_F_SOURCES?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that would also work, but in keeping with the <TARGET_NAME>_SOURCES I propose SMIOL_C_SOURCES => SMIOL_SOURCES. If that's too ambiguous of a variable name, then yes exactly what you said instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to leave the explicit C naame, esp as c sources are rare.

if (MPAS_USE_SMIOL)
set(FRAMEWORK_COMPILE_DEFINITIONS
MPAS_SMIOL_SUPPORT
mpas=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as before, I think breaking out common defines would be good, leaving only the specifics within the conditional branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the common defines out of this if/then clauses.

enable_language(Fortran)
mpas_fortran_target(smiolf)
add_library(${PROJECT_NAME}::external::smiolf ALIAS smiolf)
target_compile_definitions(smiolf PRIVATE SMIOL_PNETCDF )
Copy link
Contributor

Choose a reason for hiding this comment

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

When compiling this branch on my local machine, the build fails because the smiol target cannot find mpi.h. I attached the build log for reference.
log.make.txt
The issue is resolved by adding target_include_directories(smiol PRIVATE ${MPI_INCLUDE_PATH}) after target_compile_definitions(smiol PRIVATE SMIOL_PNETCDF SINGLE_PRECISION).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for testing and finding this.

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.

3 participants