Commit b6ec4eea authored by Wolfgang Kilian's avatar Wolfgang Kilian
Browse files

Test für leeres Neuron

parent 1d14d3d5
......@@ -11,7 +11,7 @@ MAIN = nnet
# Source code
MAIN_SRC = $(MAIN).f90
MODULES_SRC =
MODULES_SRC = kinds.f90 neurons.f90
# Test output and reference
OUTPUT = $(MAIN).out
......@@ -22,6 +22,11 @@ MAIN_OBJ = $(MAIN_SRC:.f90=.o)
OBJECTS = $(MODULES_SRC:.f90=.o) $(MAIN_OBJ)
MODULES = $(MODULES_SRC:.f90=.mod)
########################################################################
### Module dependencies
$(MAIN_OBJ): kinds.mod neurons.mod
neurons.o: kinds.mod
########################################################################
### Targets
......
module kinds
use, intrinsic :: iso_fortran_env, only: real64
implicit none
private
public :: wp
integer, parameter :: wp = real64
end module kinds
module neurons
use kinds, only: wp
implicit none
private
public :: neuron
type :: neuron
real(wp) :: a
real(wp), dimension(:), allocatable :: b
contains
procedure :: write
end type neuron
contains
subroutine write (n, u)
class(neuron), intent(in) :: n
integer, intent(in) :: u
write (u, "(1X,A)") "Neuron:"
write (u, "(3x,A,1x,F11.9)") "a =", n%a
write (u, "(3x,A,1x,A)") "b =", "[leer]"
end subroutine write
end module neurons
......@@ -6,6 +6,33 @@ program nnet
open (newunit = u, file = "nnet.out", action = "write", status = "replace")
call test_kinds
write (u, *)
call test_empty_neuron
close (u)
contains
! Test: doppelt-genaue Zahl (sqrt(2))
subroutine test_kinds
use kinds, only: wp
write (u, "(A)") "* Test: kinds"
write (u, "(F12.9)") sqrt (2._wp)
end subroutine test_kinds
! Test: leeres Neuron, nicht initialisiert
subroutine test_empty_neuron
use neurons, only: neuron
type(neuron) :: n
write (u, "(A)") "* Test: empty neuron"
call n%write (u)
end subroutine test_empty_neuron
end program nnet
* Test: kinds
1.414213562
* Test: empty neuron
Neuron:
a = 0.000000000
b = [leer]
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