10 public :: clear_storage
11 public :: refr_storage
12 public :: refw_storage
14 public :: print_storage
18 integer, parameter :: idlen = 8
19 integer :: verbose = 0 ! 0 = no prints; 1 = some prints; 2 = more; etc.
22 character(len=idlen) :: id
23 real, pointer, dimension(:,:) :: data2d
24 type(mapinfo) :: data_map
25 type(node2), pointer :: next
30 type(node1), pointer :: next
31 type(node2), pointer :: first
34 type(node1), target :: root
35 type(node1), pointer :: nnode
36 type(node2), pointer :: current
37 type(node2), pointer :: hold
38 type(node1), pointer :: holdnn
40 integer, public :: iferr
44 subroutine llstor_start(icode)
46 integer, intent(in) :: icode
48 ! First, check to see that the list ICODE has not already been started:
51 SEARCH : do while (associated(nnode%next))
53 if (nnode%id == icode) then
54 if (verbose.gt.0) write(*,&
55 '(/,"LLSTOR_START: NNODE EXISTS, not starting ", I8, /)') icode
60 ! Since it is a new ICODE, add it to the list of lists:
65 if (verbose.gt.0) write(*, '(/,"NNODE%ID = ", I8, /)') nnode%id
67 nnode%first%id = 'Root'
68 nullify(nnode%first%next)
70 end subroutine llstor_start
72 subroutine clear_storage
76 print*, 'Call clear_storage.'
82 SCANF : do while (associated(nnode%next))
86 if (nnode%id == 0) exit SEARCH
89 current => nnode%first
90 do while (associated(current%next))
92 current => current%next
94 if (current%id /= "Root") then
95 if (associated(current%data2d)) then
97 print*, 'Deallocating and nullifying 2d.', &
100 deallocate(current%data2d)
101 nullify(current%data2d)
105 if (current%id == nnode%first%id) then
115 end subroutine clear_storage
117 subroutine find_node1(inname)
119 integer :: inname, name
122 SEARCH : do while (associated(nnode%next))
124 if (nnode%id == name) then
129 if (verbose > 0) then
130 print '("FIND_NODE1: Name not found: ", I8)', name
133 end subroutine find_node1
136 subroutine get_plvls(plvl, maxlvl, nlvl)
138 integer :: maxlvl, nlvl
139 real, dimension(maxlvl) :: plvl
145 SEARCH : do while (associated(nnode%next))
148 LEVLOOP : do nn = 1, nlvl
149 if (nnode%id > plvl(nn)) then
150 plvl(nn+1:maxlvl) = plvl(nn:maxlvl-1)
151 plvl(nn) = float(nnode%id)
156 end subroutine get_plvls
158 subroutine put_storage(icode, inname, data, idum, jdum)
160 character(len=*) :: inname
161 character(len=idlen) :: name
162 integer :: idum, jdum
164 real, dimension(:,:) :: data
168 if (verbose>0) print*, 'Put Storage: '
170 call find_node1(icode)
172 call llstor_start(icode)
174 current => nnode%first
176 SEARCH : do while (associated(current%next))
177 current => current%next
178 if (current%id == name) then
179 current%data2d = data
180 current%data_map = map
181 if (verbose.gt.0) write(*,'("PUT_STORAGE: Overwriting ", A,&
182 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
187 allocate(current%next)
188 current => current%next
190 allocate(current%data2d(size(data,1),size(data,2)))
191 current%data2d = data
192 current%data_map = map
193 nullify (current%next)
194 if (verbose.gt.0) write(*,'("PUT_STORAGE: Writing ", A,&
195 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id, data(1,1)
197 end subroutine put_storage
199 subroutine refw_storage(icode, name, Pdata, idum, jdum)
201 character(len=*) :: name
203 integer :: idum, jdum
204 real, pointer, dimension(:,:) :: Pdata
206 call find_node1(icode)
208 call llstor_start(icode)
210 current => nnode%first
212 SEARCH : do while (associated(current%next))
213 current => current%next
214 if (current%id == name) then
215 if (associated(current%data2d)) then
216 deallocate(current%data2d)
217 nullify(current%data2d)
219 current%data2d => Pdata
220 current%data_map = map
221 if (verbose.gt.0) write(*,'("REFW_STORAGE: OverWriting ", A,&
222 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
227 allocate(current%next)
228 current => current%next
230 nullify(current%data2d)
231 current%data2d => Pdata
232 current%data_map = map
233 nullify(current%next)
235 if (verbose.gt.0) write(*,'("REFW_STORAGE: Writing ", A,&
236 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
239 end subroutine refw_storage
241 subroutine get_storage(icode, name, data, idum, jdum)
243 character(len=*) :: name
245 integer :: idum, jdum
246 real, dimension(:,:) :: data
248 call find_node1(icode)
250 print*, 'Cannot find code ', icode, ' in routine GET_STORAGE.'
251 stop 'GET_STORAGE_code'
253 current => nnode%first
255 SEARCH : do while (associated(current%next))
256 current => current%next
257 if (current%id == name) then
258 data = current%data2d
259 map = current%data_map
260 if (verbose.gt.0) write(*,'("GET_STORAGE: READING ", A,&
261 &" at ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
266 write(*,'("GET_STORAGE : NAME not found: ", A)') name
268 end subroutine get_storage
270 subroutine refr_storage(icode, name, Pdata, idum, jdum)
272 character(len=*) :: name
274 integer :: idum, jdum
275 real, pointer, dimension(:,:) :: Pdata
277 call find_node1(icode)
279 print*, 'Cannot find code ', icode, ' in routine REFR_STORAGE.'
280 STOP 'REFR_STORAGE_code'
282 current => nnode%first
284 SEARCH : do while (associated(current%next))
285 current => current%next
286 if (current%id == name) then
287 Pdata => current%data2d
288 map = current%data_map
289 if (verbose.gt.0) write(*,'("REFR_STORAGE: Referencing ", A,&
290 &" at ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
295 print '("REFR_STORAGE : NAME not found: ", A)', name
297 end subroutine refr_storage
299 subroutine llstor_remove(icode, name)
301 character(len=*) :: name
304 call find_node1(icode)
308 current => nnode%first
310 do while (current%id /= name )
311 if (.not. associated(current%next)) then
312 print*, 'Not there : ', name
316 current => current%next
319 if (associated(current%data2d)) then
320 deallocate(current%data2d)
323 hold%next => current%next
324 nullify(current%next)
327 end subroutine llstor_remove
329 subroutine get_dims(icode, name)
331 character(len=*) :: name
334 call find_node1(icode)
338 current => nnode%first
340 SEARCH : do while (associated(current%next))
341 current => current%next
342 if (current%id == name) then
343 map = current%data_map
348 end subroutine get_dims
350 subroutine print_storage(icode)
353 integer, optional :: icode
355 if (present(icode)) then
356 call find_node1(icode)
360 print '("PRINT_NODE1: id = ", I8)' , nnode%id
361 current => nnode%first
364 if (.not. associated(current)) then
365 print '("Nothing there.")'
368 do while ( associated(current%next))
369 if (current%id == 'Root') then
370 print*, 'id = ', current%id
371 elseif (current%id /= 'Root') then
373 if (associated(current%data2d)) then
374 isz = size(current%data2d)
375 print*, current%id, ' = ', current%data2d(1,1)
379 current => current%next
381 if (current%id == 'Root') then
382 print*, 'id = ', current%id
383 elseif (current%id /= 'Root') then
384 if (associated(current%data2d)) then
385 isz = size(current%data2d)
386 print*, current%id, ' = ', current%data2d(1,1)
389 current => current%next
394 do while (associated(nnode%next))
396 print '("PRINT_NODE1: id = ", I8)' , nnode%id
399 current => nnode%first
402 if (.not. associated(current)) then
403 print '("Nothing there.")'
406 do while ( associated(current%next))
407 if (current%id == 'Root') then
408 print*, 'id = ', current%id
409 elseif (current%id /= 'Root') then
410 if (associated(current%data2d)) then
411 isz = size(current%data2d)
412 print*, current%id, ' = ', current%data2d(1,1), isz
415 current => current%next
417 if (current%id == 'Root') then
418 print*, 'id = ', current%id
419 elseif (current%id /= 'Root') then
420 if (associated(current%data2d)) then
421 isz = size(current%data2d)
422 print*, current%id, ' = ', current%data2d(1,1), isz
425 current => current%next
430 end subroutine print_storage
432 logical function is_there(icode, name) RESULT(answer)
434 character(len=*) :: name
439 if (verbose > 0) then
440 write(*,'("Is there ",A," at ", i8, "?")', advance="NO") name, icode
443 call find_node1(icode)
444 if (iferr /= 0) go to 1000
446 current => nnode%first
448 SEARCH : do while (associated(current%next))
449 current => current%next
450 if (current%id == name) then
458 if (verbose > 0) then
463 end function is_there
465 subroutine setll(ivrb)
467 integer, optional :: ivrb
468 if (present(ivrb)) verbose = ivrb
471 subroutine getll(ivrb)
473 integer, optional :: ivrb
474 if (present(ivrb)) ivrb = verbose
477 end module storage_module