nf_geninq.f90
Go to the documentation of this file.
!------- Routines for obtaining info on dimensions, varible sizes, etc -------
! Replacement for fort-geninq.c
! Written by: Richard Weed, Ph.D.
! Center for Advanced Vehicular Systems
! Mississippi State University
! rweed@cavs.msstate.edu
! License (and other Lawyer Language)
! This software is released under the Apache 2.0 Open Source License. The
! full text of the License can be viewed at :
!
! http:www.apache.org/licenses/LICENSE-2.0.html
!
! The author grants to the University Corporation for Atmospheric Research
! (UCAR), Boulder, CO, USA the right to revise and extend the software
! without restriction. However, the author retains all copyrights and
! intellectual property rights explicitly stated in or implied by the
! Apache license
! Version 1.: Sept. 2005 - Initial Cray X1 version
! April 2006 - Updated to include 3.6.1 function nf_inq_format
! Version 2.: May 2006 - Updated to support g95
! Version 3.: April 2009 - Updated to Netcdf 4.0.1
! Version 4.: April 2010 - Updated to Netcdf 4.1.1
! Version 5.: May 2014 - Ensure return error status checked from C API calls
! Version 6.: Jan. 2016 - General code cleanup.
!
!-------------------------------- nf_inq ----------------------------------
Function nf_inq(ncid, ndims, nvars, ngatts, unlimdimid) RESULT(status)
! Inquire about number of dimensions, number of varibles, number of
! global attributes, and the id of the ulimited dimension for NetCDF file
! id ncid
USE netcdf_nc_interfaces
Implicit NONE
Integer, Intent(IN) :: ncid
Integer, Intent(OUT) :: ndims, nvars, ngatts, unlimdimid
Integer :: status
Integer(C_INT) :: cncid, cndims, cnvars, cngatts, cunlimdimid, cstatus
cncid = ncid
cstatus = nc_inq(cncid, cndims, cnvars, cngatts, cunlimdimid)
If (cstatus == nc_noerr) Then
ndims = cndims
nvars = cnvars
ngatts = cngatts
! Shift C id by plus one to Fortran id if unlimdimid is not -1
If (cunlimdimid == - 1) Then
unlimdimid = -1
Else
unlimdimid = cunlimdimid + 1
EndIf
EndIf
status = cstatus
End Function nf_inq
!-------------------------------- nf_inq_ndims -----------------------------
Function nf_inq_ndims(ncid, ndims) RESULT(status)
! Inquire about number of dimensions for NetCDF file id ncid
USE netcdf_nc_interfaces
Implicit NONE
Integer, Intent(IN) :: ncid
Integer, Intent(OUT) :: ndims
Integer :: status
Integer(C_INT) :: cncid, cndims, cstatus
cncid = ncid
cstatus = nc_inq_ndims(cncid, cndims)
If (cstatus == nc_noerr) Then
ndims = cndims
EndIf
status = cstatus
End Function nf_inq_ndims
!-------------------------------- nf_inq_nvars -----------------------------
Function nf_inq_nvars(ncid, nvars) RESULT(status)
! Inquire about number of variables for NetCDF file id ncid
USE netcdf_nc_interfaces
Implicit NONE
Integer, Intent(IN) :: ncid
Integer, Intent(OUT) :: nvars
Integer :: status
Integer(C_INT) :: cncid, cnvars, cstatus
cncid = ncid
cstatus = nc_inq_nvars(cncid, cnvars)
If (cstatus == nc_noerr) Then
nvars = cnvars
EndIf
status = cstatus
End Function nf_inq_nvars
!-------------------------------- nf_inq_natts -----------------------------
Function nf_inq_natts(ncid, ngatts) RESULT(status)
! Inquire about number of global attributes for NetCDF file id ncid
USE netcdf_nc_interfaces
Implicit NONE
Integer, Intent(IN) :: ncid
Integer, Intent(OUT) :: ngatts
Integer :: status
Integer(C_INT) :: cncid, cngatts, cstatus
cncid = ncid
cstatus = nc_inq_natts(cncid, cngatts)
If (cstatus == nc_noerr) Then
ngatts = cngatts
EndIf
status = cstatus
End Function nf_inq_natts
!-------------------------------- nf_inq_unlimdim --------------------------
Function nf_inq_unlimdim(ncid, unlimdimid) RESULT(status)
! Inquire about id of unlimited dimension for NetCDF file id ncid
USE netcdf_nc_interfaces
Implicit NONE
Integer, Intent(IN) :: ncid
Integer, Intent(OUT) :: unlimdimid
Integer :: status
Integer(C_INT) :: cncid, cunlimdimid, cstatus
cncid = ncid
cstatus = nc_inq_unlimdim(cncid, cunlimdimid)
! Shift C id by plus one to Fortran id if unlimdimid is not -1
If (cstatus == nc_noerr) Then
If (cunlimdimid == -1) Then
unlimdimid = -1
Else
unlimdimid = cunlimdimid + 1
EndIf
EndIf
status = cstatus
End Function nf_inq_unlimdim
!-------------------------------- nf_inq_format -------------------------------
Function nf_inq_format(ncid, format_type) RESULT(status)
! Inquire about internal file format for NetCDF file id ncid
USE netcdf_nc_interfaces
Implicit NONE
Integer, Intent(IN) :: ncid
Integer, Intent(OUT) :: format_type
Integer :: status
Integer(C_INT) :: cncid, cformatp, cstatus
cncid = ncid
cstatus = nc_inq_format(cncid, cformatp)
If (cstatus == nc_noerr) Then
! Return format_type
format_type = cformatp
EndIf
status = cstatus
End Function nf_inq_format
nf_inq_unlimdim
integer function nf_inq_unlimdim(ncid, unlimdimid)
Definition: nf_geninq.f90:150
netcdf_nc_interfaces::nc_inq_ndims
Definition: module_netcdf_nc_interfaces.f90:362
nf_inq_nvars
integer function nf_inq_nvars(ncid, nvars)
Definition: nf_geninq.f90:98
netcdf_nc_interfaces
Definition: module_netcdf_nc_interfaces.f90:1
netcdf_nc_interfaces::nc_inq_nvars
Definition: module_netcdf_nc_interfaces.f90:375
nf_inq
integer function nf_inq(ncid, ndims, nvars, ngatts, unlimdimid)
Definition: nf_geninq.f90:34
netcdf_nc_data::nc_noerr
integer(c_int), parameter nc_noerr
Definition: module_netcdf_nc_data.F90:244
nf_inq_format
integer function nf_inq_format(ncid, format_type)
Definition: nf_geninq.f90:182
netcdf_nc_interfaces::nc_inq_unlimdim
Definition: module_netcdf_nc_interfaces.f90:401
netcdf_nc_interfaces::nc_inq_natts
Definition: module_netcdf_nc_interfaces.f90:388
nf_inq_ndims
integer function nf_inq_ndims(ncid, ndims)
Definition: nf_geninq.f90:72
netcdf_nc_interfaces::nc_inq_format
Definition: module_netcdf_nc_interfaces.f90:414
netcdf_nc_interfaces::nc_inq
Definition: module_netcdf_nc_interfaces.f90:349
nf_inq_natts
integer function nf_inq_natts(ncid, ngatts)
Definition: nf_geninq.f90:124

Return to the Main Unidata NetCDF page.