f90boy 2024-04-25 23:19 采纳率: 65%
浏览 7
已结题

求一段fortran代码用IVF编译运行的结果

求这段 fortran90 代码用较新版本 intel fortran 编译运行的结果。因为我没有购买和安装该编译器,请各位程序员提供实机、实际编译运行结果,以便我对代码效率进行评估。
要求:
1、以 intel fortran 编译器进行实机、实际编译运行,编译优化参数为 -O3 ;
2、将实际运行结果截屏,并和运行电脑的 CPU 主频参数一起反馈给我;
3、请不要用 AI 工具作答,需要实机实测
谢谢!

module abc
type big_integer
integer*1 a(63)
integer*1 digit
end type
type(big_integer) s(9,60,0:60)
type(big_integer) tt(10),t1,t2
integer*1 b(9),b1
integer*1 nn,mm
integer*1 nb(10)
integer*1 a(9)
character*60 h
end module
use abc
integer*1 n
call cpu_time(x)
call init
do nn=1,39
write(*,'(2x,a,g0)') 'n = ',nn
call equ(tt(10),0_1)
nb(10)=nn
n=9
call cc(n)
end do
call cpu_time(x)
nt=x*1000
write(*,'(/2x,a,g0,a)') 'time = ',nt,' ms'
write(*,'(2x,a,g0)') 'total = ',mm
end
recursive subroutine cc(n)
use abc
integer*1 n,i,j,k,ii
do i=nb(n+1),0,-1
a(n)=i
nb(n)=nb(n+1)-i
call add(tt(n+1),s(n,nn,i),tt(n))
if(tt(n)%digit.gt.nn) then
cycle
else if(tt(n)%digit.lt.nn) then
call add(tt(n),s(n-1,nn,nb(n)),t2)
if(t2%digit.lt.nn) exit
end if
if(n.gt.1) then
k=s(n-1,nn,nb(n))%digit
if(s(n-1,nn,nb(n))%a(k)+tt(n)%a(k).ge.9) k=k+1
do ii=k,nn
if(tt(n)%a(ii).ne.9) exit
end do
b=0
b1=0
do j=ii+1,nn
k=tt(n)%a(j)
if(k.ge.n) then
b(k)=b(k)+1
if(b(k).gt.a(k)) exit
else
b1=b1+1
if(b1.gt.nb(n)) exit
end if
end do
if(j.le.nn) cycle
call cc(n-1_1)
else
b=0
b1=0
do j=1,nn
k=tt(n)%a(j)
if(k.gt.0) then
b(k)=b(k)+1
if(b(k).gt.a(k)) exit
else
b1=b1+1
if(b1.gt.nb(n)) exit
end if
end do
if(j.le.nn) cycle
call chr(tt(n),h)
if(h.eq.'0') cycle
write(*,'(2x,a)') trim(h)
mm=mm+1
end if
end do
end
subroutine equ(aa,n)
use abc
type(big_integer) aa
integer*1 n
aa%a=0
aa%digit=1
aa%a(1)=n
end
subroutine mul(aa,bb,n)
use abc
type(big_integer) aa,bb
integer*2 k,k1,kn
integer*1 i,ii,n
if(n.eq.0.or.aa%digit.eq.1.and.aa%a(1).eq.0) then
call equ(bb,0_1)
return
else if(n.eq.1) then
bb=aa
return
end if
bb%a=0
k1=0
ii=aa%digit
kn=n
do i=1,ii+3
k=aa%a(i)*kn+k1
bb%a(i)=mod(k,10)
k1=k/10
end do
bb%digit=ii
if(bb%a(ii+1).ne.0) bb%digit=ii+1
if(bb%a(ii+2).ne.0) bb%digit=ii+2
end
subroutine add(aa,bb,cc)
use abc
type(big_integer) aa,bb,cc
integer*1 k,k1,i,ii
if(aa%digit.eq.1.and.aa%a(1).eq.0) then
cc=bb
return
end if
if(bb%digit.eq.1.and.bb%a(1).eq.0) then
cc=aa
return
end if
cc%a=0
k1=0
ii=max(aa%digit,bb%digit)
do i=1,ii+1
k=aa%a(i)+bb%a(i)+k1
cc%a(i)=k
k1=0
if(k.ge.10) then
cc%a(i)=k-10
k1=1
end if
end do
cc%digit=ii
if(cc%a(ii+1).gt.0) cc%digit=ii+1
end
subroutine chr(aa,hh)
use abc
character*60 hh
type(big_integer) aa
integer*1 ii,j
hh=' '
ii=aa%digit
do j=1,ii
hh(ii-j+1:ii-j+1)=char(48+aa%a(j))
end do
end
subroutine init
use abc
type(big_integer) s1,s2
integer*1 i,j,k
do i=1,9
call equ(s1,1_1)
do j=1,60
call mul(s1,s2,i)
s1=s2
do k=0,60
call mul(s1,s(i,j,k),k)
end do
end do
end do
end
  • 写回答

13条回答 默认 最新

  • 地球屋里老师 2024-04-26 09:13
    关注

    操作系统: win10
    CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz 3.60
    编译器:Intel fortran oneAPI,O3优化
    运行时间:win下耗时 3312ms, 同一台电脑 WSL Ubuntu 中运行耗时 2997ms
    另外:最新的intel fortran编译器改名叫 oneAPI,完全免费,可参考配置视频:https://www.bilibili.com/video/BV1oh411o7AT?p=1

    img

    
    ```c
      n = 1
      9
      8
      7
      6
      5
      4
      3
      2
      1
      n = 2
      n = 3
      407
      371
      370
      153
      n = 4
      9474
      8208
      1634
      n = 5
      93084
      92727
      54748
      n = 6
      548834
      n = 7
      9926315
      9800817
      4210818
      1741725
      n = 8
      88593477
      24678051
      24678050
      n = 9
      912985153
      534494836
      472335975
      146511208
      n = 10
      4679307774
      n = 11
      94204591914
      82693916578
      49388550606
      44708635679
      42678290603
      40028394225
      32164049651
      32164049650
      n = 12
      n = 13
      n = 14
      28116440335967
      n = 15
      n = 16
      4338281769391371
      4338281769391370
      n = 17
      35875699062250035
      35641594208964132
      21897142587612075
      n = 18
      n = 19
      4929273885928088826
      4498128791164624869
      3289582984443187032
      1517841543307505039
      n = 20
      63105425988599693916
      n = 21
      449177399146038697307
      128468643043731391252
      n = 22
      n = 23
      35452590104031691935943
      28361281321319229463398
      27907865009977052567814
      27879694893054074471405
      21887696841122916288858
      n = 24
      239313664430041569350093
      188451485447897896036875
      174088005938065293023722
      n = 25
      4422095118095899619457938
      3706907995955475988644381
      3706907995955475988644380
      1553242162893771850669378
      1550475334214501539088894
      n = 26
      n = 27
      177265453171792792366489765
      174650464499531377631639254
      128851796696487777842012787
      121270696006801314328439376
      121204998563613372405438066
      n = 28
      n = 29
      23866716435523975980390369295
      19008174136254279995012734741
      19008174136254279995012734740
      14607640612971980372614873089
      n = 30
      n = 31
      2309092682616190307509695338915
      1927890457142960697580636236639
      1145037275765491025924292050346
      n = 32
      17333509997782249308725103962772
      n = 33
      186709961001538790100634132976991
      186709961001538790100634132976990
      n = 34
      1122763285329372541592822900204593
      n = 35
      12679937780272278566303885594196922
      12639369517103790328947807201478392
      n = 36
      n = 37
      1219167219625434121569735803609966019
      n = 38
      12815792078366059955099770545296129367
      n = 39
      115132219018763992565095597973971522401
      115132219018763992565095597973971522400
    
      time = 3312 ms
      total = 88
    
    
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(12条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 4月26日
  • 已采纳回答 4月26日
  • 修改了问题 4月26日
  • 修改了问题 4月26日
  • 展开全部

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题