fork download
  1. program wave_single
  2. implicit none
  3. integer, parameter :: nx = 1024
  4. integer, parameter :: ny = 1024
  5. integer, parameter :: b_nx = 8
  6. integer, parameter :: b_ny = 8
  7. integer, parameter :: itterations = 10
  8.  
  9. integer :: i, j, k, itt, max_itt
  10. double precision :: dx, dy, dt
  11. double precision :: xmin, xmax, ymin, ymax
  12. double precision :: r, t_start, t_end
  13. double precision :: res, jac
  14. real :: start_time, stop_time
  15.  
  16. double precision, dimension(nx, ny) :: y0_n, y1_n, y0_np1
  17. double precision, dimension(nx,ny) :: y1_np1, temp0, temp1
  18. double precision, dimension(nx) :: x
  19. double precision, dimension(ny) :: y
  20.  
  21.  
  22. xmin = -10.0
  23. xmax = 10.0
  24. ymin = -10.0
  25. ymax = 10.0
  26. max_itt = itterations * nx/b_nx
  27.  
  28. dx = (xmax-xmin)/DBLE(nx-1)
  29. dy = (ymax-ymin)/DBLE(ny-1)
  30. dt = 0.1*(xmax-xmin)/DBLE(nx)
  31.  
  32. do i = 1, nx
  33. x(i) = xmin + (i-1)*dx
  34. enddo
  35.  
  36. do j = 1, ny
  37. y(j) = ymin + (j-1)*dy
  38. enddo
  39.  
  40. do i = 1, nx
  41. do j = 1, ny
  42. y0_n(i,j) = 0
  43. y1_n(i,j) = 0
  44. y0_np1(i,j) = 0
  45. y1_np1(i,j) = 0
  46. enddo
  47. enddo
  48.  
  49. do i = 2, nx-1
  50. do j = 2, ny-1
  51. y0_n(i,j) = dexp(-x(i)*x(i)-y(j)*y(j))
  52. y0_np1(i,j) = dexp(-x(i)*x(i)-y(j)*y(j))
  53. enddo
  54. enddo
  55.  
  56. call cpu_time(start_time)
  57.  
  58. do itt = 0, max_itt - 1
  59. do k = 0, 10
  60. do i = 2, nx-1
  61. do j = 2, ny-1
  62. res = (y0_np1(i,j) - y0_n(i,j))/dt &
  63. - 0.5*(y1_np1(i,j)+y1_n(i,j))
  64. jac = 1d0/dt
  65. temp0(i,j) = y0_np1(i,j) - res/jac
  66.  
  67. res = (y1_np1(i,j) - y1_n(i,j))/dt &
  68. -0.5*(y0_np1(i-1,j)-2*y0_np1(i,j)+y0_np1(i+1,j))/(dx**2) &
  69. -0.5*(y0_np1(i,j-1)-2*y0_np1(i,j)+y0_np1(i,j+1))/(dy**2) &
  70. -0.5*(y0_n(i-1,j)-2*y0_n(i,j)+y0_n(i+1,j))/(dx**2) &
  71. -0.5*(y0_n(i,j-1)-2*y0_n(i,j)+y0_n(i,j+1))/(dy**2)
  72. jac = 1d0/dt
  73. temp1(i,j) = y1_np1(i,j) - res/jac
  74. enddo
  75. enddo
  76.  
  77. do i = 2, nx-1
  78. do j = 2, ny-1
  79. y0_np1(i,j) = temp0(i,j)
  80. y1_np1(i,j) = temp1(i,j)
  81. enddo
  82. enddo
  83. enddo
  84.  
  85. do i = 1, nx
  86. do j = 1, ny
  87. res = y0_n(i,j)
  88. y0_n(i,j) = y0_np1(i,j)
  89. y0_np1(i,j) = res
  90.  
  91. res = y1_n(i,j)
  92. y1_n(i,j) = y1_np1(i,j)
  93. y1_np1(i,j) = res
  94. enddo
  95. enddo
  96. enddo
  97.  
  98. call cpu_time(stop_time)
  99. write(*,*) "total time: ", stop_time-start_time
  100.  
  101. !call print2d(y0_n,nx,ny)
  102. !call print2d(y1_n,nx,ny)
  103. !call print2d(y0_np1,nx,ny)
  104. !call print2d(y1_np1,nx,ny)
  105.  
  106. end
  107.  
  108. subroutine print2d(y, nx, ny)
  109. implicit none
  110. integer :: nx, ny, i, j
  111. double precision, dimension(nx,ny) :: y
  112.  
  113. do j = 1, ny
  114. do i = 1, nx
  115. if (y(i,j) > 0.05) then
  116. write(*,"(i2)",advance="no") 1
  117. elseif (y(i,j) < -0.05) then
  118. write(*,"(i2)",advance="no") -1
  119. else
  120. write(*,"(i2)", advance="no") 0
  121. endif
  122. enddo
  123. write(*,*) ""
  124. enddo
  125. write(*,*) ""
  126.  
  127. end
Time limit exceeded #stdin #stdout #stderr 5s 64272KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Program received signal SIGXCPU: CPU time limit exceeded.

Backtrace for this error:
#0  0x2b2b138f6d4a
#1  0x2b2b138f5f7d
#2  0x2b2b1438e03f
#3  0x5627bf7e5217
#4  0x5627bf7e58b3
#5  0x2b2b1437b2b0
#6  0x5627bf7e4929
#7  0xffffffffffffffff