Commit 8cf3bf07 authored by Martin Beseda's avatar Martin Beseda

ENH: Fortran codes removed to the folder 'fortran2008' and CMakeLists.txt edited accordingly.

parent 3973612d
......@@ -2,17 +2,6 @@ cmake_minimum_required(VERSION 3.0)
project(4neuro)
#message ("Before enable language")
##enable_language(Fortran)
#if (WIN32)
# message ("cmake for " ${CMAKE_Fortran_COMPILER})
# set (CMAKE_FORTRAN_COMPILER ${CMAKE_Fortran_COMPILER})
# project(4Neuro)
#else ()
# project(4Neuro)
#endif ()
#message ("Start cmakeList")
#-------------------------------#
# Default installation location #
#-------------------------------#
......@@ -39,7 +28,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
#--------------------#
# Automatic settings #
#--------------------#
#get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
# Processing user variables
if (WITH_TIME_PROFILING)
......@@ -53,31 +41,29 @@ if (WIN32)
endif()
# Write compiler variables to the file - to pass them to test script
#file(WRITE compilers.env "export FC=${CMAKE_Fortran_COMPILER}\n")
file(APPEND compilers.env "export CXX=${CMAKE_CXX_COMPILER}\n")
file(APPEND compilers.env "export CC=${CMAKE_C_COMPILER}\n")
#----------------#
# User variables #
#----------------#
set(SRC_DIR src)
set(BUILD_DIR build)
set(LIB_DIR lib)
set(PROJECT_BINARY_DIR build)
#--------------------#
# Building libraries #
#--------------------#
#link_directories("${BUILD_DIR}/${LIB_DIR}")
include_directories("${BUILD_DIR}/${LIB_DIR}")
add_subdirectory("${SRC_DIR}" "${LIB_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR})
message ("Current directory:" ${PWD})
message ("SRC_DIR: " ${SRC_DIR})
message ("BUILD_DIR:" ${BUILD_DIR})
message ("LIB_DIR: " ${LIB_DIR})
if (WIN32)
message ("Windows")
......
......@@ -68,12 +68,7 @@ case `uname -s` in
esac
#-------------------------------------------------------------------------
echo "Creating folder 'build'...";
mkdir -p build/lib;
echo "Folder 'build' was created'";
cd build;
#cmake -G "MSYS Makefiles" -DCMAKE_Fortran_COMPILER=${FORTRAN_COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWITH_TIME_PROFILING:BOOLEAN=${WITH_TIME_PROFILING} ..
cmake -G "${MAKEFILE_TYPE}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWITH_TIME_PROFILING:BOOLEAN=${WITH_TIME_PROFILING} ..
rm -rf build;
cmake -G "${MAKEFILE_TYPE}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWITH_TIME_PROFILING:BOOLEAN=${WITH_TIME_PROFILING} .
make VERBOSE=1 && echo "Build complete." || exit -1;
#make install;
......@@ -5,7 +5,7 @@
#include "NeuronBinary.h"
NeuronBinary::NeuronBinary(double threshold) {
this->n_activation_function_parameters = 2;
this->activation_function_parameters = new double[1];
this->activation_function_parameters[0] = threshold;
......
!> Module containing a class abstract_base_t, which is a parental
!! class for all other classes in 4neuro. It makes creating a
!! common container for all classes possible.
!!
!! @author Martin Beseda
!! @date 2018
module abstract_base_m
implicit none
public
!------------------!-----------------------------------------
! Type definitions !
!------------------!
!-----------------------!------------------------------------
! class abstract_base_t !
!-----------------------!
!> Abstract class covering all the other classes in 4neuro
type, abstract :: abstract_base_t
end type
end module abstract_base_m
This diff is collapsed.
program connection_mem_leak_test
use connection_m
use neuron_m
use normal_m
use data_kinds_4neuro_m
type(mock_neuron_t), target :: n1, n2
class(neuron_t), pointer :: n1_p, n2_p
class(connection_t), allocatable :: n_t
type(connection_t) :: con1, con2
print *, '+---------------------------------------------------------+'
print *, '| STARTING MEMORY LEAK TESTING OF THE MODULE CONNECTION_M |'
print *, '+---------------------------------------------------------+'
print *, 'Creating instances of the class neuron_t...'
n1 = mock_neuron_t()
n2 = mock_neuron_t()
n1_p => n1
n2_p => n2
print *, 'Creating an instance of the class interval_connection_t with 2-parameters constructor...'
con2 = connection_t(input_neuron=n1_p, output_neuron=n2_p)
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
!> Module containing declaration of a container type 'container_t'.
!! This class "wraps" pointers, so it's possible to store them
!! into arrays.
!!
!! @author Martin Beseda
!! @date 2018
module container_m
use abstract_base_m
use data_kinds_4neuro_m
implicit none
public
!> Represents a container for a single container_t pointer
type :: container_t
! Variable content is public to make usage of this class with one
! specific purpose as simple as possible.
class(*), pointer, public :: content
contains
!> Scalar desctructor for single instances of the class container_t
final :: destroy_container
!> Array desctructor for arrays of instances of the class container_t
final :: destroy_container_array
end type container_t
interface container_t
!> Constructor of container_t class
!! @return Instance of the class container_t with nullified content
module procedure :: new_container_empty
!> Constructor of container_t class
!! @param[in] content_in container to be contained (pointer)
!! @return Pointer to the instance of the class container_t with assigned content
module procedure :: new_container_assigned
end interface container_t
contains
!--------------!------------------------------------------------------------------------
! Constructors !
!--------------!
!> 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) :: new_obj
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
new_obj%content => null()
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'new_container_empty')
#endif
end function new_container_empty
!> Constructor of container_t class
!! @param[in] content_in connection to be contained (pointer)
!! @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
type(container_t) :: new_obj
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
new_obj%content => content_in
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'new_container_assigned')
#endif
end function new_container_assigned
!--------------!------------------------------------------------------------------------
! Destructors !
!--------------!
!> Scalar desctructor for single instances of the class container_t
subroutine destroy_container(this)
type(container_t), intent(inout) :: this
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
nullify(this%content)
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'destroy_container')
#endif
end subroutine destroy_container
!> Array desctructor for arrays of instances of the class container_t
subroutine destroy_container_array(this)
type(container_t), intent(inout) :: this(:)
integer(kind=integer_4neuro) :: i
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
do i = 1, size(this)
nullify(this(i)%content)
end do
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'destroy_container_array')
#endif
end subroutine destroy_container_array
end module container_m
#define SINGLE 4
#define DOUBLE 8
# define PREC DOUBLE
module data_kinds_4neuro_m
integer, parameter :: integer_4neuro = PREC
integer, parameter :: real_4neuro = PREC
end module data_kinds_4neuro_m
This diff is collapsed.
program net_mem_leak_test
use data_kinds_4neuro_m
use net_m
class(net_t), allocatable :: net1, net2
print *, '+--------------------------------------------------+'
print *, '| STARTING MEMORY LEAK TESTING OF THE MODULE NET_M |'
print *, '+--------------------------------------------------+'
print *, 'Creating instances of the class net_t...'
allocate(net1)
select type(tmp => net1)
type is (mock_net_t)
tmp = mock_net_t()
end select
call net1%print_info()
call net1%save_net_bin("stored_net.dat")
!allocate(net2)
!net2 = net_t("stored_net.dat")
!call net2%print_info()
end program net_mem_leak_test
This diff is collapsed.
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
This diff is collapsed.
!> Module containing function for time measurement, mostly
!! for the time profiling regime
!!
!! @author Martin Beseda
!! @date 2017
module time_measurement_m
use data_kinds_4neuro_m
implicit none
public
contains
!> Subroutine for starting time profiling
!! @param[out] start_time Parameter, where current time will be saved (real number)
subroutine time_profiling_start(start_time)
real(kind=real_4neuro), intent(inout) :: start_time
call cpu_time(start_time)
end subroutine time_profiling_start
!> Subroutine for stopping time profiling and
!! printing the result.
!!
!! @param[in] start_time Parameter containing starting time (real number)
!! @param[in] region_name Name of the measured region (string)
subroutine time_profiling_stop(start_time, region_name)
real(kind=real_4neuro), intent(in) :: start_time
character(len=*) :: region_name
real :: stop_time
character(len=35) :: s
s = '| TIME PROFILING | Function '
call cpu_time(stop_time)
write(*, "(A)") '+----------------+'
write(*, "(A,A,A,E15.7,A)") s,region_name,'() was running for ',stop_time-start_time,'s.'
write(*, "(A)") '+----------------+'
end subroutine time_profiling_stop
end module time_measurement_m
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