destroy_2lsom Subroutine

public subroutine destroy_2lsom(kohonen_map)

Destructor of a two_level self_organized_map

Type Bound

two_level_self_organizing_map

Arguments

Type IntentOptional Attributes Name
class(two_level_self_organizing_map) :: kohonen_map

A two_level_self_organizing_map object


Calls

proc~~destroy_2lsom~~CallsGraph proc~destroy_2lsom two_level_self_organizing_map%destroy_2lsom none~destroy~9 kohonen_prototype%destroy proc~destroy_2lsom->none~destroy~9

Called by

proc~~destroy_2lsom~~CalledByGraph proc~destroy_2lsom two_level_self_organizing_map%destroy_2lsom proc~train_two_level_som train_two_level_som proc~train_two_level_som->proc~destroy_2lsom

Variables

Type Visibility Attributes Name Initial
integer, public :: ix
integer, public :: iy
integer, public :: iz

Source Code

   subroutine destroy_2lsom(kohonen_map)
   !========================================================================================
!!   Destructor of a two_level self_organized_map 
      class(two_level_self_organizing_map) :: kohonen_map
!! A `two_level_self_organizing_map` object 
      integer :: ix,iy,iz
   !
      write(*,*) 'TWO LEVEL SOM: Releasing memory...'
      if(allocated(kohonen_map%grid)) then
      do ix=1,size(kohonen_map%grid,1)
         do iy=1,size(kohonen_map%grid,2)
            do iz=1,size(kohonen_map%grid,3);
               call kohonen_map%grid(ix,iy,iz)%destroy();
            enddo
         enddo
      enddo
      deallocate(kohonen_map%grid);
      endif
   !
      if(allocated(kohonen_map%coordinates)) then
      deallocate(kohonen_map%coordinates);
      endif
   !
      if(allocated(kohonen_map%number_patterns)) then
      deallocate(kohonen_map%number_patterns);
      endif
   !
      if(allocated(kohonen_map%cells_index)) then
      deallocate(kohonen_map%cells_index);
      endif
   !
      if(allocated(kohonen_map%u_matrix)) then
      deallocate(kohonen_map%u_matrix);
      endif
   !
      if(allocated(kohonen_map%distance)) then
         deallocate(kohonen_map%distance);
      endif
   !
      if(allocated(kohonen_map%distance_function)) then
      deallocate(kohonen_map%distance_function);
      endif
   !
   ! Deallocate cluster layers arrays
   !
      do ix=1,size(kohonen_map%cluster_layer)
         call kohonen_map%cluster_layer(ix)%destroy();
      enddo
      deallocate(kohonen_map%cluster_layer)
   !
      if(allocated(kohonen_map%cluster_cells_index)) then
      deallocate(kohonen_map%cluster_cells_index);
      endif
   !
   if(allocated(kohonen_map%cluster_number_patterns)) then
      deallocate(kohonen_map%cluster_number_patterns);
   endif
   !
   if(allocated(kohonen_map%grid_cluster)) then
      deallocate(kohonen_map%grid_cluster);
   endif
   !
   if(allocated(kohonen_map%cluster_samples)) then
      deallocate(kohonen_map%cluster_samples);
   endif
   !
   if(allocated(kohonen_map%number_cluster_samples)) then
      deallocate(kohonen_map%number_cluster_samples);
   endif
   !
   if(allocated(kohonen_map%index_cluster_samples)) then
      deallocate(kohonen_map%index_cluster_samples);
   endif
   !
      write(*,*) 'TWO LEVEL SOM: Releasing memory...OK!'
   !
   end subroutine destroy_2lsom