Skip to content

Commit 8c28594

Browse files
committed
Testing NetCDF
1 parent 8b75096 commit 8c28594

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

ci/meta_tests.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,22 @@ pushd metapackage_minpack
3333
popd
3434

3535
pushd metapackage_mpi
36-
"$fpm" build --verbose
36+
"$fpm" build --verbose
3737
"$fpm" run --verbose
3838
popd
3939

4040
pushd metapackage_mpi_c
41-
"$fpm" build --verbose
41+
"$fpm" build --verbose
4242
"$fpm" run --verbose
4343
popd
4444

4545
pushd metapackage_hdf5
46-
"$fpm" build --verbose
46+
"$fpm" build --verbose
47+
"$fpm" run --verbose
48+
popd
49+
50+
pushd metapackage_netcdf
51+
"$fpm" build --verbose
4752
"$fpm" run --verbose
4853
popd
4954

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
program metapackage_netcdf
2+
use netcdf4_f03
3+
implicit none
4+
5+
integer(c_int) :: ncid, retval
6+
integer(c_int) :: ncsize = 16
7+
character(c_char), allocatable, target :: memfile(:)
8+
9+
allocate (memfile(ncsize))
10+
11+
retval = nf_create("dummy.nc", NF_INMEMORY, ncid)
12+
if (retval .ne. nf_noerr) error stop
13+
stop 0
14+
end program metapackage_netcdf
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = "metapackage_netcdf"
2+
dependencies.netcdf="*"

src/metapackage/fpm_meta_netcdf.f90

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,56 @@ module fpm_meta_netcdf
1212

1313
public :: init_netcdf
1414

15-
contains
15+
contains
1616

1717
!> Initialize NetCDF metapackage for the current system
18-
subroutine init_netcdf(this,compiler,error)
18+
subroutine init_netcdf(this, compiler, error)
1919
class(metapackage_t), intent(inout) :: this
2020
type(compiler_t), intent(in) :: compiler
2121
type(error_t), allocatable, intent(out) :: error
2222

2323
logical :: s
2424
character(len=:), allocatable :: include_flag, libdir
2525

26-
include_flag = get_include_flag(compiler,"")
26+
include_flag = get_include_flag(compiler, "")
2727

2828
!> Cleanup
2929
call destroy(this)
30-
allocate(this%link_libs(0),this%incl_dirs(0),this%external_modules(0))
31-
this%link_flags = string_t("")
32-
this%flags = string_t("")
30+
allocate (this % link_libs(0), this % incl_dirs(0), this % external_modules(0))
31+
this % link_flags = string_t("")
32+
this % flags = string_t("")
3333

3434
!> Assert pkg-config is installed
35-
if (.not.assert_pkg_config()) then
35+
if (.not. assert_pkg_config()) then
3636
call fatal_error(error, 'netcdf metapackage requires pkg-config')
3737
return
3838
end if
3939

4040
if (.not. pkgcfg_has_package('netcdf')) then
41-
call fatal_error(error,'pkg-config could not find a suitable netcdf package.')
41+
call fatal_error(error, 'pkg-config could not find a suitable netcdf package.')
4242
end if
4343
call add_pkg_config_compile_options(this, 'netcdf', include_flag, libdir, error)
4444
if (allocated(error)) return
4545

4646
if (.not. pkgcfg_has_package('netcdf-fortran')) then
4747
call fatal_error(error, &
48-
'pkg-config could not find a suitable netcdf-fortran package.')
48+
'pkg-config could not find a suitable netcdf-fortran package.')
4949
end if
5050
call add_pkg_config_compile_options(this, 'netcdf-fortran', include_flag, libdir, error)
5151
if (allocated(error)) return
5252

53-
5453
!> Add NetCDF modules as external
55-
this%has_external_modules = .true.
56-
this%external_modules = [string_t('netcdf')]
54+
this % has_external_modules = .true.
55+
this % external_modules = [string_t('netcdf'), &
56+
string_t('netcdf4_f03'), &
57+
string_t('netcdf4_nc_interfaces'), &
58+
string_t('netcdf4_nf_interfaces'), &
59+
string_t('netcdf_f03'), &
60+
string_t('netcdf_fortv2_c_interfaces'), &
61+
string_t('netcdf_nc_data'), &
62+
string_t('netcdf_nc_interfaces'), &
63+
string_t('netcdf_nf_data'), &
64+
string_t('netcdf_nf_interfaces')]
5765

5866
print *, 'NetCDF metapackage initialized successfully.'
5967

0 commit comments

Comments
 (0)