294 integer(I4B), intent(in) :: iout
295 type(DistributedSimType), pointer :: ds
296 integer(I4B), dimension(:), pointer :: model_loadmask
297 type(CharacterStringType), dimension(:), contiguous, &
298 pointer :: etypes
299 type(CharacterStringType), dimension(:), contiguous, &
300 pointer :: efiles
301 type(CharacterStringType), dimension(:), contiguous, &
302 pointer :: emnames_a
303 type(CharacterStringType), dimension(:), contiguous, &
304 pointer :: emnames_b
305 type(CharacterStringType), dimension(:), contiguous, &
306 pointer :: emempaths
307 type(CharacterStringType), dimension(:), contiguous, &
308 pointer :: mtypes
309 type(CharacterStringType), dimension(:), contiguous, &
310 pointer :: mfnames
311 type(CharacterStringType), dimension(:), contiguous, &
312 pointer :: mnames
313 character(len=LENMEMPATH) :: input_mempath, mempath
314 integer(I4B), pointer :: exgid, ncelldim
315 character(len=LINELENGTH) :: exgtype, efname, mfname
316 character(len=LENMODELNAME) :: mname1, mname2, mname
317 character(len=LENCOMPONENTNAME) :: sc_type, sc_name, mtype
318 class(StaticPkgLoadBaseType), pointer :: static_loader
319 class(DynamicPkgLoadBaseType), pointer :: dynamic_loader
320 integer(I4B) :: n, m1_idx, m2_idx, irem, isize
321
322
324 model_loadmask => ds%get_load_mask()
325
326
328
329
330 call mem_setptr(etypes,
'EXGTYPE', input_mempath)
331 call mem_setptr(efiles,
'EXGFILE', input_mempath)
332 call mem_setptr(emnames_a,
'EXGMNAMEA', input_mempath)
333 call mem_setptr(emnames_b,
'EXGMNAMEB', input_mempath)
334 call mem_setptr(mtypes,
'MTYPE', input_mempath)
335 call mem_setptr(mfnames,
'MFNAME', input_mempath)
336 call mem_setptr(mnames,
'MNAME', input_mempath)
337
338
339 call mem_allocate(emempaths, lenmempath,
size(etypes),
'EXGMEMPATHS', &
340 input_mempath)
341
342
343 do n = 1, size(etypes)
344
345 exgtype = etypes(n)
346 efname = efiles(n)
347 call inlen_check(emnames_a(n), mname1, lenmodelname,
'MODELNAME')
348 call inlen_check(emnames_b(n), mname2, lenmodelname,
'MODELNAME')
349
350
351 emempaths(n) = ''
352 irem = 0
353
354
357
358 if (m1_idx <= 0 .or. m2_idx <= 0) then
359 errmsg =
'Exchange has invalid (unrecognized) model name(s):'
360 if (m1_idx <= 0)
errmsg = trim(
errmsg)//
' '//trim(mname1)
361 if (m2_idx <= 0)
errmsg = trim(
errmsg)//
' '//trim(mname2)
363 end if
364
365
366 if (count_errors() > 0) then
367 call store_error_filename(
simfile)
368 end if
369
370
371 if (model_loadmask(m1_idx) > 0 .or. model_loadmask(m2_idx) > 0) then
372
373 if (model_loadmask(m1_idx) == 0) then
374 irem = m1_idx
375 else if (model_loadmask(m2_idx) == 0) then
376 irem = m2_idx
377 end if
378
379
380 if (irem > 0) then
381 mtype = mtypes(irem)
382 mfname = mfnames(irem)
383 mname = mnames(irem)
385 call get_isize(
'NCELLDIM', mempath, isize)
386 if (isize < 0) then
389 else
390 call mem_setptr(ncelldim,
'NCELLDIM', mempath)
391 end if
392 else
393 nullify (ncelldim)
394 end if
395
396
398 write (sc_name, '(a,i0)') trim(sc_type)//'_', n
399
400
402 emempaths(n) = mempath
403
404
406 exgid = n
407
408
410 exgtype,
'SIM', efname,
simfile)
411
412 dynamic_loader => static_loader%load(
iout)
413
414 if (associated(dynamic_loader)) then
415 errmsg =
'IDM unimplemented. Dynamic Exchanges not supported.'
417 call store_error_filename(efname)
418 else
419 call static_loader%destroy()
420 deallocate (static_loader)
421 end if
422 end if
423 end do
424
425
426 do n = 1, size(mnames)
427 if (model_loadmask(n) == 0) then
428 mname = mnames(n)
430 call get_isize(
'NCELLDIM', mempath, isize)
431 if (isize > 0) then
432 call mem_setptr(ncelldim,
'NCELLDIM', mempath)
434 end if
435 end if
436 end do
class(distributedsimtype) function, pointer, public get_dsim()
Get pointer to the distributed simulation object.
subroutine, public get_isize(name, mem_path, isize)
Get the number of elements for this variable.
This module contains the SourceCommonModule.
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
subroutine, public inlen_check(input_name, mf6_name, maxlen, name_type)
store an error for input exceeding internal name length
integer(i4b) function, public ifind_charstr(array, str)
integer(i4b) function, public remote_model_ndim(mtype, mfname)