Original files from Nvidia for the OpenACC course:
OpenACC - 2X in 4 Steps in C/C++
This commit is contained in:
46
lab1/FORTRAN/task1/task1.f90
Normal file
46
lab1/FORTRAN/task1/task1.f90
Normal file
@ -0,0 +1,46 @@
|
||||
program main
|
||||
use openacc
|
||||
implicit real(4) (A-H,O-Z)
|
||||
integer, parameter :: NN = 1024
|
||||
integer, parameter :: NM = 1024
|
||||
|
||||
real(4) A(NN,NM), Anew(NN,NM)
|
||||
iter_max = 1000
|
||||
tol = 1.0e-6
|
||||
error = 1.0
|
||||
|
||||
A(1,:) = 1.0
|
||||
A(2:NN,:) = 0.0
|
||||
Anew(1,:) = 1.0
|
||||
Anew(2:NN,:) = 0.0
|
||||
|
||||
print 100,NN,NM
|
||||
|
||||
call cpu_time(t1)
|
||||
iter = 0
|
||||
do while ( (error > tol) .and. (iter < iter_max) )
|
||||
error = 0.0
|
||||
do j = 2, NM-1
|
||||
do i = 2, NN-1
|
||||
Anew(i,j) = 0.25 * ( A(i+1,j) + A(i-1,j) + &
|
||||
A(i,j-1) + A(i,j+1) )
|
||||
error = max( error, abs(Anew(i,j) - A(i,j)) )
|
||||
end do
|
||||
end do
|
||||
|
||||
do j = 2, NM-1
|
||||
do i = 2, NN-1
|
||||
A(i,j) = Anew(i,j)
|
||||
end do
|
||||
end do
|
||||
|
||||
if(mod(iter,100) == 0) print 101,iter,error
|
||||
iter = iter + 1
|
||||
end do
|
||||
call cpu_time(t2)
|
||||
print 102,t2-t1
|
||||
|
||||
100 format("Jacobi relaxation Calculation: ",i4," x ",i4," mesh")
|
||||
101 format(2x,i4,2x,f9.6)
|
||||
102 format("total: ",f9.6," s")
|
||||
end program
|
BIN
lab1/FORTRAN/task1/task1_out.exe
Normal file
BIN
lab1/FORTRAN/task1/task1_out.exe
Normal file
Binary file not shown.
17
lab1/FORTRAN/task1/times
Normal file
17
lab1/FORTRAN/task1/times
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
Profile output - Thu Apr 03 10:52:44 CDT 2014
|
||||
Program : task1_out
|
||||
Datafile : pgprof.out
|
||||
Process : 0
|
||||
Total Time for Process : 0.000000 secs
|
||||
Sort by max time
|
||||
Select all
|
||||
|
||||
|
||||
Routine Source Line
|
||||
Calls Time(%) seconds(%) Name File No.
|
||||
|
||||
0 0 100 main task1.f90 1
|
||||
0 0 0 pgimain <unknown> 2,147,483,647
|
||||
0 0 0 [System_Time] <unknown> 2,147,483,647
|
||||
|
Reference in New Issue
Block a user