get_rw_count Subroutine

private subroutine get_rw_count(files, control)

Get read/write count

Arguments

Type IntentOptional AttributesName
type(filetype), intent(in) :: files
type(controltype), intent(inout) :: control

Called by

proc~~get_rw_count~~CalledByGraph proc~get_rw_count get_rw_count proc~read_output_control read_output_control proc~read_output_control->proc~get_rw_count proc~read_input_and_controls read_input_and_controls proc~read_input_and_controls->proc~read_output_control proc~setup_solver setup_solver proc~setup_solver->proc~read_input_and_controls proc~start_run start_run proc~start_run->proc~setup_solver program~main main program~main->proc~start_run

Contents

Source Code


Source Code

      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