343 integer(I4B), dimension(:), contiguous, intent(in) :: p_mem
344 character(len=*), intent(in) :: varname
345 character(len=*), intent(in) :: mempath
346 character(len=*), intent(in) :: shapestr
347 integer(I4B), intent(in) :: iout
348 integer(I4B), dimension(:), pointer, contiguous :: model_shape
349 integer(I4B), dimension(:, :, :), pointer, contiguous :: int3d
350 integer(I4B), dimension(:, :), pointer, contiguous :: int2d
351 integer(I4B), dimension(3) :: dis3d_shape
352 integer(I4B), dimension(2) :: dis2d_shape
353 integer(I4B), pointer :: distype
354 character(LENMEMPATH) :: input_mempath
355 character(LENCOMPONENTNAME) :: comp, subcomp
356 integer(I4B) :: i, j, k, inunit, export_dim
357 logical(LGP) :: is_layered
358
359
362 call mem_setptr(distype,
'DISENUM', input_mempath)
363 call mem_setptr(model_shape,
'MODEL_SHAPE', input_mempath)
364
365
366 export_dim = distype_export_dim(distype, shapestr, is_layered)
367
368
369 select case (export_dim)
370 case (3)
371
372 dis3d_shape(1) = model_shape(3)
373 dis3d_shape(2) = model_shape(2)
374 dis3d_shape(3) = model_shape(1)
375
376 allocate (int3d(dis3d_shape(1), dis3d_shape(2), dis3d_shape(3)))
377 int3d = reshape(p_mem, dis3d_shape)
378
379 do k = 1, dis3d_shape(3)
380 inunit = create_export_file(varname, mempath, k, iout)
381 do i = 1, model_shape(2)
382 write (inunit, '(*(i0, " "))') (int3d(j, i, k), j=1, &
383 dis3d_shape(1))
384 end do
385 close (inunit)
386 end do
387
388 deallocate (int3d)
389 case (2)
390
391 dis2d_shape(1) = model_shape(2)
392 dis2d_shape(2) = model_shape(1)
393
394 allocate (int2d(dis2d_shape(1), dis2d_shape(2)))
395 int2d = reshape(p_mem, dis2d_shape)
396 if (is_layered) then
397
398 do i = 1, dis2d_shape(2)
399 inunit = create_export_file(varname, mempath, i, iout)
400 write (inunit, '(*(i0, " "))') (int2d(j, i), j=1, dis2d_shape(1))
401 close (inunit)
402 end do
403 else
404
405 inunit = create_export_file(varname, mempath, 0, iout)
406 do i = 1, dis2d_shape(2)
407 write (inunit, '(*(i0, " "))') (int2d(j, i), j=1, dis2d_shape(1))
408 end do
409 close (inunit)
410 end if
411
412 deallocate (int2d)
413 case (1)
414
415 inunit = create_export_file(varname, mempath, 0, iout)
416 write (inunit, '(*(i0, " "))') p_mem
417 close (inunit)
418 case default
419 write (errmsg, '(a,i0)') 'EXPORT unsupported int1d export_dim=', &
420 export_dim
421 call store_error(errmsg, .true.)
422 end select