Skip to content

Commit e8f7be9

Browse files
authored
Merge pull request #31 from modern-fortran/26-fix-type-mismatch
Use consistent type kinds throughout; fixes #26
2 parents 8ec0122 + 1943823 commit e8f7be9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/mod_layer.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ end function constructor
6060

6161
pure type(array1d) function array1d_constructor(length) result(a)
6262
! Overloads the default type constructor.
63-
integer, intent(in) :: length
63+
integer(ik), intent(in) :: length
6464
allocate(a % array(length))
6565
a % array = 0
6666
end function array1d_constructor
6767

6868
pure type(array2d) function array2d_constructor(dims) result(a)
6969
! Overloads the default type constructor.
70-
integer, intent(in) :: dims(2)
70+
integer(ik), intent(in) :: dims(2)
7171
allocate(a % array(dims(1), dims(2)))
7272
a % array = 0
7373
end function array2d_constructor
@@ -76,7 +76,7 @@ pure subroutine db_init(db, dims)
7676
! Initialises biases structure.
7777
type(array1d), allocatable, intent(in out) :: db(:)
7878
integer(ik), intent(in) :: dims(:)
79-
integer :: n, nm
79+
integer(ik) :: n, nm
8080
nm = size(dims)
8181
allocate(db(nm))
8282
do n = 1, nm - 1
@@ -89,7 +89,7 @@ pure subroutine dw_init(dw, dims)
8989
! Initialises weights structure.
9090
type(array2d), allocatable, intent(in out) :: dw(:)
9191
integer(ik), intent(in) :: dims(:)
92-
integer :: n, nm
92+
integer(ik) :: n, nm
9393
nm = size(dims)
9494
allocate(dw(nm))
9595
do n = 1, nm - 1

src/mod_network.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module mod_network
1313
type :: network_type
1414

1515
type(layer_type), allocatable :: layers(:)
16-
integer, allocatable :: dims(:)
16+
integer(ik), allocatable :: dims(:)
1717

1818
contains
1919

@@ -75,7 +75,7 @@ pure real(rk) function accuracy(self, x, y)
7575
good = good + 1
7676
end if
7777
end do
78-
accuracy = real(good) / size(x, dim=2)
78+
accuracy = real(good, kind=rk) / size(x, dim=2)
7979
end function accuracy
8080

8181

@@ -86,7 +86,7 @@ pure subroutine backprop(self, y, dw, db)
8686
real(rk), intent(in) :: y(:)
8787
type(array2d), allocatable, intent(out) :: dw(:)
8888
type(array1d), allocatable, intent(out) :: db(:)
89-
integer :: n, nm
89+
integer(ik) :: n, nm
9090

9191
associate(dims => self % dims, layers => self % layers)
9292

0 commit comments

Comments
 (0)