登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
1、RANDOM_NUMBER Syntax ['sintæks]file:///C:/Users/kingtansin/AppData/Local/Packages/oice_15_974fa576_32c1d314_f21/AC/Temp/msohtmlclip1/01/clip_image001.gifn. 语法 CALL RANDOM_NUMBER (harvest结果) IntrinsicSubroutine(固有子程序):Returnsa pseudorandom number greater than or equal to zero and less than one from theuniform distribution. 返回大于或等于0且小于1,服从均匀分布的随机数 2、RNNOA/ DRNNOA (Single/Double precision) Generatepseudorandom numbers from a standard normal distribution using anacceptance/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 RNSETcan be used to initialize the seed of the random number generator. The routine RNOPTcan be used to select the form of the generator. 程序RNSET可以用来初始化随机数发生器的种子 Example In this example, RNNOA is used to generate fivepseudorandom 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 IntrinsicFunction(内部函数)Constructs an array of a specified shape from theelements of another array. 构造规定形式的数组 Syntax(语法) result = RESHAPE (source, shape [ , pad][ , order] ) source
(Input) Any type. Array whose elements will be takenin standard Fortran array order (see Remarks), and then placed into a newarray. shape
(Input) Integer. One-dimensional array that describesthe shape of the output array created from elements of source. 描述输出数组的大小的一维数组,The elements of shape are the sizes of thedimensions of the reshaped array in order. If pad is omitted省略, the total size specified by shape must be lessthan 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 thesame length as shape. Permutes the order of dimensions in the resultarray. The value of order must be a permutation of (1, 2,...n) where n is the size of shape. ReturnValue(返回值) The result is anarray 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 IntrinsicFunction(内部函数) Sumselements of an array or the elements along an optional dimension. The elementssummed can be selected by an optional mask. 将数组中的元素求和 Syntax(语法) result = SUM (array [ , dim] [ , mask] ) array
(Input) Integer, real, or complex. Array whoseelements are to be summed. dim 可选参数
(Optional; input) Integer. Dimension along which elements aresummed.
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. ReturnValue(返回值) Same type andkind as array and equal to the sum of all elements in array orthe sum of elements along dimension dim. If mask is specified,only elements that correspond to .TRUE. elements in mask aresummed. Returns a scalar if dim is omitted or array isone-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 46 i = SUM((/ 1, 2, 3 /)) ! returns 6 j = SUM(array, DIM = 1) ! returns [3 7 11] WRITE(*,*) i, j END 5、SEED Run-TimeSubroutine Changes the starting point of the pseudorandom numbergenerator. 改变随机数发生器的起始点 Module USE MSFLIB Syntax(语法) CALL SEED (iseed) iseed
(Input) INTEGER(4). Starting point for RANDOM. Remarks(注解) SEED uses iseed to establish the starting point ofthe pseudorandom number generator. A given seed always produces the samesequence of values from RANDOM. If SEED isnot called before the first call to RANDOM, RANDOM always beginswith a seed value of one. If a program must have a different pseudorandomsequence each time it runs, pass the constant RND$TIMESEED (defined inMSFLIB.F90) to the SEED routine before the first call to RANDOM. Example USE MSFLIB REAL rand CALLSEED(7531) CALL RANDOM(rand) 6、RANDOM Purpose Run-TimeSubroutine Returns apseudorandom number greater than or equal to zero and less than one from theuniform distribution. 返回大于或等于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 seedalways produces the same sequence of values from RANDOM. If SEED isnot called before the first call to RANDOM, RANDOM begins with aseed value of one. If a program must have a different pseudorandom sequenceeach time it runs, pass the constant RND$TIMESEED (defined inMSFLIB.F90) to SEED before the first call to RANDOM. All the randomprocedures (RANDOM, RAN, and RANDOM_NUMBER,and the PortLib functions DRAND, DRANDM, RAND, IRANDM,RAND, and RANDOM) use the same algorithms and thus return thesame answers. They are all compatible and can be used interchangeably. (Thealgorithm used is a “Prime Modulus M Multiplicative Linear CongruentialGenerator,” a modified version of the random number generator by Park andMiller in “Random Number Generators: Good Ones Are Hard to Find,” CACM, October1988, Vol. 31, No. 10.) Compatibility CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB Example USE MSFLIB REAL(4) ran CALLSEED(1995) CALLRANDOM(ran) 7、FFT2B Compute theinverse Fourier transform of a complex periodic two-dimensional array. 计算二维复数数组的逆傅里叶变换 Usage(用法) CALL FFT2B(NRCOEF, NCCOEF, COEF, LDCOEF, A, LDA) Arguments(参数) NRCOEF — The number of rows of COEF. (Input) 数组COEF的行数 NCCOEF — The number of columns of COEF. (Input) 数组COEF的列数 COEF — NRCOEF by NCCOEF complex array containing the Fourier coefficients to betransformed. (Input) NRCOEF行NCCOEF列数组 LDCOEF — Leading dimension of COEF exactly as specified in the dimension statement ofthe calling program. (Input) A — NRCOEF by NCCOEF complex array containing the Inverse Fouriercoefficients of COEF. (Output) NRCOEF行NCCOEF列复数数组,包含数组COEF的逆傅里叶系数 LDA — Leading dimension of A exactly as specified in the dimension statement ofthe calling program. (Input) Comments(注解) 1. Automatic workspace usage is FFT2B 4 * (NRCOEF + NCCOEF) + 32 + 2 * MAX(NRCOEF, NCCOEF) units, or DFFT2B 8 * (NRCOEF + NCCOEF ) + 64 + 4 * MAX(NRCOEF, NCCOEF) units. Workspace may beexplicitly provided, if desired, by use of F2T2B/DF2T2B. The reference is CALL F2T2B (NRCOEF, NCCOEF, A, LDA, COEF,LDCOEF,
WFF1,WFF2, CWK, CPY) The additionalarguments are as follows: WFF1 — Real array of length 4 * NRCOEF + 15 initialized by FFTCI. The initializationdepends on NRCOEF. (Input) WFF2 — Real array of length 4 * NCCOEF + 15 initialized by FFTCI. The initialization depends on NCCOEF. (Input) CWK — Complex array of length 1. (Workspace) CPY — Real array of length 2 * MAX(NRCOEF, NCCOEF). (Workspace) 2. The routine FFT2B is most efficient when NRCOEF and NCCOEF are the product of small primes. 3. The arrays COEF and A may be the same. 4. If FFT2D/FFT2B is used repeatedly, with the same values for NRCOEF and NCCOEF, then use FFTCI to fill WFF1(N = NRCOEF) and WFF2(N = NCCOEF). Follow this with repeated calls to F2T2D/F2T2B. This is more efficient than repeated calls to FFT2D/FFT2B. Algorithm The routine FFT2B computes the inverse discretecomplex Fourier transform of a complex two-dimensional array of size (NRCOEF = N) ′ (NCCOEF = M). The method used isa variant of the Cooley-Tukey algorithm , which is most efficient when Nand M are both products of small prime factors. If N and Msatisfy this condition, then the computational effort is proportional to NM log N M. This considerable savings has historically ledpeople to refer to this algorithm as the"fast Fourier transform" or FFT. Specifically,given an N ′ M array c = COEF, FFT2B returns in a file:///C:/Users/kingtansin/AppData/Local/Packages/oice_15_974fa576_32c1d314_f21/AC/Temp/msohtmlclip1/01/clip_image002.gif Furthermore, avector of Euclidean norm S is mapped into a vector of norm file:///C:/Users/kingtansin/AppData/Local/Packages/oice_15_974fa576_32c1d314_f21/AC/Temp/msohtmlclip1/01/clip_image003.gif Finally, notethat an unnormalized inverse is implemented in FFT2D. The routine FFT2B is based on the complex FFT inFFTPACK. The package FFTPACK was developed by Paul Swarztrauber at the NationalCenter for Atmospheric Research. Example In this example,we first compute the Fourier transform of the 5 ′ 4array file:///C:/Users/kingtansin/AppData/Local/Packages/oice_15_974fa576_32c1d314_f21/AC/Temp/msohtmlclip1/01/clip_image004.gif for 1 £ n£ 5and 1 £ m £ 4 using the IMSL routine FFT2D. The result file:///C:/Users/kingtansin/AppData/Local/Packages/oice_15_974fa576_32c1d314_f21/AC/Temp/msohtmlclip1/01/clip_image005.gif is then invertedby a call to FFT2B.Note that the result is an array a satisfying a = (5)(4)x = 20x.In general, FFT2B isan unnormalized inverse with expansion factor N M. INTEGER LDA, LDCOEF, M, N, NCA, NRA COMPLEX CMPLX, X(5,4), A(5,4), COEF(5,4) CHARACTER TITLE1*26, TITLE2*26,TITLE3*26 INTRINSIC CMPLX EXTERNAL FFT2B, FFT2D, WRCRN C TITLE1 = 'Theinput matrix is below ' TITLE2 ='After FFT2D ' TITLE3 ='After FFT2B ' NRA = 5 NCA = 4 LDA = 5 LDCOEF = 5 C Fill X withinitial data DO 20 N=1, NRA DO 10 M=1, NCA X(N,M)= CMPLX(FLOAT(N+5*M-5),0.0) 10 CONTINUE 20 CONTINUE C CALL WRCRN(TITLE1, NRA, NCA, X, LDA, 0) C CALL FFT2D(NRA, NCA, X, LDA, COEF, LDCOEF) C CALL WRCRN(TITLE2, NRA, NCA, COEF, LDCOEF, 0) C CALL FFT2B(NRA, NCA, COEF, LDCOEF, A, LDA) C CALL WRCRN(TITLE3, NRA, NCA, A, LDA, 0) C END Output Theinput matrix is below 1 2 3 4 1 ( 1.00, 0.00) ( 6.00, 0.00) ( 11.00, 0.00) ( 16.00, 0.00) 2 ( 2.00, 0.00) ( 7.00, 0.00) ( 12.00, 0.00) ( 17.00, 0.00) 3 ( 3.00, 0.00) ( 8.00, 0.00) ( 13.00, 0.00) ( 18.00, 0.00) 4 ( 4.00, 0.00) ( 9.00, 0.00) ( 14.00, 0.00) ( 19.00, 0.00) 5 ( 5.00, 0.00) ( 10.00, 0.00) ( 15.00, 0.00) ( 20.00, 0.00) After FFT2D 1 2 3 4 1 ( 210.0, 0.0) ( -50.0, 50.0) ( -50.0, 0.0) ( -50.0, -50.0) 2 ( -10.0, 13.8) ( 0.0, 0.0) ( 0.0, 0.0) ( 0.0, 0.0) 3 ( -10.0, 3.2) ( 0.0, 0.0) ( 0.0, 0.0) ( 0.0, 0.0) 4 ( -10.0, -3.2) ( 0.0, 0.0) ( 0.0, 0.0) ( 0.0, 0.0) 5 ( -10.0,-13.8) ( 0.0, 0.0) ( 0.0, 0.0) ( 0.0, 0.0) After FFT2B 1 2 3 4 1 ( 20.0, 0.0) ( 120.0, 0.0) ( 220.0, 0.0) ( 320.0, 0.0) 2 ( 40.0, 0.0) ( 140.0, 0.0) ( 240.0, 0.0) ( 340.0, 0.0) 3 ( 60.0, 0.0) ( 160.0, 0.0) ( 260.0, 0.0) ( 360.0, 0.0) 4 ( 80.0, 0.0) ( 180.0, 0.0) ( 280.0, 0.0) ( 380.0, 0.0) 5 ( 100.0, 0.0) ( 200.0, 0.0) ( 300.0, 0.0) ( 400.0, 0.0) 8、TIMEF Purpose PortLib Function Returns the number of seconds since the firsttime it is called, or zero. Module USE PORTLIB Syntax result = TIMEF( ) ReturnValue REAL(8). Numberof seconds that have elapsed since the first time TIMEF( ) was called.The first time called, TIMEF returns 0.0D0. Compatibility CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB Example USE PORTLIB INTEGER i, j REAL(8)elapsed_time elapsed_time= TIMEF() DO i = 1,100000 j = j + 1 END DO elapsed_time= TIMEF() PRINT *,elapsed_time END
|