-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolver.f90
50 lines (39 loc) · 1.11 KB
/
solver.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
program solver
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Program: solver
!
!
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use equations
use observer
implicit none
real, allocatable, dimension(:) :: state
real, allocatable, dimension(:) :: deltas
! get the delta-t and number of steps from the user
real :: dt = 0.01
integer :: nsteps = 2000
integer :: index
print *, "Enter delta t"
read(*,*) dt
print *, "Enter the number of steps to compute"
read(*,*) nsteps
print *, "dt:", dt, " steps:", nsteps
! open the data file for writing
call observer_init()
! get the state vector
allocate(state(get_system_size()))
allocate(deltas(get_system_size()))
call set_initial_state(state)
! save state to file
print *, 'state:', state
call observer_write(state)
do index = 1, nsteps, 1
deltas = f(dt, state)
state(:) = state(:) + deltas(:) * dt
call observer_write(state)
end do
! close data file
call observer_finalize()
end program solver