Skip to content

Commit 5953332

Browse files
committed
added original Fortran sources for PROGRAM1.
1 parent c083be1 commit 5953332

File tree

8 files changed

+498
-0
lines changed

8 files changed

+498
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# to run this program after it has been made, type
2+
# flinearad > output
3+
# to see the results after running, type
4+
# xmgrace output
5+
FC=gfortran
6+
flinearad : linaddmain.o consdiff.o linearad.o riemprob.o upwind.o
7+
$(FC) -o $@ linaddmain.o consdiff.o linearad.o riemprob.o \
8+
upwind.o
9+
clean :
10+
rm -f *.o flinearad
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
c***********************************************************************
2+
c Copyright 2006 John A. Trangenstein
3+
c
4+
c This software is made available for research and instructional use
5+
c only.
6+
c You may copy and use this software without charge for these
7+
c non-commercial purposes, provided that the copyright notice and
8+
c associated text is reproduced on all copies.
9+
c For all other uses (including distribution of modified versions),
10+
c please contact the author at
11+
c John A. Trangenstein
12+
c Department of Mathematics
13+
c Duke University
14+
c Durham, NC 27708-0320
15+
c USA
16+
c or
17+
18+
c
19+
c This software is made available "as is" without any assurance that it
20+
c is completely correct, or that it will work for your purposes.
21+
c Use the software at your own risk.
22+
c***********************************************************************
23+
subroutine consdiff(fic,lac,fif,laf,fix,lax,ifirst,ilast,
24+
& x,flux,
25+
& conservd)
26+
integer fic,lac,fif,laf,fix,lax,ifirst,ilast
27+
double precision
28+
& x(fix:lax+1),
29+
& flux(fif:laf+1)
30+
double precision
31+
& conservd(fic:lac)
32+
integer ic
33+
c ******************************************************************
34+
c update conservd to new time
35+
c ******************************************************************
36+
do ic=ifirst,ilast
37+
conservd(ic) = conservd(ic)
38+
& - (flux(ic+1)-flux(ic)) / (x(ic+1)-x(ic))
39+
enddo
40+
return
41+
end
42+
43+
function stabledt(fc,lc,fm,lm,ifirst,ilast,
44+
& conserved,lambda_cell,x)
45+
c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46+
include "./const.i"
47+
c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48+
double precision stabledt
49+
integer fc,lc,fm,lm,ifirst,ilast
50+
double precision conserved(fc:lc),lambda_cell(fc:lc),x(fm:lm+1)
51+
integer ic
52+
double precision abs_lambda,dx
53+
c ******************************************************************
54+
c compute stable timestep
55+
c ******************************************************************
56+
stabledt=huge
57+
do ic=ifirst,ilast
58+
abs_lambda=abs(lambda_cell(ic))
59+
dx = x(ic+1)-x(ic)
60+
if (abs_lambda.gt.roundoff*dx) then
61+
stabledt=min(stabledt,dx/abs_lambda)
62+
endif
63+
enddo
64+
c if (stabledt.le.0.) call abort()
65+
return
66+
end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
c***********************************************************************
2+
c Copyright 2006 John A. Trangenstein
3+
c
4+
c This software is made available for research and instructional use
5+
c only.
6+
c You may copy and use this software without charge for these
7+
c non-commercial purposes, provided that the copyright notice and
8+
c associated text is reproduced on all copies.
9+
c For all other uses (including distribution of modified versions),
10+
c please contact the author at
11+
c John A. Trangenstein
12+
c Department of Mathematics
13+
c Duke University
14+
c Durham, NC 27708-0320
15+
c USA
16+
c or
17+
18+
c
19+
c This software is made available "as is" without any assurance that it
20+
c is completely correct, or that it will work for your purposes.
21+
c Use the software at your own risk.
22+
c***********************************************************************
23+
c static char sccsid[] = "%W%\t%G%"
24+
double precision
25+
& roundoff,small,huge,undefind,lnrndoff,lnsmall
26+
integer ihuge,inhuge
27+
common/machine/roundoff,small,huge,undefind,lnrndoff,lnsmall,
28+
& ihuge,inhuge
29+
double precision
30+
& zero,sixtyfourth,thirtysecond,sixteenth,tenth,eighth,sixth,
31+
& fourth,third,point4,half,twothird,pt75,onemert2,rt75,one,
32+
& fourthir,onept5,two,three,pi,four,seven,nine,ten
33+
parameter (zero=0.d0)
34+
parameter (sixtyfourth=0.015625d0)
35+
parameter (thirtysecond=0.03125d0)
36+
parameter (sixteenth=0.0625d0)
37+
parameter (tenth=0.1d0)
38+
parameter (eighth=0.125d0)
39+
parameter (sixth=0.16666666666667d0)
40+
parameter (fourth=.25d0)
41+
parameter (third=.333333333333333d0)
42+
parameter (point4=.4d0)
43+
parameter (half=.5d0)
44+
parameter (twothird=.66666666666667d0)
45+
parameter (pt75=.75d0)
46+
parameter (onemert2=.75688326556578578920d0)
47+
parameter (rt75=.8660254037844d0)
48+
parameter (one=1.d0)
49+
parameter (fourthir=1.33333333333333d0)
50+
parameter (onept5=1.5d0)
51+
parameter (two=2.d0)
52+
parameter (three=3.d0)
53+
parameter (pi=3.14159265358979323846d0)
54+
parameter (four=4.d0)
55+
parameter (seven=7.d0)
56+
parameter (nine=9.d0)
57+
parameter (ten=10.d0)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
c***********************************************************************
2+
c Copyright 2006 John A. Trangenstein
3+
c
4+
c This software is made available for research and instructional use
5+
c only.
6+
c You may copy and use this software without charge for these
7+
c non-commercial purposes, provided that the copyright notice and
8+
c associated text is reproduced on all copies.
9+
c For all other uses (including distribution of modified versions),
10+
c please contact the author at
11+
c John A. Trangenstein
12+
c Department of Mathematics
13+
c Duke University
14+
c Durham, NC 27708-0320
15+
c USA
16+
c or
17+
18+
c
19+
c This software is made available "as is" without any assurance that it
20+
c is completely correct, or that it will work for your purposes.
21+
c Use the software at your own risk.
22+
c***********************************************************************
23+
program linaddmain
24+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25+
integer ncells
26+
! parameter (ncells=100)
27+
parameter (ncells=10000)
28+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29+
include "linearad.i"
30+
include "const.i"
31+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32+
double precision stabledt
33+
external stabledt
34+
35+
double precision
36+
& u(-2:ncells+1),
37+
& x(0:ncells),
38+
& flux(0:ncells),
39+
& dfdu(-2:ncells+1)
40+
c & flux_cell(-2:ncells+1),
41+
c & uside(0:ncells)
42+
integer nsteps
43+
double precision tmax,cfl
44+
45+
integer i,fc,lc,fm,lm,fs,ls,ifirst,ilast
46+
integer istep
47+
double precision dt,t
48+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49+
roundoff=1.d-14
50+
small=1.d-20
51+
huge=1.d300
52+
undefind=1.d300
53+
lnrndoff=14.d0
54+
lnsmall=20.d0
55+
56+
c problem-specific parameters:
57+
jump=0
58+
x_left=-0.2d0
59+
x_right=1.d0
60+
statelft=2.d0
61+
statergt=0.d0
62+
velocity=1.d0
63+
64+
nsteps=10000
65+
tmax=0.8d0
66+
cfl=0.9d0
67+
68+
c array bounds for subroutine calls:
69+
fc=-2
70+
lc=ncells+1
71+
fm=0
72+
lm=ncells-1
73+
fs=0
74+
ls=ncells-1
75+
ifirst=0
76+
ilast=ncells-1
77+
78+
c initialization:
79+
call initsl(ncells,fc,lc,fm,lm,ifirst,ilast, u,x)
80+
c do i=0,ncells
81+
c print *,"x(",i,") = ",x(i)
82+
c enddo
83+
c do i=-2,ncells+1
84+
c print *,"u(",i,") = ",u(i)
85+
c enddo
86+
call bcmesh(fm,lm,ncells, x)
87+
call bccells(fc,lc,ncells, u)
88+
call fluxderv(fc,lc,fc,lc, u, dfdu)
89+
90+
istep=0
91+
t=0.d0
92+
do while (istep.lt.nsteps .and. t.lt.tmax)
93+
call bccells(fc,lc,ncells, u)
94+
call fluxderv(fc,lc,fc,lc, u, dfdu)
95+
dt=cfl*stabledt(fc,lc,fm,lm,ifirst,ilast, u, dfdu,x)
96+
call method(dt,fc,lc,fm,lm,fs,ls,ifirst,ilast, u, flux)
97+
call consdiff(fc,lc,fs,ls,fm,lm,ifirst,ilast, x,flux, u)
98+
t=t+dt
99+
istep=istep+1
100+
enddo
101+
102+
c write results, plot later
103+
do i=0,ncells-1
104+
! print *,(x(i)+x(i+1))*0.5d0,u(i)
105+
enddo
106+
107+
stop
108+
end
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
c***********************************************************************
2+
c Copyright 2006 John A. Trangenstein
3+
c
4+
c This software is made available for research and instructional use
5+
c only.
6+
c You may copy and use this software without charge for these
7+
c non-commercial purposes, provided that the copyright notice and
8+
c associated text is reproduced on all copies.
9+
c For all other uses (including distribution of modified versions),
10+
c please contact the author at
11+
c John A. Trangenstein
12+
c Department of Mathematics
13+
c Duke University
14+
c Durham, NC 27708-0320
15+
c USA
16+
c or
17+
18+
c
19+
c This software is made available "as is" without any assurance that it
20+
c is completely correct, or that it will work for your purposes.
21+
c Use the software at your own risk.
22+
c***********************************************************************
23+
subroutine fluxderv(fc,lc,ifirst,ilast,
24+
& conservd,
25+
& dfdu )
26+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27+
include "const.i"
28+
include "linearad.i"
29+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30+
integer fc,lc,ifirst,ilast
31+
double precision conservd(fc:lc)
32+
c
33+
double precision dfdu(fc:lc)
34+
c
35+
integer ic
36+
c ******************************************************************
37+
c compute derivative of flux with respect to conserved variable
38+
c ******************************************************************
39+
do ic=ifirst,ilast
40+
dfdu(ic)=velocity
41+
enddo
42+
43+
return
44+
end
45+
46+
subroutine riemann(fs,ls,ifirst,ilast,
47+
& left,right,
48+
& flux)
49+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50+
include "linearad.i"
51+
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
52+
integer fs,ls,ifirst,ilast
53+
c
54+
double precision
55+
& left(fs:ls+1),
56+
& right(fs:ls+1)
57+
c
58+
double precision flux(fs:ls+1)
59+
integer ie
60+
c ******************************************************************
61+
c the following riemann solver is hard-wired for linear advection
62+
c with velocity > 0
63+
c ******************************************************************
64+
do ie=ifirst,ilast+1
65+
flux(ie)=velocity*left(ie)
66+
enddo
67+
return
68+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
c***********************************************************************
2+
c Copyright 2006 John A. Trangenstein
3+
c
4+
c This software is made available for research and instructional use
5+
c only.
6+
c You may copy and use this software without charge for these
7+
c non-commercial purposes, provided that the copyright notice and
8+
c associated text is reproduced on all copies.
9+
c For all other uses (including distribution of modified versions),
10+
c please contact the author at
11+
c John A. Trangenstein
12+
c Department of Mathematics
13+
c Duke University
14+
c Durham, NC 27708-0320
15+
c USA
16+
c or
17+
18+
c
19+
c This software is made available "as is" without any assurance that it
20+
c is completely correct, or that it will work for your purposes.
21+
c Use the software at your own risk.
22+
c***********************************************************************
23+
double precision jump,x_left,x_right,statelft,statergt,velocity,
24+
& dt_in
25+
common/linearad/jump,x_left,x_right,statelft,statergt,velocity,
26+
& dt_in

0 commit comments

Comments
 (0)