911
912 class(LakType), intent(inout) :: this
913
914 integer(I4B) :: n, j, ipos, nn
915 integer(I4B) :: ilak, iconn
916 integer(I4B) :: ipos0, icellid0, icellid, nn2
917 logical(LGP) :: is_lake_bed
918 character(len=LINELENGTH) :: cellid_str
919 character(len=LINELENGTH) :: ctypenm
920 character(len=LINELENGTH) :: cbleak
921 real(DP) :: top, bot, rval
922 integer(I4B), dimension(:), pointer, contiguous :: ifno => null()
923 integer(I4B), dimension(:), pointer, contiguous :: iconns => null()
924 integer(I4B), dimension(:, :), pointer, contiguous :: cellid => null()
925 type(CharacterStringType), dimension(:), pointer, contiguous :: &
926 claktype => null()
927 type(CharacterStringType), dimension(:), pointer, contiguous :: &
928 bedleak => null()
929 real(DP), dimension(:), pointer, contiguous :: belev => null()
930 real(DP), dimension(:), pointer, contiguous :: telev => null()
931 real(DP), dimension(:), pointer, contiguous :: connlen => null()
932 real(DP), dimension(:), pointer, contiguous :: connwidth => null()
933 integer(I4B), allocatable :: nboundchk(:)
934
935
936 call mem_allocate(this%imap, this%MAXBOUND, 'IMAP', this%memoryPath)
937 call mem_allocate(this%gwfconn, this%MAXBOUND, 'GWFCONN', this%memoryPath)
938 call mem_allocate(this%nodesontop, this%MAXBOUND, 'NODESONTOP', &
939 this%memoryPath)
940 call mem_allocate(this%ictype, this%MAXBOUND, 'ICTYPE', this%memoryPath)
941 call mem_allocate(this%bedleak, this%MAXBOUND, 'BEDLEAK', this%memoryPath)
942 call mem_allocate(this%belev, this%MAXBOUND, 'BELEV', this%memoryPath)
943 call mem_allocate(this%telev, this%MAXBOUND, 'TELEV', this%memoryPath)
944 call mem_allocate(this%connlength, this%MAXBOUND, 'CONNLENGTH', &
945 this%memoryPath)
946 call mem_allocate(this%connwidth, this%MAXBOUND, 'CONNWIDTH', &
947 this%memoryPath)
948 call mem_allocate(this%sarea, this%MAXBOUND, 'SAREA', this%memoryPath)
949 call mem_allocate(this%warea, this%MAXBOUND, 'WAREA', this%memoryPath)
950 call mem_allocate(this%satcond, this%MAXBOUND, 'SATCOND', this%memoryPath)
951 call mem_allocate(this%simcond, this%MAXBOUND, 'SIMCOND', this%memoryPath)
952 call mem_allocate(this%simlakgw, this%MAXBOUND, 'SIMLAKGW', this%memoryPath)
953
954 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
955 ' CONNECTIONDATA'
956
957
958 call mem_setptr(ifno, 'CONNDATA_IFNO', this%input_mempath)
959 call mem_setptr(iconns, 'ICONN', this%input_mempath)
960 call mem_setptr(cellid, 'CELLID', this%input_mempath)
961 call mem_setptr(claktype, 'CLAKTYPE', this%input_mempath)
962 call mem_setptr(bedleak, 'BEDLEAK', this%input_mempath)
963 call mem_setptr(belev, 'BELEV', this%input_mempath)
964 call mem_setptr(telev, 'TELEV', this%input_mempath)
965 call mem_setptr(connlen, 'CONNLEN', this%input_mempath)
966 call mem_setptr(connwidth, 'CONNWIDTH', this%input_mempath)
967
968
969 allocate (nboundchk(this%MAXBOUND))
970 nboundchk = 0
971
972 do n = 1, this%MAXBOUND
973
974 ilak = ifno(n)
975 iconn = iconns(n)
976
977 if (ilak < 1 .or. ilak > this%nlakes) then
978 write (errmsg, '(a,1x,i0)') 'lakeno MUST BE > 0 and <= ', this%nlakes
979 call store_error(errmsg)
980 cycle
981 end if
982 if (iconn < 1 .or. iconn > this%nlakeconn(ilak)) then
983 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
984 'iconn FOR LAKE ', ilak, 'MUST BE > 0 and <= ', this%nlakeconn(ilak)
985 call store_error(errmsg)
986 cycle
987 end if
988
989 ipos = this%idxlakeconn(ilak) + iconn - 1
990 this%imap(ipos) = ilak
991 nboundchk(ipos) = nboundchk(ipos) + 1
992
993
994 write (cellid_str, '(10(i0,1x))') cellid(1:this%dis%ndim, n)
995 nn = this%dis%noder_from_cellid(cellid_str, this%inunit, this%iout)
996 if (nn < 1) then
997 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
998 'INVALID cellid FOR LAKE ', ilak, 'connection', iconn
999 call store_error(errmsg)
1000 end if
1001 this%gwfconn(ipos) = nn
1002 this%nodesontop(ipos) = nn
1003
1004
1005 ctypenm = claktype(n)
1006 select case (trim(ctypenm))
1007 case ('VERTICAL')
1008 this%ictype(ipos) = 0
1009 case ('HORIZONTAL')
1010 this%ictype(ipos) = 1
1011 case ('EMBEDDEDH')
1012 this%ictype(ipos) = 2
1013 case ('EMBEDDEDV')
1014 this%ictype(ipos) = 3
1015 case default
1016 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,a,a)') &
1017 'UNKNOWN ctype FOR LAKE ', ilak, 'connection', iconn, &
1018 '(', trim(ctypenm), ')'
1019 call store_error(errmsg)
1020 end select
1021
1022
1023 cbleak = bedleak(n)
1024 select case (trim(cbleak))
1025 case ('NONE')
1026 is_lake_bed = .false.
1027 rval = dnodata
1028 write (warnmsg, '(2(a,1x,i0,1x),a,1pe8.1,a)') &
1029 'BEDLEAK for connection', iconn, 'in lake', ilak, &
1030 'is specified to be NONE. Lake connections where the lake-GWF '// &
1031 'connection conductance is solely a function of aquifer '// &
1032 'properties in the connected GWF cell should be specified '// &
1033 'with a DNODATA (', dnodata, ') value.'
1034 call deprecation_warning('CONNECTIONDATA', 'bedleak=NONE', '6.4.3', &
1035 warnmsg, this%inunit)
1036 case default
1037 read (cbleak, *) rval
1038 if (is_close(rval, dnodata)) then
1039 is_lake_bed = .false.
1040 else
1041 is_lake_bed = .true.
1042 end if
1043 end select
1044 this%bedleak(ipos) = rval
1045 if (is_lake_bed .and. this%bedleak(ipos) < dzero) then
1046 write (errmsg, '(a,1x,i0,1x,a)') 'bedleak FOR LAKE ', ilak, &
1047 'MUST BE >= 0'
1048 call store_error(errmsg)
1049 end if
1050
1051
1052 this%belev(ipos) = belev(n)
1053
1054
1055 this%telev(ipos) = telev(n)
1056
1057
1058 rval = connlen(n)
1059 if (rval <= dzero) then
1060 if (this%ictype(ipos) == 1 .or. this%ictype(ipos) == 2 .or. &
1061 this%ictype(ipos) == 3) then
1062 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,a,1x,a)') &
1063 'connection length (connlen) FOR LAKE ', ilak, &
1064 ', CONNECTION NO.', iconn, ', MUST BE > 0 FOR SPECIFIED ', &
1065 'connection type (ctype)', trim(ctypenm)
1066 call store_error(errmsg)
1067 else
1068 rval = dzero
1069 end if
1070 end if
1071 this%connlength(ipos) = rval
1072
1073
1074 rval = connwidth(n)
1075 if (rval < dzero) then
1076 if (this%ictype(ipos) == 1) then
1077 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1078 'cell width (connwidth) FOR LAKE ', ilak, &
1079 ' HORIZONTAL CONNECTION ', iconn, 'MUST BE >= 0'
1080 call store_error(errmsg)
1081 else
1082 rval = dzero
1083 end if
1084 end if
1085 this%connwidth(ipos) = rval
1086 end do
1087
1088 write (this%iout, '(1x,a)') &
1089 'END OF '//trim(adjustl(this%text))//' CONNECTIONDATA'
1090
1091
1092 if (count_errors() > 0) then
1093 call store_error_filename(this%input_fname)
1094 end if
1095
1096
1097 do n = 1, this%nlakes
1098 j = 0
1099 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1100 if (this%ictype(ipos) /= 2 .and. this%ictype(ipos) /= 3) cycle
1101 j = j + 1
1102 if (j > 1) then
1103 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1104 'nlakeconn FOR LAKE', n, 'EMBEDDED CONNECTION', j, ' EXCEEDS 1.'
1105 call store_error(errmsg)
1106 end if
1107 end do
1108 end do
1109
1110
1111 do n = 1, this%nlakes
1112 ipos0 = this%idxlakeconn(n)
1113 icellid0 = this%gwfconn(ipos0)
1114 if (this%ictype(ipos0) /= 2 .and. this%ictype(ipos0) /= 3) cycle
1115 do nn2 = 1, this%nlakes
1116 if (nn2 == n) cycle
1117 j = 0
1118 do ipos = this%idxlakeconn(nn2), this%idxlakeconn(nn2 + 1) - 1
1119 j = j + 1
1120 icellid = this%gwfconn(ipos)
1121 if (icellid == icellid0) then
1122 if (this%ictype(ipos) == 0) then
1123 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1124 'EMBEDDED LAKE', n, &
1125 'CANNOT COINCIDE WITH VERTICAL CONNECTION', j, &
1126 'IN LAKE', nn2, '.'
1127 call store_error(errmsg)
1128 end if
1129 end if
1130 end do
1131 end do
1132 end do
1133
1134
1135 do n = 1, this%nlakes
1136 j = 0
1137 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1138 j = j + 1
1139 nn = this%gwfconn(ipos)
1140 top = this%dis%top(nn)
1141 bot = this%dis%bot(nn)
1142 if (this%ictype(ipos) == 0) then
1143 this%telev(ipos) = top + this%surfdep
1144 this%belev(ipos) = top
1145 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
1146 else if (this%ictype(ipos) == 1) then
1147 if (this%belev(ipos) == this%telev(ipos)) then
1148 this%telev(ipos) = top
1149 this%belev(ipos) = bot
1150 else
1151 if (this%belev(ipos) >= this%telev(ipos)) then
1152 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a)') &
1153 'telev FOR LAKE ', n, ' HORIZONTAL CONNECTION ', j, &
1154 'MUST BE >= belev'
1155 call store_error(errmsg)
1156 else if (this%belev(ipos) < bot) then
1157 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
1158 'belev FOR LAKE ', n, ' HORIZONTAL CONNECTION ', j, &
1159 'MUST BE >= cell bottom (', bot, ')'
1160 call store_error(errmsg)
1161 else if (this%telev(ipos) > top) then
1162 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
1163 'telev FOR LAKE ', n, ' HORIZONTAL CONNECTION ', j, &
1164 'MUST BE <= cell top (', top, ')'
1165 call store_error(errmsg)
1166 end if
1167 end if
1168 this%laketop(n) = max(this%telev(ipos), this%laketop(n))
1169 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
1170 else if (this%ictype(ipos) == 2 .or. this%ictype(ipos) == 3) then
1171 this%telev(ipos) = top
1172 this%belev(ipos) = bot
1173 this%lakebot(n) = bot
1174 end if
1175
1176
1177 if (nboundchk(ipos) == 0) then
1178 write (errmsg, '(a,1x,i0,1x,a,1x,i0)') &
1179 'NO DATA SPECIFIED FOR LAKE', n, 'CONNECTION', j
1180 call store_error(errmsg)
1181 else if (nboundchk(ipos) > 1) then
1182 write (errmsg, '(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1183 'DATA FOR LAKE', n, 'CONNECTION', j, &
1184 'SPECIFIED', nboundchk(ipos), 'TIMES'
1185 call store_error(errmsg)
1186 end if
1187 end do
1188 if (this%laketop(n) == -dep20) then
1189 this%laketop(n) = this%lakebot(n) + 100.
1190 end if
1191 end do
1192
1193 deallocate (nboundchk)
1194
1195 if (count_errors() > 0) then
1196 call store_error_filename(this%input_fname)
1197 end if
1198
1199
1200 call memorystore_release('CONNDATA_IFNO', this%input_mempath)
1201 call memorystore_release('ICONN', this%input_mempath)
1202 call memorystore_release('CELLID', this%input_mempath)
1203 call memorystore_release('CLAKTYPE', this%input_mempath)
1204 call memorystore_release('BEDLEAK', this%input_mempath)
1205 call memorystore_release('BELEV', this%input_mempath)
1206 call memorystore_release('TELEV', this%input_mempath)
1207 call memorystore_release('CONNLEN', this%input_mempath)
1208 call memorystore_release('CONNWIDTH', this%input_mempath)