-
Notifications
You must be signed in to change notification settings - Fork 114
Metapackage for NetCDF #1120
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
Merged
Merged
Metapackage for NetCDF #1120
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8b75096
Added NetCDF metapackage
krystophny 8c28594
Testing NetCDF
krystophny 97d9dfd
GitHub CI for NetCDF test
krystophny 5dd6013
clean: remove output and unused import
krystophny 0c792c2
Merge branch 'fortran-lang:main' into metapackage_netcdf
krystophny 06a3893
clean: remove unused variables
krystophny 7fbaac1
Modern syntax, output error
krystophny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,17 @@ on: | |
# On push, only run if any of the metapackage files has changed | ||
push: | ||
paths: | ||
- 'src/*meta*.f90' | ||
- 'src/*meta*.f90' | ||
- 'src/fpm/*meta*.f90' | ||
- 'src/fpm/manifest/*meta*.f90' | ||
- 'src/ci/meta_tests.sh' | ||
- 'src/.github/workflows/meta.yml' | ||
# Always run on PR or release | ||
# Always run on PR or release | ||
pull_request: | ||
release: | ||
types: [published] | ||
# Allow manual triggering | ||
workflow_dispatch: | ||
workflow_dispatch: | ||
|
||
env: | ||
CI: "ON" # We can detect this in the build system and other vendors implement it | ||
|
@@ -51,7 +51,7 @@ jobs: | |
|
||
- name: (Ubuntu/macOS) setup gcc version | ||
if: contains(matrix.os,'ubuntu') || contains(matrix.os,'macos') | ||
run: | | ||
run: | | ||
echo "GCC_V=14" >> $GITHUB_ENV | ||
|
||
- name: (Windows) Install MSYS2 | ||
|
@@ -67,6 +67,8 @@ jobs: | |
unzip | ||
curl | ||
hdf5 | ||
netcdf | ||
netcdf-fortran | ||
|
||
- name: (Windows) Setup VS Build environment | ||
if: contains(matrix.os,'windows') && contains(matrix.mpi,'intel') | ||
|
@@ -84,7 +86,7 @@ jobs: | |
Remove-Item "oneAPI" -Force -Recurse | ||
|
||
- name: (Ubuntu) Install gfortran | ||
if: contains(matrix.os,'ubuntu') | ||
if: contains(matrix.os,'ubuntu') | ||
run: | | ||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \ | ||
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \ | ||
|
@@ -94,13 +96,15 @@ jobs: | |
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'openmpi') | ||
run: | | ||
sudo apt-get update | ||
sudo apt install -y -q openmpi-bin libopenmpi-dev hwloc fabric libhdf5-dev libhdf5-fortran-102 | ||
sudo apt install -y -q openmpi-bin libopenmpi-dev hwloc fabric libhdf5-dev \ | ||
libhdf5-fortran-102 libnetcdf-dev libnetcdff-dev | ||
|
||
- name: (Ubuntu) Install MPICH | ||
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'mpich') | ||
run: | | ||
sudo apt-get update | ||
sudo apt install -y -q mpich hwloc fabric libhdf5-dev libhdf5-fortran-102 | ||
sudo apt install -y -q mpich hwloc fabric libhdf5-dev libhdf5-fortran-102 \ | ||
libnetcdf-dev libnetcdff-dev | ||
|
||
- name: (Ubuntu) Retrieve Intel toolchain | ||
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel') | ||
|
@@ -115,16 +119,16 @@ jobs: | |
uses: fortran-lang/[email protected] | ||
id: setup-fortran | ||
with: | ||
compiler: intel | ||
version: 2024.1.0 | ||
compiler: intel | ||
version: 2024.1.0 | ||
|
||
- name: (Ubuntu) finalize oneAPI environment | ||
- name: (Ubuntu) finalize oneAPI environment | ||
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel') | ||
run: | | ||
# Install MPI | ||
sudo apt-get install -y -q intel-oneapi-mpi-devel ninja-build cmake | ||
sudo apt-get install -y -q intel-oneapi-mpi-devel ninja-build cmake libcurl4-gnutls-dev | ||
source /opt/intel/oneapi/setvars.sh --force | ||
printenv >> $GITHUB_ENV | ||
printenv >> $GITHUB_ENV | ||
# To run HDF5 with oneAPI, we need to build it from source. Use CMake to generate pkg-config info | ||
curl -O -L https://github.com/HDFGroup/hdf5/archive/refs/tags/snapshot-1.14.tar.gz | ||
tar zxf snapshot-1.14.tar.gz | ||
|
@@ -133,6 +137,17 @@ jobs: | |
cd build | ||
make -j | ||
sudo make install | ||
curl -L https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz -o - | tar xz | ||
cd netcdf-c-4.9.2 | ||
CC=icx CXX=icpx FC=ifx ./configure --prefix=/usr --with-hdf5=/usr | ||
CC=icx CXX=icpx FC=ifx make -j | ||
sudo make install | ||
curl -L https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz -o - | tar xz | ||
cd netcdf-fortran-4.6.1 | ||
cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_INSTALL_PREFIX=/usr | ||
cd build | ||
make -j | ||
sudo make install | ||
|
||
- name: (Windows) Put MSYS2_MinGW64 on PATH | ||
if: contains(matrix.os,'windows') && (!contains(matrix.mpi,'intel')) | ||
|
@@ -214,8 +229,14 @@ jobs: | |
|
||
- name: (macOS) Install homebrew HDF5 | ||
if: contains(matrix.os,'macos') | ||
run: | | ||
brew install hdf5 | ||
run: | | ||
brew install hdf5 | ||
|
||
- name: (macOS) Install homebrew NetCDF | ||
if: contains(matrix.os,'macos') | ||
run: | | ||
brew install netcdf | ||
brew install netcdf-fortran | ||
|
||
# Phase 1: Bootstrap fpm with existing version | ||
- name: Install fpm | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
program metapackage_netcdf | ||
use netcdf4_f03 | ||
implicit none | ||
|
||
integer(c_int) :: ncid, retval | ||
integer(c_int) :: ncsize = 16 | ||
character(c_char), allocatable, target :: memfile(:) | ||
|
||
allocate (memfile(ncsize)) | ||
|
||
retval = nf_create("dummy.nc", NF_INMEMORY, ncid) | ||
if (retval .ne. nf_noerr) error stop | ||
krystophny marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
stop 0 | ||
end program metapackage_netcdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name = "metapackage_netcdf" | ||
dependencies.netcdf="*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module fpm_meta_netcdf | ||
use fpm_compiler, only: compiler_t, get_include_flag | ||
use fpm_meta_base, only: metapackage_t, destroy | ||
use fpm_meta_util, only: add_pkg_config_compile_options | ||
use fpm_pkg_config, only: assert_pkg_config, pkgcfg_has_package | ||
use fpm_strings, only: string_t | ||
use fpm_error, only: error_t, fatal_error | ||
|
||
implicit none | ||
|
||
private | ||
|
||
public :: init_netcdf | ||
|
||
contains | ||
|
||
!> Initialize NetCDF metapackage for the current system | ||
subroutine init_netcdf(this, compiler, error) | ||
class(metapackage_t), intent(inout) :: this | ||
type(compiler_t), intent(in) :: compiler | ||
type(error_t), allocatable, intent(out) :: error | ||
|
||
logical :: s | ||
character(len=:), allocatable :: include_flag, libdir | ||
|
||
include_flag = get_include_flag(compiler, "") | ||
|
||
!> Cleanup | ||
call destroy(this) | ||
allocate (this % link_libs(0), this % incl_dirs(0), this % external_modules(0)) | ||
this % link_flags = string_t("") | ||
this % flags = string_t("") | ||
|
||
!> Assert pkg-config is installed | ||
if (.not. assert_pkg_config()) then | ||
call fatal_error(error, 'netcdf metapackage requires pkg-config') | ||
return | ||
end if | ||
|
||
if (.not. pkgcfg_has_package('netcdf')) then | ||
call fatal_error(error, 'pkg-config could not find a suitable netcdf package.') | ||
end if | ||
call add_pkg_config_compile_options(this, 'netcdf', include_flag, libdir, error) | ||
if (allocated(error)) return | ||
|
||
if (.not. pkgcfg_has_package('netcdf-fortran')) then | ||
call fatal_error(error, & | ||
'pkg-config could not find a suitable netcdf-fortran package.') | ||
end if | ||
call add_pkg_config_compile_options(this, 'netcdf-fortran', include_flag, libdir, error) | ||
if (allocated(error)) return | ||
|
||
!> Add NetCDF modules as external | ||
this % has_external_modules = .true. | ||
this % external_modules = [string_t('netcdf'), & | ||
string_t('netcdf4_f03'), & | ||
string_t('netcdf4_nc_interfaces'), & | ||
string_t('netcdf4_nf_interfaces'), & | ||
string_t('netcdf_f03'), & | ||
string_t('netcdf_fortv2_c_interfaces'), & | ||
string_t('netcdf_nc_data'), & | ||
string_t('netcdf_nc_interfaces'), & | ||
string_t('netcdf_nf_data'), & | ||
string_t('netcdf_nf_interfaces')] | ||
end subroutine init_netcdf | ||
end module fpm_meta_netcdf |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.