From f6ccad98a600a2b575f38b51e236522bcd36d6c0 Mon Sep 17 00:00:00 2001
From: bes0030 <bes0030@r34u12n917.ib0.smc.salomon.it4i.cz>
Date: Wed, 6 Jun 2018 00:09:26 +0200
Subject: [PATCH] NEW: Added neuron_m memory leak test with storing into and
 reading from binary file.

---
 src/neuron_m.f90               |  3 +--
 src/neuron_m_mem_leak_test.f90 | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 src/neuron_m_mem_leak_test.f90

diff --git a/src/neuron_m.f90 b/src/neuron_m.f90
index d06505ac..bbe17e1c 100644
--- a/src/neuron_m.f90
+++ b/src/neuron_m.f90
@@ -354,6 +354,7 @@ module neuron_m
 #endif 
             this%potential = 0
             this%state     = 0  !TODO maybe init with values from normal distribution
+            this%id        = 1  !TODO modify - should be index in the whole set of neurons
 
 #ifdef TIME_PROFILING
             call time_profiling_stop(start_time, 'neuron_init_components_impl')
@@ -386,7 +387,6 @@ module neuron_m
             integer, intent(in)         :: unit
             integer, intent(out)        :: iostat
             character(*), intent(inout) :: iomsg
-            integer                     :: i !< Counter
 #ifdef TIME_PROFILING
             real                        :: start_time
             call time_profiling_start(start_time)
@@ -405,7 +405,6 @@ module neuron_m
             integer, intent(in)            :: unit
             integer, intent(out)           :: iostat
             character(*), intent(inout)    :: iomsg
-            integer                        :: i
 #ifdef TIME_PROFILING
             real                           :: start_time
             call time_profiling_start(start_time)
diff --git a/src/neuron_m_mem_leak_test.f90 b/src/neuron_m_mem_leak_test.f90
new file mode 100644
index 00000000..2558f801
--- /dev/null
+++ b/src/neuron_m_mem_leak_test.f90
@@ -0,0 +1,21 @@
+program neuron_m_mem_leak_test
+    use neuron_m
+
+    implicit none
+
+    type(linear_neuron_t) :: ln
+    type(linear_neuron_t), allocatable :: ln2
+    ln = linear_neuron_t()
+
+    allocate(ln2)
+
+    open(123,file='neuron.test', form='unformatted')
+        write(123) ln
+    close(123)
+
+    open(123,file='neuron.test', form='unformatted')
+        read(123) ln2
+    close(123)
+
+    write(*,*) ln2%get_potential(), ln2%get_state(), ln2%get_id()
+end program neuron_m_mem_leak_test
-- 
GitLab