地板怎么没有主要类型?

时间:2011-10-05 00:41:47

标签: fortran

/home/disk/p/atms380/xx/October-Runs/timeManMod/SourceMods/time_manager.F90(664):
error #6404: This name does not have a type, and must have an explicit
type.   [FLOOR]
tmd = day_earth/PLANET_DAY_RATIO - floor(day_earth/PLANET_DAY_RATIO)

我使用ifort编译器运行Fortran 90。据我所知,floor是Fortran 90中引入的函数

Using Fortran compiler: ifort  -O -I/home/disk/eos11/bitz/cam3.1/cam1/models/utils/esmf -I/home/disk/eos11/bitz/cam3.1/cam1/models/utils/esmf/src/include -I/home/disk/eos11/bitz/cam3.1/cam1/models/utils/esmf/build/linux_intel -I/home/disk/eos11/bitz/cam3.1/cam1/models/utils/esmf/include   -I/home/disk/eos11/bitz/cam3.1/cam1/models/utils/esmf/src/Infrastructure/mpiuni                         
Fortran Compiler version:
Intel(R) Fortran Intel(R) 64 Compiler Professional for applications running on Intel(R) 64, Version 11.1    Build 20091130 Package ID: l_cprof_p_11.1.064

==

这就是我在子程序中定义PLANET_DAY_RATIO的方法:

subroutine get_curr_date(yr, mon, day, tod, offset)

! Return date components valid at end of current timestep with an optional
! offset (positive or negative) in seconds.

implicit none

! Arguments
integer, intent(out) ::&
yr, &! year
mon, &! month
day, &! day of month
tod ! time of day (seconds past 0Z)

integer, optional, intent(in) :: offset ! Offset from current time in seconds.
! Positive for future times, negative
! for previous times.

! Local variables
character(len=*), parameter :: sub = 'get_curr_date'
integer :: rc
type(esmf_date) :: date
type(esmf_time) :: off
integer :: ymd
integer :: leap_days
integer :: yZero
integer :: day_earth
float :: PLANET_DAY_RATIO

(stuff)

yr = ymd/10000
mon = mod(ymd, 10000) / 100
day = mod(ymd, 100)
PLANET_DAY_RATIO = 0.5 !0.5 is for spinning twice as fast, or 43200 seconds
yZero = start_ymd/10000
leap_days = (yr -yZero)/4
day_earth = day_earth + 365*(yr -yZero) + leap_days
tmd = day_earth/PLANET_DAY_RATIO - floor(day_earth / PLANET_DAY_RATIO)

end subroutine get_curr_date

1 个答案:

答案 0 :(得分:4)

你没有看错正确的错误!

未正确声明变量 PLANET_DAY_RATIO float 不是有效的实数声明。请将浮动替换为真实

关于编译器的令人惊讶的警告,这仅仅是因为函数FLOOR是通用的:编译器需要知道参数的类型以选择正确的FLOOR变体函数。由于参数不正确,编译器推断出FLOOR是程序的标识符(是的!它被授权声明与Fortran内部函数名匹配的变量或函数,因为Fortran是一种没有保留关键字的语言)。