@@ -10,7 +10,7 @@ module IdmLoadModule
1010 use SimVariablesModule, only: errmsg
1111 use ConstantsModule, only: LINELENGTH, LENMEMPATH, LENMODELNAME, &
1212 LENEXCHANGENAME, LENCOMPONENTNAME
13- use SimModule, only: store_error, store_error_filename
13+ use SimModule, only: store_error, count_errors, store_error_filename
1414 use ListModule, only: ListType
1515 use InputLoadTypeModule, only: StaticPkgLoadBaseType, &
1616 DynamicPkgLoadBaseType, &
@@ -213,10 +213,10 @@ subroutine load_models(iout)
213213 use MemoryHelperModule, only: create_mem_path
214214 use MemoryManagerModule, only: mem_setptr
215215 use CharacterStringModule, only: CharacterStringType
216- use SimVariablesModule, only: idm_context
217216 use DistributedSimModule, only: DistributedSimType, get_dsim
217+ use SimVariablesModule, only: idm_context, simfile
218218 use ModelPackageInputsModule, only: ModelPackageInputsType
219- use SourceCommonModule, only: idm_component_type
219+ use SourceCommonModule, only: idm_component_type, inlen_check
220220 use SourceLoadModule, only: load_modelnam
221221 ! -- dummy
222222 integer (I4B), intent (in ) :: iout
@@ -252,7 +252,12 @@ subroutine load_models(iout)
252252 ! -- attributes for this model
253253 mtype = mtypes(n)
254254 mfname = mfnames(n)
255- mname = mnames(n)
255+ call inlen_check(mnames(n), mname, LENMODELNAME, ' MODELNAME' )
256+ !
257+ ! -- terminate if errors were detected
258+ if (count_errors() > 0 ) then
259+ call store_error_filename(simfile)
260+ end if
256261 !
257262 ! -- load specified model inputs
258263 if (model_loadmask(n) > 0 ) then
@@ -290,7 +295,8 @@ subroutine load_exchanges(iout)
290295 use CharacterStringModule, only: CharacterStringType
291296 use SimVariablesModule, only: idm_context, simfile
292297 use DistributedSimModule, only: DistributedSimType, get_dsim
293- use SourceCommonModule, only: idm_subcomponent_type, ifind_charstr
298+ use SourceCommonModule, only: idm_subcomponent_type, ifind_charstr, &
299+ inlen_check
294300 use SourceLoadModule, only: create_input_loader, remote_model_ndim
295301 ! -- dummy
296302 integer (I4B), intent (in ) :: iout
@@ -348,8 +354,8 @@ subroutine load_exchanges(iout)
348354 ! -- attributes for this exchange
349355 exgtype = etypes(n)
350356 efname = efiles(n)
351- mname1 = emnames_a(n)
352- mname2 = emnames_b(n)
357+ call inlen_check( emnames_a(n), mname1, LENMODELNAME, ' MODELNAME ' )
358+ call inlen_check( emnames_b(n), mname2, LENMODELNAME, ' MODELNAME ' )
353359 !
354360 ! initialize mempath as no path
355361 emempaths(n) = ' '
@@ -364,6 +370,10 @@ subroutine load_exchanges(iout)
364370 if (m1_idx <= 0 ) errmsg = trim (errmsg)// ' ' // trim (mname1)
365371 if (m2_idx <= 0 ) errmsg = trim (errmsg)// ' ' // trim (mname2)
366372 call store_error(errmsg)
373+ end if
374+ !
375+ ! -- terminate if errors were detected
376+ if (count_errors() > 0 ) then
367377 call store_error_filename(simfile)
368378 end if
369379 !
0 commit comments