资源描述:
《Fortran常用函数》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1、RANDOM_NUMBERSyntax['sintæks]n.语法CALLRANDOM_NUMBER(harvest结果)IntrinsicSubroutine(固有子程序):Returnsapseudorandomnumbergreaterthanorequaltozeroandlessthanonefromtheuniformdistribution.返回大于或等于0且小于1,服从均匀分布的随机数2、RNNOA/DRNNOA(Single/Doubleprecision)Generatepseudorandomnumbersfromastandardnormaldis
2、tributionusinganacceptance/rejectionmethod.产生服从标准正态分布的随机数Usage(用法)CALLRNNOA(NR,R)Arguments(参数)NR—Numberofrandomnumberstogenerate.(Input)要产生随机数的个数R—VectoroflengthNRcontainingtherandomstandardnormaldeviates.(Output)输出长度为NR,随机正态分布的向量Comments(注解)TheroutineRNSETcanbeusedtoinitializetheseedofther
3、andomnumbergenerator.TheroutineRNOPTcanbeusedtoselecttheformofthegenerator.程序RNSET可以用来初始化随机数发生器的种子ExampleInthisexample,RNNOAisusedtogeneratefivepseudorandomdeviatesfromastandardnormaldistribution.INTEGERISEED,NOUT,NRREALR(5)EXTERNALRNNOA,RNSET,UMACHCCALLUMACH(2,NOUT)NR=5ISEED=123457CALLRNSE
4、T(ISEED)CALLRNNOA(NR,R)WRITE(NOUT,99999)R99999FORMAT('Standardnormalrandomdeviates:',5F8.4)ENDOutputStandardnormalrandomdeviates:2.05161.08330.08261.2777-1.22603、RESHAPEIntrinsicFunction(内部函数)Constructsanarrayofaspecifiedshapefromtheelementsofanotherarray.构造规定形式的数组Syntax(语法)result=RESHAPE(s
5、ource,shape[,pad][,order])source(Input)Anytype.ArraywhoseelementswillbetakeninstandardFortranarrayorder(seeRemarks),andthenplacedintoanewarray.shape(Input)Integer.One-dimensionalarraythatdescribestheshapeoftheoutputarraycreatedfromelementsofsource.描述输出数组的大小的一维数组,Theelementsofshapearethesize
6、softhedimensionsofthereshapedarrayinorder.Ifpadisomitted省略,thetotalsizespecifiedbyshapemustbelessthanorequaltosource.pad可选参数(Optional;input)Sametypeassource.Mustbeanarray.Iftherearenotenoughelementsinsourcetofilltheresultarray,elementsofpadareaddedinstandardFortranarrayorder.Ifnecessary,ext
7、racopiesofpadareusedtofillthearray.order可选参数(Optional;input)Integer.One-dimensionalarray.Mustbethesamelengthasshape.Permutestheorderofdimensionsintheresultarray.Thevalueofordermustbeapermutationof(1,2,...n)wherenisthesizeofshape.ReturnValue(返回值)Theresult