397
398 integer(I4B), intent(in) :: iu, iout
399 integer(I4B), intent(in) :: jj, ii
400 real(DP), dimension(jj, ii), intent(inout) :: darr
401 character(len=*), intent(in) :: aname
402 integer(I4B), intent(in) :: ndim
403 integer(I4B), intent(in) :: k
404
405 logical(LGP) :: isok
406 integer(I4B) :: i, iclose, iprn, j, locat, ncpl, ndig
407 integer(I4B) :: nval
408 real(DP) :: cnstnt
409 logical :: prowcolnum
410 character(len=100) :: prfmt
411 integer(I4B) :: istat
412 character(len=30) :: arrname
413 character(len=MAXCHARLEN) :: ermsgr
414
4152 format(/, 1x, a, ' = ', g14.7, ' FOR LAYER ', i0)
4163 format(/, 1x, a, ' = ', g14.7)
417
418
419 call read_control_dbl(iu, iout, aname, locat, cnstnt, iclose, iprn)
420
421
422 if (locat == 0) then
423
424 do i = 1, ii
425 do j = 1, jj
426 darr(j, i) = cnstnt
427 end do
428 end do
429 if (iout > 0) then
430 if (k > 0) then
431 write (iout, 2) trim(aname), cnstnt, k
432 else
433 write (iout, 3) trim(aname), cnstnt
434 end if
435 end if
436 elseif (locat > 0) then
437
438 do i = 1, ii
439 read (locat, *, iostat=istat, iomsg=ermsgr) (darr(j, i), j=1, jj)
440 if (istat /= 0) then
441 arrname = adjustl(aname)
442 errmsg = "Error reading data for array '"// &
443 trim(adjustl(arrname))//"'. "//trim(adjustl(ermsgr))
444 call store_error(errmsg)
445 call store_error_unit(locat)
446 end if
447 do j = 1, jj
448 if (darr(j, i) /= dnodata) darr(j, i) = darr(j, i) * cnstnt
449 end do
450 end do
451 if (iclose == 1) then
452 close (locat)
453 end if
454 else
455
456 locat = -locat
457 call read_binary_header(locat, iout, aname, nval)
458 isok = check_binary_size(nval, 0, size(darr), aname, locat)
459 if (isok) then
460 do i = 1, ii
461 read (locat, iostat=istat, iomsg=ermsgr) (darr(j, i), j=1, jj)
462 if (istat /= 0) then
463 arrname = adjustl(aname)
464 errmsg = "Error reading data for array '"// &
465 trim(adjustl(arrname))//"'. "//trim(adjustl(ermsgr))
466 call store_error(errmsg)
467 call store_error_unit(locat)
468 end if
469 do j = 1, jj
470 if (darr(j, i) /= dnodata) darr(j, i) = darr(j, i) * cnstnt
471 end do
472 end do
473 end if
474 if (iclose == 1) then
475 close (locat)
476 end if
477 end if
478
479
480 if (iprn >= 0 .and. locat /= 0) then
481 prowcolnum = (ndim == 3)
482 call build_format_dbl(iprn, prfmt, prowcolnum, ncpl, ndig)
483 call print_array_dbl(darr, aname, iout, jj, ii, k, prfmt, ncpl, &
484 ndig, prowcolnum)
485 end if