Skip to content

Commit

Permalink
fix: Merge branch 'master' into arrayPropertyColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
abensonca committed Sep 13, 2023
2 parents 8933743 + 2358c05 commit a07ddd1
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 58 deletions.
67 changes: 43 additions & 24 deletions source/nodes.property_extractor.galaxy_major_merger_time.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
private
integer :: galaxyMajorMergerTimeID
contains
procedure :: extract => galaxyMajorMergerTimeExtract
procedure :: name => galaxyMajorMergerTimeName
procedure :: description => galaxyMajorMergerTimeDescription
procedure :: unitsInSI => galaxyMajorMergerTimeUnitsInSI
procedure :: elementCount => galaxyMajorMergerTimeElementCount
procedure :: extract => galaxyMajorMergerTimeExtract
procedure :: names => galaxyMajorMergerTimeNames
procedure :: descriptions => galaxyMajorMergerTimeDescriptions
procedure :: unitsInSI => galaxyMajorMergerTimeUnitsInSI
end type nodePropertyExtractorGalaxyMajorMergerTime

interface nodePropertyExtractorGalaxyMajorMergerTime
Expand Down Expand Up @@ -76,59 +77,77 @@ function galaxyMajorMergerTimeConstructorInternal() result(self)
return
end function galaxyMajorMergerTimeConstructorInternal

integer function galaxyMajorMergerTimeElementCount(self)
!!{
Return a count of the number of properties extracted.
!!}
implicit none
class(nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self

galaxyMajorMergerTimeElementCount=1
return
end function galaxyMajorMergerTimeElementCount

function galaxyMajorMergerTimeExtract(self,node,instance) result(timeMajorMergers)
!!{
Implement a galaxyMajorMergerTime output extractor.
!!}
use :: Galacticus_Nodes, only : nodeComponentBasic
implicit none
double precision , dimension(:) , allocatable :: timeMajorMergers
class (nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
type (treeNode ), intent(inout) :: node
type (multiCounter ), intent(inout), optional :: instance
class (nodeComponentBasic ) , pointer :: basic
double precision , dimension(:,:), allocatable :: timeMajorMergers
class (nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
type (treeNode ), intent(inout) :: node
type (multiCounter ), intent(inout) , optional :: instance
class (nodeComponentBasic ) , pointer :: basic
double precision , dimension(: ), allocatable :: times
!$GLC attributes unused :: instance

basic => node %basic ( )
timeMajorMergers = basic%floatRank1MetaPropertyGet(self%galaxyMajorMergerTimeID)
basic => node %basic ( )
times = basic%floatRank1MetaPropertyGet(self%galaxyMajorMergerTimeID)
allocate(timeMajorMergers(size(times),1))
timeMajorMergers(:,1)=times
return
end function galaxyMajorMergerTimeExtract

function galaxyMajorMergerTimeName(self)
subroutine galaxyMajorMergerTimeNames(self,names)
!!{
Return the names of the {\normalfont \ttfamily galaxyMajorMergerTime} properties.
!!}
implicit none
type (varying_string ) :: galaxyMajorMergerTimeName
class(nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
class(nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
type (varying_string ), intent(inout), dimension(:) , allocatable :: names
!$GLC attributes unused :: self

galaxyMajorMergerTimeName=var_str('galaxyMajorMergerTime')
allocate(names(1))
names(1)=var_str('galaxyMajorMergerTime')
return
end function galaxyMajorMergerTimeName
end subroutine galaxyMajorMergerTimeNames

function galaxyMajorMergerTimeDescription(self)
subroutine galaxyMajorMergerTimeDescriptions(self,descriptions)
!!{
Return the descriptions of the {\normalfont \ttfamily galaxyMajorMergerTime} properties.
!!}
implicit none
type (varying_string ) :: galaxyMajorMergerTimeDescription
class(nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
class(nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
type (varying_string ), intent(inout), dimension(:) , allocatable :: descriptions
!$GLC attributes unused :: self

galaxyMajorMergerTimeDescription=var_str('Time of the last galaxy major merger.')
allocate(descriptions(1))
descriptions(1)=var_str('Time of the last galaxy major merger.')
return
end function galaxyMajorMergerTimeDescription
end subroutine galaxyMajorMergerTimeDescriptions

double precision function galaxyMajorMergerTimeUnitsInSI(self)
function galaxyMajorMergerTimeUnitsInSI(self) result(unitsInSI)
!!{
Return the units of the {\normalfont \ttfamily galaxyMajorMergerTime} properties in the SI system.
!!}
use :: Numerical_Constants_Astronomical, only : gigaYear
implicit none
class(nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
double precision , dimension(:) , allocatable :: unitsInSI
class (nodePropertyExtractorGalaxyMajorMergerTime), intent(inout) :: self
!$GLC attributes unused :: self

galaxyMajorMergerTimeUnitsInSI=gigaYear
allocate(unitsInSI(1))
unitsInSI(1)=gigaYear
return
end function galaxyMajorMergerTimeUnitsInSI
52 changes: 33 additions & 19 deletions source/nodes.property_extractor.list.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,62 +32,76 @@
contains
!![
<methods>
<method method="count" description="Return a count of the number of properties extracted." />
<method method="extract" description="Extract the properties from the given {\normalfont \ttfamily node}."/>
<method method="name" description="Return the name of the properties extracted." />
<method method="description" description="Return a description of the properties extracted." />
<method method="unitsInSI" description="Return the units of the properties extracted in the SI system." />
<method method="metaData" description="Populate a hash with meta-data for the property." />
</methods>
!!]
procedure(listExtract ), deferred :: extract
procedure(listName ), deferred :: name
procedure(listDescription), deferred :: description
procedure(listUnitsInSI ), deferred :: unitsInSI
procedure :: metaData => listMetaData
procedure(listElementCount), deferred :: elementCount
procedure(listExtract ), deferred :: extract
procedure(listNames ), deferred :: names
procedure(listDescriptions), deferred :: descriptions
procedure(listUnitsInSI ), deferred :: unitsInSI
procedure :: metaData => listMetaData
end type nodePropertyExtractorList

abstract interface
function listElementCount(self)
!!{
Interface for list property count.
!!}
import nodePropertyExtractorList
integer :: listElementCount
class (nodePropertyExtractorList), intent(inout) :: self
end function listElementCount
end interface

abstract interface
function listExtract(self,node,instance)
!!{
Interface for list property extraction.
!!}
import nodePropertyExtractorList, treeNode, multiCounter
double precision , dimension(:) , allocatable :: listExtract
class (nodePropertyExtractorList), intent(inout) :: self
type (treeNode ), intent(inout) :: node
type (multiCounter ), intent(inout), optional :: instance
double precision , dimension(:,:), allocatable :: listExtract
class (nodePropertyExtractorList), intent(inout) :: self
type (treeNode ), intent(inout) :: node
type (multiCounter ), intent(inout) , optional :: instance
end function listExtract
end interface

abstract interface
function listName(self)
subroutine listNames(self,names)
!!{
Interface for list names.
!!}
import varying_string, nodePropertyExtractorList
type (varying_string ) :: listName
class(nodePropertyExtractorList), intent(inout) :: self
end function listName
class(nodePropertyExtractorList), intent(inout) :: self
type (varying_string ), intent(inout), dimension(:) , allocatable :: names
end subroutine listNames
end interface

abstract interface
function listDescription(self)
subroutine listDescriptions(self,descriptions)
!!{
Interface for list descriptions.
!!}
import varying_string, nodePropertyExtractorList
type (varying_string ) :: listDescription
class(nodePropertyExtractorList), intent(inout) :: self
end function listDescription
class(nodePropertyExtractorList), intent(inout) :: self
type (varying_string ), intent(inout), dimension(:) , allocatable :: descriptions
end subroutine listDescriptions
end interface

abstract interface
double precision function listUnitsInSI(self)
function listUnitsInSI(self)
!!{
Interface for list property units.
!!}
import nodePropertyExtractorList
class (nodePropertyExtractorList), intent(inout) :: self
double precision , dimension(:) , allocatable :: listUnitsInSI
class (nodePropertyExtractorList), intent(inout) :: self
end function listUnitsInSI
end interface

Expand Down
39 changes: 24 additions & 15 deletions source/nodes.property_extractor.multi.F90
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ integer function multiElementCount(self,elementType,time)
class is (nodePropertyExtractorArray )
if (elementType == elementTypeDouble ) multiElementCount=multiElementCount+extractor_%elementCount(time)
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) multiElementCount=multiElementCount+1
if (elementType == elementTypeDouble ) multiElementCount=multiElementCount+extractor_%elementCount( )
class default
call Error_Report('unsupported property extractor type'//{introspection:location})
end select
Expand Down Expand Up @@ -242,11 +242,13 @@ function multiExtractDouble(self,node,time,instance,ranks)
end do
deallocate(rank1)
class is (nodePropertyExtractorList )
elementCount=1
rank0=extractor_%extract(node ,instance)
multiExtractDouble(offset+1)=polyRankDouble(rank0(:))
deallocate(rank0)
if (present(ranks)) ranks(offset+1)=-1
elementCount=extractor_%elementCount()
rank1=extractor_%extract(node ,instance)
do i=1,elementCount
multiExtractDouble(offset+i)=polyRankDouble(rank1(:,i))
if (present(ranks)) ranks(offset+i)=-1
end do
deallocate(rank1)
class is (nodePropertyExtractorIntegerScalar)
elementCount=0
class is (nodePropertyExtractorIntegerTuple )
Expand Down Expand Up @@ -388,8 +390,12 @@ subroutine multiNames(self,elementType,time,names)
end if
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) then
elementCount =1
names (offset+1:offset+elementCount)=extractor_%name ( )
elementCount=extractor_%elementCount()
if (elementCount > 0) then
call extractor_%names(namesTmp )
names(offset+1:offset+elementCount)=namesTmp
deallocate(namesTmp)
end if
end if
class default
call Error_Report('unsupported property extractor type'//{introspection:location})
Expand Down Expand Up @@ -464,7 +470,7 @@ subroutine multiColumnDescriptions(self,elementType,i,time,descriptions,values,v
end if
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) then
elementCount=1
elementCount=extractor_%elementCount()
if (offset+elementCount >= i) then
allocate(descriptions(0))
return
Expand Down Expand Up @@ -538,8 +544,12 @@ subroutine multiDescriptions(self,elementType,time,descriptions)
end if
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) then
elementCount=1
descriptions (offset+1:offset+elementCount)=extractor_%description ( )
elementCount=extractor_%elementCount()
if (elementCount > 0) then
call extractor_%descriptions(descriptionsTmp)
descriptions(offset+1:offset+elementCount)=descriptionsTmp
deallocate(descriptionsTmp)
end if
end if
class default
call Error_Report('unsupported property extractor type'//{introspection:location})
Expand Down Expand Up @@ -596,7 +606,7 @@ function multiUnitsInSI(self,elementType,time)
end if
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) then
elementCount=1
elementCount=extractor_%elementCount()
multiUnitsInSI(offset+1:offset+elementCount)=extractor_%unitsInSI( )
end if
class default
Expand Down Expand Up @@ -654,7 +664,7 @@ function multiRanks(self,elementType,time)
end if
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) then
elementCount=1
elementCount=extractor_%elementCount()
multiRanks(offset+1:offset+elementCount)=-1
end if
class default
Expand All @@ -666,7 +676,6 @@ function multiRanks(self,elementType,time)
return
end function multiRanks


subroutine multiMetaData(self,elementType,time,iProperty,metaData)
!!{
Populate multiple property meta-data.
Expand Down Expand Up @@ -713,7 +722,7 @@ subroutine multiMetaData(self,elementType,time,iProperty,metaData)
end if
class is (nodePropertyExtractorList )
if (elementType == elementTypeDouble ) then
elementCount=1
elementCount=extractor_%elementCount()
if (offset+1 <= iProperty .and. offset+elementCount >= iProperty) call extractor_%metaData( metaData)
end if
class default
Expand Down

0 comments on commit a07ddd1

Please sign in to comment.