30 #include "../base/base_uses.f90"
36 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
37 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'distribution_1d_types'
39 PUBLIC :: distribution_1d_type
43 TYPE local_particle_type
44 TYPE(rng_stream_p_type),
DIMENSION(:),
POINTER :: rng => null()
45 END TYPE local_particle_type
62 TYPE distribution_1d_type
63 INTEGER :: ref_count = -1
64 LOGICAL :: listbased_distribution = .false.
65 INTEGER,
DIMENSION(:),
POINTER :: n_el => null()
66 TYPE(cp_1d_i_p_type),
DIMENSION(:),
POINTER :: list => null()
67 TYPE(mp_para_env_type),
POINTER :: para_env => null()
68 TYPE(local_particle_type),
DIMENSION(:),
POINTER :: local_particle_set => null()
69 END TYPE distribution_1d_type
87 TYPE(distribution_1d_type),
POINTER :: distribution_1d
88 TYPE(mp_para_env_type),
POINTER :: para_env
89 LOGICAL,
INTENT(in),
OPTIONAL :: listbased_distribution
90 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: n_el
91 INTEGER,
INTENT(in),
OPTIONAL :: n_lists
93 INTEGER :: ilist, my_n_lists
96 IF (
PRESENT(n_el)) my_n_lists =
SIZE(n_el)
97 IF (
PRESENT(n_lists)) my_n_lists = n_lists
99 ALLOCATE (distribution_1d)
101 distribution_1d%ref_count = 1
103 distribution_1d%para_env => para_env
104 CALL para_env%retain()
106 distribution_1d%listbased_distribution = .false.
107 IF (
PRESENT(listbased_distribution)) &
108 distribution_1d%listbased_distribution = listbased_distribution
110 ALLOCATE (distribution_1d%n_el(my_n_lists), distribution_1d%list(my_n_lists))
112 IF (
PRESENT(n_el))
THEN
113 distribution_1d%n_el(1:my_n_lists) = n_el(1:my_n_lists)
114 DO ilist = 1, my_n_lists
115 ALLOCATE (distribution_1d%list(ilist)%array(n_el(ilist)))
116 distribution_1d%list(ilist)%array = -1
119 distribution_1d%n_el(1:my_n_lists) = 0
120 DO ilist = 1, my_n_lists
121 NULLIFY (distribution_1d%list(ilist)%array)
135 TYPE(distribution_1d_type),
INTENT(INOUT) :: distribution_1d
137 cpassert(distribution_1d%ref_count > 0)
138 distribution_1d%ref_count = distribution_1d%ref_count + 1
149 TYPE(distribution_1d_type),
POINTER :: distribution_1d
151 INTEGER :: ilist, iparticle_kind, iparticle_local, &
152 nparticle_kind, nparticle_local
153 TYPE(local_particle_type),
DIMENSION(:),
POINTER :: local_particle_set
155 IF (
ASSOCIATED(distribution_1d))
THEN
156 cpassert(distribution_1d%ref_count > 0)
157 distribution_1d%ref_count = distribution_1d%ref_count - 1
158 IF (distribution_1d%ref_count == 0)
THEN
159 DEALLOCATE (distribution_1d%n_el)
161 DO ilist = 1,
SIZE(distribution_1d%list)
162 DEALLOCATE (distribution_1d%list(ilist)%array)
164 DEALLOCATE (distribution_1d%list)
168 local_particle_set => distribution_1d%local_particle_set
170 IF (
ASSOCIATED(local_particle_set))
THEN
171 nparticle_kind =
SIZE(local_particle_set)
172 DO iparticle_kind = 1, nparticle_kind
173 IF (
ASSOCIATED(local_particle_set(iparticle_kind)%rng))
THEN
174 nparticle_local =
SIZE(local_particle_set(iparticle_kind)%rng)
175 DO iparticle_local = 1, nparticle_local
176 IF (
ASSOCIATED(local_particle_set(iparticle_kind)% &
177 rng(iparticle_local)%stream))
THEN
178 DEALLOCATE (local_particle_set(iparticle_kind)% &
179 rng(iparticle_local)%stream)
182 DEALLOCATE (local_particle_set(iparticle_kind)%rng)
185 DEALLOCATE (local_particle_set)
190 DEALLOCATE (distribution_1d)
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public distribution_1d_retain(distribution_1d)
retains a distribution_1d
subroutine, public distribution_1d_create(distribution_1d, para_env, listbased_distribution, n_el, n_lists)
creates a local list
subroutine, public distribution_1d_release(distribution_1d)
releases the given distribution_1d
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.