Free C++ tally filter memory

This commit is contained in:
Sterling Harper 2018-10-02 22:19:35 -04:00
parent b27242e726
commit 3e953ef7cf
3 changed files with 27 additions and 0 deletions

View file

@ -51,5 +51,9 @@ public:
virtual void initialize() = 0;
};
//==============================================================================
extern "C" void free_memory_tally_c();
} // namespace openmc
#endif // OPENMC_TALLY_FILTER_H

View file

@ -15,6 +15,22 @@ namespace openmc {
std::vector<TallyFilterMatch> filter_matches;
std::vector<TallyFilter*> tally_filters;
//==============================================================================
// Non-member functions
//==============================================================================
void
free_memory_tally_c()
{
#pragma omp parallel
{
filter_matches.clear();
}
for (TallyFilter* filt : tally_filters) {delete filt;}
tally_filters.clear();
}
//==============================================================================
// Fortran compatibility functions
//==============================================================================

View file

@ -412,6 +412,13 @@ contains
!===============================================================================
subroutine free_memory_tally()
interface
subroutine free_memory_tally_c() bind(C)
end subroutine free_memory_tally_c
end interface
call free_memory_tally_c()
n_tallies = 0
if (allocated(tallies)) deallocate(tallies)
call tally_dict % clear()