Skip to content

Commit

Permalink
Add initialization routine
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick Stein authored and fstein93 committed Feb 28, 2023
1 parent 9ee8bdf commit 0b78d42
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/mpiwrap/message_passing.F
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ MODULE message_passing
PROCEDURE, PUBLIC, PASS(comm2), NON_OVERRIDABLE :: from_dup => mp_comm_dup
PROCEDURE, PUBLIC, PASS(comm), NON_OVERRIDABLE :: free => mp_comm_free

PROCEDURE, PUBLIC, PASS(comm) :: mp_comm_init
GENERIC, PUBLIC :: init => mp_comm_init

PROCEDURE, PUBLIC, PASS(comm), NON_OVERRIDABLE :: environ => mp_environ_l

PROCEDURE, PRIVATE, PASS(sub_comm), NON_OVERRIDABLE :: mp_comm_split, mp_comm_split_direct
Expand Down Expand Up @@ -882,6 +885,11 @@ ELEMENTAL SUBROUTINE mp_${type}$_type_set_handle(this, handle)
#else
this%handle = handle
#endif

#:if type=="comm"
CALL this%init()
#:endif

END SUBROUTINE mp_${type}$_type_set_handle

ELEMENTAL FUNCTION mp_${type}$_type_get_handle(this) RESULT(handle)
Expand Down Expand Up @@ -944,6 +952,7 @@ SUBROUTINE mp_world_init(mp_comm)
#endif
debug_comm_count = 1
mp_comm = mp_comm_world
CALL mp_comm%init()
CALL add_mp_perf_env()
END SUBROUTINE mp_world_init

Expand Down Expand Up @@ -994,6 +1003,7 @@ SUBROUTINE mp_reordering(mp_comm, mp_new_comm, ranks_order)
mp_new_comm%handle = mp_comm_default_handle
#endif
debug_comm_count = debug_comm_count + 1
CALL mp_new_comm%init()
CALL mp_timestop(handle)
END SUBROUTINE mp_reordering

Expand Down Expand Up @@ -1507,6 +1517,7 @@ SUBROUTINE mp_cart_create(comm_old, ndims, dims, pos, comm_cart)
comm_cart%handle = mp_comm_default_handle
#endif
debug_comm_count = debug_comm_count + 1
CALL comm_cart%init()
CALL mp_timestop(handle)

END SUBROUTINE mp_cart_create
Expand Down Expand Up @@ -1617,6 +1628,7 @@ SUBROUTINE mp_cart_sub(comm, rdim, sub_comm)
sub_comm%handle = mp_comm_default_handle
#endif
debug_comm_count = debug_comm_count + 1
CALL sub_comm%init()
CALL mp_timestop(handle)

END SUBROUTINE mp_cart_sub
Expand Down Expand Up @@ -1676,15 +1688,25 @@ SUBROUTINE mp_comm_dup(comm1, comm2)
comm2%handle = mp_comm_default_handle
#endif
debug_comm_count = debug_comm_count + 1
CALL comm2%init()
CALL mp_timestop(handle)

END SUBROUTINE mp_comm_dup

SUBROUTINE mp_comm_copy(comm_new, comm_old)
ELEMENTAL IMPURE SUBROUTINE mp_comm_copy(comm_new, comm_old)
CLASS(mp_comm_type), INTENT(IN) :: comm_old
CLASS(mp_comm_type), INTENT(OUT) :: comm_new

comm_new%handle = comm_old%handle
CALL comm_new%init()
END SUBROUTINE

ELEMENTAL SUBROUTINE mp_comm_init(comm)
CLASS(mp_comm_type), INTENT(IN) :: comm

! No initialization necessary for mp_comm_type
MARK_USED(comm)

END SUBROUTINE

! **************************************************************************************************
Expand Down Expand Up @@ -2203,6 +2225,7 @@ SUBROUTINE mp_comm_split_direct(comm, sub_comm, color, key)
MARK_USED(key)
#endif
debug_comm_count = debug_comm_count + 1
CALL sub_comm%init()
CALL mp_timestop(handle)
END SUBROUTINE mp_comm_split_direct
Expand Down Expand Up @@ -2331,6 +2354,7 @@ SUBROUTINE mp_comm_split(comm, sub_comm, ngroups, group_distribution, &
MARK_USED(group_partition)
#endif
debug_comm_count = debug_comm_count + 1
CALL sub_comm%init()
CALL mp_timestop(handle)
END SUBROUTINE mp_comm_split
Expand Down

0 comments on commit 0b78d42

Please sign in to comment.