Debian Codegraph @

src/libexact.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-2020 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 !-------------------------------------------------------------------------
24 ! Module providing library version of splash exact routines
25 ! specifies c interfaces to corresponding Fortran subroutines
26 !-------------------------------------------------------------------------
27 module libexact
28
29 use shock, only:exact_shock
30 use shock_sr, only:exact_shock_sr
31 use sedov, only:exact_sedov
32 use polytrope, only:exact_polytrope
33 use toystar1D, only:exact_toystar1D
34 use toystar2D, only:exact_toystar2D
35 use gresho, only:exact_gresho
36 use mhdshock, only:exact_mhdshock
37 use rhoh, only:exact_rhoh
38 use densityprofiles, only:exact_densityprofiles
39 use torus, only:exact_torus
40 use ringspread, only:exact_ringspread
41 use dustywaves, only:exact_dustywave
42 use rochelobe, only:exact_rochelobe
43 use cshock, only:exact_cshock
44 use planetdisc, only:exact_planetdisc
45 use bondi, only:exact_bondi
46 use libutils, only:check_argcv, c_real
47 use iso_c_binding, only:c_int, c_bool
48
49 implicit none
50
51 public
52
53 contains
54 subroutine check_argcv_c() bind(c, name='check_argcv')
55 call check_argcv()
56 end subroutine check_argcv_c
57
58 subroutine shock_c(iplot,npart,time,gamma,xshock,rho_L,rho_R,p_L,p_R,v_L,v_R,&
59 rdust_to_gas,xplot,yplot,ierr) bind(c, name='_shock')
60 integer(c_int), intent(in) :: iplot, npart
61 integer(c_int), intent(out) :: ierr
62 real(c_real), intent(in) :: time,gamma,xshock
63 real(c_real), intent(in) :: rho_L,rho_R,p_L,p_R,v_L,v_R,rdust_to_gas
64 real(c_real), intent(in) :: xplot(npart)
65 real(c_real), intent(out) :: yplot(npart)
66
67 call exact_shock(iplot,time,gamma,xshock,rho_L,rho_R,p_L,p_R,v_L,v_R,&
68 rdust_to_gas,xplot,yplot,ierr)
69
70 end subroutine shock_c
71
72 subroutine shock_sr_c(iplot,npart,time,gamma,rho_L,rho_R,p_L,p_R,v_L,v_R,&
73 xplot,yplot,ierr) bind(c, name='_shock_sr')
74 integer(c_int), intent(in) :: iplot, npart
75 integer(c_int), intent(out) :: ierr
76 real(c_real), intent(in) :: time,gamma
77 real(c_real), intent(in) :: rho_L,rho_R,p_L,p_R,v_L,v_R
78 real(c_real), intent(inout) :: xplot(npart)
79 real(c_real), intent(out) :: yplot(npart)
80
81 call exact_shock_sr(iplot,time,gamma,rho_L,rho_R,p_L,p_R,v_L,v_R,xplot,yplot,ierr)
82
83 end subroutine shock_sr_c
84
85 subroutine sedov_c(iplot,npart,time,gamma,rhozero,energy,rmax,&
86 rplot,yplot,ierr) bind(c, name='_sedov')
87 integer(c_int), intent(in) :: iplot, npart
88 integer(c_int), intent(out) :: ierr
89 real(c_real), intent(in) :: time,gamma
90 real(c_real), intent(in) :: rhozero,energy,rmax
91 real(c_real), intent(inout) :: rplot(npart)
92 real(c_real), intent(out) :: yplot(npart)
93
94 call exact_sedov(iplot,time,gamma,rhozero,energy,rmax,rplot,yplot,ierr)
95
96 end subroutine sedov_c
97
98 subroutine polytrope_c(npart,gamma,polyk,totmass,rplot,yplot,&
99 npartout,ierr) bind(c, name='_polytrope')
100 integer(c_int), intent(in) :: npart
101 integer(c_int), intent(out) :: ierr,npartout
102 real(c_real), intent(in) :: gamma,polyk,totmass
103 real(c_real), intent(inout) :: rplot(npart)
104 real(c_real), intent(out) :: yplot(npart)
105
106 call exact_polytrope(gamma,polyk,totmass,rplot,yplot,npartout,ierr)
107
108 end subroutine polytrope_c
109
110 subroutine toystar1D_c(iplot,npart,time,gamma,H0,A0,C0,sigma,norder,&
111 xplot,yplot,ierr) bind(c, name='_toystar1D')
112 integer(c_int), intent(in) :: iplot,npart,norder
113 integer(c_int), intent(out) :: ierr
114 real(c_real), intent(in) :: time,gamma,sigma,H0,A0,C0
115 real(c_real), intent(inout) :: xplot(npart)
116 real(c_real), intent(out) :: yplot(npart)
117
118 call exact_toystar1D(iplot,time,gamma,H0,A0,C0,sigma,&
119 norder,xplot,yplot,npart,ierr)
120
121 end subroutine toystar1D_c
122
123 subroutine toystar2D_c(iplot,npart,time,gamma,polyk,totmass,ampl,&
124 denscentre,C0,jorder,morder,V11,V22,V12,V21,&
125 xplot,yplot,ierr) bind(c, name='_toystar2D')
126 integer(c_int), intent(in) :: iplot,npart,jorder,morder
127 integer(c_int), intent(out) :: ierr
128 real(c_real), intent(in) :: time,gamma,polyk,totmass,&
129 C0, ampl, denscentre,&
130 V11,V22,V12,V21
131 real(c_real), intent(inout) :: xplot(npart)
132 real(c_real), intent(out) :: yplot(npart)
133
134 call exact_toystar2D(iplot,time,gamma,polyk,totmass, &
135 ampl,denscentre,C0,jorder,morder, &
136 V11,V22,V12,V21,xplot,yplot,ierr)
137
138 end subroutine toystar2D_c
139
140 subroutine gresho_c(iplot,npart,xplot,yplot,ierr) bind(c, name='_gresho')
141 integer(c_int), intent(in) :: iplot,npart
142 integer(c_int), intent(out) :: ierr
143 real(c_real), intent(in) :: xplot(npart)
144 real(c_real), intent(out) :: yplot(npart)
145
146 call exact_gresho(iplot,xplot,yplot,ierr)
147 end subroutine gresho_c
148
149 subroutine mhdshock_c(iplot,npart,ishk,time,gamma,xmin,xmax,xshock,&
150 xplot,yplot,npts,ierr) bind(c, name='_mhdshock')
151 integer(c_int), intent(in) :: iplot,npart,ishk
152 integer(c_int), intent(out) :: npts,ierr
153 real(c_real), intent(in) :: time,gamma,xmin,xmax,xshock
154 real(c_real), intent(inout) :: xplot(npart)
155 real(c_real), intent(out) :: yplot(npart)
156
157 call exact_mhdshock(iplot,ishk,time,gamma,xmin,xmax,xshock,xplot,yplot,npts,ierr)
158
159 end subroutine mhdshock_c
160
161 subroutine rhoh_c(iplot,npart,ndim,hfact,pmassval,&
162 xplot,yplot,ierr) bind(c, name='_rhoh')
163 integer(c_int), intent(in) :: iplot,ndim,npart
164 integer(c_int), intent(out) :: ierr
165 real(c_real), intent(in) :: hfact,pmassval
166 real(c_real), intent(in) :: xplot(npart)
167 real(c_real), intent(out) :: yplot(npart)
168
169 call exact_rhoh(iplot,ndim,hfact,pmassval,xplot,yplot,ierr)
170
171 end subroutine rhoh_c
172
173 subroutine densityprofiles_c(iplot,npart,iprofile,Mspherex,Mspherey,&
174 rsoftx,rsofty,xplot,yplot,ierr)&
175 bind(c, name='_denstyprofiles')
176 integer(c_int), intent(in) :: iplot,iprofile,npart
177 integer(c_int), intent(out) :: ierr
178 real(c_real), intent(in) :: Mspherex,Mspherey,rsoftx,rsofty
179 real(c_real), intent(in) :: xplot(npart)
180 real(c_real), intent(out) :: yplot(npart)
181
182 call exact_densityprofiles(iplot,iprofile,[Mspherex,Mspherey],&
183 [rsoftx,rsofty],xplot,yplot,ierr)
184
185 end subroutine densityprofiles_c
186
187 subroutine torus_c(iplot,npart,itorus,Mstar,Rtorus,AA,distortion,&
188 gamma,xplot,yplot,ierr) bind(c, name='_torus')
189 integer(c_int), intent(in) :: iplot,itorus,npart
190 integer(c_int), intent(out) :: ierr
191 real(c_real), intent(in) :: Mstar,Rtorus,AA,gamma,distortion
192 real(c_real), intent(in) :: xplot(npart)
193 real(c_real), intent(out) :: yplot(npart)
194
195 call exact_torus(iplot,itorus,Mstar,Rtorus,AA,distortion,gamma,xplot,yplot,ierr)
196
197 end subroutine torus_c
198
199 subroutine ringspread_c(iplot,npart,time,Mdisk,Rdisk,viscnu,&
200 xplot,yplot,ierr) bind(c, name='_ringspread')
201 integer(c_int), intent(in) :: iplot,npart
202 integer(c_int), intent(out) :: ierr
203 real(c_real), intent(in) :: time,Mdisk,Rdisk,viscnu
204 real(c_real), intent(in) :: xplot(npart)
205 real(c_real), intent(out) :: yplot(npart)
206
207 call exact_ringspread(iplot,time,Mdisk,Rdisk,viscnu,xplot,yplot,ierr)
208
209 end subroutine ringspread_c
210
211 subroutine dustywave_c(iplot,npart,time,ampl,cs,Kdragin,lambda,x0,&
212 rhog0,rhod0,xplot,yplot,ierr) bind(c, name='_dustywave')
213 integer(c_int), intent(in) :: iplot,npart
214 integer(c_int), intent(out) :: ierr
215 real(c_real), intent(in) :: time, ampl, cs, Kdragin, lambda, x0, rhog0, rhod0
216 real(c_real), intent(in) :: xplot(npart)
217 real(c_real), intent(out) :: yplot(npart)
218
219 call exact_dustywave(iplot,time,ampl,cs,Kdragin,lambda,x0,&
220 rhog0,rhod0,xplot,yplot,ierr)
221
222 end subroutine dustywave_c
223
224 subroutine rochelobe_c(npart,x1,y1,x2,y2,m1,m2,&
225 xplot,yplot,ierr) bind(c, name='_rochelobe')
226 integer(c_int), intent(in) :: npart
227 integer(c_int), intent(out) :: ierr
228 real(c_real), intent(in) :: x1,y1,x2,y2,m1,m2
229 real(c_real), intent(inout) :: xplot(npart),yplot(npart)
230
231 call exact_rochelobe(x1,y1,x2,y2,m1,m2,xplot,yplot,ierr)
232 ierr = 0
233
234 end subroutine rochelobe_c
235
236 subroutine cshock_c(iplot,npart,time,gamma,machs,macha,xmin,xmax,&
237 xplot,yplot,ierr) bind(c, name='_cshock')
238 integer(c_int), intent(in) :: iplot,npart
239 integer(c_int), intent(out) :: ierr
240 real(c_real), intent(in) :: time,gamma,machs,macha,xmin,xmax
241 real(c_real), intent(inout) :: xplot(npart)
242 real(c_real), intent(out) :: yplot(npart)
243
244 call exact_cshock(iplot,time,gamma,machs,macha,xmin,xmax,xplot,yplot,ierr)
245
246 end subroutine cshock_c
247
248 subroutine planetdisc_c(iplot,npart,ispiral,iclockwise,inonlin,time,HonR,rplanet,q,narms,&
249 params,rplot,yplot,ierr) bind(c, name='_planetdisc')
250 integer(c_int), intent(in) :: iplot,ispiral,narms,npart,iclockwise,inonlin
251 integer(c_int), intent(out) :: ierr
252 real(c_real), intent(in) :: time, HonR, rplanet, q, params(7,10)
253 real(c_real), intent(inout) :: rplot(npart)
254 real(c_real), intent(out) :: yplot(npart)
255 logical :: use_clockwise,use_nonlin
256
257 use_clockwise = (iclockwise > 0)
258 use_nonlin = (inonlin > 0)
259
260 call exact_planetdisc(iplot,ispiral,use_clockwise,use_nonlin,&
261 time,HonR,rplanet,q,0.,narms,&
262 params,rplot,yplot,ierr)
263 ierr = 0
264 end subroutine planetdisc_c
265
266 subroutine bondi_c(iplot,npart,time,gamma,const1,const2,m,relativistic,&
267 geodesic_flow,is_wind,xplot,yplot,ierr) bind(c, name='_bondi')
268 integer(c_int), intent(in) :: iplot,npart
269 integer(c_int), intent(out) :: ierr
270 real(c_real), intent(in) :: time,gamma,const1,const2,m
271 logical(c_bool), intent(in) :: relativistic, geodesic_flow,is_wind
272 real(c_real), intent(in) :: xplot(npart)
273 real(c_real), intent(out) :: yplot(npart)
274
275 logical :: relativistic_f,geodesic_flow_f,is_wind_f
276
277 relativistic_f = relativistic
278 geodesic_flow_f = geodesic_flow
279 is_wind_f = is_wind
280
281 call exact_bondi(iplot,time,gamma,const1,const2,m,relativistic_f,&
282 geodesic_flow_f,is_wind_f,xplot,yplot,ierr)
283
284 end subroutine bondi_c
285 end module libexact