forked from csc-training/summerschool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.F90
54 lines (39 loc) · 1.28 KB
/
core.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
! Main solver routines for heat equation solver
module core
use heat
contains
! Exchange the boundary data between MPI tasks
subroutine exchange(field0, parallel)
implicit none
type(field), intent(inout) :: field0
type(parallel_data), intent(in) :: parallel
integer :: ierr
! TODO start: implement halo exchange
! Send to left, receive from right
! Send to right, receive from left
! TODO end
end subroutine exchange
! Compute one time step of temperature evolution
! Arguments:
! curr (type(field)): current temperature values
! prev (type(field)): values from previous time step
! a (real(dp)): update equation constant
! dt (real(dp)): time step value
subroutine evolve(curr, prev, a, dt)
implicit none
type(field), intent(inout) :: curr, prev
real(dp) :: a, dt
integer :: i, j, nx, ny
nx = curr%nx
ny = curr%ny
do j = 1, ny
do i = 1, nx
curr%data(i, j) = prev%data(i, j) + a * dt * &
& ((prev%data(i-1, j) - 2.0 * prev%data(i, j) + &
& prev%data(i+1, j)) / curr%dx**2 + &
& (prev%data(i, j-1) - 2.0 * prev%data(i, j) + &
& prev%data(i, j+1)) / curr%dy**2)
end do
end do
end subroutine evolve
end module core