MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
netcdfcommonmodule Module Reference

This module contains the NetCDFCommonModule. More...

Functions/Subroutines

integer(i4b) function, public nc_fopen (nc_fname, iout)
 Open netcdf file. More...
 
subroutine, public nc_fclose (ncid, nc_fname)
 Close netcdf file. More...
 
subroutine, public nf_verify (res, nc_fname)
 error check a netcdf-fortran interface call More...
 

Variables

integer(i4b), parameter, public netcdf_max_dim = 6
 
integer(i4b), parameter, public netcdf_attr_strlen = 80
 

Detailed Description

Common NetCDF interfaces and constants

Function/Subroutine Documentation

◆ nc_fclose()

subroutine, public netcdfcommonmodule::nc_fclose ( integer(i4b), intent(in)  ncid,
character(len=*), intent(in)  nc_fname 
)

Definition at line 40 of file NetCDFCommon.f90.

41  integer(I4B), intent(in) :: ncid
42  character(len=*), intent(in) :: nc_fname
43  ! close netcdf file
44  call nf_verify(nf90_close(ncid), nc_fname)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_fopen()

integer(i4b) function, public netcdfcommonmodule::nc_fopen ( character(len=*), intent(in)  nc_fname,
integer(i4b), intent(in)  iout 
)

Definition at line 28 of file NetCDFCommon.f90.

29  character(len=*), intent(in) :: nc_fname
30  integer(I4B), intent(in) :: iout
31  integer(I4B) :: ncid
32  ! initialize
33  ncid = -1
34  ! open netcdf file
35  call nf_verify(nf90_open(nc_fname, nf90_nowrite, ncid), nc_fname)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nf_verify()

subroutine, public netcdfcommonmodule::nf_verify ( integer(i4b), intent(in)  res,
character(len=*), intent(in)  nc_fname 
)

Definition at line 49 of file NetCDFCommon.f90.

50  integer(I4B), intent(in) :: res
51  character(len=*), intent(in) :: nc_fname
52  character(len=LINELENGTH) :: errstr
53 
54  ! strings are set for a subset of errors
55  ! but the exit status will always be reported
56  if (res /= nf90_noerr) then
57  !
58  select case (res)
59  case (-33) ! (NC_EBADID)
60  errstr = 'Not a netcdf id'
61  case (nf90_einval) ! (-36)
62  errstr = 'Invalid Argument'
63  case (nf90_eperm) ! (-37)
64  errstr = 'Write to read only'
65  case (-38) ! (NC_ENOTINDEFINE)
66  errstr = 'Operation not allowed in data mode'
67  case (-39) ! (NC_EINDEFINE)
68  errstr = 'Operation not allowed in define mode'
69  case (nf90_einvalcoords) ! (-40)
70  errstr = 'Index exceeds dimension bound'
71  case (nf90_enameinuse) ! (-42)
72  errstr = 'String match to name in use'
73  case (nf90_enotatt) ! (-43)
74  errstr = 'Attribute not found'
75  case (-45) ! (NC_EBADTYPE)
76  errstr = 'Not a netcdf data type'
77  case (nf90_ebaddim) ! (-46)
78  errstr = 'Invalid dimension id or name'
79  case (nf90_enotvar) ! (-49)
80  errstr = 'Variable not found'
81  case (nf90_enotnc) ! (-51)
82  errstr = 'Not a netcdf file'
83  case (nf90_echar) ! (-56)
84  errstr = 'Attempt to convert between text & numbers'
85  case (nf90_eedge) ! (-57)
86  errstr = 'Edge+start exceeds dimension bound'
87  case (nf90_estride) ! (-58)
88  errstr = 'Illegal stride'
89  case (nf90_ebadname) ! (-59)
90  errstr = 'Attribute or variable name contains illegal characters'
91  case (-127) ! (NC_EBADCHUNK)
92  errstr = 'Bad chunksize.'
93  case default
94  errstr = ''
95  end select
96 
97  if (errstr /= '') then
98  write (errmsg, '(a,a,a,i0,a)') 'NetCDF library error [error="', &
99  trim(errstr), '", exit code=', res, '].'
100  else
101  write (errmsg, '(a,i0,a)') 'NetCDF library error [exit code=', &
102  res, '].'
103  end if
104 
105  call store_error(errmsg)
106  call store_error_filename(nc_fname)
107  end if
Here is the call graph for this function:

Variable Documentation

◆ netcdf_attr_strlen

integer(i4b), parameter, public netcdfcommonmodule::netcdf_attr_strlen = 80

Definition at line 22 of file NetCDFCommon.f90.

22  integer(I4B), parameter :: NETCDF_ATTR_STRLEN = 80

◆ netcdf_max_dim

integer(i4b), parameter, public netcdfcommonmodule::netcdf_max_dim = 6

Definition at line 21 of file NetCDFCommon.f90.

21  integer(I4B), parameter :: NETCDF_MAX_DIM = 6