[Fortran] 纯文本查看 复制代码 program www_fcode_cn
use params
use extrafunc
use interpreter
implicit none
character(len=255) :: s, f,error1,error2
real(fdp) :: r
real(fdp), dimension(:),allocatable :: varvals
integer :: funcnum
write(*,*)"依次输入函数的自变量:"
read(*,'(a)')s
allocate(varvals(f_numbervars(s))) ! f_numbervars(s)为自变量的个数
write(*,*)"输入关于自变量的函数:"
read(*,'(a)')f
write(*,*)"依次输入对应自变量的值:"
read(*,*)varvals
call s_createfn(f, s, funcnum,error1) ! 创建函数
write(*,'(a)')trim(error1) ! 提示出错信息
call s_evaluatefn(funcnum, varvals, r,error2) ! 计算函数值
write(*,'(a)')trim(error2) ! 提示出错信息
write(*,*)"函数值等于:",r
call s_destroyfn(funcnum) ! 销毁函数
stop
end program www_fcode_cn |