@@ -13,11 +13,11 @@ Subroutine BEGIN(param_file,spatial_file)
1313 character (len= 200 ):: param_file,source_file,spatial_file
1414 !
1515 integer :: Julian
16- integer :: head_name,trib_cell
16+ integer :: head_name,trib_cell
1717 integer :: jul_start,main_stem,nyear1,nyear2,nc,ncell,nseg
1818 integer :: ns_max_test,node,ncol,nrow,nr,cum_sgmnt
1919 !
20- integer :: nreservoir
20+ integer :: nreservoir,nseg_temp,nseg_cum
2121 !
2222 logical :: first_cell,source
2323 !
@@ -83,6 +83,7 @@ Subroutine BEGIN(param_file,spatial_file)
8383 allocate (res_start_node(nres))
8484 allocate (res_end_node(nres))
8585 allocate (res_capacity_mcm(nres))
86+ allocate (nseg_out(nreach,heat_cells,nseg_out_num))
8687 !
8788 ! Start reading the reach date and initialize the reach index, NR
8889 ! and the cell index, NCELL
@@ -117,12 +118,13 @@ Subroutine BEGIN(param_file,spatial_file)
117118 ! Initialize NSEG, the total number of segments in this reach
118119 !
119120 nseg= 0
121+ nseg_cum= 0
120122 write (* ,* ) ' Starting to read reach ' ,nr
121123 !
122124 ! Read the number of cells in this reach, the headwater #,
123125 ! the number of the cell where it enters the next higher order stream,
124126 ! the headwater number of the next higher order stream it enters, and
125- ! the river mile of the headwaters.
127+ ! the river mile of the headwaters.
126128 !
127129 read (90 ,' (i5,11x,i4,10x,i5,15x,i5,15x,f10.0,i5)' ) no_cells(nr) &
128130 ,head_name,trib_cell,main_stem,rmile0
@@ -139,7 +141,7 @@ Subroutine BEGIN(param_file,spatial_file)
139141 if (trib_cell.gt. 0 ) then
140142 no_tribs(trib_cell) = no_tribs(trib_cell)+ 1
141143 trib(trib_cell,no_tribs(trib_cell)) = nr
142- end if
144+ end if
143145 !
144146 ! Reading Mohseni parameters for each headwaters (UW_JRY_2011/06/18)
145147 !
@@ -165,7 +167,7 @@ Subroutine BEGIN(param_file,spatial_file)
165167 end if
166168 !
167169 ! The headwaters index for each cell in this reach is given
168- ! in the order the cells are read
170+ ! in the order the cells are read
169171 !
170172 ! Card Type 3. Cell indexing #, Node # Row # Column Lat Long RM
171173 !
@@ -175,14 +177,14 @@ Subroutine BEGIN(param_file,spatial_file)
175177 if (reservoir) then
176178 read (90 ,' (5x,i5,5x,i5,8x,i5,6x,a8,6x,a10,7x,f10.0,f5.0,i6)' ) &
177179 node,nrow,ncol,lat,long,rmile1,ndelta(ncell),res_num(ncell)
178- write (* ,* ) node,nrow,ncol,lat,long,rmile1,ndelta(ncell),res_num(ncell)
180+ ! write(*,*) node,nrow,ncol,lat,long,rmile1,ndelta(ncell),res_num(ncell)
179181 if (res_num(ncell) .gt. 0 ) then
180182 res_pres(ncell) = .TRUE.
181183 end if
182184 else
183185 read (90 ,' (5x,i5,5x,i5,8x,i5,6x,a8,6x,a10,7x,f10.0,f5.0)' ) &
184186 node,nrow,ncol,lat,long,rmile1,ndelta(ncell)
185- write (* ,* ) node,nrow,ncol,lat,long,rmile1,ndelta(ncell)
187+ ! write(*,*) node,nrow,ncol,lat,long,rmile1,ndelta(ncell)
186188 end if
187189 !
188190 ! Set the number of segments of the default, if not specified
@@ -197,9 +199,16 @@ Subroutine BEGIN(param_file,spatial_file)
197199 ! Added variable ndelta (UW_JRY_2011/03/15)
198200 !
199201 dx(ncell)= miles_to_ft* (rmile0- rmile1)/ ndelta(ncell)
200- rmile0= rmile1
201- nndlta= 0
202- 200 continue
202+ rmile0= rmile1
203+ !
204+ ! Here we define the output segments
205+ !
206+ do nseg_temp= 1 ,nseg_out_num
207+ nseg_out(nr,ncell,nseg_temp)= nseg_cum+ ndelta(ncell)* nseg_temp/ (nseg_out_num)
208+ end do
209+ nseg_cum = nseg_cum+ ndelta(ncell)
210+ nndlta= 0
211+ 200 continue
203212 nndlta= nndlta+1
204213 nseg= nseg+1
205214 segment_cell(nr,nseg)= ncell
@@ -208,20 +217,25 @@ Subroutine BEGIN(param_file,spatial_file)
208217 !
209218 ! Write Segment List for mapping to temperature output (UW_JRY_2008/11/19)
210219 !
211- open (22 ,file= TRIM (spatial_file),status= ' unknown' ) ! (changed by WUR_WF_MvV_2011/01/05)
212- write (22 ,' (4i6,1x,a8,1x,a10,f5.0)' ) nr,ncell,nrow,ncol,lat,long,nndlta
220+ do nseg_temp= 1 ,nseg_out_num
221+ if (nseg_out(nr,ncell,nseg_temp).eq. nseg) then
222+ open (22 ,file= TRIM (spatial_file),status= ' unknown' ) ! (changed by WUR_WF_MvV_2011/01/05)
223+ write (22 ,' (4i6,1x,a8,1x,a10,i5)' ) nr,ncell,nrow,ncol,lat,long,nseg_temp
224+ end if
225+ end do
213226 !
214227 !
215228 !
216229 ! Added variable ndelta (UW_JRY_2011/03/15)
217230 !
218231 if (nndlta.lt. ndelta(ncell)) go to 200
219- no_celm(nr)= nseg
232+ no_celm(nr)= nseg
220233 segment_cell(nr,nseg)= ncell
221- x_dist(nr,nseg)= miles_to_ft* rmile1
234+ x_dist(nr,nseg)= miles_to_ft* rmile1
235+ write (* ,* ) ' number of segment in reach' , nr, nseg
222236 !
223237 ! End of cell and segment loop
224- !
238+ !
225239 end do
226240 !
227241 ! If this is a reach that is tributary to another, set the confluence cell to the previous
@@ -233,26 +247,26 @@ Subroutine BEGIN(param_file,spatial_file)
233247 conflnce(trib_cell,no_tribs(trib_cell)) = ncell
234248 end if
235249
236- if (ns_max_test.lt. nseg) ns_max_test= nseg
237- !
250+ if (ns_max_test.lt. nseg) ns_max_test= nseg
251+ !
238252! End of reach loop
239- !
253+ !
240254end do
241255if (ns_max_test.gt. ns_max) then
242256 write (* ,* ) ' RBM is terminating because'
243257 write (* ,* ) ' NS_MAX exceeded. Change NS_MAX in Block_Network to: ' ,ns_max_test
244258 stop
245- end if
246- !
247- nwpd= 1
248- xwpd= nwpd
249- dt_comp= 86400 ./ xwpd
259+ end if
260+ !
261+ nwpd= 1
262+ xwpd= nwpd
263+ dt_comp= 86400 ./ xwpd
264+ !
265+ ! ******************************************************
266+ ! Return to RMAIN
267+ ! ******************************************************
250268!
251- ! ******************************************************
252- ! Return to RMAIN
253- ! ******************************************************
254- !
255- 900 continue
269+ 900 continue
256270!
257271!
258272end subroutine BEGIN
0 commit comments