real(8) function f(x) implicit none real(8), intent(in) :: x f = x**2 end function f ! 实现梯形积分法 real(8) function trapezoid(a, b, n, f) implicit none real(8), intent(in) :: a, b integer, intent(in) :: n real(8), external :: f real(8) :: h, sum integer ...
real在Fortran中表示实数类型。其中有两种精度:单精准度(REAL*4)双精准度(REAL*8)相应的实数范围:real(kind=4):±1.18*10-38 ~ ±3.40*1038,有效6-7位 real(kind=8):±2.23*10-308 ~ ±1.79*10308,有效15位
INTEGER\REAL\COMPLEX\LOGICAL语句 IMPLICIT语句 EXTERNAL语句 INTRINSIC语句 SAVE语句 类型语句的一边形式: typ V[,v]... 例子: COMPLEX COMPA,COMPB REAL*8::I(15,20,30),IJIM,NETINTEGER::AT(10,10,20),HIT,OTT(10,20)LOGICAL SWITCH,CODE,LIGHT DOUBLE COMPLEX Z12,23 CHARACTER[*LEN[,]]NAM[,NAM]...
external moment_get_js integer(4) jd real(8) js call moment_new(foo, 1, 2d0) jd = moment_get_jd(foo) js = moment_get_js(foo) write(*,*) jd, js end 以Fortran的call moment_new(foo, 1, 2d0)语句为例,其中foo为void*格式,1与2d0分别为INTEGER*4与REAL*8的常量,那么该语句的调用...
(kind = 8) VDP00(4,4,4,2),VDP10(4,4,4,2),VDP01(4,4,4,2),VDP20(4,4,4,2),VDP11(4,4,4,2),VDP02(4,4,4,2),yv(4,2),ffu(4,2) integer i,deg,j,i1,j1,p real(kind = 8) :: Linfty = 0 real(kind = 8) :: h1 = h/2 real(kind = 8),external :: eig...
real*8 :: y(2),y2(2),omega(10),V4 real*8 :: h,h1,T,ngt real*8,external :: V,V1,V2,V3 y2(1) = sqrt(2.0d0*T)*[h*omega(2) - h1*omega(3) + h1*h*omega(4) - h1*h1*omega(6) + & (-h1*h*omega(4) + 2.0d0*h1*h1*omega(6))*V2(y(1)) - h1*h1*...
在泛型接口内部,通过复制过程的定义部分来指定外部过程(external procedures)的接口。 对于在同一模块中定义的过程,我们需要使用module procedure<nameOfModuleProcedure>来指定。 下面的示例说明了这两种情况: 该示例将外部子例程swapReal和模块过程swapInteger分组,以便通过通用名称swap调用它们 ...
Real , External :: func Interface Real Function func( x ) real :: x End Function func End Interface Real , intent( IN ) :: low_bound , up_bound , delta integer :: i real :: x y = 0.0 x = low_bound + delta/2.0 Do !// Do x = low_bound , up_bound , delta y = y +...
program test_dgesv implicit none real(8) :: a(3,3),b(3)integer :: v(3),iflag,i external dgesv a=reshape([2.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,4.0],[3,3])b=[20.0,33.0,48.0]print*, 'a = 'do i = 1,3 print '(3(f14.8,x))',a(i,:)end do...
real,intrinsic ::sin !声明sin是库函数 call ExecFunc(func) !输入自定义函数func call ExecFunc(sin) !输入库函数sin end subroutine ExecFunc(f) implicit none real,external ::f !声明参数f是个函数 write(*,*) f(1.0) !执行输入函数f return ...