forked from MODFLOW-USGS/modflow6
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
207 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
module GridFileReaderModule | ||
|
||
use KindModule | ||
use SimModule, only: store_error, store_error_unit | ||
use ConstantsModule, only: LINELENGTH | ||
use BaseDisModule, only: DisBaseType | ||
use InputOutputModule, only: urword, read_line | ||
use LongLineReaderModule, only: LongLineReaderType | ||
|
||
implicit none | ||
|
||
private | ||
public :: GridFileReaderType | ||
|
||
type :: GridFileReaderType | ||
integer(I4B), public :: inunit | ||
! character(len=:), public, allocatable :: grid_type | ||
! character(len=:), public, allocatable :: version | ||
! integer(I4B), public :: ntxt | ||
! integer(I4B), public :: lentxt | ||
type(LongLineReaderType) :: line_reader | ||
contains | ||
procedure, public :: initialize | ||
procedure, public :: load_grb | ||
procedure, public :: finalize | ||
procedure :: get_next_line | ||
end type GridFileReaderType | ||
|
||
contains | ||
|
||
!< @brief Initialize the grid file reader. | ||
subroutine initialize(this, iu) | ||
class(GridFileReaderType) :: this | ||
integer(I4B), intent(in) :: iu | ||
this%inunit = iu | ||
end subroutine initialize | ||
|
||
!> @brief Load the grid file into the discretization object. | ||
subroutine load_grb(this, dis) | ||
! dummy | ||
class(GridFileReaderType) :: this | ||
class(DisBaseType), pointer :: dis | ||
! local | ||
character(len=LINELENGTH) :: errmsg | ||
character(len=:), allocatable :: line | ||
integer(I4B) :: lloc, istart, istop, ival | ||
real(DP) :: rval | ||
logical(LGP) :: eof | ||
|
||
! -- Parse the attribute | ||
do | ||
|
||
call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0) | ||
select case (line(istart:istop)) | ||
case ('GRID') | ||
! call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0) | ||
! this%grid = line(istart:istop) | ||
case ('VERSION') | ||
! call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0) | ||
! this%version = rval | ||
case ('NTXT') | ||
case ('LENTXT') | ||
case ('NCELLS') | ||
case ('NLAY') | ||
case ('NROW') | ||
case ('NCOL') | ||
case ('NCPL') | ||
case ('NVERT') | ||
case ('NJAVERT') | ||
case ('NJA') | ||
case ('XORIGIN') | ||
case ('YORIGIN') | ||
case ('ANGROT') | ||
case ('TOP') | ||
case ('BOTM') | ||
case ('VERTICES') | ||
case ('CELLX') | ||
case ('CELLY') | ||
case ('IAVERT') | ||
case ('JAVERT') | ||
case ('IA') | ||
case ('JA') | ||
case ('IDOMAIN') | ||
case ('ICELLTYPE') | ||
case default | ||
exit | ||
! write (errmsg, '(a,a)') & | ||
! 'Unknown grid file attribute: ', line(istart:istop) | ||
! call store_error(errmsg, terminate=.TRUE.) | ||
end select | ||
end do | ||
|
||
! TODO proper implementation | ||
|
||
rewind (this%inunit) | ||
end subroutine load_grb | ||
|
||
!> @ brief Get the next line | ||
!! | ||
!! Method to get the next line from a file. | ||
!! | ||
!< | ||
subroutine read_line(this, end) | ||
! dummy variables | ||
class(GridFileReaderType), intent(inout) :: this !< this object | ||
logical, intent(out) :: end !< boolean indicating end of the text header section | ||
! local variables | ||
integer(I4B) :: ierr | ||
integer(I4B) :: ival | ||
integer(I4B) :: istart | ||
integer(I4B) :: istop | ||
real(DP) :: rval | ||
character(len=10) :: key | ||
logical :: lineread | ||
! | ||
! initialize local variables | ||
end = .false. | ||
ierr = 0 | ||
lineread = .false. | ||
! | ||
! read next line | ||
loop1: do | ||
if (lineread) exit loop1 | ||
call this%line_reader%rdcom(this%iuext, this%iout, this%line, ierr) | ||
this%lloc = 1 | ||
call urword(this%line, this%lloc, istart, istop, 0, ival, rval, & | ||
this%iout, this%iuext) | ||
key = this%line(istart:istop) | ||
call upcase(key) | ||
print *, "key: ", key | ||
if (key == 'END' .or. key == 'BEGIN') then | ||
call uterminate_block(this%inunit, this%iout, key, & | ||
this%blockNameFound, this%lloc, this%line, & | ||
ierr, this%iuext) | ||
this%iuactive = this%iuext | ||
endOfBlock = .true. | ||
lineread = .true. | ||
elseif (key == '') then | ||
! End of file reached. | ||
! If this is an OPEN/CLOSE file, close the file and read the next | ||
! line from this%inunit. | ||
if (this%iuext /= this%inunit) then | ||
close (this%iuext) | ||
this%iuext = this%inunit | ||
this%iuactive = this%inunit | ||
else | ||
errmsg = 'Unexpected end of file reached.' | ||
call store_error(errmsg) | ||
call this%StoreErrorUnit() | ||
end if | ||
else | ||
this%lloc = 1 | ||
this%linesRead = this%linesRead + 1 | ||
lineread = .true. | ||
end if | ||
end do loop1 | ||
end subroutine read_line | ||
|
||
!> @brief Finalize the grid file reader. | ||
subroutine finalize(this) | ||
class(GridFileReaderType) :: this | ||
close (this%inunit) | ||
end subroutine finalize | ||
|
||
end module GridFileReaderModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters