Function has no implicit type

Move the line

end program

to the end of your source file and, in its place, write the line

contains

As you have written your program it has no knowledge of the function test, which is what the compiler is telling you. I have suggested one of the ways in which you can provide the program with the knowledge it needs, but there are others. Since you are a learner I'll leave you to figure out what's going on in detail.


Just in case, someone has the same problem an alternative way (especially for the case discussed in the comment) is to add

integer,external :: test

after

implicit none

in the main program.


Another simple way, not mentioned in the current answers:

Move the function before the main program, put module subs, implicit none and contains before the function and end module after the function. The put use subs into your program.

This way the program can see everything necessary ("explicit interface") about the procedures in the subs module and will know how to call them correctly. The compiler will be able to provide warnings and error messages if you try to call the procedures incorrectly.

module subs
  implicit none
contains
  integer function test(n)
    !implicit none no longer necessary here
  end function test
end module

program main
  use subs
  implicit none

Just put this:

program main
  implicit none

integer test

  write(*,*) test(4)
end program
...

You need to declare the function as a variable for the compiler to know the return type of the function.