关键词不能为空

当前您在: 主页 > 英语 >

Fortran常用函数

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-28 09:32
tags:

-

2021年2月28日发(作者:perth什么意思)



1



RANDOM_ NUMBER



Syntax


['sint?ks]


n.


语法



CALL RANDOM_NUMBER (


harvest< /p>


结果


)



Intrinsic Subroutine



固有子程序)



Returns a pseudorandom number greater than or equal


to zero and less than one from the uniform distribution.


返回大于或等于


0


且小于


1


,服从均匀分布的随机数



2



RNNOA/ DRNNOA



Single/Double precision




Generate pseudorandom numbers from a standard normal distribution using an


acceptance/rejection method.


产生服从标准正态分布的随机数



Usage


(用法)



CALL RNNOA (NR, R)



Arguments


(参数)



NR




Number of random numbers to generate.




(Input)


要产生随机数的个数



R




Vector of length


NR


containing the random standard normal deviates.




(Output)




输出长度为


NR


,随机正态分布的向量



Comments


(注解)



The routine RNSET can be used to initialize the seed of the random number generator.


The routine RNOPT can be used to select the form of the generator.

< br>程序


RNSET


可以用来初始化随机数发生器的种子



Example



In this example,


RNNOA


is used to generate five pseudorandom deviates from a standard


normal distribution.







INTEGER ISEED, NOUT, NR



REAL R(5)



EXTERNAL RNNOA, RNSET, UMACH



C



CALL UMACH (2, NOUT)



NR = 5



ISEED = 123457



CALL RNSET (ISEED)



CALL RNNOA (NR, R)



WRITE (NOUT,99999) R



99999 FORMAT (' Standard normal random deviates: ', 5F8.4)



END



Output




Standard normal random deviates: 2.0516 1.0833 0.0826 1.2777


-1.2260






3



RESHAPE



Intrinsic Function


(内部函数)


Constructs an array of a specified shape from the elements


of another array.


构造规定形式的数组



Syntax


(语法)






result


=


RESHAPE


(


source


,


shape


[ ,


pad


]



[ ,


order


]




)



source



(Input)



Any type. Array whose elements will be taken in standard Fortran array order


(see Remarks), and then placed into a new array.



shape



(Input)



Integer. One-dimensional array that describes the shape of the output array


created from elements of


source


.


描述输出数组的大小的一维数组,


The elements of


shape


are the sizes of the dimensions of the reshaped array in order. If


pad


is omitted


省略


, the total size specified by


shape


must be less than or equal to


source.



pad


可选参数



(Optional; input)



Same type as


source


. Must be an array. If there are not enough


elements in


source


to fill the result array, elements of


pad


are added in standard


Fortran array order. If necessary, extra copies of


pad


are used to fill the array.



order


可选参数



(Optional; input)



Integer. One- dimensional array. Must be the same length as


shape


.


Permutes the order of dimensions in the result array. The value of


order


must be a


permutation of (


1, 2,...n


) where


n


is the size of


shape


.



Return Value


(返回值)



The result is an array the same data type and kind as


source


and a shape as defined in


shape


.



Examples




INTEGER AR1( 2, 5)



REAL F(5,3,8)



REAL C(8,3,5)



AR1 = RESHAPE((/1,2,3,4,5,6/),(/2,5/),(/0,0/),(/2,1/))



! returns 1 2 3 4 5



! 6 0 0 0 0



!



! Change Fortran array order to C array order



C = RESHAPE(F, (/8,3,5/), ORDER = (/3, 2, 1/))



END




4



SUM


Intrinsic Function


(内部函数)





Sums elements of an array or the elements along an


optional dimension. The elements summed can be selected by an optional mask.



将数组中的元素求和



Syntax


(语法)






result


=


SUM


(


array


[ ,


dim


] [ ,


mask


]



)



array



(Input)



Integer, real, or complex. Array whose elements are to be summed.



dim


可选参数





(Optional; input)



Integer. Dimension along which elements are summed.



1


?



dim



?



n


, where


n


is the number of dimensions in


array


.



mask


可选参数



(Optional; input)



Logical. Must be same shape as


array


. If


mask


is specified, only


elements in


array


that correspond to


.TRUE.


elements in


mask


are summed.



Return Value


(返回值)



Same type and kind as


array


and equal to the sum of all elements in


array


or the sum of


elements along dimension


dim


. If


mask


is specified, only elements that correspond


to


.TRUE.


elements in


mask


are summed. Returns a scalar if


dim


is omitted or


array


is


one- dimensional. Otherwise, returns an array one dimension smaller than


array


.



Examples




INTEGER array (2, 3), i, j(3)



array = RESHAPE((/1, 2, 3, 4, 5, 6/), (/2, 3/))



! array is 1 3 5



! 2 4 6



i = SUM((/ 1, 2, 3 /)) ! returns 6



j = SUM(array, DIM = 1) ! returns [3 7 11]



WRITE(*,*) i, j



END



5



SEED



Run-Time Subroutine




Changes the starting point of the pseudorandom number


generator.


改变随机数发生器的起始点



Module






USE



MSFLIB



Syntax


(语法)






CALL



SEED


(


iseed


)



iseed



(Input)



INTEGER(4). Starting point for


RANDOM


.



Remarks


(注解)



SEED


uses


iseed


to establish the starting point of the pseudorandom number generator.


A given seed always produces the same sequence of values from


RANDOM


.



If


SEED


is not called before the first call to


RANDOM


,


RANDOM


always begins with a


seed value of one. If a program must have a different pseudorandom sequence each time


it runs, pass the constant


RND$$TIMESEED


(defined in MSFLIB.F90) to the


SEED


routine


before the first call to


RANDOM


.



Example




USE MSFLIB



REAL rand



CALL SEED(7531)



CALL RANDOM(rand)



6


、< /p>


RANDOM





Purpose



Run-Time Subroutine







Returns a pseudorandom number greater than or equal to


zero and less than one from the uniform distribution.


返回大于或等于< /p>


0


且小于


1


,服 从均匀


分布的随机数



Module






USE



MSFLIB



Syntax






CALL



RANDOM


(


ranval


)



ranval



(Output)



REAL(4). Pseudorandom number, 0


?



ranval



?


1, from the uniform


distribution.



Remarks



A given seed always produces the same sequence of values from


RANDOM


.



If


SEED


is not called before the first call to


RANDOM


,


RANDOM


begins with a seed value


of one. If a program must have a different pseudorandom sequence each time it runs,


pass the constant


RND$$TIMESEED


(defined in MSFLIB.F90) to


SEED


before the first call


to


RANDOM


.



All the random procedures (


RANDOM


,


RAN


,


and



RANDOM_NUMBER


, and the PortLib


functions


DRAND


,


DRANDM


,


RAND


,


IRANDM


,


RAND


, and


RANDOM)


use the same


algorithms and thus return the same answers. They are all compatible and can be used


interchangeably. (The algorithm used is a “Prime Modulus M Multiplicative Linear


Congruential Generator,” a modified version of t


he random number generator by Park and


Miller in “Random Number Generators: Good Ones Are Hard to Find,” CACM, October


1988, Vol. 31, No. 10.)



Compatibility



CONSOLE




STANDARD GRAPHICS




QUICKWIN GRAPHICS




WINDOWS




DLL




LIB



Example




USE MSFLIB



REAL(4) ran






CALL SEED(1995)



CALL RANDOM(ran)



7



FFT2B



Compute the inverse Fourier transform of a complex periodic two-dimensional array.


计算二维复数数组的逆傅里叶变换



Usage


(用法)



-


-


-


-


-


-


-


-



本文更新与2021-02-28 09:32,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/680034.html

Fortran常用函数的相关文章