How to resolve Implicit type related error?


I am trying to run fortran 90 code file but i am getting these error. Can anyone please help me to fix these errors ?

In general please show your code when asking for help. From the error messages I think the first problem is that you are invoking the random_number intrinsic as a function, when it is actually a subroutine. You could write a function to wrap random_number, for example

module ran_mod
implicit none
integer, parameter :: dp = kind(1.0d0)
contains
function rannum() result(xran)
real(kind=dp) :: xran
call random_number(xran)
end function rannum
end module ran_mod

program main
use ran_mod, only: rannum
implicit none
call random_seed()
print*,rannum()
print*,rannum()
end program main

with sample output

  0.63224103693793376     
  0.99794562181167690

First, random_number is a subroutine, not a function. Instead you’ll need to do

call random_number(harvest)
test=... harvest ...

Next, it looks like you’re missing a use statement to bring the ch_nn function into scope, or a declaration if the function is not in a module. You’ll need one of the following.

  1. a use statement if the function is in a module. I.e.
use module_where_ch_nn_is
  1. an interface block. I.e.
interface
  function ch_nn(x)
    real, intent(in) :: x
    real :: ch_nn
  end function
end interface
  1. an external declaration, but I recommend against it because then the compiler won’t tell you if you got the wrong number or types of arguments. I.e.
real, external :: ch_nn
1 Like