| 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-2019 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!------------------------------------------------------------------------- |
| 24 |
! module providing library version of splash interpolation routines |
| 25 |
! specifies c interfaces to corresponding Fortran subroutines |
| 26 |
!------------------------------------------------------------------------- |
| 27 |
module libinterpolation |
| 28 |
|
| 29 |
use projections3D, only: interpolate3d_projection, interpolate3d_proj_vec |
| 30 |
use xsections3D, only: interpolate3d_fastxsec, interpolate3d_xsec_vec |
| 31 |
use interpolate3D_opacity, only: interp3d_proj_opacity |
| 32 |
use projections3Dgeom, only: interpolate3D_proj_geom, interpolate3D_xsec_geom |
| 33 |
use iso_c_binding, only: c_float, c_int, c_bool |
| 34 |
|
| 35 |
implicit none |
| 36 |
|
| 37 |
contains |
| 38 |
!------------------------------------------------------------------------- |
| 39 |
! 3D projection (column density) |
| 40 |
!------------------------------------------------------------------------- |
| 41 |
subroutine interpolate3d_projection_c( & |
| 42 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, datsmooth, npixx, npixy, & |
| 43 |
pixwidthx, pixwidthy, normalise, zobserver, dscreen, useaccelerate, iverbose & |
| 44 |
) bind(c, name='interpolate3d_projection') |
| 45 |
|
| 46 |
real(c_float), intent(in) :: x(npart), & |
| 47 |
y(npart), & |
| 48 |
z(npart), & |
| 49 |
hh(npart), & |
| 50 |
weight(npart), & |
| 51 |
dat(npart), & |
| 52 |
xmin, & |
| 53 |
ymin, & |
| 54 |
pixwidthx, & |
| 55 |
pixwidthy, & |
| 56 |
zobserver, & |
| 57 |
dscreen |
| 58 |
integer(c_int), intent(in) :: npart, & |
| 59 |
npixx, & |
| 60 |
npixy, & |
| 61 |
itype(npart), & |
| 62 |
iverbose |
| 63 |
logical(c_bool), intent(in) :: normalise, & |
| 64 |
useaccelerate, & |
| 65 |
exact_rendering, & |
| 66 |
real(c_float), intent(out) :: datsmooth(npixx,npixy) |
| 67 |
|
| 68 |
logical :: normalise_f,useaccelerate_f,exact_rendering_f |
| 69 |
|
| 70 |
normalise_f = normalise |
| 71 |
useaccelerate_f = useaccelerate |
| 72 |
exact_rendering_f = exact_rendering |
| 73 |
|
| 74 |
call interpolate3d_projection( & |
| 75 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, datsmooth, npixx, & |
| 76 |
npixy, pixwidthx, pixwidthy, normalise_f, zobserver, dscreen, & |
| 77 |
useaccelerate_f, exact_rendering_f, iverbose) |
| 78 |
|
| 79 |
end subroutine interpolate3d_projection_c |
| 80 |
|
| 81 |
!------------------------------------------------------------------------- |
| 82 |
! 3D projection of vectors |
| 83 |
!------------------------------------------------------------------------- |
| 84 |
subroutine interpolate3d_proj_vec_c( & |
| 85 |
x, y, z, hh, weight, vecx, vecy, itype, npart, xmin, ymin, vecsmoothx, & |
| 86 |
vecsmoothy, npixx, npixy, pixwidthx, pixwidthy, normalise, zobserver, & |
| 87 |
dscreen, iverbose & |
| 88 |
) bind(c, name='interpolate3d_proj_vec') |
| 89 |
|
| 90 |
integer(c_int), intent(in) :: npart, & |
| 91 |
npixx, & |
| 92 |
npixy, & |
| 93 |
itype(npart), & |
| 94 |
iverbose |
| 95 |
real(c_float), intent(in) :: x(npart), & |
| 96 |
y(npart), & |
| 97 |
z(npart), & |
| 98 |
hh(npart), & |
| 99 |
weight(npart), & |
| 100 |
vecx(npart), & |
| 101 |
vecy(npart), & |
| 102 |
xmin, & |
| 103 |
ymin, & |
| 104 |
pixwidthx, & |
| 105 |
pixwidthy, & |
| 106 |
zobserver, & |
| 107 |
dscreen |
| 108 |
logical(c_bool), intent(in) :: normalise |
| 109 |
real(c_float), intent(out) :: vecsmoothx(npixx,npixy), & |
| 110 |
vecsmoothy(npixx,npixy) |
| 111 |
|
| 112 |
logical :: normalise_f |
| 113 |
|
| 114 |
normalise_f = normalise |
| 115 |
|
| 116 |
call interpolate3d_proj_vec( & |
| 117 |
x, y, z, hh, weight, vecx, vecy, itype, npart, xmin, ymin, vecsmoothx, & |
| 118 |
vecsmoothy, npixx, npixy, pixwidthx, pixwidthy, normalise_f, zobserver, & |
| 119 |
dscreen, iverbose) |
| 120 |
|
| 121 |
end subroutine interpolate3d_proj_vec_c |
| 122 |
|
| 123 |
!------------------------------------------------------------------------- |
| 124 |
! cross sections of 3D data |
| 125 |
!------------------------------------------------------------------------- |
| 126 |
subroutine interpolate3d_fastxsec_c( & |
| 127 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, zslice, datsmooth, & |
| 128 |
npixx, npixy, pixwidthx, pixwidthy, normalise, iverbose & |
| 129 |
) bind(c, name='interpolate3d_fastxsec') |
| 130 |
|
| 131 |
integer(c_int), intent(in) :: npart, & |
| 132 |
npixx, & |
| 133 |
npixy, & |
| 134 |
itype(npart), & |
| 135 |
iverbose |
| 136 |
real(c_float), intent(in) :: x(npart), & |
| 137 |
y(npart), & |
| 138 |
z(npart), & |
| 139 |
hh(npart), & |
| 140 |
weight(npart), & |
| 141 |
dat(npart), & |
| 142 |
xmin, & |
| 143 |
ymin, & |
| 144 |
pixwidthx, & |
| 145 |
pixwidthy, & |
| 146 |
zslice |
| 147 |
logical(c_bool), intent(in) :: normalise |
| 148 |
real(c_float), intent(out) :: datsmooth(npixx,npixy) |
| 149 |
|
| 150 |
logical :: normalise_f |
| 151 |
|
| 152 |
normalise_f = normalise |
| 153 |
|
| 154 |
call interpolate3d_fastxsec( & |
| 155 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, zslice, datsmooth, & |
| 156 |
npixx, npixy, pixwidthx, pixwidthy, normalise_f, iverbose) |
| 157 |
|
| 158 |
end subroutine interpolate3d_fastxsec_c |
| 159 |
|
| 160 |
!------------------------------------------------------------------------- |
| 161 |
! cross sections of 3D vector data |
| 162 |
!------------------------------------------------------------------------- |
| 163 |
subroutine interpolate3d_xsec_vec_c( & |
| 164 |
x, y, z, hh, weight, vecx, vecy, itype, npart, xmin, ymin, zslice, & |
| 165 |
vecsmoothx, vecsmoothy, npixx, npixy, pixwidthx, pixwidthy, normalise, & |
| 166 |
iverbose) bind(c, name='interpolate3d_xsec_vec') |
| 167 |
|
| 168 |
integer(c_int), intent(in) :: npart, & |
| 169 |
npixx, & |
| 170 |
npixy, & |
| 171 |
itype(npart), & |
| 172 |
iverbose |
| 173 |
real(c_float), intent(in) :: x(npart), & |
| 174 |
y(npart), & |
| 175 |
z(npart), & |
| 176 |
hh(npart), & |
| 177 |
weight(npart), & |
| 178 |
vecx(npart), & |
| 179 |
vecy(npart), & |
| 180 |
xmin, & |
| 181 |
ymin, & |
| 182 |
pixwidthx, & |
| 183 |
pixwidthy, & |
| 184 |
zslice |
| 185 |
logical(c_bool), intent(in) :: normalise |
| 186 |
real(c_float), intent(out) :: vecsmoothx(npixx,npixy), & |
| 187 |
vecsmoothy(npixx,npixy) |
| 188 |
|
| 189 |
logical :: normalise_f |
| 190 |
|
| 191 |
normalise_f = normalise |
| 192 |
|
| 193 |
call interpolate3d_xsec_vec( & |
| 194 |
x, y, z, hh, weight, vecx, vecy, itype, npart, xmin, ymin, zslice, & |
| 195 |
vecsmoothx, vecsmoothy, npixx, npixy, pixwidthx, pixwidthy, normalise_f, & |
| 196 |
iverbose) |
| 197 |
|
| 198 |
end subroutine interpolate3d_xsec_vec_c |
| 199 |
|
| 200 |
!------------------------------------------------------------------------- |
| 201 |
! opacity rendering of 3D data |
| 202 |
!------------------------------------------------------------------------- |
| 203 |
subroutine interp3d_proj_opacity_c( & |
| 204 |
x, y, z, pmass, npmass, hh, weight, dat, zorig, itype, npart, xmin, ymin, & |
| 205 |
datsmooth, brightness, npixx, npixy, pixwidth, zobserver, & |
| 206 |
dscreenfromobserver, rkappa, zcut, iverbose & |
| 207 |
) bind(c, name='interp3d_proj_opacity') |
| 208 |
|
| 209 |
integer(c_int), intent(in) :: npart, & |
| 210 |
npixx, & |
| 211 |
npixy, & |
| 212 |
npmass, & |
| 213 |
itype(npart), & |
| 214 |
iverbose |
| 215 |
real(c_float), intent(in) :: x(npart), & |
| 216 |
y(npart), & |
| 217 |
z(npart), & |
| 218 |
hh(npart), & |
| 219 |
weight(npart), & |
| 220 |
dat(npart), & |
| 221 |
zorig(npart), & |
| 222 |
pmass(npmass), & |
| 223 |
xmin, & |
| 224 |
ymin, & |
| 225 |
pixwidth, & |
| 226 |
zobserver, & |
| 227 |
dscreenfromobserver, & |
| 228 |
zcut, & |
| 229 |
rkappa |
| 230 |
real(c_float), intent(out) :: datsmooth(npixx,npixy), & |
| 231 |
brightness(npixx,npixy) |
| 232 |
|
| 233 |
call interp3d_proj_opacity( & |
| 234 |
x, y, z, pmass, npmass, hh, weight, dat, zorig, itype, npart, xmin, ymin, & |
| 235 |
datsmooth, brightness, npixx, npixy, pixwidth, zobserver, & |
| 236 |
dscreenfromobserver, rkappa, zcut, iverbose) |
| 237 |
|
| 238 |
end subroutine interp3d_proj_opacity_c |
| 239 |
|
| 240 |
subroutine interpolate3D_proj_geom_c( & |
| 241 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, datsmooth, npixx, npixy, & |
| 242 |
pixwidthx, pixwidthy, normalise, igeom, iplotx, iploty, iplotz, ix, xorigin & |
| 243 |
) bind(c, name='interpolate3D_proj_geom') |
| 244 |
|
| 245 |
integer(c_int), intent(in) :: npart, & |
| 246 |
npixx, & |
| 247 |
npixy, & |
| 248 |
itype(npart), & |
| 249 |
igeom, & |
| 250 |
iplotx, & |
| 251 |
iploty, & |
| 252 |
iplotz, & |
| 253 |
ix(3) |
| 254 |
real(c_float), intent(in) :: x(npart), & |
| 255 |
y(npart), & |
| 256 |
z(npart), & |
| 257 |
hh(npart), & |
| 258 |
weight(npart), & |
| 259 |
dat(npart), & |
| 260 |
xmin, & |
| 261 |
ymin, & |
| 262 |
pixwidthx, & |
| 263 |
pixwidthy, & |
| 264 |
xorigin(3) |
| 265 |
real(c_float), intent(out) :: datsmooth(npixx,npixy) |
| 266 |
logical(c_bool), intent(inout) :: normalise |
| 267 |
|
| 268 |
logical :: normalise_f |
| 269 |
|
| 270 |
normalise_f = normalise |
| 271 |
|
| 272 |
call interpolate3D_proj_geom( & |
| 273 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, datsmooth, npixx, & |
| 274 |
npixy, pixwidthx, pixwidthy, normalise_f, igeom, iplotx, iploty, iplotz, & |
| 275 |
ix, xorigin) |
| 276 |
|
| 277 |
end subroutine interpolate3D_proj_geom_c |
| 278 |
|
| 279 |
subroutine interpolate3D_xsec_geom_c( & |
| 280 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, zslice, datsmooth, & |
| 281 |
npixx, npixy, pixwidthx, pixwidthy, normalise, igeom, iplotx, iploty, & |
| 282 |
iplotz, ix, xorigin) bind(c, name='interpolate3D_xsec_geom') |
| 283 |
|
| 284 |
integer(c_int), intent(in) :: npart, & |
| 285 |
npixx, & |
| 286 |
npixy, & |
| 287 |
itype(npart), & |
| 288 |
igeom, & |
| 289 |
iplotx, & |
| 290 |
iploty, & |
| 291 |
iplotz, & |
| 292 |
ix(3) |
| 293 |
real(c_float), intent(in) :: x(npart), & |
| 294 |
y(npart), & |
| 295 |
z(npart), & |
| 296 |
hh(npart), & |
| 297 |
weight(npart), & |
| 298 |
dat(npart), & |
| 299 |
xmin, & |
| 300 |
ymin, & |
| 301 |
zslice, & |
| 302 |
pixwidthx, & |
| 303 |
pixwidthy, & |
| 304 |
xorigin(3) |
| 305 |
real(c_float), intent(out) :: datsmooth(npixx,npixy) |
| 306 |
logical(c_bool), intent(inout) :: normalise |
| 307 |
|
| 308 |
logical :: normalise_f |
| 309 |
|
| 310 |
normalise_f = normalise |
| 311 |
|
| 312 |
call interpolate3D_xsec_geom( & |
| 313 |
x, y, z, hh, weight, dat, itype, npart, xmin, ymin, zslice, datsmooth, & |
| 314 |
npixx, npixy, pixwidthx, pixwidthy, normalise_f, igeom, iplotx, iploty, & |
| 315 |
iplotz, ix, xorigin) |
| 316 |
|
| 317 |
end subroutine interpolate3D_xsec_geom_c |
| 318 |
|
| 319 |
end module libinterpolation |