Get read/write count
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(filetype), | intent(in) | :: | files | |||
type(controltype), | intent(inout) | :: | control |
subroutine get_rw_count(files, control)
!< Get read/write count
implicit none
type(filetype), intent(in) :: files
type(controltype), intent(inout) :: control
integer :: ios
character(len=64) :: buf
logical :: ok
control%r_count=0
control%w_count=0
inquire(files%OUTIN_FILE_UNIT, opened=ok)
if(ok) close(files%OUTIN_FILE_UNIT)
!call close_file(files%OUTIN_FILE_UNIT)
open(files%OUTIN_FILE_UNIT, file=files%outin_file, status='old', action='read')
! write list dimension
do while(.true.)
read(files%OUTIN_FILE_UNIT, *, iostat=ios) buf
if(trim(buf)=='{') EXIT
if(is_iostat_end(ios)) EXIT
end do
control%w_count = 0
do while (.true.)
read(files%OUTIN_FILE_UNIT, *, iostat=ios) buf
if (trim(buf)=='}') EXIT
if(is_iostat_end(ios)) EXIT
control%w_count = control%w_count + 1
end do
if(control%w_count>0) then
allocate(control%w_list(1:control%w_count))
else
control%w_count=3
allocate(control%w_list(1:control%w_count))
control%w_list(1) = "Velocity"
control%w_list(2) = "Density"
control%w_list(3) = "Pressure"
end if
! read list dimesnion
do while(.true.)
read(files%OUTIN_FILE_UNIT, *, iostat=ios) buf
if(trim(buf)=='{') EXIT
if(is_iostat_end(ios)) EXIT
end do
control%r_count = 0
do while (.true.)
read(files%OUTIN_FILE_UNIT, *, iostat=ios) buf
if (trim(buf)=='}') EXIT
if(is_iostat_end(ios)) EXIT
control%r_count = control%r_count + 1
end do
if(control%r_count==0) then
allocate(control%r_list(1:control%w_count))
else
allocate(control%r_list(1:control%r_count))
end if
close(files%OUTIN_FILE_UNIT)
end subroutine get_rw_count