Next: NF90_INQUIRE_VARIABLE, Previous: NF90_DEF_VAR, Up: Variables
The function NF90_INQ_VARID returns the ID of a netCDF variable, given its name.
function nf90_inq_varid(ncid, name, varid) integer, intent( in) :: ncid character (len = *), intent( in) :: name integer, intent(out) :: varid integer :: nf90_inq_varid
ncid
name
varid
NF90_INQ_VARID returns the value NF90_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
Here is an example using NF90_INQ_VARID to find out the ID of a variable named rh in an existing netCDF dataset named foo.nc:
use netcdf implicit none integer :: status, ncid, RhVarId ... status = nf90_open("foo.nc", nf90_NoWrite, ncid) if(status /= nf90_NoErr) call handle_err(status) ... status = nf90_inq_varid(ncid, "rh", RhVarId) if(status /= nf90_NoErr) call handle_err(status)