298 class(DistributedSimType) :: this
300 integer(I4B) :: im, imm, ie, ip, cnt
301 integer(I4B) :: nr_models, nr_gwf_models
302 integer(I4B) :: nr_exchanges
303 integer(I4B) :: min_per_proc, nr_left
305 integer(I4B),
dimension(:),
allocatable :: nr_models_proc
306 character(len=LENPACKAGETYPE) :: model_type_str
307 character(len=LENMEMPATH) :: input_mempath
308 type(CharacterStringType),
dimension(:),
contiguous, &
310 type(CharacterStringType),
dimension(:),
contiguous, &
312 type(CharacterStringType),
dimension(:),
contiguous, &
314 type(CharacterStringType),
dimension(:),
contiguous, &
316 type(CharacterStringType),
dimension(:),
contiguous, &
322 input_mempath = create_mem_path(
'SIM',
'NAM', idm_context)
323 call mem_setptr(mtypes,
'MTYPE', input_mempath)
324 call mem_setptr(mnames,
'MNAME', input_mempath)
325 call mem_setptr(etypes,
'EXGTYPE', input_mempath)
326 call mem_setptr(emnames_a,
'EXGMNAMEA', input_mempath)
327 call mem_setptr(emnames_b,
'EXGMNAMEB', input_mempath)
330 nr_models =
size(mnames)
333 if (mtypes(im) ==
'GWF6')
then
334 nr_gwf_models = nr_gwf_models + 1
337 if (mtypes(im) ==
'GWF6' .or. &
338 mtypes(im) ==
'GWT6' .or. &
339 mtypes(im) ==
'GWE6')
then
343 model_type_str = mtypes(im)
344 write (errmsg, *)
'Model type ', model_type_str, &
345 ' not supported in parallel mode.'
346 call store_error(errmsg, terminate=.true.)
350 allocate (nr_models_proc(nr_procs))
351 min_per_proc = nr_gwf_models / nr_procs
352 nr_left = nr_gwf_models - nr_procs * min_per_proc
356 nr_models_proc(ip) = min_per_proc
357 if (rank < nr_left)
then
358 nr_models_proc(ip) = nr_models_proc(ip) + 1
365 if (mtypes(im) ==
'GWF6')
then
366 if (nr_models_proc(rank + 1) == 0)
then
369 this%model_ranks(im) = rank
370 nr_models_proc(rank + 1) = nr_models_proc(rank + 1) - 1
375 nr_exchanges =
size(etypes)
377 if (mtypes(im) ==
'GWT6')
then
380 do ie = 1, nr_exchanges
381 if (etypes(ie) ==
'GWF6-GWT6' .and. mnames(im) == emnames_b(ie))
then
383 do imm = 1, nr_models
384 if (mnames(imm) == emnames_a(ie))
then
385 rank = this%model_ranks(imm)
389 this%model_ranks(im) = rank
394 else if (mtypes(im) ==
'GWE6')
then
395 do ie = 1, nr_exchanges
396 if (etypes(ie) ==
'GWF6-GWE6' .and. mnames(im) == emnames_b(ie))
then
398 do imm = 1, nr_models
399 if (mnames(imm) == emnames_a(ie))
then
400 rank = this%model_ranks(imm)
404 this%model_ranks(im) = rank
415 deallocate (nr_models_proc)