mtimer_write Subroutine

private impure subroutine mtimer_write(this, file_name)

Writes the MPI 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~~mtimer_write~~CalledByGraph proc~mtimer_write timer%mtimer_write program~test11 test11 program~test11->proc~mtimer_write program~test12 test12 program~test12->proc~mtimer_write program~test23 test23 program~test23->proc~mtimer_write program~test24 test24 program~test24->proc~mtimer_write

Source Code

   impure subroutine mtimer_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 MPI time to the file
      write(nunit, '(g0)') this%mpi_time

      ! Close the file
      close(nunit)

   end subroutine mtimer_write