Skip to content

Commit

Permalink
fix(build): Allow build to succeed with meta-properties and GALACTICU…
Browse files Browse the repository at this point in the history
…S_ACTIVE_COMPONENTS

When GALACTICUS_ACTIVE_COMPONENTS is used to specify a list of active components in the build this previously broke the build due to incompatibility with the recently-added meta-property functionality. This patch fixes that issue.
  • Loading branch information
abensonca committed Aug 17, 2021
1 parent 6eca993 commit 44364dd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 41 deletions.
4 changes: 3 additions & 1 deletion perl/Galacticus/Build/Components/Classes/CreateDestroy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ sub Class_Add_Meta_Property {
}
]
};
$function->{'content'} = fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} = fill_in_string(<<'CODE', PACKAGE => 'code');
!$GLC attributes unused :: self
!$omp critical ({class->{'name'}}MetaPropertyUpdate)
Expand Down Expand Up @@ -317,6 +318,7 @@ if (.not.found) then
end if
!$omp end critical ({class->{'name'}}MetaPropertyUpdate)
CODE
}
# Insert a type-binding for this function.
push(
@{$build->{'types'}->{"nodeComponent".ucfirst($code::class->{'name'})}->{'boundFunctions'}},
Expand Down
26 changes: 16 additions & 10 deletions perl/Galacticus/Build/Components/Classes/Evolve.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ sub Build_Rate_Functions {
]
};
# Build the function.
$function->{'content'} = fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} = fill_in_string(<<'CODE', PACKAGE => 'code');
!$GLC attributes unused :: interrupt, interruptProcedure, self
CODE
$code::offsetNameAll = &offsetName('all' ,$class->{'name'},'metaProperties');
$code::offsetNameActive = &offsetName('active' ,$class->{'name'},'metaProperties');
$code::offsetNameInactive = &offsetName('inactive',$class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
$code::offsetNameAll = &offsetName('all' ,$class->{'name'},'metaProperties');
$code::offsetNameActive = &offsetName('active' ,$class->{'name'},'metaProperties');
$code::offsetNameInactive = &offsetName('inactive',$class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (rateComputeState == propertyTypeAll ) then
offset={$offsetNameAll}(metaPropertyID)
else if (rateComputeState == propertyTypeActive ) then
Expand All @@ -93,6 +94,7 @@ else
end if
nodeRates(offset)=nodeRates(offset)+setValue
CODE
}
# Insert a type-binding for this function into the relevant type.
push(
@{$build->{'types'}->{$classTypeName}->{'boundFunctions'}},
Expand All @@ -101,7 +103,7 @@ CODE
descriptor => $function,
name => "metaPropertyRate"
}
);
);
}

sub Build_Scale_Functions {
Expand Down Expand Up @@ -136,11 +138,13 @@ sub Build_Scale_Functions {
]
};
# Build the function.
$code::offsetName = &offsetName('all',$class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$code::offsetName = &offsetName('all',$class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
!$GLC attributes unused :: self
nodeScales({$offsetName}(metaPropertyID))=setValue
CODE
}
# Insert a type-binding for this function into the relevant type.
push(
@{$build->{'types'}->{$classTypeName}->{'boundFunctions'}},
Expand Down Expand Up @@ -179,11 +183,13 @@ sub Build_Inactive_Functions {
]
};
# Build the function.
$code::offsetName = &offsetName('all',$class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$code::offsetName = &offsetName('all',$class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
!$GLC attributes unused :: self
nodeInactives({$offsetName}(metaPropertyID))=.true.
CODE
}
# Insert a type-binding for this function into the relevant type.
push(
@{$build->{'types'}->{$classTypeName}->{'boundFunctions'}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ CODE
}
}
# Allocate and initialize meta-properties.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames).and..not.allocated(self%metaProperties)) then
allocate(self%metaProperties(size({$class->{'name'}}MetaPropertyNames)))
self%metaProperties=0.0d0
end if
CODE
}
# Add required modules to function.
push(@{$function->{'modules'}},keys(%modules))
if ( %modules );
Expand Down Expand Up @@ -398,7 +400,8 @@ CODE
CODE
}
# Build any meta-properties.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) then
!$omp critical (FoX_DOM_Access)
do i=1,size(({$class->{'name'}}MetaPropertyNames))
Expand All @@ -412,6 +415,7 @@ if (allocated({$class->{'name'}}MetaPropertyNames)) then
!$omp end critical (FoX_DOM_Access)
end if
CODE
}
# Insert a type-binding for this function.
push(
@{$build->{'types'}->{$code::implementationTypeName}->{'boundFunctions'}},
Expand Down
48 changes: 24 additions & 24 deletions perl/Galacticus/Build/Components/Implementations/ODESolver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ CODE
name=self%nodeComponent{ucfirst($member->{'extends'}->{'class'}).ucfirst($member->{'extends'}->{'name'})}%nameFromIndex(count,propertyType)
if (count <= 0) return
CODE
} else {
} elsif ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
# Include meta-properties here.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) then
Expand Down Expand Up @@ -251,8 +251,8 @@ CODE
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
{$implementationTypeName}SerializeCount=self%nodeComponent{ucfirst($member->{'extends'}->{'class'}).ucfirst($member->{'extends'}->{'name'})}%serializeCount(propertyType)
CODE
} else {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
} elsif ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
{$implementationTypeName}SerializeCount={$class->{'name'}}MetaPropertyEvolvableCount
CODE
}
Expand Down Expand Up @@ -389,7 +389,7 @@ if (count > 0) then
offset=offset+count
end if
CODE
} else {
} elsif ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
# For non-extended types serialize meta-properties.
$code::offsetName = &offsetName('all',$code::class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
Expand Down Expand Up @@ -533,7 +533,7 @@ if (count > 0) then
offset=offset+count
end if
CODE
} else {
} elsif ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
# For non-extended types serialize meta-properties.
$code::offsetName = &offsetName('all',$code::class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
Expand Down Expand Up @@ -662,7 +662,7 @@ CODE
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
call self%nodeComponent{ucfirst($code::member->{'extends'}->{'class'}).ucfirst($code::member->{'extends'}->{'name'})}%serializationOffsets(count,countSubset,propertyType)
CODE
} else {
} elsif ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
# For non-extended types compute offsets for meta-properties.
# Set the offset for this property to the current count plus 1 (since we haven't yet updated the count.
$code::offsetNameAll = &offsetName('all' ,$code::class->{'name'},'metaProperties');
Expand All @@ -671,19 +671,17 @@ CODE
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) then
CODE

foreach my $status ( "all", "active", "inactive" ) {
$code::offsetName = &offsetName($status,$code::class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
foreach my $status ( "all", "active", "inactive" ) {
$code::offsetName = &offsetName($status,$code::class->{'name'},'metaProperties');
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (.not.allocated({$offsetName})) then
allocate({$offsetName}({$class->{'name'}}MetaPropertyEvolvableCount))
else if (size({$offsetName}) /= {$class->{'name'}}MetaPropertyEvolvableCount) then
deallocate({$offsetName})
allocate({$offsetName}({$class->{'name'}}MetaPropertyEvolvableCount))
end if
CODE
}

}
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
do i=1,size({$class->{'name'}}MetaPropertyNames)
if (.not.{$class->{'name'}}MetaPropertyEvolvable(i)) cycle
Expand Down Expand Up @@ -761,18 +759,20 @@ sub Implementation_ODE_Offset_Variables {
my $class = shift();
my $member = shift();
# Include meta-properties for just the null class (since we need only one copy of these per-class).
if ( $member->{'name'} eq "null" ) {
foreach my $status ( "all", "active", "inactive" ) {
my $offsetName = &offsetName($status,$class->{'name'},'metaProperties');
push(
@{$build->{'variables'}},
{
intrinsic => "integer",
ompPrivate => 1,
attributes => [ "allocatable", "dimension(:)" ],
variables => [ $offsetName ]
}
);
if ( grep {$class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
if ( $member->{'name'} eq "null" ) {
foreach my $status ( "all", "active", "inactive" ) {
my $offsetName = &offsetName($status,$class->{'name'},'metaProperties');
push(
@{$build->{'variables'}},
{
intrinsic => "integer",
ompPrivate => 1,
attributes => [ "allocatable", "dimension(:)" ],
variables => [ $offsetName ]
}
);
}
}
}
# Iterate over non-virtual, evolving properties.
Expand Down
16 changes: 12 additions & 4 deletions perl/Galacticus/Build/Components/Implementations/Serialization.pm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ CODE
}
}
# Serialize meta-properties.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) then
do i=1,size(({$class->{'name'}}MetaPropertyNames))
write (label,{$formatLabel{'double'}}) self%metaProperties(i)
Expand All @@ -151,6 +152,7 @@ if (allocated({$class->{'name'}}MetaPropertyNames)) then
end do
end if
CODE
}
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
call displayUnindent('done')
CODE
Expand Down Expand Up @@ -264,13 +266,15 @@ CODE
}
}
# Serialize meta-properties.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) then
do i=1,size(({$class->{'name'}}MetaPropertyNames))
write (fileHandle,'(a,a,a,{$formatLabel{'double'}},a,a,a)') ' <'//char({$class->{'name'}}MetaPropertyNames(i))//'>',self%metaProperties(i),'</'//char({$class->{'name'}}MetaPropertyNames(i))//'>'
end do
end if
CODE
}
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
write (fileHandle,'(a)') ' </{$class->{'name'}}>'
CODE
Expand Down Expand Up @@ -368,9 +372,11 @@ CODE
}
}
# Serialize meta-properties.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) write (fileHandle) self%metaProperties
CODE
}
# Insert a type-binding for this function.
push(
@{$build->{'types'}->{$implementationTypeName}->{'boundFunctions'}},
Expand Down Expand Up @@ -485,9 +491,11 @@ CODE
}
}
# Deserialize meta-properties.
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if ( grep {$code::class->{'name'} eq $_} @{$build->{'componentClassListActive'}} ) {
$function->{'content'} .= fill_in_string(<<'CODE', PACKAGE => 'code');
if (allocated({$class->{'name'}}MetaPropertyNames)) read (fileHandle) self%metaProperties
CODE
}
# Insert a type-binding for this function.
push(
@{$build->{'types'}->{$implementationTypeName}->{'boundFunctions'}},
Expand Down

0 comments on commit 44364dd

Please sign in to comment.