10 public :: llstor_start
11 public :: clear_storage
12 public :: refr_storage
13 public :: refw_storage
15 public :: print_storage
19 integer, parameter :: idlen = 8
20 integer :: verbose = 0 ! 0 = no prints; 1 = some prints; 2 = more; etc.
23 character(len=idlen) :: id
24 real, pointer, dimension(:,:) :: data2d
25 type(mapinfo) :: data_map
26 type(node2), pointer :: next
31 type(node1), pointer :: next
32 type(node2), pointer :: first
35 type(node1), target :: root
36 type(node1), pointer :: nnode
37 type(node2), pointer :: current
38 type(node2), pointer :: hold
39 type(node1), pointer :: holdnn
41 integer, public :: iferr
45 subroutine llstor_start(icode)
47 integer, intent(in) :: icode
49 ! First, check to see that the list ICODE has not already been started:
52 SEARCH : do while (associated(nnode%next))
54 if (nnode%id == icode) then
55 if (verbose.gt.0) write(*,&
56 '(/,"LLSTOR_START: NNODE EXISTS, not starting ", I8, /)') icode
61 ! Since it is a new ICODE, add it to the list of lists:
66 if (verbose.gt.0) write(*, '(/,"NNODE%ID = ", I8, /)') nnode%id
68 nnode%first%id = 'Root'
69 nullify(nnode%first%next)
71 end subroutine llstor_start
73 subroutine clear_storage
77 print*, 'Call clear_storage.'
83 SCANF : do while (associated(nnode%next))
87 if (nnode%id == 0) exit SEARCH
90 current => nnode%first
91 do while (associated(current%next))
93 current => current%next
95 if (current%id /= "Root") then
96 if (associated(current%data2d)) then
98 print*, 'Deallocating and nullifying 2d.', &
101 deallocate(current%data2d)
102 nullify(current%data2d)
106 if (current%id == nnode%first%id) then
116 end subroutine clear_storage
118 subroutine find_node1(inname)
120 integer :: inname, name
123 SEARCH : do while (associated(nnode%next))
125 if (nnode%id == name) then
130 if (verbose > 0) then
131 print '("FIND_NODE1: Name not found: ", I8)', name
134 end subroutine find_node1
137 subroutine get_plvls(plvl, maxlvl, nlvl)
139 integer :: maxlvl, nlvl
140 real, dimension(maxlvl) :: plvl
146 SEARCH : do while (associated(nnode%next))
149 LEVLOOP : do nn = 1, nlvl
150 if (nnode%id > plvl(nn)) then
151 plvl(nn+1:maxlvl) = plvl(nn:maxlvl-1)
152 plvl(nn) = float(nnode%id)
157 end subroutine get_plvls
159 subroutine put_storage(icode, inname, data, idum, jdum)
161 character(len=*) :: inname
162 character(len=idlen) :: name
163 integer :: idum, jdum
165 real, dimension(:,:) :: data
169 if (verbose>0) print*, 'Put Storage: '
171 call find_node1(icode)
173 call llstor_start(icode)
175 current => nnode%first
177 SEARCH : do while (associated(current%next))
178 current => current%next
179 if (current%id == name) then
180 current%data2d = data
181 current%data_map = map
182 if (verbose.gt.0) write(*,'("PUT_STORAGE: Overwriting ", A,&
183 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
188 allocate(current%next)
189 current => current%next
191 allocate(current%data2d(size(data,1),size(data,2)))
192 current%data2d = data
193 current%data_map = map
194 nullify (current%next)
195 if (verbose.gt.0) write(*,'("PUT_STORAGE: Writing ", A,&
196 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id, data(1,1)
198 end subroutine put_storage
200 subroutine refw_storage(icode, name, Pdata, idum, jdum)
202 character(len=*) :: name
204 integer :: idum, jdum
205 real, pointer, dimension(:,:) :: Pdata
207 call find_node1(icode)
209 call llstor_start(icode)
211 current => nnode%first
213 SEARCH : do while (associated(current%next))
214 current => current%next
215 if (current%id == name) then
216 if (associated(current%data2d)) then
217 deallocate(current%data2d)
218 nullify(current%data2d)
220 current%data2d => Pdata
221 current%data_map = map
222 if (verbose.gt.0) write(*,'("REFW_STORAGE: OverWriting ", A,&
223 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
228 allocate(current%next)
229 current => current%next
231 nullify(current%data2d)
232 current%data2d => Pdata
233 current%data_map = map
234 nullify(current%next)
236 if (verbose.gt.0) write(*,'("REFW_STORAGE: Writing ", A,&
237 &" to ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
240 end subroutine refw_storage
242 subroutine get_storage(icode, name, data, idum, jdum)
244 character(len=*) :: name
246 integer :: idum, jdum
247 real, dimension(:,:) :: data
249 call find_node1(icode)
251 print*, 'Cannot find code ', icode, ' in routine GET_STORAGE.'
252 stop 'GET_STORAGE_code'
254 current => nnode%first
256 SEARCH : do while (associated(current%next))
257 current => current%next
258 if (current%id == name) then
259 data = current%data2d
260 map = current%data_map
261 if (verbose.gt.0) write(*,'("GET_STORAGE: READING ", A,&
262 &" at ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
267 write(*,'("GET_STORAGE : NAME not found: ", A)') name
269 end subroutine get_storage
271 subroutine refr_storage(icode, name, Pdata, idum, jdum)
273 character(len=*) :: name
275 integer :: idum, jdum
276 real, pointer, dimension(:,:) :: Pdata
278 call find_node1(icode)
280 print*, 'Cannot find code ', icode, ' in routine REFR_STORAGE.'
281 STOP 'REFR_STORAGE_code'
283 current => nnode%first
285 SEARCH : do while (associated(current%next))
286 current => current%next
287 if (current%id == name) then
288 Pdata => current%data2d
289 map = current%data_map
290 if (verbose.gt.0) write(*,'("REFR_STORAGE: Referencing ", A,&
291 &" at ID ", I8, " Value: ", F16.6)') current%id, nnode%id,&
296 print '("REFR_STORAGE : NAME not found: ", A)', name
298 end subroutine refr_storage
300 subroutine llstor_remove(icode, name)
302 character(len=*) :: name
305 call find_node1(icode)
309 current => nnode%first
311 do while (current%id /= name )
312 if (.not. associated(current%next)) then
313 print*, 'Not there : ', name
317 current => current%next
320 if (associated(current%data2d)) then
321 deallocate(current%data2d)
324 hold%next => current%next
325 nullify(current%next)
328 end subroutine llstor_remove
330 subroutine get_dims(icode, name)
332 character(len=*) :: name
335 call find_node1(icode)
339 current => nnode%first
341 SEARCH : do while (associated(current%next))
342 current => current%next
343 if (current%id == name) then
344 map = current%data_map
349 end subroutine get_dims
351 subroutine print_storage(icode)
354 integer, optional :: icode
356 if (present(icode)) then
357 call find_node1(icode)
361 ! print '("PRINT_NODE1: id = ", I8)' , nnode%id
362 call mprintf(.true.,DEBUG,"PRINT_NODE1: id = %i ",i1=nnode%id)
363 current => nnode%first
366 call mprintf(.true.,DEBUG,' ',newline=.true.)
367 if (.not. associated(current)) then
368 ! print '("Nothing there.")'
369 call mprintf(.true.,DEBUG,"Nothing there. ")
372 do while ( associated(current%next))
373 if (current%id == 'Root') then
374 ! print*, 'id = ', current%id
375 call mprintf(.true.,DEBUG," id = %s ",s1=current%id)
376 elseif (current%id /= 'Root') then
378 if (associated(current%data2d)) then
379 isz = size(current%data2d)
380 ! print*, current%id, ' = ', current%data2d(1,1)
381 call mprintf(.true.,DEBUG," %s = %f ",s1=current%id,f1=current%data2d(1,1))
385 current => current%next
387 if (current%id == 'Root') then
388 ! print*, 'id = ', current%id
389 call mprintf(.true.,DEBUG," id = %s ",s1=current%id)
390 elseif (current%id /= 'Root') then
391 if (associated(current%data2d)) then
392 isz = size(current%data2d)
393 ! print*, current%id, ' = ', current%data2d(1,1)
394 call mprintf(.true.,DEBUG," %s = %f ",s1=current%id,f1=current%data2d(1,1))
397 current => current%next
399 call mprintf(.true.,DEBUG,' ',newline=.true.)
403 do while (associated(nnode%next))
405 ! print '("PRINT_NODE1: id = ", I8)' , nnode%id
406 call mprintf(.true.,DEBUG,"PRINT_NODE1: id = %i ",i1=nnode%id)
408 current => nnode%first
411 call mprintf(.true.,DEBUG,' ',newline=.true.)
412 if (.not. associated(current)) then
413 ! print '("Nothing there.")'
414 call mprintf(.true.,DEBUG,"Nothing there. ")
417 do while ( associated(current%next))
418 if (current%id == 'Root') then
419 ! print*, 'id = ', current%id
420 call mprintf(.true.,DEBUG," id = %s ",s1=current%id)
421 elseif (current%id /= 'Root') then
422 if (associated(current%data2d)) then
423 isz = size(current%data2d)
424 ! print*, current%id, ' = ', current%data2d(1,1), isz
425 call mprintf(.true.,DEBUG," %s = %f isz = %i", &
426 s1=current%id,f1=current%data2d(1,1),i1=isz)
429 current => current%next
431 if (current%id == 'Root') then
432 ! print*, 'id = ', current%id
433 call mprintf(.true.,DEBUG," id = %s ",s1=current%id)
434 elseif (current%id /= 'Root') then
435 if (associated(current%data2d)) then
436 isz = size(current%data2d)
437 ! print*, current%id, ' = ', current%data2d(1,1), isz
438 call mprintf(.true.,DEBUG," %s = %f isz = %i", &
439 s1=current%id,f1=current%data2d(1,1),i1=isz)
442 current => current%next
444 call mprintf(.true.,DEBUG,' ',newline=.true.)
448 end subroutine print_storage
450 logical function is_there(icode, name) RESULT(answer)
452 character(len=*) :: name
457 if (verbose > 0) then
458 write(*,'("Is there ",A," at ", i8, "?")', advance="NO") name, icode
461 call find_node1(icode)
462 if (iferr /= 0) go to 1000
464 current => nnode%first
466 SEARCH : do while (associated(current%next))
467 current => current%next
468 if (current%id == name) then
476 if (verbose > 0) then
481 end function is_there
483 subroutine setll(ivrb)
485 integer, optional :: ivrb
486 if (present(ivrb)) verbose = ivrb
489 subroutine getll(ivrb)
491 integer, optional :: ivrb
492 if (present(ivrb)) ivrb = verbose
495 end module storage_module