1. 内部函数(intrinsic function) 内建在Fortran语言中的函数,例如:SIN(X),LOG(X) 2. 用户自定义函数(user-defined function) 用户定义函数由程序员定义, 用来满足标准内部函数无法解决的特定需求。 通用格式: FUNCTIONname(parameter_list)...!在声明部分必须声明name的类型...!执行部分...name=exprRETURNEND ...
program declaration use, intrinsic :: iso_fortran_env, only: rk => real64 implicit none integer :: i = 1 !! 单精度整型 real(rk) :: x = 1.0_rk, xs(10) !! 浮点型标量 x 与数组 xs real(rk) :: y = 2.0_rk !! 设置特定的浮点型精度 xs = [real(rk) ::(i, i=1, 10)] !
function myfun ([argument list]) result ([return variable name]) [Module imports here] implicit none [Arguments with intent (in)] !< Description of 'in' argument [Return variable type declaration] !< Description of return variable [Local constants] [Local variables] [Executable code] end func...
What does the declaration of a function look like that returns a c_ptr? Translate Tags: Intel® Fortran Compiler0 Kudos Reply All forum topics Previous topic Next topic 1 2 23 Replies MWind2 New Contributor III 03-01-2012 08:31 PM 644 Views Thanks. ...
programprogram_nameimplicitnone! type declaration statements! executable statementsendprogramprogram_name Fortran中的一个简单程序 让我们编写一个程序,添加两个数字并打印结果 - programaddNumbers! This simple program adds two numbersimplicitnone! Type declarationsreal:: a, b, result! Executable statementsa ...
(Declaration section must declare type of name) ... (Execution section) ... name = expr RETURN END FUNCTION [name] 其中,TYPE表示函数的返回值类型,使用IMPLICIT NONE语句时,必须要指名函数的返回类型,如果有使用IMPLICIT NONE语句,那么函数的返回类型将默认使用Fortran的内置规则。RETURN语句只是表示结束本函...
For any function whose return value is not an intrinsic type, you can use the RESULT(var) attribute in the function declaration. For example:[fortran]function myalloc(nbytes) result(cptr) bind(C) use iso_c_binding integer, value :: nbytes type(c_ptr) :: cptr ... cptr ...
我有以下Fortran函数create_pointer,它调用一个名为create_pointer的C函数,该函数创建一个指针并返回其地址: FUNCTION create_pointer() RESULT(c_intptr_t) BIND(C, name = "create_pointer") USE, INTRINSIC :: iso_c_binding, ONLY: c_intptr_t END FUNCTION 作为参考,C函数create_pointer如下: intptr_...
Fortran程序是由程序单元,如一个主程序,模块和外部子程序或程序的集合。 每个程序包括一个主程序和可以或可以不包含其它程序单元。主程序的语法如下: program program_name implicit none ! type declaration statements ! executable statements end program program_name 一个简单的Fortran程序 让我们来写一个程序,相加...
D U M A C I E N L Definition/Declaration Simple use Modified occurrence Actual argument Subroutine/Function call Initialization: DATA or extended declaration Occurrence in EQUIVALENCE Occurrence in NAMELIST Use Module Cross Reference PROGRAM FORM Program --- repeat Cross Reference Mon Mar 18 15:40...