-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathch_read.f90
More file actions
117 lines (95 loc) · 3.65 KB
/
Copy pathch_read.f90
File metadata and controls
117 lines (95 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
subroutine ch_read
use basin_module
use input_file_module
use channel_data_module
use maximum_data_module
use hydrograph_module
use pesticide_data_module
implicit none
character (len=80) :: titldum = "" ! |title of file
character (len=80) :: header = "" ! |header of file
integer :: eof = 0 ! |end of file
integer :: i = 0 !units |description
integer :: imax = 0 !units |description
logical :: i_exist ! |check to determine if file exists
integer :: ichi = 0 !none |counter
integer :: k = 0 !units |description
integer :: iinit = 0 !none |counter
integer :: ihyd = 0 !none |counter
integer :: ised = 0 !none |counter
integer :: inut = 0 !none |counter
integer :: itemp = 0 !none |counter
eof = 0
imax = 0
inquire (file=in_cha%dat, exist=i_exist)
if (.not. i_exist .or. in_cha%dat == "null") then
allocate (ch_dat(0:0))
allocate (ch_dat_c(0:0))
else
do
open (105,file=in_cha%dat)
read (105,*,iostat=eof) titldum
if (eof < 0) exit
read (105,*,iostat=eof) header
if (eof < 0) exit
do while (eof == 0)
read (105,*,iostat=eof) i
if (eof < 0) exit
imax = Max(imax,i)
end do
db_mx%ch_dat = imax
allocate (ch_dat(0:imax))
allocate (ch_dat_c(0:imax))
rewind (105)
read (105,*,iostat=eof) titldum
if (eof < 0) exit
read (105,*,iostat=eof) header
if (eof < 0) exit
do ichi = 1, db_mx%ch_dat
read (105,*,iostat=eof) i
if (eof < 0) exit
backspace (105)
read (105,*,iostat=eof) k, ch_dat_c(ichi)
if (eof < 0) exit
do iinit = 1, db_mx%ch_init
if (ch_init(iinit)%name == ch_dat_c(ichi)%init) then
ch_dat(ichi)%init = iinit
exit
end if
end do
do ihyd = 1, db_mx%ch_hyd
if (ch_hyd(ihyd)%name == ch_dat_c(ichi)%hyd) then
ch_dat(ichi)%hyd = ihyd
exit
end if
end do
do ised = 1, db_mx%ch_sed
if (ch_sed(ised)%name == ch_dat_c(ichi)%sed) then
ch_dat(ichi)%sed = ised
exit
end if
end do
do inut = 1, db_mx%ch_nut
if (ch_nut(inut)%name == ch_dat_c(ichi)%nut) then
ch_dat(ichi)%nut = inut
exit
end if
end do
do itemp = 1, db_mx%w_temp
if (w_temp(itemp)%name == ch_dat_c(ichi)%temp) then
ch_dat(ichi)%temp = itemp
exit
end if
end do
if (ch_dat(ichi)%init == 0) write (9001,*) ch_dat_c(ichi)%init, " not found (initial.cha)"
if (ch_dat(ichi)%hyd == 0) write (9001,*) ch_dat_c(ichi)%hyd, " not found (hydrology.cha)"
if (ch_dat(ichi)%sed == 0) write (9001,*) ch_dat_c(ichi)%sed, " not found (sediment.cha)"
if (ch_dat(ichi)%nut == 0) write (9001,*) ch_dat_c(ichi)%nut, " not found (nutrients.cha)"
if (ch_dat(ichi)%nut == 0) write (9001,*) ch_dat_c(ichi)%temp, " not found (temperature.cha)"
end do
close (105)
exit
enddo
endif
return
end subroutine ch_read