FV3 Bundle
test_nc_unlimdims.F90
Go to the documentation of this file.
2  use ncd_kinds, only: i_long
6  use netcdf, only: nf90_open, nf90_inquire_dimension, nf90_close, &
7  nf90_max_name, nf90_nowrite
9 
10  implicit none
11 
12 #ifdef USE_MPI
13 ! We don't use this option here, and setting it will cause problems
14 ! with ncdc_util.F90, so let's unset it.
15 #undef USE_MPI
16 #endif
17 
18  integer(i_long) :: tmp_dim_size, i
19  character(len=NF90_MAX_NAME) :: tmp_dim_name
20  integer(i_long), dimension(:), allocatable :: unlim_dims
21 
22  call get_command_argument(0, prgm_name)
23  cli_arg_count = command_argument_count()
24 
25  if (cli_arg_count /= 1) &
26  call ncdc_error("Usage: " // trim(prgm_name) // " [input NetCDF4 file]")
27 
28  call get_command_argument(1, input_file)
29 
30  call ncdc_info("Opening NetCDF4 file: " // trim(input_file))
31 
32  call ncdc_check(nf90_open(input_file, nf90_nowrite, ncid_input))
33 
35 
36  write (*, "(A, I0)") "Number of unlimited dimensions: ", num_unlims
37  allocate(unlim_dims(num_unlims))
38 
40 
41  do i = 1, num_unlims
42  call ncdc_check(nf90_inquire_dimension(ncid_input, int(unlim_dims(i)), &
43  tmp_dim_name, tmp_dim_size))
44  write (*, "(A, I0, A, I0, A)") " => Unlimited dimension | ID: ", unlim_dims(i), " | Size: ", tmp_dim_size, &
45  " | Name = " // trim(tmp_dim_name)
46  end do
47 
48  deallocate(unlim_dims)
49  call ncdc_check(nf90_close(ncid_input))
50 end program test_nc_unlimdims
integer(c_int) function pf_nf90_inq_unlimdims(ncid, num_unlim_dims, unlim_dims)
program test_nc_unlimdims
integer, parameter, public i_long
Definition: ncd_kinds.F90:47
integer(i_long) cli_arg_count
Definition: ncdc_state.F90:12
character(len=10000000) prgm_name
Definition: ncdc_state.F90:11
subroutine ncdc_error(err)
Definition: ncdc_climsg.F90:29
integer(i_long) ncid_input
Definition: ncdc_state.F90:14
subroutine ncdc_info(ifo)
Definition: ncdc_climsg.F90:72
subroutine ncdc_check(status)
Definition: ncdc_climsg.F90:21
character(len=10000000) input_file
Definition: ncdc_state.F90:11
integer(i_long) num_unlims
Definition: ncdc_state.F90:27