31SUBROUTINE readstate(stateyear, latstart, latend, lonstart, lonend, nspc)
40 INTEGER,
INTENT(in) :: latStart, latEnd, lonStart, lonEnd
41 INTEGER,
INTENT(in) :: nspc
42 INTEGER,
INTENT(out) :: stateyear
46 isp, i, currentLine, &
48 latOffset, lonOffset, &
50 character(len=1024) :: lineBuffer
51 character(len=200) :: ioerrmsg
52 character(len=100) :: nameLong
56 looplat:
do lat = latstart, latend
57 looplon:
do lon = lonstart, lonend
61 do height = 0,
spec(i)%maxhtc
62 stategrid(lat, lon)%sp(i)%numin(height) = 0.
83 currentline = currentline + 1
86 read (
statein_file%unit,
"(A)", iostat=err, iomsg=ioerrmsg) linebuffer
91 else if (err > 0)
then
92 write (
logmessage,
"(A,I10)")
"[Statfile] Could not read line in statefile. Line: ", currentline
94 call logerror(
"[Statfile][Details] io-msg: "//ioerrmsg)
95 write (
logmessage,
"(A,I3)")
"[Statfile][Details] io-stat: ",err
98 call logerror(
"[Statfile][Details] line: "//linebuffer)
104 read (linebuffer, *, iostat=err) namelong, stateyear, lat, lon;
108 write (
logmessage,
"(A,I10)")
"[Statfile] Could not parse line in statefile. Line: ", currentline
110 call logerror(
"[Statfile][Details] line content: "//linebuffer)
115 if(lat+latoffset >
maxlat .or. lat+latoffset < 0 .or. lon+lonoffset >
maxlon .or. lon+lonoffset < 0)
then
116 write (
logmessage,
"(A,I10)")
"[Statfile] lat/lon are out of bounds in statefile. Line: ", currentline
118 write (
logmessage,
"(A,I7,',',I7)")
"[Statfile][Details] (latOffset, lonOffset): ", latoffset, lonoffset
120 write (
logmessage,
"(A,I7,',',I7)")
"[Statfile][Details] (lat,lon) inc. offset : ", lat+latoffset, lon+lonoffset
124 call logerror(
"[Statfile][Details] line content: "//linebuffer)
130 if(namelong ==
spec(isp)%nl) exit;
141 read (linebuffer, *, iostat=err) namelong, stateyear, lat, lon, &
142 stategrid(lat + latoffset, lon + lonoffset)%sp(isp)%seedBank, &
143 stategrid(lat + latoffset, lon + lonoffset)%sp(isp)%antagonist, &
145 (
stategrid(lat + latoffset, lon + lonoffset)%sp(isp)%numin(height), height=0, min(
spec(isp)%maxhtc,nhtc))
149 write (
logmessage,
"(A,I10)")
"[Statfile] Could not parse line in statefile. Line: ", currentline
151 call logerror(
"[Details] line content: "//linebuffer)
159 write (
logmessage,
"(A,I7)")
"[Statefile] Reading statefile complete. State year:",stateyear
164 write (
logmessage,
"(A,I6,A,I6,A)")
"[Statfile] State-file year is smaller than the simulation start year."&
165 "State-file year will be set to start year. (",stateyear,
"->",
simustartyear,
")"
subroutine readstate(stateyear, latstart, latend, lonstart, lonend, nspc)
ReadState.