诸位高人,小弟初学Fortran,在编写如下程序的时候发生错误,万望高人指点如何改正!不胜感激!
Function function1_basicsalary(workhour)
1
Error: Function result 'function1_basicsalary' at (1) has no IMPLICIT type
t3.f95:11.12:
basicsalary=function1_basicsalary(workhour)
1
Error: Can't convert UNKNOWN to REAL(4) at (1)
PROGRAM TestSubprograms
IMPLICIT NONE
! Provide the INTERFACE block if external subprograms are chosen
! The declaration statement(s)
Real::workhour,wage,basicsalary,overwage
! The statements that reference the subprograms written in Step 1 and 2
CALL subroutine1_overwage(workhour,overwage,wage)
basicsalary=function1_basicsalary(workhour)
! CONTAIN keyword goes here and the subprogram codes follow immediately
! if internal subprograms are chosen
CONTAINS
Function function1_basicsalary(workhour)
real::basicsalary
real,INTENT(IN)::workhour
IF (workhour.LE.40) THEN
basicsalary=wage*workhour
ELSE
basicsalary=wage*40
END IF
END Function function1_basicsalary
END PROGRAM TestSubprograms
! Subprogram codes start here if external subprograms are chosen
Subroutine subroutine1_overwage(workhour,overwage,wage)
REAL,INTENT(OUT)::overwage
REAL,INTENT(IN)::wage,workhour
IF (workhour.LE.40) THEN
overwage=0
ELSE IF (workhour.LE.45.AND.workhour.GT.40) THEN
overwage=wage*(workhour-40)*1.5
ELSE IF (workhour.GT.45.AND.workhour.LE.50) THEN
overwage=wage*(workhour-40)**2*1.5
ELSE
overwage=wage*(workhour-40)**3*1.5
END IF
END SUBROUTINE subroutine1_overwage
|