关键词不能为空

当前您在: 主页 > 英语 >

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常用函数的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文