Function has no implicit type

前端 未结 4 689
梦如初夏
梦如初夏 2020-12-06 11:07

I am trying to learn to work with functions. I have the following code:

program main
  implicit none

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

integer function test         


        
4条回答
  •  旧巷少年郎
    2020-12-06 11:49

    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.

提交回复
热议问题