FWHWriteToFile Subroutine

public subroutine FWHWriteToFile(self, force)

Uses

    • MPI_Process_Info

Type Bound

FWHClass

Arguments

Type IntentOptional Attributes Name
class(FWHClass) :: self
logical, optional :: force

Source Code

    Subroutine FWHWriteToFile(self, force)
!
!        ******************************************************************
!              This routine has a double behaviour:
!           force = .true.  -> Writes to file and resets buffers
!           force = .false. -> Just writes to file if the buffer is full
!        ******************************************************************
!
        use MPI_Process_Info
        implicit none

        class(FWHClass)                                     :: self
        logical, optional                                   :: force

!       ---------------
!       Local variables
!       ---------------
        integer                                             :: i 
        logical                                             :: forceVal

!       Check if is activated
!       ------------------------
        if (.not. self % isActive) return

        if ( present ( force ) ) then
           forceVal = force
        else
           forceVal = .false.
        end if

        if ( forceVal ) then 
!
!           In this case the observers are exported to their files and the buffer is reset
!           ------------------------------------------------------------------------------
            if (.not. self % firstWrite .and. self % interpolate) then
                do i =1, self % numberOfObservers
                    call self % observers(i) % interpolateSol(self % t, self % bufferLine)
                end do
                self % firstWrite = .TRUE.
            end if
            do i =1, self%numberOfObservers
                call self % observers(i) % writeToFile(self % iter, self % t, self % bufferLine)
            end do
!               Reset buffer
!               ------------
                self % bufferLine = 0
        else
!               The observers are exported just if the buffer is full
!               ----------------------------------------------------
            if ( self % bufferLine .eq. OB_BUFFER_SIZE ) then
                if (.not. self % firstWrite .and. self % interpolate) then
                    do i =1, self % numberOfObservers
                        call self % observers(i) % interpolateSol(self % t, self % bufferLine)
                    end do
                    self % firstWrite = .TRUE.
                end if
                do i =1, self%numberOfObservers
                    call self % observers(i) % writeToFile(self % iter, self % t, self % bufferLine)
                end do
!               Reset buffer
!               ------------
                self % bufferLine = 0
            end if
        end if

    End Subroutine FWHWriteToFile