Skip to content

Commit

Permalink
In src/colormap_class.f90: a finalize method for memory cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vmagnin committed May 8, 2024
1 parent 8b02110 commit 756be0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to the gtk-fortran project are documented in this file. The

## [forcolormap dev]

### Added
- In `src/colormap_class.f90`: a `finalize` method for memory cleanup.

### Fixed
* In `fpm.toml`, `name = "forcolormap"` is now lower case because fpm dependencies are case sensitive.

Expand Down
10 changes: 9 additions & 1 deletion src/colormap_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
! SOFTWARE.
!-------------------------------------------------------------------------------
! Contributed by vmagnin: 2023-09-26
! Last modification: gha3mi 2024-02-16, vmagnin 2024-03-06
! Last modification: gha3mi 2024-02-16, vmagnin 2024-05-08
!-------------------------------------------------------------------------------


Expand Down Expand Up @@ -52,6 +52,7 @@ module forcolormap
integer, dimension(:, :), allocatable, private :: map
contains
procedure :: set
procedure :: finalize
procedure :: create
procedure :: create_lagrange
procedure :: create_bezier
Expand Down Expand Up @@ -586,6 +587,13 @@ pure subroutine set(self, name, zmin, zmax, levels, varargs, reverse)
end if
end subroutine set

!> A finalizer procedure for memory cleanup:
pure subroutine finalize(self)
class(Colormap), intent(inout) :: self
if (allocated(self%map)) deallocate(self%map)
end subroutine


!> You can create a custom colormap from a "map" array.
pure subroutine create(self, name, zmin, zmax, map, reverse)
class(Colormap), intent(inout) :: self
Expand Down

0 comments on commit 756be0f

Please sign in to comment.