New subroutines in table
These allow to invert the x and f arrays and make the X axis cumulative sum.
This commit is contained in:
parent
b171f801fc
commit
94ff12b1cb
1 changed files with 48 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ MODULE moduleTable
|
|||
PROCEDURE, PASS:: init => initTable1D
|
||||
PROCEDURE, PASS:: get => getValueTable1D
|
||||
PROCEDURE, PASS:: convert => convertUnits
|
||||
PROCEDURE, PASS:: invertXF
|
||||
PROCEDURE, PASS:: cumsumX
|
||||
|
||||
END TYPE table1D
|
||||
|
||||
|
|
@ -126,4 +128,50 @@ MODULE moduleTable
|
|||
|
||||
END SUBROUTINE convertUnits
|
||||
|
||||
! Invert the arrays of x and f
|
||||
SUBROUTINE invertXF(self)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(table1D), INTENT(inout):: self
|
||||
REAL(8), ALLOCATABLE:: xTemp(:)
|
||||
REAL(8):: xTempMin, xTempMax
|
||||
|
||||
! Store temporal x data
|
||||
xTemp = self%x
|
||||
xTempMin = self%xMin
|
||||
xTempMax = self%xMax
|
||||
|
||||
! Replace x data with f data
|
||||
self%x = self%f
|
||||
self%xMin = self%fMin
|
||||
self%xMax = self%fMax
|
||||
|
||||
! Put temporal x data in f data
|
||||
self%f = xTemp
|
||||
self%fMin = xTempMin
|
||||
self%fMax = xTempMax
|
||||
|
||||
END SUBROUTINE invertXF
|
||||
|
||||
! Makes the x axis its cumulative sum
|
||||
SUBROUTINE cumSumX(self)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(table1D), INTENT(inout):: self
|
||||
INTEGER:: nTotal, n
|
||||
REAL(8), ALLOCATABLE:: cumX(:)
|
||||
|
||||
nTotal = SIZE(self%x)
|
||||
ALLOCATE(cumX(1:nTotal))
|
||||
cumX(1) = self%x(1)
|
||||
DO n = 2, nTotal
|
||||
cumX(n) = self%x(n) + cumX(n-1)
|
||||
|
||||
END DO
|
||||
|
||||
self%x = cumX / cumX(nTotal)
|
||||
DEALLOCATE(cumX)
|
||||
|
||||
END SUBROUTINE cumSumX
|
||||
|
||||
END MODULE moduleTable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue