73 class(NCPackageVarsType) :: this
74 character(len=*), intent(in) :: tagname
75 integer(I4B), optional :: layer
76 integer(I4B), optional :: iaux
77 integer(I4B) :: varid
78 integer(I4B) :: n, l, p, a
79 class(NCFileMf6VarType), pointer :: nc_var
80
81
82 varid = -1
83 l = -1
84 p = -1
85 a = -1
86
87
88 if (present(layer)) then
89 l = layer
90 end if
91
92
93 if (present(iaux)) then
94 a = iaux
95 end if
96
97 do n = 1, this%nc_vars%Count()
98 nc_var => ncvar_get(this%nc_vars, n)
99 if (nc_var%tagname == tagname .and. &
100 nc_var%layer == l .and. &
101 nc_var%iaux == a) then
102 varid = nc_var%varid
103 end if
104 end do
105
106
107 if (varid == -1) then
108 if (this%nc_fname /= '') then
109 write (errmsg, '(a)') &
110 'NetCDF variable not found, tagname="'//trim(tagname)//'"'
111 if (present(layer)) then
112 write (errmsg, '(a,i0)') trim(errmsg)//', layer=', layer
113 end if
114 if (present(iaux)) then
115 write (errmsg, '(a,i0)') trim(errmsg)//', iaux=', iaux
116 end if
117 write (errmsg, '(a)') trim(errmsg)//'.'
118 call store_error(errmsg)
119 call store_error_filename(this%nc_fname)
120 else
121 write (errmsg, '(a)') &
122 'NetCDF variable not found, tagname="'//trim(tagname)// &
123 '". NetCDF input not provided for model "'//trim(this%modelname)//'".'
124 call store_error(errmsg, .true.)
125 end if
126 end if