ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:98.62KB ,
资源ID:22136320      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22136320.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(intelvisualfortran在visualstudio中如何正常的使用openmp并行程序文档格式.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

intelvisualfortran在visualstudio中如何正常的使用openmp并行程序文档格式.docx

1、 However, the parallel version computes the sum in a different order than the serial version; some of the quantities added are quite small, and so this will affect the accuracy of the results. Modified: 29 January 2003 Author: John Burkardt A FORTRAN 90 module may be available: use omp_lib A FORTRAN

2、 77 include file may be available: include omp_lib.h implicit none integer, parameter : r4_logn_max = 9 integer id integer nthreads integer omp_get_num_procs integer omp_get_num_threads integer omp_get_thread_num call timestamp ( ) write ( *, (a) ) TEST_OMP FORTRAN90 version Estimate the value of PI

3、 by summing a series. This program includes Open MP directives, which may be used to run the program in parallel. The number of processors available:(a,i8) OMP_GET_NUM_PROCS () = , omp_get_num_procs ( ) nthreads = 4(a,i8,a) Call OMP_SET_NUM_THREADS, and request , & nthreads, threads. call omp_set_nu

4、m_threads ( nthreads ) Note that the call to OMP_GET_NUM_THREADS will always return 1 if called outside a parallel region!$OMP parallel private ( id ) id = omp_get_thread_num ( )(a,i3) This is process , id if ( id = 0 ) then Calling OMP_GET_NUM_THREADS inside a parallel region, we get the number of

5、threads is , omp_get_num_threads ( ) end if$OMP end parallel call r4_test ( r4_logn_max ) Normal end of execution. stopendsubroutine r4_test ( logn_max ) R4_TEST estimates the value of PI using single precision. PI is estimated using N terms. N is increased from 102 to 10LOGN_MAX. The calculation is

6、 repeated using both sequential and Open MP enabled code. Wall clock time is measured by calling SYSTEM_CLOCK. 06 January 2003 integer clock_max integer clock_rate integer clock_start integer clock_stop real error real estimate integer logn integer logn_max character ( len = 3 ) mode integer n real

7、r4_pi real timeR4_TEST: Estimate the value of PI, using single precision arithmetic. N = number of terms computed and added; ESTIMATE = the computed estimate of PI; ERROR = ( the computed estimate - PI ); TIME = elapsed wall clock time; Note that you cant increase N forever, because: A) ROUNDOFF sta

8、rts to be a problem, and B) maximum integer size is a problem.(a,i12) The maximum integer: , huge ( n ) N Mode Estimate Error Time n = 1 do logn = 2, logn_max mode = OMP call system_clock ( clock_start, clock_rate, clock_max ) call r4_pi_est_omp ( n, estimate ) call system_clock ( clock_stop, clock_

9、rate, clock_max ) time = real ( clock_stop - clock_start ) / real ( clock_rate ) error = abs ( estimate - r4_pi ( ) )( i12, 2x, a3, 2x, f14.10, 2x, g14.6, 2x, g14.6 ) ) & n, mode, estimate, error, time n = n * 10 end do returnsubroutine r4_pi_est_omp ( n, estimate ) R4_PI_EST_OMP estimates the value

10、 of PI, using Open MP. The calculation is based on the formula for the indefinite integral: Integral 1 / ( 1 + X*2 ) dx = Arctan ( X ) Hence, the definite integral Integral ( 0 = X = 1 ) 1 / ( 1 + X*2 ) dx = Arctan ( 1 ) - Arctan ( 0 ) = PI / 4. A standard way to approximate an integral uses the mid

11、point rule. If we create N equally spaced intervals of width 1/N, then the midpoint of the I-th interval is X(I) = (2*I-1)/(2*N). The approximation for the integral is then: Sum ( 1 = I = N ) (1/N) * 1 / ( 1 + X(I)*2 ) In order to compute PI, we multiply this by 4; we also can pull out the factor of

12、 1/N, so that the formula you see in the program looks like: ( 4 / N ) * Sum ( 1 = N ) 1 / ( 1 + X(I)*2 ) Until roundoff becomes an issue, greater accuracy can be achieved by increasing the value of N. Parameters: Input, integer N, the number of terms to add up. Output, real ESTIMATE, the estimated

13、value of pi. real h integer i real sum2 real x h = 1.0E+00 / real ( 2 * n ) sum2 = 0.0E+00$OMP parallel do private(x) shared(h) reduction(+: sum2) do i = 1, n x = h * real ( 2 * i - 1 ) sum2 = sum2 + 1.0E+00 / ( 1.0E+00 + x*2 ) estimate = 4.0E+00 * sum2 / real ( n )function r4_pi ( ) R4_PI returns t

14、he value of pi. 02 February 2000 Output, real R4_PI, the value of pi. r4_pi = 3.14159265358979323846264338327950288419716939937510E+00subroutine timestamp ( ) TIMESTAMP prints the current YMDHMS date as a time stamp. Example: May 31 2001 9:45:54.872 AM 31 May 2001 None character ( len = 8 ) ampm int

15、eger d character ( len = 8 ) date integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) : month = (/ &January , February March April May June July August SeptemberOctober November December /) integer s character ( len = 10 ) time integer values(8) integer y character ( len =

16、 5 ) zone call date_and_time ( date, time, zone, values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h 12 ) then ampm = AM else if ( h = 12 ) then if ( n = 0 .and. s = 0 ) thenNoon elsePM h = h - 12Midnight(a,1x,i2,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a) trim ( month(m) ), d, y, h, , n, , s, ., mm, trim ( ampm )=COPY上面的程序,可以完全运行成功,运行界面如下:

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1