Commit fed66e14 authored by bes0030's avatar bes0030
Browse files

TMP: NOT COMPILABLE

parent f6ccad98
......@@ -111,12 +111,14 @@ if (WIN32)
message ("Windows")
else ()
add_executable(connection_m_mem_leak_test.out ${SRC_DIR}/connection_m_mem_leak_test.f90)
target_link_libraries(connection_m_mem_leak_test.out connection_m)
add_executable(connection_m_mem_leak_test.out ${SRC_DIR}/connection_m_mem_leak_test.f90)
target_link_libraries(connection_m_mem_leak_test.out connection_m)
add_executable(net_m_mem_leak_test.out ${SRC_DIR}/net_m_mem_leak_test.f90)
target_link_libraries(net_m_mem_leak_test.out net_m)
#add_executable(net_m_mem_leak_test.out ${SRC_DIR}/net_m_mem_leak_test.f90)
#target_link_libraries(net_m_mem_leak_test.out net_m)
add_executable(neuron_m_mem_leak_test.out ${SRC_DIR}/neuron_m_mem_leak_test.f90)
target_link_libraries(neuron_m_mem_leak_test.out neuron_m)
message ("Not Windows")
endif ()
......@@ -11,7 +11,7 @@ add_library(normal_m SHARED normal_m.f90)
add_library(data_kinds_4neuro_m SHARED data_kinds_4neuro_m.f90)
add_library(container_m SHARED container_m.f90)
target_link_libraries(container_m abstract_base_m data_kinds_4neuro_m)
target_link_libraries(container_m abstract_base_m data_kinds_4neuro_m abstract_base_m)
add_library(time_measurement_m SHARED time_measurement_m.f90)
target_link_libraries(time_measurement_m data_kinds_4neuro_m abstract_base_m)
......@@ -20,11 +20,11 @@ add_library(neuron_m SHARED neuron_m.f90)
target_link_libraries(neuron_m time_measurement_m normal_m abstract_base_m)
add_library(connection_m SHARED connection_m.f90)
target_link_libraries(connection_m neuron_m time_measurement_m normal_m abstract_base_m)
target_link_libraries(connection_m neuron_m time_measurement_m normal_m abstract_base_m container_m)
add_library(interconnection_m SHARED net_m.f90)
target_link_libraries(interconnection_m data_kinds_4neuro_m time_measurement_m abstract_base_m)
#add_library(interconnection_m SHARED net_m.f90)
#target_link_libraries(interconnection_m data_kinds_4neuro_m time_measurement_m abstract_base_m)
add_library(net_m SHARED net_m.f90)
target_link_libraries(net_m interconnection_m data_kinds_4neuro_m time_measurement_m neuron_m connection_m abstract_base_m container_m)
#add_library(net_m SHARED net_m.f90)
#target_link_libraries(net_m interconnection_m data_kinds_4neuro_m time_measurement_m neuron_m connection_m abstract_base_m container_m)
......@@ -11,6 +11,7 @@ module connection_m
use neuron_m
use time_measurement_m
use normal_m
use container_m
implicit none
......@@ -354,7 +355,7 @@ module connection_m
!! @param[out] iostat Diagnostic value "returned" by the subroutine
!! @param[inout] iomsg Explaining note about error
subroutine write_connection_sample(this, unit, iostat, iomsg)
class(connection_t), intent(in) :: this
class(connection_t), target, intent(in) :: this
integer, intent(in) :: unit
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
......@@ -367,9 +368,9 @@ module connection_m
!write(unit, iostat=iostat, iomsg=iomsg) SIZE(this%input_neuron), &
! SIZE(this%output_neuron)
write(unit, iostat=iostat, iomsg=iomsg) this%input_neuron, &
this%output_neuron, &
this%weight
write(unit, iostat=iostat, iomsg=iomsg) container_t(this%input_neuron), &
container_t(this%output_neuron), &
container_t(this%weight)
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'write_connection_sample')
#endif
......@@ -382,6 +383,7 @@ module connection_m
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
integer :: i
class(container_t), allocatable :: inp_n, out_n
!integer :: s1, s2, s3, s4 !< Sizes of stored allocatable properties
#ifdef TIME_PROFILING
real :: start_time
......@@ -397,8 +399,8 @@ module connection_m
! this%connection_arr(s4))
! And then finally the reading.
read(unit, iostat=iostat, iomsg=iomsg) this%input_neuron, &
this%output_neuron, &
read(unit, iostat=iostat, iomsg=iomsg) inp_n, &
out_n, &
this%weight
#ifdef TIME_PROFILING
......
......@@ -5,7 +5,8 @@ program connection_mem_leak_test
use data_kinds_4neuro_m
type(mock_neuron_t), target :: n1, n2
type(mock_neuron_t), pointer :: n1_p, n2_p
class(neuron_t), pointer :: n1_p, n2_p
class(connection_t), allocatable :: n_t
type(connection_t) :: con1, con2
print *, '+---------------------------------------------------------+'
......@@ -25,4 +26,12 @@ program connection_mem_leak_test
print *, 'Creating an instance of the class interval_connection_t with 3-parameters constructor...'
con1 = connection_t(input_neuron=n1_p, output_neuron=n2_p, weight=real(5.25, real_4neuro))
open(123,file='connection.test', form='unformatted')
write(123) con1
close(123)
!open(123,file='connection.test', form='unformatted')
! read(123) n_t
!close(123)
end program connection_mem_leak_test
......@@ -17,7 +17,7 @@ module container_m
! Variable content is public to make usage of this class with one
! specific purpose as simple as possible.
class(abstract_base_t), pointer, public :: content
class(*), pointer, public :: content
contains
!> Scalar desctructor for single instances of the class container_t
......@@ -47,12 +47,11 @@ contains
!> Constructor of container_t class
!! @return Instance of the class container_t with nullified content
function new_container_empty() result(new_obj)
type(container_t), pointer :: new_obj
type(container_t) :: new_obj
#ifdef TIME_PROFILING
real :: start_time
real :: start_time
call time_profiling_start(start_time)
#endif
allocate(new_obj)
new_obj%content => null()
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'new_container_empty')
......@@ -64,12 +63,11 @@ contains
!! @return Pointer to the instance of the class connection_t with assigned content
function new_container_assigned(content_in) result(new_obj)
class(abstract_base_t), pointer, intent(in) :: content_in
class(container_t), pointer :: new_obj
type(container_t) :: new_obj
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
allocate(new_obj)
new_obj%content => content_in
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'new_container_assigned')
......@@ -109,3 +107,4 @@ contains
end subroutine destroy_container_array
end module container_m
......@@ -10,7 +10,7 @@ module net_m
use time_measurement_m
use neuron_m
use connection_m
!use container_m
use container_m
implicit none
......@@ -20,6 +20,10 @@ module net_m
! class net_t !
!-------------!
type :: container
class(*), pointer :: content
end type
!> Class representing a general network
type :: net_t
private
......@@ -28,7 +32,7 @@ module net_m
integer(kind=integer_4neuro) :: num_of_neurons !< Number of neurons in the net
character(:), allocatable :: training_method !< Used training method
class(*), allocatable :: neuron_arr(:) !< Array containing all neurons
class(container_t), allocatable :: neuron_arr(:) !< Array containing all neurons
integer(kind=integer_4neuro), allocatable :: input_neuron_arr(:) !< Array of input neuron indices
integer(kind=integer_4neuro), allocatable :: output_neuron_arr(:) !< Array of output neuron indices
class(connection_t), allocatable :: connection_arr(:) !< Array of all connections
......@@ -173,10 +177,10 @@ contains
SIZE(this%connection_arr)
select type(tmp => this%neuron_arr)
type is(neuron_t)
type is(container_t)
select type(tmp2 => this%connection_arr)
type is(connection_t)
write(unit, iostat=iostat, iomsg=iomsg) (tmp(i)%get_id(), &
write(unit, iostat=iostat, iomsg=iomsg) (tmp(i)%content%get_id(), &
tmp(i)%get_potential(), &
tmp(i)%get_state(), &
i=1,SIZE(this%neuron_arr)), &
......@@ -209,17 +213,14 @@ contains
read(unit, iostat=iostat, iomsg=iomsg) s1, s2, s3, s4
! So we do the allocation
select type(tmp => this%neuron_arr)
type is(neuron_t)
allocate(tmp(s1), &
allocate(this%neuron_arr(s1), &
this%input_neuron_arr(s2), &
this%output_neuron_arr(s3), &
this%connection_arr(s4))
end select
! And then finally the reading.
select type(tmp => this%neuron_arr)
type is(neuron_t)
type is(container_t)
select type(tmp2 => this%connection_arr)
type is(connection_t)
read(unit, iostat=iostat, iomsg=iomsg) (tmp(i)%id, &
......@@ -254,6 +255,7 @@ contains
integer :: i !< Counter
class(neuron_t), pointer :: n_p1, n_p2
class(neuron_t), pointer :: n_p(:)
type(mock_neuron_t), target :: n_tmp
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
......@@ -263,11 +265,12 @@ contains
new_obj%training_method = 'MOCK TRAINING'
! Init object
allocate(mock_neuron_t :: new_obj%neuron_arr(5))
allocate(container_t :: new_obj%neuron_arr(5))
select type(tmp => new_obj%neuron_arr)
type is (mock_neuron_t)
type is (container_t)
do i=1,5
tmp(i) = mock_neuron_t()
n_tmp = mock_neuron_t()
tmp(i) = container_t(n_tmp)
end do
end select
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment