dtimer_write Subroutine

private impure subroutine dtimer_write(this, file_name)

Writes the elapsed time to a file.

Type Bound

timer

Arguments

Type IntentOptional Attributes Name
class(timer), intent(in) :: this
character(len=*), intent(in) :: file_name

Called by

proc~~dtimer_write~~CalledByGraph proc~dtimer_write timer%dtimer_write program~example6 example6 program~example6->proc~dtimer_write program~test26 test26 program~test26->proc~dtimer_write program~test27 test27 program~test27->proc~dtimer_write program~test29 test29 program~test29->proc~dtimer_write program~test30 test30 program~test30->proc~dtimer_write

Source Code

   impure subroutine dtimer_write(this, file_name)
      class(timer), intent(in) :: this
      character(*), intent(in) :: file_name
      logical                  :: file_exists
      integer                  :: nunit

      ! Check if the file exists
      inquire(file=file_name, exist=file_exists)

      ! Open the file in appropriate mode
      if (file_exists) then
         open(newunit=nunit, file=file_name, status='old', action='write', position='append')
      else
         open(newunit=nunit, file=file_name, status='new', action='write')
      end if

      ! Write the elapsed time to the file
      write(nunit, '(g0)') this%elapsed_dtime

      ! Close the file
      close(nunit)

   end subroutine dtimer_write