add tugas3

This commit is contained in:
gabrielkheisa 2022-11-14 14:45:53 +07:00
parent 599f6846ce
commit 03cf2abf2e
2 changed files with 39 additions and 0 deletions

27
tugas3.f90 Normal file
View File

@ -0,0 +1,27 @@
program sample3
use omp_lib
implicit real(8)(a-h,o-z)
parameter (n=4096)
real(8) a(n,n),c(n,n)
real(4) b(n,n)
real*8 t1, t2
a=0.0d0
call random_number(b)
call random_number(c)
write(6,50) 'Matrix Size = ', n
50 format(1x,a,i5)
t1 = omp_get_wtime()
!$OMP parallel do
do j=1,n
do k=1,n
do i=1,n
a(i,j)=a(i,j)+b(i,k)*c(k,j)
end do
end do
end do
!$OMP end parallel do
write(6,60) 'Execution Time = ', t2-t1, ' sec','A(n,n) = ',a(n,n)
60 format(1x,a,f10.3,a,1x,a,d24.15)
stop
end

12
tugas3.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --time=00:01:10
#SBATCH --job-name=Gabriel
whoami
hostname
gfortran -fopenmp tugas3.f90 -o tugas3.x
export OMP_NUM_THREADS=4
./tugas3.x