MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
Double1dReader.f90
Go to the documentation of this file.
2
3 use kindmodule, only: dp, i4b, lgp
13
14 implicit none
15 private
16 public :: read_dbl1d
17
19
20 real(dp) :: constant_array_value = dzero
21 real(dp) :: factor = done
22 real(dp), dimension(:), contiguous, pointer :: dbl1d => null()
23
24 contains
25
26 procedure :: reset_reader
27 procedure :: set_constant ! must be overridden
28 procedure :: fill_constant ! must be overridden
29 procedure :: read_ascii ! must be overridden
30 procedure :: read_binary ! must be overridden
31 procedure :: set_factor ! must be overridden
32 procedure :: apply_factor ! must be overridden
33
34 end type double1dreadertype
35
36contains
37
38 subroutine read_dbl1d(parser, dbl1d, aname)
39 ! -- dummy
40 type(blockparsertype), intent(in), target :: parser
41 real(dp), dimension(:), contiguous, target :: dbl1d
42 character(len=*), intent(in) :: aname
43 ! -- local
44 type(double1dreadertype) :: this
45
46 this%parser => parser
47 this%dbl1d => dbl1d
48 this%array_name = aname
49
50 call this%read_array()
51
52 end subroutine read_dbl1d
53
54 subroutine reset_reader(this)
55 class(double1dreadertype) :: this
56 call this%ArrayReaderBaseType%reset_reader()
57 this%constant_array_value = dzero
58 this%factor = done
59 end subroutine reset_reader
60
61 subroutine set_constant(this)
62 class(double1dreadertype) :: this
63 this%constant_array_value = this%parser%GetDouble()
64 end subroutine set_constant
65
66 subroutine fill_constant(this)
67 class(double1dreadertype) :: this
68 integer(I4B) :: i
69 do i = 1, size(this%dbl1d)
70 this%dbl1d(i) = this%constant_array_value
71 end do
72 end subroutine fill_constant
73
74 subroutine read_ascii(this)
75 class(double1dreadertype) :: this
76 integer(I4B) :: i
77 integer(I4B) :: istat
78 read (this%input_unit, *, iostat=istat, iomsg=errmsg) &
79 (this%dbl1d(i), i=1, size(this%dbl1d))
80 if (istat /= 0) then
81 errmsg = 'Error reading data for array '//trim(this%array_name)// &
82 '. '//trim(errmsg)
84 call store_error_unit(this%input_unit)
85 end if
86 end subroutine read_ascii
87
88 subroutine read_binary(this)
89 class(double1dreadertype) :: this
90 integer(I4B) :: i
91 integer(I4B) :: nvals
92 integer(I4B) :: istat
93 integer(I4B) :: expected_size
94 expected_size = binary_header_bytes + (size(this%dbl1d) * binary_double_bytes)
95 call read_binary_header(this%input_unit, this%iout, this%array_name, nvals)
96 call check_binary_filesize(this%input_unit, expected_size, this%array_name)
97 read (this%input_unit, iostat=istat, iomsg=errmsg) &
98 (this%dbl1d(i), i=1, size(this%dbl1d))
99 if (istat /= 0) then
100 errmsg = 'Error reading data for array '//trim(this%array_name)// &
101 '. '//trim(errmsg)
102 call store_error(errmsg)
103 call store_error_unit(this%input_unit)
104 end if
105 end subroutine read_binary
106
107 subroutine set_factor(this)
108 class(double1dreadertype) :: this
109 this%factor = this%parser%GetDouble()
110 end subroutine set_factor
111
112 subroutine apply_factor(this)
113 class(double1dreadertype) :: this
114 integer(I4B) :: i
115 if (this%factor /= dzero) then
116 do i = 1, size(this%dbl1d)
117 ! no data values are not scaled
118 if (this%dbl1d(i) == dnodata) cycle
119 this%dbl1d(i) = this%dbl1d(i) * this%factor
120 end do
121 end if
122 end subroutine apply_factor
123
124end module double1dreadermodule
subroutine set_factor(this)
subroutine fill_constant(this)
subroutine reset_reader(this)
subroutine set_constant(this)
subroutine apply_factor(this)
subroutine read_binary(this)
subroutine read_ascii(this)
subroutine, public read_binary_header(locat, iout, arrname, nval)
subroutine, public check_binary_filesize(locat, expected_size, arrname)
integer(i4b), parameter, public binary_header_bytes
array text
integer(i4b), parameter, public binary_double_bytes
This module contains block parser methods.
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
real(dp), parameter done
real constant 1
Definition Constants.f90:76
subroutine, public read_dbl1d(parser, dbl1d, aname)
This module defines variable data types.
Definition kind.f90:8
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
Definition Sim.f90:172
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string