130 class(GridFileReaderType) :: this
132 character(len=:),
allocatable :: body
133 character(len=:),
allocatable :: line
134 character(len=10) :: key, dtype
136 integer(I4B) :: i, lloc, istart, istop, ival, pos
137 integer(I4B) :: nvars, ndim, dim, ishp
138 integer(I4B),
allocatable :: shp(:)
140 allocate (this%keys(this%ntxt))
141 allocate (
character(len=this%lentxt*this%ntxt) :: body)
142 allocate (
character(len=this%lentxt) :: line)
145 read (this%inunit) body
146 inquire (this%inunit, pos=pos)
147 do i = 1, this%lentxt * this%ntxt, this%lentxt
148 line = body(i:i + this%lentxt - 1)
153 call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0)
154 key = line(istart:istop)
156 this%keys(nvars) = key
159 call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0)
160 dtype = line(istart:istop)
161 if (dtype ==
"INTEGER")
then
162 call this%typ%add(key, 1)
163 else if (dtype ==
"DOUBLE")
then
164 call this%typ%add(key, 2)
165 else if (dtype ==
"CHARACTER")
then
166 call this%typ%add(key, 3)
170 call urword(line, lloc, istart, istop, 0, ival, rval, 0, 0)
171 call urword(line, lloc, istart, istop, 2, ival, rval, 0, 0)
173 call this%dim%add(key, ndim)
176 if (
allocated(shp))
deallocate (shp)
180 call urword(line, lloc, istart, istop, 2, ival, rval, 0, 0)
183 ishp =
size(this%shp)
184 call expandarray(this%shp, increment=ndim)
185 this%shp(ishp + 1:ishp + ndim) = shp
186 call this%shp_idx%add(key, ishp + 1)
190 call this%pos%add(key, pos)
192 if (dtype ==
"INTEGER")
then
194 else if (dtype ==
"DOUBLE")
then
198 if (dtype ==
"INTEGER")
then
199 pos = pos + (product(shp) * 4)
200 else if (dtype ==
"DOUBLE")
then
201 pos = pos + (product(shp) * 8)
202 else if (dtype ==
"CHARACTER")
then
203 pos = pos + (product(shp) * 8)