| 本帖最后由 kyra 于 2020-3-9 15:22 编辑 
 
 [Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode subroutine day1year()
implicit none
integer :: year , mon , days
    common year , mon 
    Integer :: DaysInMonth(12) = [31,28,31,30,31,30,31,31,30,31,30,31]
    if ( ( (MOD(year,4)==0).and.(MOD(year,100)/=0) ) .or. (mod(year,400)==0) ) then
      DaysInMonth(2) = 29
    else
      DaysInMonth(2) = 28
    end if
  days = sum( DaysInMonth )
end subroutine day1year
subroutine dayfromyear( year , mon , day )
implicit none
integer :: day , i , daylast
Integer :: DaysInMonth(12) = [31,28,31,30,31,30,31,31,30,31,30,31]
integer :: k
integer :: years(51) = (/(k,k=1957,2007)/)
integer :: sumday = 0
  do i=1,k,1
  call day1year (years(i))
  sumday = sumday + days
  end do
daylast = sum( DaysInMonth(:mon-1) ) + day +sumday
end subroutine
出现Error: Symbol 'year' at (1) has no IMPLICIT type
 Error: Symbol 'mon' at (1) has no IMPLICIT type
 Error: Symbol 'days' at (1) has no IMPLICIT type
 在第一个子程序中已经声明了这三个变量,并且设为了全局变量,为什么到第二个子程序中还是显示没有声明类型。
 
 
 |