70 INTERFACE nodes_create_start
71 MODULE PROCEDURE nodes_create_start_region
72 MODULE PROCEDURE nodes_create_start_interface
76 INTERFACE nodes_initialise
77 MODULE PROCEDURE nodes_initialise_region
78 MODULE PROCEDURE nodes_initialise_interface
82 INTERFACE nodes_label_get
83 MODULE PROCEDURE nodes_label_get_c
84 MODULE PROCEDURE nodes_label_get_vs
88 INTERFACE nodes_label_set
89 MODULE PROCEDURE nodes_label_set_c
90 MODULE PROCEDURE nodes_label_set_vs
93 PUBLIC node_check_exists
95 PUBLIC nodes_create_finish,nodes_create_start,nodes_destroy
97 PUBLIC nodes_label_get,nodes_label_set
99 PUBLIC nodes_number_of_nodes_get
101 PUBLIC nodes_user_number_get,nodes_user_number_set
103 PUBLIC nodesusernumbersallset
114 SUBROUTINE node_check_exists(NODES,USER_NUMBER,NODE_EXISTS,GLOBAL_NUMBER,ERR,ERROR,*)
118 INTEGER(INTG),
INTENT(IN) :: user_number
119 LOGICAL,
INTENT(OUT) :: node_exists
120 INTEGER(INTG),
INTENT(OUT) :: global_number
121 INTEGER(INTG),
INTENT(OUT) :: err
126 enters(
"NODE_CHECK_EXISTS",err,error,*999)
130 IF(
ASSOCIATED(nodes))
THEN 132 CALL tree_search(nodes%NODES_TREE,user_number,tree_node,err,error,*999)
133 IF(
ASSOCIATED(tree_node))
THEN 138 CALL flagerror(
"Nodes is not associated.",err,error,*999)
141 exits(
"NODE_CHECK_EXISTS")
143 999 errorsexits(
"NODE_CHECK_EXISTS",err,error)
145 END SUBROUTINE node_check_exists
152 SUBROUTINE node_finalise(NODE,ERR,ERROR,*)
156 INTEGER(INTG),
INTENT(OUT) :: err
160 enters(
"NODE_FINALISE",err,error,*999)
166 exits(
"NODE_FINALISE")
168 999 errorsexits(
"NODE_FINALISE",err,error)
170 END SUBROUTINE node_finalise
177 SUBROUTINE nodes_create_finish(NODES,ERR,ERROR,*)
181 INTEGER(INTG),
INTENT(OUT) :: err
186 enters(
"NODES_CREATE_FINISH",err,error,*999)
188 IF(
ASSOCIATED(nodes))
THEN 189 IF(nodes%NODES_FINISHED)
THEN 190 CALL flagerror(
"Nodes have already been finished.",err,error,*999)
192 nodes%NODES_FINISHED=.true.
195 CALL flagerror(
"Nodes is not associated.",err,error,*999)
200 DO np=1,nodes%NUMBER_OF_NODES
213 exits(
"NODES_CREATE_FINISH")
215 999 errorsexits(
"NODES_CREATE_FINISH",err,error)
218 END SUBROUTINE nodes_create_finish
225 SUBROUTINE nodes_create_start_generic(NODES,NUMBER_OF_NODES,ERR,ERROR,*)
229 INTEGER(INTG),
INTENT(IN) :: number_of_nodes
230 INTEGER(INTG),
INTENT(OUT) :: err
233 INTEGER(INTG) :: insert_status,np
236 enters(
"NODES_CREATE_START_GENERIC",err,error,*999)
238 IF(
ASSOCIATED(nodes))
THEN 239 IF(number_of_nodes>0)
THEN 240 ALLOCATE(nodes%NODES(number_of_nodes),stat=err)
241 IF(err/=0)
CALL flagerror(
"Could not allocate nodes nodes.",err,error,*999)
242 nodes%NUMBER_OF_NODES=number_of_nodes
247 DO np=1,nodes%NUMBER_OF_NODES
248 nodes%NODES(np)%GLOBAL_NUMBER=np
249 nodes%NODES(np)%USER_NUMBER=np
250 nodes%NODES(np)%LABEL=
"" 254 local_error=
"The specified number of nodes of "//
trim(
number_to_vstring(number_of_nodes,
"*",err,error))// &
255 &
" is invalid. The number of nodes must be > 0." 256 CALL flagerror(local_error,err,error,*999)
259 CALL flagerror(
"Nodes is not associated.",err,error,*999)
262 exits(
"NODES_CREATE_GENERIC")
264 999 errorsexits(
"NODES_CREATE_START_GENERIC",err,error)
267 END SUBROUTINE nodes_create_start_generic
274 SUBROUTINE nodes_create_start_interface(INTERFACE,NUMBER_OF_NODES,NODES,ERR,ERROR,*)
278 INTEGER(INTG),
INTENT(IN) :: number_of_nodes
280 INTEGER(INTG),
INTENT(OUT) :: err
283 INTEGER(INTG) :: dummy_err
286 enters(
"NODES_CREATE_START_INTERFACE",err,error,*998)
288 IF(
ASSOCIATED(interface))
THEN 289 IF(
ASSOCIATED(nodes))
THEN 290 CALL flagerror(
"Nodes is already associated.",err,error,*999)
292 IF(
ASSOCIATED(interface%NODES))
THEN 293 CALL flagerror(
"Interface already has nodes associated.",err,error,*998)
296 CALL nodes_initialise(interface,err,error,*999)
298 CALL nodes_create_start_generic(interface%NODES,number_of_nodes,err,error,*999)
300 nodes=>interface%NODES
304 CALL flagerror(
"Interface is not associated.",err,error,*998)
307 exits(
"NODES_CREATE_START_INTERFACE")
309 999
CALL nodes_finalise(interface%NODES,dummy_err,dummy_error,*998)
310 998 errorsexits(
"NODES_CREATE_START_INTERFACE",err,error)
313 END SUBROUTINE nodes_create_start_interface
320 SUBROUTINE nodes_create_start_region(REGION,NUMBER_OF_NODES,NODES,ERR,ERROR,*)
324 INTEGER(INTG),
INTENT(IN) :: number_of_nodes
326 INTEGER(INTG),
INTENT(OUT) :: err
329 INTEGER(INTG) :: dummy_err
332 enters(
"NODES_CREATE_START_REGION",err,error,*998)
335 IF(
ASSOCIATED(region))
THEN 336 IF(
ASSOCIATED(region%NODES))
THEN 337 CALL flagerror(
"Region already has nodes associated.",err,error,*998)
339 IF(
ASSOCIATED(nodes))
THEN 340 CALL flagerror(
"Nodes is already associated.",err,error,*998)
343 CALL nodes_initialise(region,err,error,*999)
345 CALL nodes_create_start_generic(region%NODES,number_of_nodes,err,error,*999)
351 CALL flagerror(
"Region is not associated.",err,error,*998)
354 exits(
"NODES_CREATE_START_REGION")
356 999
CALL nodes_finalise(region%NODES,dummy_err,dummy_error,*998)
357 998 errorsexits(
"NODES_CREATE_START_REGION",err,error)
360 END SUBROUTINE nodes_create_start_region
367 SUBROUTINE nodes_destroy(NODES,ERR,ERROR,*)
371 INTEGER(INTG),
INTENT(OUT) :: err
375 enters(
"NODES_DESTROY",err,error,*999)
377 IF(
ASSOCIATED(nodes))
THEN 378 IF(
ASSOCIATED(nodes%REGION))
THEN 379 NULLIFY(nodes%REGION%NODES)
381 IF(
ASSOCIATED(nodes%INTERFACE))
THEN 382 NULLIFY(nodes%INTERFACE%NODES)
384 CALL flagerror(
"Nodes region and interface are not associated.",err,error,*999)
387 CALL nodes_finalise(nodes,err,error,*999)
389 CALL flagerror(
"Nodes is not associated.",err,error,*999)
392 exits(
"NODES_DESTROY")
394 999 errorsexits(
"NODES_DESTROY",err,error)
397 END SUBROUTINE nodes_destroy
404 SUBROUTINE nodes_finalise(NODES,ERR,ERROR,*)
408 INTEGER(INTG),
INTENT(OUT) :: err
413 enters(
"NODES_FINALISE",err,error,*999)
415 IF(
ASSOCIATED(nodes))
THEN 416 IF(
ALLOCATED(nodes%NODES))
THEN 417 DO np=1,
SIZE(nodes%NODES,1)
418 CALL node_finalise(nodes%NODES(np),err,error,*999)
420 DEALLOCATE(nodes%NODES)
422 IF(
ASSOCIATED(nodes%NODES_TREE))
CALL tree_destroy(nodes%NODES_TREE,err,error,*999)
426 exits(
"NODES_FINALISE")
428 999 errorsexits(
"NODES_FINALISE",err,error)
430 END SUBROUTINE nodes_finalise
437 SUBROUTINE nodes_initialise_generic(NODES,ERR,ERROR,*)
441 INTEGER(INTG),
INTENT(OUT) :: err
445 enters(
"NODES_INITIALISE_GENERIC",err,error,*999)
447 IF(
ASSOCIATED(nodes))
THEN 448 NULLIFY(nodes%REGION)
449 NULLIFY(nodes%INTERFACE)
450 nodes%NODES_FINISHED=.false.
451 nodes%NUMBER_OF_NODES=0
452 NULLIFY(nodes%NODES_TREE)
454 CALL flagerror(
"Nodes is not associated.",err,error,*999)
457 exits(
"NODES_INITIALISE_GENERIC")
459 999 errorsexits(
"NODES_INITIALISE_GENERIC",err,error)
461 END SUBROUTINE nodes_initialise_generic
468 SUBROUTINE nodes_initialise_interface(INTERFACE,ERR,ERROR,*)
472 INTEGER(INTG),
INTENT(OUT) :: err
476 enters(
"NODES_INITIALISE_INTERFACE",err,error,*999)
478 IF(
ASSOCIATED(interface))
THEN 479 IF(
ASSOCIATED(interface%NODES))
THEN 480 CALL flagerror(
"Interface already has associated nodes.",err,error,*999)
482 ALLOCATE(interface%NODES,stat=err)
483 IF(err/=0)
CALL flagerror(
"Could not allocate interface nodes.",err,error,*999)
484 CALL nodes_initialise_generic(interface%NODES,err,error,*999)
485 interface%NODES%INTERFACE=>
INTERFACE 488 CALL flagerror(
"Interface is not associated.",err,error,*999)
491 exits(
"NODES_INITIALISE_INTERFACE")
493 999 errorsexits(
"NODES_INITIALISE_INTERFACE",err,error)
496 END SUBROUTINE nodes_initialise_interface
503 SUBROUTINE nodes_initialise_region(REGION,ERR,ERROR,*)
507 INTEGER(INTG),
INTENT(OUT) :: err
511 enters(
"NODES_INITIALISE_REGION",err,error,*999)
513 IF(
ASSOCIATED(region))
THEN 514 IF(
ASSOCIATED(region%NODES))
THEN 515 CALL flagerror(
"Region has associated nodes.",err,error,*999)
517 ALLOCATE(region%NODES,stat=err)
518 IF(err/=0)
CALL flagerror(
"Could not allocate region nodes.",err,error,*999)
519 CALL nodes_initialise_generic(region%NODES,err,error,*999)
520 region%NODES%REGION=>region
523 CALL flagerror(
"Region is not associated.",err,error,*999)
526 exits(
"NODES_INITIALISE_REGION")
528 999 errorsexits(
"NODES_INITIALISE_REGION",err,error)
530 END SUBROUTINE nodes_initialise_region
537 SUBROUTINE nodes_label_get_c(NODES,GLOBAL_NUMBER,LABEL,ERR,ERROR,*)
541 INTEGER(INTG),
INTENT(IN) :: global_number
542 CHARACTER(LEN=*),
INTENT(OUT) :: label
543 INTEGER(INTG),
INTENT(OUT) :: err
546 INTEGER :: c_length,vs_length
549 enters(
"NODES_LABEL_GET_C",err,error,*999)
551 IF(
ASSOCIATED(nodes))
THEN 552 IF(nodes%NODES_FINISHED)
THEN 553 IF(global_number>=1.AND.global_number<=nodes%NUMBER_OF_NODES)
THEN 555 vs_length=
len_trim(nodes%NODES(global_number)%LABEL)
556 IF(c_length>vs_length)
THEN 559 label=
char(nodes%NODES(global_number)%LABEL,c_length)
562 local_error=
"The specified global node number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
563 &
" is invalid. The global node number should be between 1 and "// &
565 CALL flagerror(local_error,err,error,*999)
568 CALL flagerror(
"Nodes have not been finished.",err,error,*999)
571 CALL flagerror(
"Nodes is not associated.",err,error,*999)
574 exits(
"NODES_LABEL_GET_C")
576 999 errorsexits(
"NODES_LABEL_GET_C",err,error)
579 END SUBROUTINE nodes_label_get_c
586 SUBROUTINE nodes_label_get_vs(NODES,GLOBAL_NUMBER,LABEL,ERR,ERROR,*)
590 INTEGER(INTG),
INTENT(IN) :: global_number
592 INTEGER(INTG),
INTENT(OUT) :: err
597 enters(
"NODES_LABEL_GET_VS",err,error,*999)
599 IF(
ASSOCIATED(nodes))
THEN 600 IF(nodes%NODES_FINISHED)
THEN 601 IF(global_number>=1.AND.global_number<=nodes%NUMBER_OF_NODES)
THEN 602 label=nodes%NODES(global_number)%LABEL
604 local_error=
"The specified global node number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
605 &
" is invalid. The global node number should be between 1 and "// &
607 CALL flagerror(local_error,err,error,*999)
610 CALL flagerror(
"Nodes have not been finished.",err,error,*999)
613 CALL flagerror(
"Nodes is not associated.",err,error,*999)
616 exits(
"NODES_LABEL_GET_VS")
618 999 errorsexits(
"NODES_LABEL_GET_VS",err,error)
621 END SUBROUTINE nodes_label_get_vs
628 SUBROUTINE nodes_label_set_c(NODES,GLOBAL_NUMBER,LABEL,ERR,ERROR,*)
632 INTEGER(INTG),
INTENT(IN) :: global_number
633 CHARACTER(LEN=*),
INTENT(IN) :: label
634 INTEGER(INTG),
INTENT(OUT) :: err
639 enters(
"NODES_LABEL_SET_C",err,error,*999)
641 IF(
ASSOCIATED(nodes))
THEN 642 IF(nodes%NODES_FINISHED)
THEN 643 CALL flagerror(
"Nodes have been finished.",err,error,*999)
645 IF(global_number>=1.AND.global_number<=nodes%NUMBER_OF_NODES)
THEN 646 nodes%NODES(global_number)%LABEL=label
648 local_error=
"The specified global node number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
649 &
" is invalid. The global node number should be between 1 and "// &
651 CALL flagerror(local_error,err,error,*999)
655 CALL flagerror(
"Nodes is not associated.",err,error,*999)
658 exits(
"NODES_LABEL_SET_C")
660 999 errorsexits(
"NODES_LABEL_SET_C",err,error)
663 END SUBROUTINE nodes_label_set_c
670 SUBROUTINE nodes_label_set_vs(NODES,GLOBAL_NUMBER,LABEL,ERR,ERROR,*)
674 INTEGER(INTG),
INTENT(IN) :: global_number
676 INTEGER(INTG),
INTENT(OUT) :: err
681 enters(
"NODES_LABEL_SET_VS",err,error,*999)
683 IF(
ASSOCIATED(nodes))
THEN 684 IF(nodes%NODES_FINISHED)
THEN 685 CALL flagerror(
"Nodes have been finished.",err,error,*999)
687 IF(global_number>=1.AND.global_number<=nodes%NUMBER_OF_NODES)
THEN 688 nodes%NODES(global_number)%LABEL=label
690 local_error=
"The specified global node number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
691 &
" is invalid. The global node number should be between 1 and "// &
693 CALL flagerror(local_error,err,error,*999)
697 CALL flagerror(
"Nodes is not associated.",err,error,*999)
700 exits(
"NODES_LABEL_SET_VS")
702 999 errorsexits(
"NODES_LABEL_SET_VS",err,error)
705 END SUBROUTINE nodes_label_set_vs
712 SUBROUTINE nodes_number_of_nodes_get(NODES,NUMBER_OF_NODES,ERR,ERROR,*)
716 INTEGER(INTG),
INTENT(OUT) :: number_of_nodes
717 INTEGER(INTG),
INTENT(OUT) :: err
721 enters(
"NODES_NUMBER_OF_NODES_GET",err,error,*999)
723 IF(
ASSOCIATED(nodes))
THEN 724 IF(nodes%NODES_FINISHED)
THEN 725 number_of_nodes=nodes%NUMBER_OF_NODES
727 CALL flagerror(
"Nodes have not been finished.",err,error,*999)
730 CALL flagerror(
"Nodes is not associated.",err,error,*999)
733 exits(
"NODES_NUMBER_OF_NODES_GET")
735 999 errorsexits(
"NODES_NUMBER_OF_NODES_GET",err,error)
738 END SUBROUTINE nodes_number_of_nodes_get
745 SUBROUTINE nodes_user_number_get(NODES,GLOBAL_NUMBER,USER_NUMBER,ERR,ERROR,*)
749 INTEGER(INTG),
INTENT(IN) :: global_number
750 INTEGER(INTG),
INTENT(OUT) :: user_number
751 INTEGER(INTG),
INTENT(OUT) :: err
756 enters(
"NODES_USER_NUMBER_GET",err,error,*999)
758 IF(
ASSOCIATED(nodes))
THEN 759 IF(nodes%NODES_FINISHED)
THEN 760 IF(global_number>=1.AND.global_number<=nodes%NUMBER_OF_NODES)
THEN 761 user_number=nodes%NODES(global_number)%USER_NUMBER
763 local_error=
"The specified global node number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
764 &
" is invalid. The global node number should be between 1 and "// &
766 CALL flagerror(local_error,err,error,*999)
769 CALL flagerror(
"Nodes have not been finished.",err,error,*999)
772 CALL flagerror(
"Nodes is not associated.",err,error,*999)
775 exits(
"NODES_USER_NUMBER_GET")
777 999 errorsexits(
"NODES_USER_NUMBER_GET",err,error)
780 END SUBROUTINE nodes_user_number_get
787 SUBROUTINE nodes_user_number_set(NODES,GLOBAL_NUMBER,USER_NUMBER,ERR,ERROR,*)
791 INTEGER(INTG),
INTENT(IN) :: global_number
792 INTEGER(INTG),
INTENT(IN) :: user_number
793 INTEGER(INTG),
INTENT(OUT) :: err
796 INTEGER(INTG) :: insert_status,old_global_number
797 LOGICAL :: node_exists
800 enters(
"NODES_USER_NUMBER_SET",err,error,*999)
802 IF(
ASSOCIATED(nodes))
THEN 803 IF(nodes%NODES_FINISHED)
THEN 804 CALL flagerror(
"Nodes have been finished.",err,error,*999)
806 IF(global_number>=1.AND.global_number<=nodes%NUMBER_OF_NODES)
THEN 808 CALL node_check_exists(nodes,user_number,node_exists,old_global_number,err,error,*999)
810 IF(old_global_number/=global_number)
THEN 811 local_error=
"The specified node user number of "//
trim(
number_to_vstring(user_number,
"*",err,error))// &
812 &
" is already used by global node number "//
trim(
number_to_vstring(old_global_number,
"*",err,error))// &
813 &
". User node numbers must be unique." 814 CALL flagerror(local_error,err,error,*999)
817 CALL tree_item_delete(nodes%NODES_TREE,nodes%NODES(global_number)%USER_NUMBER,err,error,*999)
818 CALL tree_item_insert(nodes%NODES_TREE,user_number,global_number,insert_status,err,error,*999)
820 nodes%NODES(global_number)%USER_NUMBER=user_number
823 local_error=
"The specified global node number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
824 &
" is invalid. The global node number should be between 1 and "// &
826 CALL flagerror(local_error,err,error,*999)
830 CALL flagerror(
"Nodes is not associated.",err,error,*999)
833 exits(
"NODE_USER_NUMBER_SET")
835 999 errorsexits(
"NODE_USER_NUMBER_SET",err,error)
838 END SUBROUTINE nodes_user_number_set
845 SUBROUTINE nodesusernumbersallset(nodes,userNumbers,err,error,*)
849 INTEGER(INTG),
INTENT(IN) :: usernumbers(:)
850 INTEGER(INTG),
INTENT(OUT) :: err
853 INTEGER(INTG) :: nodeidx,insertstatus
857 NULLIFY(newnodestree)
859 enters(
"NodesUserNumbersAllSet",err,error,*999)
861 IF(
ASSOCIATED(nodes))
THEN 862 IF(nodes%NODES_FINISHED)
THEN 863 CALL flagerror(
"Nodes have been finished.",err,error,*999)
865 IF(nodes%NUMBER_OF_NODES==
SIZE(usernumbers,1))
THEN 870 DO nodeidx=1,nodes%NUMBER_OF_NODES
871 CALL tree_item_insert(newnodestree,usernumbers(nodeidx),nodeidx,insertstatus,err,error,*999)
873 localerror=
"The specified user number of "//
trim(
numbertovstring(usernumbers(nodeidx),
"*",err,error))// &
875 &
" is a duplicate. The user node numbers must be unique." 876 CALL flagerror(localerror,err,error,*999)
880 nodes%NODES_TREE=>newnodestree
881 NULLIFY(newnodestree)
882 DO nodeidx=1,nodes%NUMBER_OF_NODES
883 nodes%NODES(nodeidx)%GLOBAL_NUMBER=nodeidx
884 nodes%NODES(nodeidx)%USER_NUMBER=usernumbers(nodeidx)
887 localerror=
"The number of specified node user numbers ("// &
889 ") does not match number of nodes ("// &
891 CALL flagerror(localerror,err,error,*999)
895 CALL flagerror(
"Nodes is not associated.",err,error,*999)
898 exits(
"NodesUserNumbersAllSet")
900 999
IF(
ASSOCIATED(newnodestree))
CALL tree_destroy(newnodestree,err,error,*998)
901 998 errorsexits(
"NodesUserNumbersAllSet",err,error)
904 END SUBROUTINE nodesusernumbersallset
910 END MODULE node_routines
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
subroutine, public tree_insert_type_set(TREE, INSERT_TYPE, ERR, ERROR,)
Sets/changes the insert type for a tree.
Contains information for a region.
Converts a number to its equivalent varying string representation.
Implements trees of base types.
integer(intg), parameter, public tree_node_insert_sucessful
Successful insert status.
subroutine, public tree_search(TREE, KEY, X, ERR, ERROR,)
Searches a tree to see if it contains a key.
This module contains all string manipulation and transformation routines.
Contains information about a node.
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
subroutine, public tree_output(ID, TREE, ERR, ERROR,)
Outputs a tree to the specified output stream ID.
subroutine, public exits(NAME)
Records the exit out of the named procedure.
This module contains all type definitions in order to avoid cyclic module references.
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
subroutine, public tree_item_delete(TREE, KEY, ERR, ERROR,)
Deletes a tree node specified by a key from a tree.
subroutine, public tree_create_finish(TREE, ERR, ERROR,)
Finishes the creation of a tree created with TREE_CREATE_START.
integer(intg), parameter, public tree_no_duplicates_allowed
No duplicate keys allowed tree type.
logical, save, public diagnostics1
.TRUE. if level 1 diagnostic output is active in the current routine
subroutine, public tree_destroy(TREE, ERR, ERROR,)
Destroys a tree.
integer(intg), parameter, public diagnostic_output_type
Diagnostic output type.
Contains information on the nodes defined on a region.
subroutine, public tree_item_insert(TREE, KEY, VALUE, INSERT_STATUS, ERR, ERROR,)
Inserts a tree node into a red-black tree.
Contains information for the interface data.
subroutine, public tree_node_value_get(TREE, TREE_NODE, VALUE, ERR, ERROR,)
Gets the value at a specified tree node.
Flags an error condition.
subroutine, public tree_create_start(TREE, ERR, ERROR,)
Starts the creation of a tree and returns a pointer to the created tree.
This module contains all kind definitions.