define the integrand function integrand(z) implicit none real*8 ::z real*8 ::integrand integrand=legendre(z,j)*func(z)*z**l*pi return end function end function 上面我们积分的函数gauss_integral只能投入一个单变量的函数作为变量,但是我们的被积函数integrand中需要使用legendre函数(双变量),其中的j...
例如函数 void cCharFunction( char *msg );需要定义成:void cCharFunction( char *msg , int len ); 经过上面的define之后,在Fortran中,只需调用CCHARFUNCTION( MSG )即可。由于Fortran程序没有明显得字符串结束标志,这样,如果两个字符串连在一起的话,C的程序里就会取到这个连在一起的字符串,因此,最好在...
END FUNCTION [name] 由于函数必须返回一个值,因此需要定义函数返回值类型,有两种,如下: INTEGER FUNCTION my_function(i,j) FUNCTION my_function(i,j) INTEGER :: my_function 函数名为输出变量的名称,并且该变量已被定义,因此不需要在函数中再次定义。但是输入参数需要定义! 过程作为参数传递给其它过程 用户定...
例如函数 void cCharFunction( char *msg );需要定义成:void cCharFunction( char *msg , int len ); 经过上面的define之后,在Fortran中,只需调用CCHARFUNCTION( MSG )即可。由于Fortran程序没有明显得字符串结束标志,这样,如果两个字符串连在一起的话,C的程序里就会取到这个连在一起的字符串,因此,最好在...
function f(x,a,b,c,d,...) implicit none real(kind=RP) :: x,a,b,c,d,... real(kind=RP) :: f ! Here you define your function f = ... end function f function g(x) implicit none real(kind=RP) :: x , g ! Here you call "f" function with the frozen variables *0 g...
C Define function F(X) = DSQRT(X) C Set up interpolation points DO 10 I=1, NDATA XDATA(I) = DBLE(I-1)/DBLE(NDATA-1) FDATA(I) = F(XDATA(I)) 10 CONTINUE C Generate knot sequence CALL DBSNAK (NDATA, XDATA, KORDER, XKNOT) ...
# matrix_add.pyimportnumpyasnpimportctypes# Load the FORTRAN dynamic libraryfortran_lib=ctypes.CDLL('libmatrix_add.so')# Define the function signaturematrix_add=fortran_lib.matrix_add matrix_add.argtypes=[np.ctypeslib.ndpointer(dtype=np.float64),np.ctypeslib.ndpointer(dtype=np.float64),np.ct...
1、1/133 FORTRAN语言程序设计初步2/133FORTRAN语言程序设计初步语言程序设计初步任何一种程序设计语言都有自己的任何一种程序设计语言都有自己的一套语法规则以及由基本符号按语一套语法规则以及由基本符号按语法规则构成的各种语法成分:如常法规则构成的各种语法成分:如常量、变量、表达式、语句、函数等量、变量、表达式...
function Fun1(a &#ifdef EOF,b &#endif)result(c)implicit nonereal,intent(in) :: a#ifdef EOFreal,intent(in) :: b#endifreal :: cc = a**2#ifdef EOFc = a**2+b#endifend function Fun1end module module_ex! main_program.f90#define EOFprogram main_programuse m...
Define the pairing of the pointer-based variable and the pointer in a POINTER statement. Define the type of the pointer-based variable. The pointer itself is integer type and should not appear in a type declaration. Set the pointer to the address of an area of memory that has the ...