fortran中CPU_TIME计时程序
program mainimplicit none
real(kind=4)::t1_real, t2_real
integer i, j ,k
call CPU_TIME(t1_real)
do i = 1,10000
do j = 1,10000
k = j
end do
end do
call CPU_TIME(t2_real)
write(*,*) "count1",t1_real
write(*,*) "count2",t2_real
write(*,*) "时间",t2_real - t1_real
end program
以上程序的输出结果为: count10.0000000E+00
count23.1250000E-02
时间3.1250000E-02
当我把以上程序写入abaqus子程序中:
subroutine umat(stress,statev,ddsdde,sse,spd,scd,......)
...
...
...
...
real(kind=4) :: t1_real, t2_real
integeri,j,k
...
...
...
...
call CPU_TIME(t1_real)
do i = 1,10000
do j = 1,10000
k = j
end do
end do
call CPU_TIME(t2_real)
write(*,*) "count1",t1_real !默认输出在log文件里
write(*,*) "count2",t2_real !默认输出在log文件里
write(*,*) "时间",t2_real - t1_real !默认输出在log文件里
...
...
...
...
end
在log文件中查看输出结果:
count1 6.250000
count2 6.250000
时间0.0000000E+00
count1 6.250000
count2 6.250000
时间0.0000000E+00
....
....
...
所有的 count1和count2都相等,时间为0.是由于某些原因CPU_TIME函数在abaqus子程序中失效了吗?
可能你的umat是用release编译的,开了优化。而主程序代码是debug编译的,没有开优化。
一旦你开启了优化,你的代码
do i = 1,10000
do j = 1,10000
k = j
end do
end do
就可能自动被优化为 k=10000 这句代码。
页:
[1]