reference_test.f90 1.88 KB
Newer Older
1 2 3 4

program test_systems 

  use dataStructure, only : dstruc, systems_generation
Rémy Mozul's avatar
Rémy Mozul committed
5
  use LinearAlgebra, only : init, declare, build, solve, erase, finalize
6 7 8 9 10 11 12 13 14 15

  implicit none

  ! number of systems
  integer(kind=4), parameter :: nb_systems = 16
  ! list of sparse systems
  type(dstruc), dimension(nb_systems) :: systems
  !
  integer(kind=4) :: i_sys, info

Rémy Mozul's avatar
Rémy Mozul committed
16 17
  call init()

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  call systems_generation(systems)

  !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i_sys)
  !$OMP DO SCHEDULE(RUNTIME)
  do i_sys = 1, nb_systems
    call declare( systems(i_sys)%sparse_sys, systems(i_sys)%nb_dofs, &
                  systems(i_sys)%nb_nz, systems(i_sys)%i_ind       , &
                  systems(i_sys)%j_ind, systems(i_sys)%sym, info     )
    if( info /= 0 ) then
      print *, 'Error when declaring system : ', i_sys
      stop 1
    end if
  end do
  !$OMP END DO
  !$OMP END PARALLEL
  
  !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i_sys)
  !$OMP DO SCHEDULE(RUNTIME)
  do i_sys = 1, nb_systems
    call build( systems(i_sys)%sparse_sys, systems(i_sys)%val, info)
    if( info /= 0 ) then
      print *, 'Error when building system : ', i_sys
      stop 2
    end if
  end do
  !$OMP END DO
  !$OMP END PARALLEL
  
  !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i_sys)
  !$OMP DO SCHEDULE(RUNTIME)
  do i_sys = 1, nb_systems
    call solve( systems(i_sys)%sparse_sys, systems(i_sys)%rhs, info)
    print *, i_sys, systems(i_sys)%rhs
    if( info /= 0 ) then
      print *, 'Error when solving system : ', i_sys
      stop 3
    end if
  end do
  !$OMP END DO
  !$OMP END PARALLEL
  
  !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i_sys)
  !$OMP DO SCHEDULE(RUNTIME)
  do i_sys = 1, nb_systems
    deallocate(systems(i_sys)%i_ind)
    deallocate(systems(i_sys)%j_ind)
    deallocate(systems(i_sys)%val)
    deallocate(systems(i_sys)%rhs)
    call erase( systems(i_sys)%sparse_sys)
  end do
  !$OMP END DO
  !$OMP END PARALLEL
  
Rémy Mozul's avatar
Rémy Mozul committed
71 72
  call finalize()

73
end program