common_dict.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: common_dict.f90 #
5!# #
6!# Copyright (C) 2015 Manuel Jung <mjung@astrophysik.uni-kiel.de> #
7!# #
8!# This program is free software; you can redistribute it and/or modify #
9!# it under the terms of the GNU General Public License as published by #
10!# the Free Software Foundation; either version 2 of the License, or (at #
11!# your option) any later version. #
12!# #
13!# This program is distributed in the hope that it will be useful, but #
14!# WITHOUT ANY WARRANTY; without even the implied warranty of #
15!# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
16!# NON INFRINGEMENT. See the GNU General Public License for more #
17!# details. #
18!# #
19!# You should have received a copy of the GNU General Public License #
20!# along with this program; if not, write to the Free Software #
21!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
22!# #
23!#############################################################################
24!----------------------------------------------------------------------------!
60!----------------------------------------------------------------------------!
62 !USE dict_common, InitDict_common => InitDict
64 !--------------------------------------------------------------------------!
65 IMPLICIT NONE
66 !--------------------------------------------------------------------------!
67 PRIVATE
68 ! exclude interface block from doxygen processing
70 INTERFACE setattr
71 MODULE PROCEDURE setattr0a, setattr0b, &
75 END INTERFACE setattr
76 INTERFACE getattr
77 MODULE PROCEDURE getattr0, &
81 END INTERFACE getattr
82 INTERFACE ref
83 MODULE PROCEDURE ref1, ref2
84 END INTERFACE ref
85 INTERFACE OPERATOR (/)
86 MODULE PROCEDURE assign0, assign1, assign2, assign3, assign4, &
89 END INTERFACE
91 ! constants
92 INTEGER, PARAMETER :: max_char_len = 128
93 INTEGER, PARAMETER :: dict_none = 0
94 INTEGER, PARAMETER :: dict_int = 1
95 INTEGER, PARAMETER :: dict_real = 2
96 INTEGER, PARAMETER :: dict_char = 3
97 INTEGER, PARAMETER :: dict_bool = 4
98 INTEGER, PARAMETER :: dict_real_oned = 5
99 INTEGER, PARAMETER :: dict_real_twod = 6
100 INTEGER, PARAMETER :: dict_real_threed = 7
101 INTEGER, PARAMETER :: dict_real_fourd = 8
102 INTEGER, PARAMETER :: dict_int_oned = 9
103 INTEGER, PARAMETER :: dict_real_p = 10
104 INTEGER, PARAMETER :: dict_int_p = 11
105 INTEGER, PARAMETER :: dict_real_fived = 12
106#define TYPE_DICT_KEY CHARACTER(LEN=MAX_CHAR_LEN)
107#define TYPE_DICT_INT INTEGER
108#define TYPE_DICT_REAL REAL
109#define TYPE_DICT_CHAR CHARACTER(LEN=MAX_CHAR_LEN)
110#define TYPE_DICT_BOOL LOGICAL
111#define TYPE_DICT_REAL_ONED REAL, DIMENSION(:)
112#define TYPE_DICT_REAL_TWOD REAL, DIMENSION(:,:), POINTER
113#define TYPE_DICT_REAL_THREED REAL, DIMENSION(:,:,:), POINTER
114#define TYPE_DICT_REAL_FOURD REAL, DIMENSION(:,:,:,:), POINTER
115#define TYPE_DICT_REAL_FIVED REAL, DIMENSION(:,:,:,:,:), POINTER
116#define TYPE_DICT_INT_ONED INTEGER, DIMENSION(:)
117#define TYPE_DICT_REAL_P REAL, POINTER
118#define TYPE_DICT_INT_P INTEGER, POINTER
119! Type of the mold, which holds all the data
120#define TYPE_DICT_MOLD CHARACTER(LEN=1), DIMENSION(:)
121 ! common data structure
122 type_dict_mold, ALLOCATABLE :: mold
124 PRIVATE
125 CHARACTER(LEN=MAX_CHAR_LEN) :: key = ""
126 INTEGER :: type = dict_none
127 type_dict_mold, POINTER :: value => null()
128 TYPE(dict_typ), POINTER :: child => null()
129 TYPE(dict_typ), POINTER :: next => null()
130 END TYPE dict_typ
132 type_dict_real_p :: p
133 END TYPE
134 TYPE int_t
135 type_dict_int_p :: p
136 END TYPE
138 type_dict_real_twod :: p
139 END TYPE
141 type_dict_real_threed :: p
142 END TYPE
144 type_dict_real_fourd :: p
145 END TYPE
147 type_dict_real_fived :: p
148 END TYPE
149 TYPE(logging_base), SAVE :: this
150 !--------------------------------------------------------------------------!
151 PUBLIC :: &
152 ! types
154 ! constants
158 ! methods
159 setattr, &
160 getattr, &
161 getnext, &
162 getchild, &
163 getkey, &
164 getdatasize, &
165 getdatatype, &
166 getdata, &
167 setdata, &
168 haschild, &
169 hasdata, &
170 haskey, &
171 ref, &
172 OPERATOR(/), &
173 dict, &
175 copydict, &
176 printdict, &
177 initdict, &
178 closedict, &
180 !--------------------------------------------------------------------------!
181
182CONTAINS
183 SUBROUTINE initdict()
184 IMPLICIT NONE
185 !------------------------------------------------------------------------!
186 IF (.NOT.ALLOCATED(mold)) ALLOCATE(mold(1))
187 END SUBROUTINE initdict
188
189
190 SUBROUTINE closedict()
191 IMPLICIT NONE
192 !------------------------------------------------------------------------!
193 IF (ALLOCATED(mold)) DEALLOCATE(mold)
194 END SUBROUTINE closedict
195
196
201 FUNCTION findpath(root, key, create) RESULT(res)
202 IMPLICIT NONE
203 !------------------------------------------------------------------------!
204 TYPE(dict_typ),POINTER :: root
205 CHARACTER(LEN=*) :: key
206 LOGICAL, OPTIONAL :: create
207 TYPE(dict_typ),POINTER :: res
208 !------------------------------------------------------------------------!
209 TYPE(dict_typ),POINTER :: parent,node
210 LOGICAL :: c
211 type_dict_char :: k, key_
212 !------------------------------------------------------------------------!
213 INTENT(IN) :: key, create
214 !------------------------------------------------------------------------!
215 c = .false.
216 IF(PRESENT(create)) &
217 c = create
218 key_ = trim(key)
219 NULLIFY(parent)
220 node => root
221 k = tokenize(key_)
222 DO WHILE(len_trim(k).GT.0)
223 node => findchild(node,trim(k))
224 IF(ASSOCIATED(node)) THEN
225 parent => node
226 node => node%child
227 ELSE
228 IF(c) THEN
229 ALLOCATE(node)
230 node%key = k
231 IF(ASSOCIATED(parent)) THEN
232 IF(ASSOCIATED(parent%child)) THEN
233 parent => getlast(parent%child)
234 parent%next => node
235 ELSE
236 parent%child => node
237 END IF
238 ELSE
239 IF(ASSOCIATED(root)) THEN
240 parent => getlast(root)
241 parent%next => node
242 ELSE
243 root => node
244 END IF
245 END IF
246 parent => node
247 ELSE
248 NULLIFY(parent)
249 k = ''
250 key_ = ''
251 END IF
252 END IF
253 k = tokenize(key_)
254 END DO
255 res => parent
256
257 IF(c.EQV..true.) THEN
258 IF (.NOT.ASSOCIATED(res)) &
259 CALL this%Error("FindPath","Create was activated, so res should be associated.")
260 END IF
261 END FUNCTION findpath
262
265 RECURSIVE SUBROUTINE setattr0a(root, key, value)
266 IMPLICIT NONE
267 !------------------------------------------------------------------------!
268 TYPE(dict_typ), POINTER :: root
269 CHARACTER(LEN=*) :: key
270 TYPE(dict_typ), TARGET :: value
271 !------------------------------------------------------------------------!
272 TYPE(dict_typ), POINTER :: node, parent
273 type_dict_char :: k
274 !------------------------------------------------------------------------!
275 INTENT(IN) :: key
276 !------------------------------------------------------------------------!
277 node => value
278 DO WHILE(ASSOCIATED(node))
279 WRITE(k,'(A,A,A)') trim(key),'/',trim(node%key)
280 parent => node
281
282 IF(ASSOCIATED(node%child)) THEN
283 CALL setattr0a(root, trim(k), node%child)
284 ELSE
285 CALL setattr0b(root, trim(k), node%value, node%type)
286 END IF
287 node => node%next
288 CALL deletenode(parent,k)
289 END DO
290 END SUBROUTINE setattr0a
291
294 SUBROUTINE setattr0b(root, key, value, type)
295 IMPLICIT NONE
296 !------------------------------------------------------------------------!
297 TYPE(dict_typ),POINTER :: root
298 CHARACTER(LEN=*) :: key
299 INTEGER :: type
300 type_dict_mold :: value
301 !------------------------------------------------------------------------!
302 TYPE(dict_typ),POINTER :: node
303 !------------------------------------------------------------------------!
304 INTENT(IN) :: key, type, value
305 !------------------------------------------------------------------------!
306 node => findpath(root,key,.true.)
307 node%type = type
308 CALL setdata(node,value)
309 END SUBROUTINE setattr0b
310
314 SUBROUTINE getattr0a(root, key, parent)
315 IMPLICIT NONE
316 !------------------------------------------------------------------------!
317 TYPE(dict_typ),POINTER :: root, parent, child
318 CHARACTER(LEN=*) :: key
319 !------------------------------------------------------------------------!
320 type_dict_char :: k, key_
321 !------------------------------------------------------------------------!
322 INTENT(IN) :: key
323 !------------------------------------------------------------------------!
324 parent => root
325 child => root
326 key_ = trim(key)
327 DO WHILE(ASSOCIATED(child).AND.len_trim(key_).GT.0)
328 k = tokenize(key_)
329 parent => findchild(child,k)
330 IF(ASSOCIATED(parent)) &
331 child => parent%child
332 END DO
333 IF(len_trim(key_).GT.0) &
334 NULLIFY(parent)
335 END SUBROUTINE getattr0a
336
341 SUBROUTINE getattr0b(root, key, type, value, default)
342 IMPLICIT NONE
343 !------------------------------------------------------------------------!
344 TYPE(dict_typ), POINTER :: root
345 CHARACTER(LEN=*) :: key
346 INTEGER :: type
347 type_dict_mold, POINTER :: value
348 type_dict_mold, OPTIONAL :: default
349 !------------------------------------------------------------------------!
350 TYPE(dict_typ), POINTER :: node
351 CHARACTER(LEN=10) :: b1,b2
352 !------------------------------------------------------------------------!
353 INTENT(IN) :: key, type, default
354 !------------------------------------------------------------------------!
355 CALL getattr0a(root, key, node)
356 IF(.NOT.ASSOCIATED(node)) THEN
357 IF(PRESENT(default)) THEN
358 CALL setattr0b(root,key,default,type)
359 CALL getattr0a(root, key, node)
360 IF(.NOT.ASSOCIATED(node)) &
361 CALL this%Error("GetAttr", "Setting a default value has gone wrong.")
362 ELSE
363 CALL this%Error("GetAttr", "Couldn't find key '"//trim(key)//"'.")
364 END IF
365 END IF
366 IF(type.NE.node%type) THEN
367 WRITE(b1,"(I4.4)") node%type
368 WRITE(b2,"(I4.4)") type
369 CALL this%Error("GetAttr", "Key '"//trim(key)//"' is of type "//trim(b1) &
370 //", but type "//trim(b2)//" requested.")
371 END IF
372 value => node%value
373 END SUBROUTINE getattr0b
374
377 FUNCTION findchild(root,key) RESULT(res)
378 IMPLICIT NONE
379 !------------------------------------------------------------------------!
380 CHARACTER(LEN=*), INTENT(IN) :: key
381 TYPE(dict_typ), POINTER :: root,res
382 !------------------------------------------------------------------------!
383 res => root
384 DO WHILE(ASSOCIATED(res))
385 IF(trim(res%key).EQ.trim(key)) EXIT
386 res => res%next
387 END DO
388 END FUNCTION findchild
389
391 FUNCTION getnext(root) RESULT(res)
392 IMPLICIT NONE
393 !------------------------------------------------------------------------!
394 TYPE(dict_typ), POINTER :: root, res
395 !------------------------------------------------------------------------!
396 res => root%next
397 END FUNCTION getnext
398
400 FUNCTION getlast(root) RESULT(res)
401 IMPLICIT NONE
402 !------------------------------------------------------------------------!
403 TYPE(dict_typ), POINTER :: root, res
404 !------------------------------------------------------------------------!
405 res => root
406 IF(ASSOCIATED(res)) THEN
407 DO WHILE(ASSOCIATED(res%next))
408 res => res%next
409 END DO
410 END IF
411 END FUNCTION getlast
412
414 FUNCTION getchild(root) RESULT(res)
415 IMPLICIT NONE
416 !------------------------------------------------------------------------!
417 TYPE(dict_typ), POINTER :: root, res
418 !------------------------------------------------------------------------!
419 res => root%child
420 END FUNCTION getchild
421
423 FUNCTION getkey(root) RESULT(res)
424 IMPLICIT NONE
425 !------------------------------------------------------------------------!
426 TYPE(dict_typ), POINTER :: root
427 type_dict_char :: res
428 !------------------------------------------------------------------------!
429 res = root%key
430 END FUNCTION getkey
431
435 FUNCTION getdatasize(root) RESULT(res)
436 IMPLICIT NONE
437 !------------------------------------------------------------------------!
438 TYPE(dict_typ), POINTER :: root
439 INTEGER :: res
440 !------------------------------------------------------------------------!
441 IF(ASSOCIATED(root%value)) THEN
442 res = SIZE(root%value)
443 ELSE
444 res = 0
445 END IF
446 END FUNCTION getdatasize
447
449 FUNCTION getdatatype(root) RESULT(res)
450 IMPLICIT NONE
451 !------------------------------------------------------------------------!
452 TYPE(dict_typ), POINTER :: root
453 INTEGER :: res
454 !------------------------------------------------------------------------!
455 res = root%type
456 END FUNCTION getdatatype
457
459 FUNCTION getdata(root) RESULT(res)
460 IMPLICIT NONE
461 !------------------------------------------------------------------------!
462 TYPE(dict_typ), POINTER :: root
463 type_dict_mold, POINTER :: res
464 !------------------------------------------------------------------------!
465 res => root%value
466 END FUNCTION getdata
467
469 FUNCTION haschild(root) RESULT(res)
470 IMPLICIT NONE
471 !------------------------------------------------------------------------!
472 TYPE(dict_typ), POINTER :: root
473 LOGICAL :: res
474 !------------------------------------------------------------------------!
475 res = ASSOCIATED(root%child)
476 END FUNCTION haschild
477
479 FUNCTION hasdata(root) RESULT(res)
480 IMPLICIT NONE
481 !------------------------------------------------------------------------!
482 TYPE(dict_typ), POINTER :: root
483 LOGICAL :: res
484 !------------------------------------------------------------------------!
485 res = ASSOCIATED(root%value)
486 END FUNCTION hasdata
487
489 FUNCTION haskey(root, key) RESULT(res)
490 IMPLICIT NONE
491 !------------------------------------------------------------------------!
492 TYPE(dict_typ), POINTER :: root
493 CHARACTER(LEN=*) :: key
494 LOGICAL :: res
495 !------------------------------------------------------------------------!
496 res = ASSOCIATED(findpath(root,trim(key)))
497 END FUNCTION haskey
498
500 SUBROUTINE setdata(node, val)
501 IMPLICIT NONE
502 !------------------------------------------------------------------------!
503 TYPE(dict_typ), POINTER :: node
504 type_dict_mold :: val
505 !------------------------------------------------------------------------!
506 INTENT(IN) :: val
507 !------------------------------------------------------------------------!
508 IF(SIZE(val).LE.0) &
509 CALL this%Error("SetData", "Array size smaller 0 is not possible.")
510 IF(ASSOCIATED(node%value)) &
511 DEALLOCATE(node%value)
512 ALLOCATE(node%value(SIZE(val)))
513 node%value = val
514 END SUBROUTINE setdata
515
519 FUNCTION tokenize(key,back) RESULT(res)
520 IMPLICIT NONE
521 !------------------------------------------------------------------------!
522 CHARACTER(LEN=MAX_CHAR_LEN) :: key
523 LOGICAL,OPTIONAL :: back
524 type_dict_char :: res
525 !------------------------------------------------------------------------!
526 LOGICAL :: back_
527 INTEGER :: i
528 !------------------------------------------------------------------------!
529 INTENT(IN) :: back
530 INTENT(INOUT) :: key
531 !------------------------------------------------------------------------!
532 IF(PRESENT(back)) THEN
533 back_ = back
534 ELSE
535 back_ = .false.
536 END IF
537 res = ''
538 IF(key(1:1).EQ.'/') key = key(2:)
539 i = scan(key,'/',back_)
540 IF(i.GT.0) THEN
541 IF(.NOT.back_) THEN
542 res = key(1:i-1)
543 key = key(i+1:)
544 ELSE
545 res = key(i+1:)
546 key = key(1:i-1)
547 END IF
548 ELSE
549 res = key
550 key = ''
551 END IF
552 END FUNCTION tokenize
553
559 FUNCTION dict(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,&
560 n18,n19,n20) RESULT(res)
561 IMPLICIT NONE
562 !------------------------------------------------------------------------!
563 TYPE(dict_typ), POINTER :: res,n1
564 TYPE(dict_typ), POINTER, OPTIONAL :: n2,n3,n4,n5,n6,n7,n8,n9,n10,n11, &
565 n12,n13,n14,n15,n16,n17,n18,n19,n20
566 !------------------------------------------------------------------------!
567 NULLIFY(res)
568 CALL setattr0a(res,'',n1)
569 IF(PRESENT( n2)) CALL setattr0a(res,'', n2)
570 IF(PRESENT( n3)) CALL setattr0a(res,'', n3)
571 IF(PRESENT( n4)) CALL setattr0a(res,'', n4)
572 IF(PRESENT( n5)) CALL setattr0a(res,'', n5)
573 IF(PRESENT( n6)) CALL setattr0a(res,'', n6)
574 IF(PRESENT( n7)) CALL setattr0a(res,'', n7)
575 IF(PRESENT( n8)) CALL setattr0a(res,'', n8)
576 IF(PRESENT( n9)) CALL setattr0a(res,'', n9)
577 IF(PRESENT(n10)) CALL setattr0a(res,'',n10)
578 IF(PRESENT(n11)) CALL setattr0a(res,'',n11)
579 IF(PRESENT(n12)) CALL setattr0a(res,'',n12)
580 IF(PRESENT(n13)) CALL setattr0a(res,'',n13)
581 IF(PRESENT(n14)) CALL setattr0a(res,'',n14)
582 IF(PRESENT(n15)) CALL setattr0a(res,'',n15)
583 IF(PRESENT(n16)) CALL setattr0a(res,'',n16)
584 IF(PRESENT(n17)) CALL setattr0a(res,'',n17)
585 IF(PRESENT(n18)) CALL setattr0a(res,'',n18)
586 IF(PRESENT(n19)) CALL setattr0a(res,'',n19)
587 IF(PRESENT(n20)) CALL setattr0a(res,'',n20)
588 END FUNCTION dict
589
590 SUBROUTINE setattr1(root, key, val)
591 IMPLICIT NONE
592 !------------------------------------------------------------------------!
593 TYPE(dict_typ), POINTER :: root
594 CHARACTER(LEN=*) :: key
595 type_dict_int :: val
596 !------------------------------------------------------------------------!
597 INTENT(IN) :: key, val
598 !------------------------------------------------------------------------!
599 CALL setattr0b(root,key,transfer(val,mold),dict_int)
600 END SUBROUTINE setattr1
601
602 SUBROUTINE setattr2(root, key, val)
603 IMPLICIT NONE
604 !------------------------------------------------------------------------!
605 TYPE(dict_typ), POINTER :: root
606 CHARACTER(LEN=*) :: key
607 type_dict_real :: val
608 !------------------------------------------------------------------------!
609 INTENT(IN) :: key, val
610 !------------------------------------------------------------------------!
611 CALL setattr0b(root,key,transfer(val,mold),dict_real)
612 END SUBROUTINE setattr2
613
614 SUBROUTINE setattr3(root, key, val)
615 IMPLICIT NONE
616 !------------------------------------------------------------------------!
617 TYPE(dict_typ), POINTER :: root
618 CHARACTER(LEN=*) :: key, val
619 type_dict_char :: val_
620 !------------------------------------------------------------------------!
621 INTENT(IN) :: key, val
622 !------------------------------------------------------------------------!
623 val_ = trim(val)
624 CALL setattr0b(root,key,transfer(val_,mold),dict_char)
625 END SUBROUTINE setattr3
626
627 SUBROUTINE setattr4(root, key, val)
628 IMPLICIT NONE
629 !------------------------------------------------------------------------!
630 TYPE(dict_typ), POINTER :: root
631 CHARACTER(LEN=*) :: key
632 type_dict_bool :: val
633 !------------------------------------------------------------------------!
634 INTENT(IN) :: key, val
635 !------------------------------------------------------------------------!
636 CALL setattr0b(root,key,transfer(val,mold),dict_bool)
637 END SUBROUTINE setattr4
638
639 SUBROUTINE setattr5(root, key, val)
640 IMPLICIT NONE
641 !------------------------------------------------------------------------!
642 TYPE(dict_typ), POINTER :: root
643 CHARACTER(LEN=*) :: key
644 type_dict_real_oned :: val
645 !------------------------------------------------------------------------!
646 INTENT(IN) :: key, val
647 !------------------------------------------------------------------------!
648 CALL setattr0b(root,key,transfer(val,mold),dict_real_oned)
649 END SUBROUTINE setattr5
650
651 SUBROUTINE setattr6(root, key, val)
652 IMPLICIT NONE
653 !------------------------------------------------------------------------!
654 TYPE(dict_typ), POINTER :: root
655 CHARACTER(LEN=*) :: key
656 REAL, DIMENSION(:,:), TARGET :: val
657 TYPE(real_twod_t) :: c
658 !------------------------------------------------------------------------!
659 INTENT(IN) :: key,val
660 !------------------------------------------------------------------------!
661 c%p => val
662 CALL setattr0b(root,key,transfer(c,mold),dict_real_twod)
663 END SUBROUTINE setattr6
664
665 SUBROUTINE setattr7(root, key, val)
666 IMPLICIT NONE
667 !------------------------------------------------------------------------!
668 TYPE(dict_typ), POINTER :: root
669 CHARACTER(LEN=*) :: key
670 REAL, DIMENSION(:,:,:), TARGET :: val
671 TYPE(real_threed_t) :: c
672 !------------------------------------------------------------------------!
673 INTENT(IN) :: key, val
674 !------------------------------------------------------------------------!
675 c%p => val
676 CALL setattr0b(root,key,transfer(c,mold),dict_real_threed)
677 END SUBROUTINE setattr7
678
679 SUBROUTINE setattr8(root, key, val)
680 IMPLICIT NONE
681 !------------------------------------------------------------------------!
682 TYPE(dict_typ), POINTER :: root
683 CHARACTER(LEN=*) :: key
684 REAL, DIMENSION(:,:,:,:), TARGET :: val
685 TYPE(real_fourd_t) :: c
686 !------------------------------------------------------------------------!
687 INTENT(IN) :: key, val
688 !------------------------------------------------------------------------!
689 c%p => val
690 CALL setattr0b(root,key,transfer(c,mold),dict_real_fourd)
691 END SUBROUTINE setattr8
692
693 SUBROUTINE setattr9(root, key, val)
694 IMPLICIT NONE
695 !------------------------------------------------------------------------!
696 TYPE(dict_typ), POINTER :: root
697 CHARACTER(LEN=*) :: key
698 type_dict_int_oned :: val
699 !------------------------------------------------------------------------!
700 INTENT(IN) :: key, val
701 !------------------------------------------------------------------------!
702 CALL setattr0b(root,key,transfer(val,mold),dict_int_oned)
703 END SUBROUTINE setattr9
704
705 SUBROUTINE setattr10(root, key, val)
706 IMPLICIT NONE
707 !------------------------------------------------------------------------!
708 TYPE(dict_typ), POINTER :: root
709 CHARACTER(LEN=*) :: key
710 TYPE(real_t) :: val
711 !------------------------------------------------------------------------!
712 INTENT(IN) :: key, val
713 !------------------------------------------------------------------------!
714 CALL setattr0b(root,key,transfer(val,mold),dict_real_p)
715 END SUBROUTINE setattr10
716
717 SUBROUTINE setattr11(root, key, val)
718 IMPLICIT NONE
719 !------------------------------------------------------------------------!
720 TYPE(dict_typ), POINTER :: root
721 CHARACTER(LEN=*) :: key
722 TYPE(int_t) :: val
723 !------------------------------------------------------------------------!
724 INTENT(IN) :: key, val
725 !------------------------------------------------------------------------!
726 CALL setattr0b(root,key,transfer(val,mold),dict_int_p)
727 END SUBROUTINE setattr11
728
729 SUBROUTINE setattr12(root, key, val)
730 IMPLICIT NONE
731 !------------------------------------------------------------------------!
732 TYPE(dict_typ), POINTER :: root
733 CHARACTER(LEN=*) :: key
734 REAL, DIMENSION(:,:,:,:,:), TARGET :: val
735 TYPE(real_fived_t) :: c
736 !------------------------------------------------------------------------!
737 INTENT(IN) :: key, val
738 !------------------------------------------------------------------------!
739 c%p => val
740 CALL setattr0b(root,key,transfer(c,mold),dict_real_fived)
741 END SUBROUTINE setattr12
742
743 RECURSIVE SUBROUTINE printdict(root, prefix)
744 IMPLICIT NONE
745 !------------------------------------------------------------------------!
746 TYPE(dict_typ), TARGET ::root
747 CHARACTER(LEN=*), OPTIONAL :: prefix
748 !------------------------------------------------------------------------!
749 TYPE(dict_typ), POINTER :: node
750 type_dict_char :: prefix_
751 type_dict_char :: s,str
752 !------------------------------------------------------------------------!
753 node => root
754 prefix_ = ''
755 IF(PRESENT(prefix)) &
756 prefix_ = trim(prefix)
757 DO WHILE(ASSOCIATED(node))
758 WRITE(s,'(A,A,A)') trim(prefix_),'/',trim(node%key)
759 IF(ASSOCIATED(node%value)) THEN
760 WRITE(str,'(A,I2,A,A,A,I4)') "type=",node%type,", key=",trim(s),&
761 ", size=",SIZE(node%value)
762 ELSE
763 WRITE(str,'(A,I2,A,A)') "type=",node%type,", key=",trim(s)
764 END IF
765 CALL this%Info(str)
766 IF(ASSOCIATED(node%child)) &
767 CALL printdict(node%child, s)
768 node => node%next
769 END DO
770 END SUBROUTINE printdict
771
773 RECURSIVE SUBROUTINE copydict(root, outdir)
774 IMPLICIT NONE
775 !------------------------------------------------------------------------!
776 TYPE(dict_typ), POINTER :: root, outdir, dir, odir, tmp
777 !------------------------------------------------------------------------!
778 dir => root
779 NULLIFY(outdir)
780 NULLIFY(odir)
781 DO WHILE(ASSOCIATED(dir))
782 IF(ASSOCIATED(odir)) THEN
783 ALLOCATE(odir%next)
784 odir => odir%next
785 ELSE
786 ALLOCATE(odir)
787 outdir => odir
788 END IF
789 odir%type = dir%type
790 odir%key = dir%key
791 IF(ASSOCIATED(dir%value)) THEN
792 CALL setdata(odir,dir%value)
793 END IF
794
795 IF(ASSOCIATED(dir%child)) THEN
796 CALL copydict(dir%child, tmp)
797 odir%child => tmp
798 END IF
799 dir => dir%next
800 END DO
801 END SUBROUTINE copydict
802
803
805 RECURSIVE SUBROUTINE copyhierarchy(root, outdir)
806 IMPLICIT NONE
807 !------------------------------------------------------------------------!
808 TYPE(dict_typ), POINTER :: root, outdir, dir, odir
809 !------------------------------------------------------------------------!
810 dir => root
811 NULLIFY(outdir)
812 NULLIFY(odir)
813 DO WHILE(ASSOCIATED(dir))
814 IF(ASSOCIATED(dir%child)) THEN
815 IF(ASSOCIATED(odir)) THEN
816 ALLOCATE(odir%next)
817 odir => odir%next
818 ELSE
819 ALLOCATE(odir)
820 outdir => odir
821 END IF
822 odir%key = dir%key
823 CALL copyhierarchy(dir%child,odir%child)
824 END IF
825 dir => dir%next
826 END DO
827 END SUBROUTINE copyhierarchy
828
831 SUBROUTINE getattr0(root, key, res)
832 IMPLICIT NONE
833 !------------------------------------------------------------------------!
834 TYPE(dict_typ), POINTER :: root, res
835 CHARACTER(LEN=*) :: key
836 !------------------------------------------------------------------------!
837 INTENT(IN) :: key
838 !------------------------------------------------------------------------!
839 CALL getattr0a(root, key, res)
840 IF(ASSOCIATED(res)) THEN
841 IF(.NOT.hasdata(res).AND.haschild(res)) THEN
842 res => res%child
843 END IF
844 END IF
845 END SUBROUTINE getattr0
846
847 SUBROUTINE getattr1(root, key, res, default)
848 IMPLICIT NONE
849 !------------------------------------------------------------------------!
850 TYPE(dict_typ), POINTER :: root
851 type_dict_int :: res
852 type_dict_int, OPTIONAL :: default
853 CHARACTER(LEN=*) :: key
854 !------------------------------------------------------------------------!
855 type_dict_mold, POINTER :: value
856 !------------------------------------------------------------------------!
857 INTENT(IN) :: key, default
858 INTENT(INOUT) :: res
859 !------------------------------------------------------------------------!
860 IF(PRESENT(default)) THEN
861 CALL getattr0b(root, key, dict_int, value, transfer(default,mold))
862 ELSE
863 CALL getattr0b(root, key, dict_int, value)
864 END IF
865 res = transfer(value,res)
866 END SUBROUTINE getattr1
867
868 SUBROUTINE getattr2(root, key, res, default)
869 IMPLICIT NONE
870 !------------------------------------------------------------------------!
871 TYPE(dict_typ), POINTER :: root
872 type_dict_real :: res
873 type_dict_real, OPTIONAL :: default
874 CHARACTER(LEN=*) :: key
875 !------------------------------------------------------------------------!
876 type_dict_mold, POINTER :: value
877 !------------------------------------------------------------------------!
878 INTENT(IN) :: key, default
879 INTENT(INOUT) :: res
880 !------------------------------------------------------------------------!
881 IF(PRESENT(default)) THEN
882 CALL getattr0b(root, key, dict_real, value, transfer(default,mold))
883 ELSE
884 CALL getattr0b(root, key, dict_real, value)
885 END IF
886 res = transfer(value,res)
887 END SUBROUTINE getattr2
888
889 SUBROUTINE getattr3(root, key, res, default)
890 IMPLICIT NONE
891 !------------------------------------------------------------------------!
892 TYPE(dict_typ), POINTER :: root
893 type_dict_char :: res
894 type_dict_char, OPTIONAL :: default
895 CHARACTER(LEN=*) :: key
896 !------------------------------------------------------------------------!
897 type_dict_mold, POINTER :: value
898 !------------------------------------------------------------------------!
899 INTENT(IN) :: key
900 INTENT(INOUT) :: res
901 !------------------------------------------------------------------------!
902 IF(PRESENT(default)) THEN
903 CALL getattr0b(root, key, dict_char, value, transfer(default,mold))
904 ELSE
905 CALL getattr0b(root, key, dict_char, value)
906 END IF
907 res = transfer(value,res)
908 END SUBROUTINE getattr3
909
910 SUBROUTINE getattr4(root, key, res, default)
911 IMPLICIT NONE
912 !------------------------------------------------------------------------!
913 TYPE(dict_typ), POINTER :: root
914 type_dict_bool :: res
915 type_dict_bool, OPTIONAL :: default
916 CHARACTER(LEN=*) :: key
917 !------------------------------------------------------------------------!
918 type_dict_mold, POINTER :: value
919 !------------------------------------------------------------------------!
920 INTENT(IN) :: key
921 INTENT(INOUT) :: res
922 !------------------------------------------------------------------------!
923 IF(PRESENT(default)) THEN
924 CALL getattr0b(root, key, dict_bool, value, transfer(default,mold))
925 ELSE
926 CALL getattr0b(root, key, dict_bool, value)
927 END IF
928 res = transfer(value,res)
929 END SUBROUTINE getattr4
930
931 SUBROUTINE getattr5(root, key, res, default)
932 IMPLICIT NONE
933 !------------------------------------------------------------------------!
934 TYPE(dict_typ), POINTER :: root
935 type_dict_real_oned :: res
936 type_dict_real_oned, OPTIONAL :: default
937 CHARACTER(LEN=*) :: key
938 !------------------------------------------------------------------------!
939 type_dict_mold, POINTER :: value
940 !------------------------------------------------------------------------!
941 INTENT(IN) :: key
942 INTENT(INOUT) :: res
943 !------------------------------------------------------------------------!
944 IF(PRESENT(default)) THEN
945 CALL getattr0b(root, key, dict_real_oned, value, transfer(default,mold))
946 ELSE
947 CALL getattr0b(root, key, dict_real_oned, value)
948 END IF
949 IF(SIZE(transfer(value,res)).NE.SIZE(res)) &
950 CALL this%Error("GetAttr5","1D array with key '" // trim(key) &
951 // "' has the wrong size.")
952
953 res = transfer(value,res)
954 END SUBROUTINE getattr5
955
956 SUBROUTINE getattr6(root, key, res, default)
957 IMPLICIT NONE
958 !------------------------------------------------------------------------!
959 TYPE(dict_typ), POINTER :: root
960 type_dict_real_twod :: res
961 type_dict_real_twod, OPTIONAL :: default
962 CHARACTER(LEN=*) :: key
963 !------------------------------------------------------------------------!
964 type_dict_mold, POINTER :: value
965 TYPE(real_twod_t) :: c
966 !------------------------------------------------------------------------!
967 INTENT(IN) :: key
968 !------------------------------------------------------------------------!
969 IF(PRESENT(default)) THEN
970 c%p => default
971 CALL getattr0b(root, key, dict_real_twod, value, transfer(c,mold))
972 ELSE
973 CALL getattr0b(root, key, dict_real_twod, value)
974 END IF
975 c = transfer(value,c)
976 res => c%p
977 END SUBROUTINE getattr6
978
979 SUBROUTINE getattr7(root, key, res, default)
980 IMPLICIT NONE
981 !------------------------------------------------------------------------!
982 TYPE(dict_typ), POINTER :: root
983 type_dict_real_threed :: res
984 type_dict_real_threed, OPTIONAL :: default
985 CHARACTER(LEN=*) :: key
986 !------------------------------------------------------------------------!
987 type_dict_mold, POINTER :: value
988 TYPE(real_threed_t) :: c
989 !------------------------------------------------------------------------!
990 INTENT(IN) :: key
991 !------------------------------------------------------------------------!
992 IF(PRESENT(default)) THEN
993 c%p => default
994 CALL getattr0b(root, key, dict_real_threed, value, transfer(c,mold))
995 ELSE
996 CALL getattr0b(root, key, dict_real_threed, value)
997 END IF
998 c = transfer(value,c)
999 res => c%p
1000 END SUBROUTINE getattr7
1001
1002 SUBROUTINE getattr8(root, key, res, default)
1003 IMPLICIT NONE
1004 !------------------------------------------------------------------------!
1005 TYPE(dict_typ), POINTER :: root
1006 type_dict_real_fourd :: res
1007 type_dict_real_fourd, OPTIONAL :: default
1008 CHARACTER(LEN=*) :: key
1009 !------------------------------------------------------------------------!
1010 type_dict_mold, POINTER :: value
1011 TYPE(real_fourd_t) :: c
1012 !------------------------------------------------------------------------!
1013 INTENT(IN) :: key
1014 !------------------------------------------------------------------------!
1015 IF(PRESENT(default)) THEN
1016 c%p => default
1017 CALL getattr0b(root, key, dict_real_fourd, value, transfer(c,mold))
1018 ELSE
1019 CALL getattr0b(root, key, dict_real_fourd, value)
1020 END IF
1021 c = transfer(value,c)
1022 res => c%p
1023 END SUBROUTINE getattr8
1024
1025 SUBROUTINE getattr9(root, key, res, default)
1026 IMPLICIT NONE
1027 !------------------------------------------------------------------------!
1028 TYPE(dict_typ), POINTER :: root
1029 type_dict_int_oned :: res
1030 type_dict_int_oned, OPTIONAL :: default
1031 CHARACTER(LEN=*) :: key
1032 !------------------------------------------------------------------------!
1033 type_dict_mold, POINTER :: value
1034 !------------------------------------------------------------------------!
1035 INTENT(IN) :: key
1036 INTENT(INOUT) :: res
1037 !------------------------------------------------------------------------!
1038 IF(PRESENT(default)) THEN
1039 CALL getattr0b(root, key, dict_int_oned, value, transfer(default,mold))
1040 ELSE
1041 CALL getattr0b(root, key, dict_int_oned, value)
1042 END IF
1043 res = transfer(value,res)
1044 END SUBROUTINE getattr9
1045
1046 SUBROUTINE getattr10(root, key, res, default)
1047 IMPLICIT NONE
1048 !------------------------------------------------------------------------!
1049 TYPE(dict_typ), POINTER :: root
1050 TYPE(real_t) :: res
1051 TYPE(real_t), OPTIONAL :: default
1052 CHARACTER(LEN=*) :: key
1053 !------------------------------------------------------------------------!
1054 type_dict_mold, POINTER :: value
1055 !------------------------------------------------------------------------!
1056 INTENT(IN) :: key
1057 !------------------------------------------------------------------------!
1058 IF(PRESENT(default)) THEN
1059 CALL getattr0b(root, key, dict_real_p, value, transfer(default,mold))
1060 ELSE
1061 CALL getattr0b(root, key, dict_real_p, value)
1062 END IF
1063 res = transfer(value,res)
1064 END SUBROUTINE getattr10
1065
1066 SUBROUTINE getattr11(root, key, res, default)
1067 IMPLICIT NONE
1068 !------------------------------------------------------------------------!
1069 TYPE(dict_typ), POINTER :: root
1070 TYPE(int_t) :: res
1071 TYPE(int_t), OPTIONAL :: default
1072 CHARACTER(LEN=*) :: key
1073 !------------------------------------------------------------------------!
1074 type_dict_mold, POINTER :: value
1075 !------------------------------------------------------------------------!
1076 INTENT(IN) :: key
1077 !------------------------------------------------------------------------!
1078 IF(PRESENT(default)) THEN
1079 CALL getattr0b(root, key, dict_int_p, value, transfer(default,mold))
1080 ELSE
1081 CALL getattr0b(root, key, dict_int_p, value)
1082 END IF
1083 res = transfer(value,res)
1084 END SUBROUTINE getattr11
1085
1086 SUBROUTINE getattr12(root, key, res, default)
1087 IMPLICIT NONE
1088 !------------------------------------------------------------------------!
1089 TYPE(dict_typ), POINTER :: root
1090 type_dict_real_fived :: res
1091 type_dict_real_fived, OPTIONAL :: default
1092 CHARACTER(LEN=*) :: key
1093 !------------------------------------------------------------------------!
1094 type_dict_mold, POINTER :: value
1095 TYPE(real_fived_t) :: c
1096 !------------------------------------------------------------------------!
1097 INTENT(IN) :: key
1098 !------------------------------------------------------------------------!
1099 IF(PRESENT(default)) THEN
1100 c%p => default
1101 CALL getattr0b(root, key, dict_real_fived, value, transfer(c,mold))
1102 ELSE
1103 CALL getattr0b(root, key, dict_real_fived, value)
1104 END IF
1105 c = transfer(value,c)
1106 res => c%p
1107 END SUBROUTINE getattr12
1108
1109 SUBROUTINE deletenode(node,k)
1110 IMPLICIT NONE
1111 !------------------------------------------------------------------------!
1112 TYPE(dict_typ), POINTER :: node
1113 CHARACTER(LEN=*) :: k
1114 LOGICAL, SAVE :: first=.true.
1115 !------------------------------------------------------------------------!
1116 INTEGER :: status
1117 CHARACTER(LEN=512) :: str
1118 !------------------------------------------------------------------------!
1119 NULLIFY(node%child,node%next)
1120 IF(ASSOCIATED(node%value)) &
1121 DEALLOCATE(node%value)
1122 DEALLOCATE(node,stat=status)
1123 IF(status.NE.0.AND.first) THEN
1124 ! This warning (no. 195) does occur on the SX ACE. The definite reason
1125 ! is unknown. It is probably related to deallocating a pointer, which
1126 ! has been associated to a TARGET subroutine parameter. But this cannot
1127 ! be change, since a TARGET instead of a POINTER is required for
1128 ! overloading the '/' operator.
1129 WRITE(str,'(A,A,A,I3)')&
1130 "Deallocating key '",trim(k),&
1131 "' throws the error nio.: ",status
1132 !CALL Warning(this,"SetAttr0a",TRIM(str))
1133 WRITE(str,'(A,A,A,I3)')&
1134 "More invocations of this error will be suppressed."
1135 !CALL Warning(this,"SetAttr0a",TRIM(str))
1136 first = .false.
1137 END IF
1138 END SUBROUTINE deletenode
1139
1141 RECURSIVE SUBROUTINE deletedict(root)
1142 IMPLICIT NONE
1143 !------------------------------------------------------------------------!
1144 TYPE(dict_typ), POINTER :: root, node, next, child
1145 !------------------------------------------------------------------------!
1146 type_dict_char :: k
1147 !------------------------------------------------------------------------!
1148 node => root
1149 DO WHILE(ASSOCIATED(node))
1150 next => node%next
1151 child => node%child
1152 k = trim(node%key)
1153 CALL deletenode(node,trim(k))
1154 IF (ASSOCIATED(child)) &
1155 CALL deletedict(child)
1156 node => next
1157 END DO
1158 NULLIFY(root)
1159 END SUBROUTINE deletedict
1160
1161 FUNCTION assign0(key, val) RESULT(res)
1162 IMPLICIT NONE
1163 !------------------------------------------------------------------------!
1164 TYPE(dict_typ), POINTER :: res
1165 CHARACTER(LEN=*) :: key
1166 TYPE(dict_typ), TARGET :: val
1167 !------------------------------------------------------------------------!
1168 INTENT(IN) :: key,val
1169 !------------------------------------------------------------------------!
1170 NULLIFY(res)
1171 CALL setattr(res, key, val)
1172 END FUNCTION assign0
1173
1174 FUNCTION assign1(key, val) RESULT(res)
1175 IMPLICIT NONE
1176 !------------------------------------------------------------------------!
1177 TYPE(dict_typ), POINTER :: res
1178 CHARACTER(LEN=*) :: key
1179 type_dict_int :: val
1180 !------------------------------------------------------------------------!
1181 INTENT(IN) :: key, val
1182 !------------------------------------------------------------------------!
1183 NULLIFY(res)
1184 CALL setattr(res, key, val)
1185 END FUNCTION assign1
1186
1187 FUNCTION assign2(key, val) RESULT(res)
1188 IMPLICIT NONE
1189 !------------------------------------------------------------------------!
1190 TYPE(dict_typ), POINTER :: res
1191 CHARACTER(LEN=*) :: key
1192 type_dict_real :: val
1193 !------------------------------------------------------------------------!
1194 INTENT(IN) :: key, val
1195 !------------------------------------------------------------------------!
1196 NULLIFY(res)
1197 CALL setattr(res, key, val)
1198 END FUNCTION assign2
1199
1200 FUNCTION assign3(key, val) RESULT(res)
1201 IMPLICIT NONE
1202 !------------------------------------------------------------------------!
1203 TYPE(dict_typ), POINTER :: res
1204 CHARACTER(LEN=*) :: key, val
1205 !------------------------------------------------------------------------!
1206 INTENT(IN) :: key, val
1207 !------------------------------------------------------------------------!
1208 NULLIFY(res)
1209 CALL setattr(res, key, val)
1210 END FUNCTION assign3
1211
1212 FUNCTION assign4(key, val) RESULT(res)
1213 IMPLICIT NONE
1214 !------------------------------------------------------------------------!
1215 TYPE(dict_typ), POINTER :: res
1216 CHARACTER(LEN=*) :: key
1217 type_dict_bool :: val
1218 !------------------------------------------------------------------------!
1219 INTENT(IN) :: key, val
1220 !------------------------------------------------------------------------!
1221 NULLIFY(res)
1222 CALL setattr(res, key, val)
1223 END FUNCTION assign4
1224
1225 FUNCTION assign5(key, val) RESULT(res)
1226 IMPLICIT NONE
1227 !------------------------------------------------------------------------!
1228 TYPE(dict_typ), POINTER :: res
1229 CHARACTER(LEN=*) :: key
1230 type_dict_real_oned :: val
1231 !------------------------------------------------------------------------!
1232 INTENT(IN) :: key, val
1233 !------------------------------------------------------------------------!
1234 NULLIFY(res)
1235 CALL setattr(res, key, val)
1236 END FUNCTION assign5
1237
1238 FUNCTION assign6(key, val) RESULT(res)
1239 IMPLICIT NONE
1240 !------------------------------------------------------------------------!
1241 TYPE(dict_typ), POINTER :: res
1242 CHARACTER(LEN=*) :: key
1243 REAL, DIMENSION(:,:), TARGET :: val
1244 !------------------------------------------------------------------------!
1245 INTENT(IN) :: key, val
1246 !------------------------------------------------------------------------!
1247 NULLIFY(res)
1248 CALL setattr(res, key, val)
1249 END FUNCTION assign6
1250
1251 FUNCTION assign7(key, val) RESULT(res)
1252 IMPLICIT NONE
1253 !------------------------------------------------------------------------!
1254 TYPE(dict_typ), POINTER :: res
1255 CHARACTER(LEN=*) :: key
1256 REAL, DIMENSION(:,:,:), TARGET :: val
1257 !------------------------------------------------------------------------!
1258 INTENT(IN) :: key, val
1259 !------------------------------------------------------------------------!
1260 NULLIFY(res)
1261 CALL setattr(res, key, val)
1262 END FUNCTION assign7
1263
1264 FUNCTION assign8(key, val) RESULT(res)
1265 IMPLICIT NONE
1266 !------------------------------------------------------------------------!
1267 TYPE(dict_typ), POINTER :: res
1268 CHARACTER(LEN=*) :: key
1269 REAL, DIMENSION(:,:,:,:), TARGET :: val
1270 !------------------------------------------------------------------------!
1271 INTENT(IN) :: key, val
1272 !------------------------------------------------------------------------!
1273 NULLIFY(res)
1274 CALL setattr(res, key, val)
1275 END FUNCTION assign8
1276
1277 FUNCTION assign9(key, val) RESULT(res)
1278 IMPLICIT NONE
1279 !------------------------------------------------------------------------!
1280 TYPE(dict_typ), POINTER :: res
1281 CHARACTER(LEN=*) :: key
1282 type_dict_int_oned :: val
1283 !------------------------------------------------------------------------!
1284 INTENT(IN) :: key, val
1285 !------------------------------------------------------------------------!
1286 NULLIFY(res)
1287 CALL setattr(res, key, val)
1288 END FUNCTION assign9
1289
1290 FUNCTION assign10(key, val) RESULT(res)
1291 IMPLICIT NONE
1292 !------------------------------------------------------------------------!
1293 TYPE(dict_typ), POINTER :: res
1294 CHARACTER(LEN=*) :: key
1295 TYPE(real_t) :: val
1296 !------------------------------------------------------------------------!
1297 INTENT(IN) :: key, val
1298 !------------------------------------------------------------------------!
1299 NULLIFY(res)
1300 CALL setattr(res, key, val)
1301 END FUNCTION assign10
1302
1303 FUNCTION assign11(key, val) RESULT(res)
1304 IMPLICIT NONE
1305 !------------------------------------------------------------------------!
1306 TYPE(dict_typ), POINTER :: res
1307 CHARACTER(LEN=*) :: key
1308 TYPE(int_t) :: val
1309 !------------------------------------------------------------------------!
1310 INTENT(IN) :: key, val
1311 !------------------------------------------------------------------------!
1312 NULLIFY(res)
1313 CALL setattr(res, key, val)
1314 END FUNCTION assign11
1315
1316 FUNCTION assign12(key, val) RESULT(res)
1317 IMPLICIT NONE
1318 !------------------------------------------------------------------------!
1319 TYPE(dict_typ), POINTER :: res
1320 CHARACTER(LEN=*) :: key
1321 REAL, DIMENSION(:,:,:,:,:), TARGET :: val
1322 !------------------------------------------------------------------------!
1323 INTENT(IN) :: key, val
1324 !------------------------------------------------------------------------!
1325 NULLIFY(res)
1326 CALL setattr(res, key, val)
1327 END FUNCTION assign12
1328
1329 FUNCTION ref1(p) RESULT(res)
1330 IMPLICIT NONE
1331 !------------------------------------------------------------------------!
1332 type_dict_real_p :: p
1333 TYPE(real_t) :: res
1334 !------------------------------------------------------------------------!
1335 res%p => p
1336 END FUNCTION ref1
1337
1338 FUNCTION ref2(p) RESULT(res)
1339 IMPLICIT NONE
1340 !------------------------------------------------------------------------!
1341 type_dict_int_p :: p
1342 TYPE(int_t) :: res
1343 !------------------------------------------------------------------------!
1344 res%p => p
1345 END FUNCTION ref2
1346
1347END MODULE common_dict
Dictionary for generic data types.
Definition: common_dict.f90:61
integer, parameter, public dict_real
Definition: common_dict.f90:95
subroutine getattr8(root, key, res, default)
subroutine getattr6(root, key, res, default)
type(dict_typ) function, pointer assign9(key, val)
recursive subroutine, public deletedict(root)
Delete the dictionary 'root' and all subnodes.
recursive subroutine setattr0a(root, key, value)
Set the dictionary 'value' as child at the path 'key' relative to 'root'. If a child at this path is ...
integer, parameter, public dict_int_oned
subroutine setattr5(root, key, val)
pointer, public getdata(root)
Return the datatype of node 'root'.
type(dict_typ) function, pointer assign10(key, val)
type(dict_typ) function, pointer findpath(root, key, create)
Search for the path in 'key' beginning at root and return a pointer to this node in 'res'....
subroutine getattr4(root, key, res, default)
subroutine setattr0b(root, key, value, type)
Create an empty node at path 'key' relative to 'root', if value and type are not defined....
subroutine getattr1(root, key, res, default)
subroutine setattr12(root, key, val)
logical function, public haschild(root)
Check if the node 'root' has one or more children.
type(dict_typ) function, pointer assign1(key, val)
integer, parameter, public dict_real_fourd
logical function, public haskey(root, key)
Checks if a node with key 'key' exists.
logical function, public hasdata(root)
Checks if the node 'root' has data associated.
subroutine getattr11(root, key, res, default)
integer, parameter, public dict_real_threed
subroutine getattr9(root, key, res, default)
subroutine setattr8(root, key, val)
subroutine setattr3(root, key, val)
integer, parameter, public dict_int_p
integer function, public getdatatype(root)
Return the datatype of node 'root'.
function, public getkey(root)
Get the key of pointer 'root'.
integer function, public getdatasize(root)
Get the size of the data in node 'root'. If there is no data 0 is returned. note: This is also the by...
type(real_t) function ref1(p)
subroutine getattr3(root, key, res, default)
recursive subroutine, public copydict(root, outdir)
Copy complete Dictionary.
subroutine getattr10(root, key, res, default)
type(dict_typ) function, pointer assign5(key, val)
type(dict_typ) function, pointer assign6(key, val)
subroutine getattr0b(root, key, type, value, default)
Retrieve the data 'value' of kind 'type' at path 'key' relative to 'root'. If the path can not be fou...
subroutine setattr6(root, key, val)
function tokenize(key, back)
Cuts a path into two tokens, which is explained best with an example: back=.FALSE....
subroutine deletenode(node, k)
integer, parameter, public dict_real_fived
type(dict_typ) function, pointer, public dict(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20)
Construct a new dictionary from several key/value pairs. Together with the Assign subroutine and over...
integer, parameter, public max_char_len
Definition: common_dict.f90:92
subroutine getattr0(root, key, res)
Return the node at path 'key' relative to 'root' in 'res'. If this node has no data,...
integer, parameter, public dict_real_twod
Definition: common_dict.f90:99
integer, parameter, public dict_real_p
type(int_t) function ref2(p)
type(dict_typ) function, pointer assign8(key, val)
subroutine, public initdict()
type(dict_typ) function, pointer assign2(key, val)
type(dict_typ) function, pointer assign4(key, val)
subroutine setattr2(root, key, val)
type(dict_typ) function, pointer assign0(key, val)
type(dict_typ) function, pointer getlast(root)
Get the pointer to the last child.
type(dict_typ) function, pointer assign12(key, val)
type(dict_typ) function, pointer assign7(key, val)
subroutine getattr2(root, key, res, default)
type(dict_typ) function, pointer assign11(key, val)
subroutine setattr1(root, key, val)
recursive subroutine, public copyhierarchy(root, outdir)
Copy all nodes, which have children from 'root' to 'outdir'.
type(dict_typ) function, pointer findchild(root, key)
Find the direct child with key 'key' in a list of childs. 'root' points to the first child....
subroutine, public closedict()
type(dict_typ) function, pointer, public getnext(root)
Get the pointer to the next child.
subroutine setattr10(root, key, val)
integer, parameter, public dict_real_oned
Definition: common_dict.f90:98
recursive subroutine, public printdict(root, prefix)
subroutine getattr0a(root, key, parent)
Retrieve the node at path 'key' relative to 'root'. The result will be given as third argument 'paren...
type(dict_typ) function, pointer assign3(key, val)
type(logging_base), save this
integer, parameter, public dict_int
Definition: common_dict.f90:94
type(dict_typ) function, pointer, public getchild(root)
Get the pointer to a direct child of the pointer 'root'.
integer, parameter, public dict_char
Definition: common_dict.f90:96
subroutine getattr7(root, key, res, default)
subroutine setattr11(root, key, val)
subroutine getattr5(root, key, res, default)
subroutine setattr9(root, key, val)
integer, parameter, public dict_none
Definition: common_dict.f90:93
subroutine, public setdata(node, val)
Set data of 'node' ot 'val'.
subroutine getattr12(root, key, res, default)
subroutine setattr7(root, key, val)
integer, parameter, public dict_bool
Definition: common_dict.f90:97
subroutine setattr4(root, key, val)
Basic fosite module.
character(len=1), save prefix
preceds info output
common data structure