1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
!------- 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
|