我收到一条带有此错误的消息 Function ‘area circle’ requires an argument list ,为什么?

I got a message with this erro Function ‘areacircle’ requires an argument list ,Why?

这是程序。我得到了一个错误,为什么?

  ''''code'''''

不知道为什么没有整体出现,我试着求一个随机数的面积和体积。 - - - - - - - - 为什么 - - - - - - - '''Fortran

'program exercise2'
!
      integer :: N,i
      type :: Values
      double precision :: radius,area,volume
      end type
!
!
      type(Values),allocatable, dimension(:) :: s
      integer :: bi
!
!Read the data to create the random number
      write(6,*) 'write your number '
      read(5,*) N
      allocate(s(N))
      bi = 3.14
!create the random number
      call random_seed()
      do i=1,N
        call random_number(s(i)%radius)
        s(i)%area=areacircle(s(i)%radius)
        s(i)%volume=volumesphere(s(i)%radius)
      end do
!
      open(15,file='radius.out',status='new')
      write(15,*) s(i)%radius
      open(16,file='output2.out',status='new')
      r = real(s(i)%radius)
!Two function
      contains
      
      double precision function areacircle (s)
      implicit none
      double precision :: s
      do i=1 , N
         areacircle=bi*r**2
      end do
      return
      end function areacircle
!
!
      double precision function volumesphere (s)
      implicit none
      double precision :: s
      do i=1,N
         volumesphere=4/3*bi*r**3
      end do
      return
      write(16,*)  r    ,     areacircle   ,     volumesphere
      end function volumesphere
'end program exercise2'

''''''' 所以有人知道为什么吗?

这可能符合您的要求。由于面积和体积的计算涉及一个不变的输入,我已将您的函数更改为 elemental。这允许一个数组参数,其中为数组的每个元素执行函数。我还更改了 double precision 以使用 Fortran 类类型参数机制,因为键入 real(dp) 更短。 最后,永远不要在没有 implicit none 语句的情况下编写 Fortran 程序。

program exercise2

  implicit none ! Never write a program without this statement

  integer, parameter :: dp = kind(1.d0)  !  kind type parameter
  integer n, i
  type values
     real(dp) radius, area, volume
  end type

  type(values), allocatable :: s(:)
  real(dp) bi  ! integer :: bi?

  ! Read the data to create the random number
  write(6,*) 'write your number '
  read(5,*) n

  ! Validate n is validate.
  if (n < 1) stop 'Invalid number'

  allocate(s(n))

  bi = 4 * atan(1.d0)  !   bi = 3.14?  correctly determine pi

  call random_seed()                  ! Use default seeding
  call random_number(s%radius)        ! Fill radii with random numbers
  s%area   = areacircle(s%radius)     ! Compute area  
  s%volume = volumesphere(s%radius)   ! Compute volume

  write(*,'(A)') '   Radii    Area    Volume'
  do i = 1, n
     write(*, '(3F9.5)') s(i)
  end do

  contains
  
     elemental function areacircle(s) result(area)
        real(dp) area
        real(dp), intent(in) :: s
        area = bi * s**2
     end function areacircle

     elemental function volumesphere(s) result(volume)
        real(dp) volume
        real(dp), intent(in) :: s
        volume = (4 * bi / 3) * s**3
     end function volumesphere
end program exercise2