FV3 Bundle
netcdf_unlimdims.F90
Go to the documentation of this file.
1 ! polyfill for nc_inq_unlimdims
2 ! (Polyfill = code that provides API support when API support is
3 ! missing!)
4 ! Needed to supplement Fortran API, since the NetCDF devs were a bit
5 ! lazy with the Fortran side of things...
6 
8  use iso_c_binding
9  implicit none
10 
11  interface
12  integer (C_INT) function nc_inq_unlimdims(ncid, nunlimdimsp, unlimdimidsp) bind(c)
13  use iso_c_binding
14  integer(c_int), value :: ncid
15  type(c_ptr), value :: nunlimdimsp
16  type(c_ptr), value :: unlimdimidsp
17  end function
18  end interface
19 
20  contains
21  ! pf = polyfill
22  integer(c_int) function pf_nf90_inq_unlimdims(ncid, num_unlim_dims, unlim_dims)
23  integer(c_int), intent(in) :: ncid
24  integer(c_int), target, intent(inout) :: num_unlim_dims
25  integer(c_int), target, intent(out), optional :: unlim_dims(:)
26 
27  integer :: i
28 
29  if (present(unlim_dims)) then
30  ! Assume num_unlim_dims is set!
31  pf_nf90_inq_unlimdims = nc_inq_unlimdims(ncid, c_loc(num_unlim_dims), c_loc(unlim_dims))
32 
33  do i = 1, num_unlim_dims
34  unlim_dims(i) = unlim_dims(i) + 1
35  end do
36  else
37  pf_nf90_inq_unlimdims = nc_inq_unlimdims(ncid, c_loc(num_unlim_dims), c_null_ptr)
38  end if
39  end function pf_nf90_inq_unlimdims
40 
41 end module netcdf_unlimdims
integer(c_int) function pf_nf90_inq_unlimdims(ncid, num_unlim_dims, unlim_dims)