gfortran - "PROCEDURE attribute conflicts with INTENT attribute" when compiling simple Fortran program with module -
i have simple fortran 95 program
include "sandboxlib.f95" program sandbox implicit none write(*, *) 'abc' end program
and simple module containing function
module sandboxlib integer, parameter :: dp = kind(1.d0) contains function cumsum(mat, m, n) result(c) implicit none real(dp), intent(in) :: mat integer, intent(in) :: m, n integer i, j real(dp), dimension(m, n) :: c c(:, 1) = 0.d0 = 2, m j = 1, n c(i, j) = c(i-1, j) + mat(i, j) end end end function end module
i compile sandbox.f95
command
/usr/bin/gfortran -o -std=gnu -wfatal-errors -pedantic -wall sandbox.f95 -o sandbox
which results in error
sandboxlib.f95:6.23: included @ sandbox.f95:1: function cumsum(mat, m, n) 1 error: procedure attribute conflicts intent attribute in 'mat' @ (1)
i looked around , found few questions discuss modules, functions, etc. or error this, can't figure out why won't compile.
your mat
declared scalar
real(dp), intent(in) :: mat
but use array
c(i, j) = c(i-1, j) + mat(i, j)
and compiler parses function call , assumes mat()
function. , functions cannot have intent
.
i assume correct thing make mat
array in declaration. mat(:,:)
or mat(m,n)
. former can avoid passing m
, n
arguments.
Comments
Post a Comment