268 class(DistributedSimType) :: this
270 integer(I4B) :: im, imm, ie, ip, cnt
271 integer(I4B) :: nr_models, nr_gwf_models
272 integer(I4B) :: nr_exchanges
273 integer(I4B) :: min_per_proc, nr_left
275 integer(I4B),
dimension(:),
allocatable :: nr_models_proc
276 character(len=LENPACKAGETYPE) :: model_type_str
277 character(len=LENMEMPATH) :: input_mempath
278 type(CharacterStringType),
dimension(:),
contiguous, &
280 type(CharacterStringType),
dimension(:),
contiguous, &
282 type(CharacterStringType),
dimension(:),
contiguous, &
284 type(CharacterStringType),
dimension(:),
contiguous, &
286 type(CharacterStringType),
dimension(:),
contiguous, &
292 input_mempath = create_mem_path(
'SIM',
'NAM', idm_context)
293 call mem_setptr(mtypes,
'MTYPE', input_mempath)
294 call mem_setptr(mnames,
'MNAME', input_mempath)
295 call mem_setptr(etypes,
'EXGTYPE', input_mempath)
296 call mem_setptr(emnames_a,
'EXGMNAMEA', input_mempath)
297 call mem_setptr(emnames_b,
'EXGMNAMEB', input_mempath)
300 nr_models =
size(mnames)
303 if (mtypes(im) ==
'GWF6')
then
304 nr_gwf_models = nr_gwf_models + 1
307 if (mtypes(im) ==
'GWF6' .or. &
308 mtypes(im) ==
'GWT6' .or. &
309 mtypes(im) ==
'GWE6')
then
313 model_type_str = mtypes(im)
314 write (errmsg, *)
'Model type ', model_type_str, &
315 ' not supported in parallel mode.'
316 call store_error(errmsg, terminate=.true.)
320 allocate (nr_models_proc(nr_procs))
321 min_per_proc = nr_gwf_models / nr_procs
322 nr_left = nr_gwf_models - nr_procs * min_per_proc
326 nr_models_proc(ip) = min_per_proc
327 if (rank < nr_left)
then
328 nr_models_proc(ip) = nr_models_proc(ip) + 1
335 if (mtypes(im) ==
'GWF6')
then
336 if (nr_models_proc(rank + 1) == 0)
then
339 this%model_ranks(im) = rank
340 nr_models_proc(rank + 1) = nr_models_proc(rank + 1) - 1
345 nr_exchanges =
size(etypes)
347 if (mtypes(im) ==
'GWT6')
then
350 do ie = 1, nr_exchanges
351 if (etypes(ie) ==
'GWF6-GWT6' .and. mnames(im) == emnames_b(ie))
then
353 do imm = 1, nr_models
354 if (mnames(imm) == emnames_a(ie))
then
355 rank = this%model_ranks(imm)
359 this%model_ranks(im) = rank
364 else if (mtypes(im) ==
'GWE6')
then
365 do ie = 1, nr_exchanges
366 if (etypes(ie) ==
'GWF6-GWE6' .and. mnames(im) == emnames_b(ie))
then
368 do imm = 1, nr_models
369 if (mnames(imm) == emnames_a(ie))
then
370 rank = this%model_ranks(imm)
374 this%model_ranks(im) = rank
385 deallocate (nr_models_proc)