Debian Codegraph @

src/exact_wave.f90

raw
1 !-----------------------------------------------------------------
2 !
3 ! This file is (or was) part of SPLASH, a visualisation tool
4 ! for Smoothed Particle Hydrodynamics written by Daniel Price:
5 !
6 ! http://users.monash.edu.au/~dprice/splash
7 !
8 ! SPLASH comes with ABSOLUTELY NO WARRANTY.
9 ! This is free software; and you are welcome to redistribute
10 ! it under the terms of the GNU General Public License
11 ! (see LICENSE file for details) and the provision that
12 ! this notice remains intact. If you modify this file, please
13 ! note section 2a) of the GPLv2 states that:
14 !
15 ! a) You must cause the modified files to carry prominent notices
16 ! stating that you changed the files and the date of any change.
17 !
18 ! Copyright (C) 2005-2009 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 ! ----------------------------------------------------------------------
24 ! compute exact solution for a linear wave
25 ! plots a sine function with a given amplitude, period and wavelength
26 ! ----------------------------------------------------------------------
27 module wave
28 implicit none
29
30 contains
31
32 subroutine exact_wave(time,ampl,period,lambda,x0,ymean,xplot,yplot,ierr)
33 integer :: i
34 real, parameter :: pi = 3.1415926536
35 real, intent(in) :: time, ampl, period, lambda, x0, ymean
36 real, intent(in), dimension(:) :: xplot
37 real, intent(out), dimension(size(xplot)) :: yplot
38 integer, intent(out) :: ierr
39 real :: omega
40
41 print*,'plotting sine wave... mean = ',ymean
42 print*,' lambda = ',lambda,' ampl = ',ampl,' period = ',period
43 !
44 ! check for errors
45 !
46 ierr = 0
47 if (lambda <= 0.) then
48 print*,'error: lambda <= 0'
49 ierr = 1
50 return
51 endif
52 if (abs(period) > tiny(period)) then
53 omega = 2.*pi/period
54 else
55 print*,'warning: period <= 0'
56 omega = 0.
57 endif
58
59 do i=1,size(xplot)
60 if (abs(ymean) <= 0.) then
61 yplot(i) = ymean + ampl*sin(2.*pi/lambda*(xplot(i)-x0) - omega*time)
62 else
63 yplot(i) = ymean*(1. + ampl*sin(2.*pi/lambda*(xplot(i)-x0) - omega*time))
64 endif
65 enddo
66
67 return
68 end subroutine exact_wave
69
70 end module wave