|
8 | 8 | # |
9 | 9 | fort_compiler = "gfortran" |
10 | 10 | shared_object_name = "delsparse_clib.so" |
11 | | -path_to_lib = os.path.join(os.curdir, shared_object_name) |
| 11 | +source_dir = os.path.abspath(os.path.dirname(__file__)) |
| 12 | +path_to_lib = os.path.join(source_dir, shared_object_name) |
12 | 13 | compile_options = "-fPIC -shared -O3 -fopenmp -std=legacy" |
13 | 14 | # ^^ 'fPIC' and 'shared' are required. 'O3' is for speed and 'fopenmp' |
14 | 15 | # is necessary for supporting CPU parallelism during execution. |
|
29 | 30 | # Remove the shared object if it exists, because it is faulty. |
30 | 31 | if os.path.exists(shared_object_name): |
31 | 32 | os.remove(shared_object_name) |
| 33 | + # Warn the user if they are using a local blas and lapack that |
| 34 | + # this is known to cause extrapolation errors. |
| 35 | + if (blas_lapack == "blas.f lapack.f"): |
| 36 | + import warnings |
| 37 | + warnings.warn("\n The provided 'blas.f' and 'lapack.f' are known to cause extrapolation errors."+ |
| 38 | + "\n Consider using local libraries via compiler flags instead (see config"+ |
| 39 | + "\n coments for 'blas_lapack' in '"+os.path.join(path_to_lib,__file__)+"').") |
32 | 40 | # Compile a new shared object. |
33 | 41 | command = " ".join([fort_compiler, compile_options, blas_lapack, |
34 | 42 | ordered_dependencies, "-o", path_to_lib]) |
@@ -280,7 +288,10 @@ def delaunaysparses(d, n, pts, m, q, simps, weights, ierr, interp_in=None, inter |
280 | 288 |
|
281 | 289 | # Setting up "ierr" |
282 | 290 | ierr_local = np.asarray(ierr, dtype=ctypes.c_int) |
283 | | - ierr_dim_1 = ctypes.c_int(ierr_local.shape[0]) |
| 291 | + # In accordance with how the Fortran code might be normally used, |
| 292 | + # and mathematical notation, grabbing the last dimension allows |
| 293 | + # ierr to be passed as a column vector instead of a flat vector. |
| 294 | + ierr_dim_1 = ctypes.c_int(ierr_local.shape[-1]) |
284 | 295 |
|
285 | 296 | # Setting up "interp_in" |
286 | 297 | interp_in_present = ctypes.c_bool(True) |
@@ -339,12 +350,18 @@ def delaunaysparses(d, n, pts, m, q, simps, weights, ierr, interp_in=None, inter |
339 | 350 | rnorm_present = ctypes.c_bool(False) |
340 | 351 | rnorm = np.zeros(shape=(1), dtype=ctypes.c_double, order='F') |
341 | 352 | elif (type(rnorm) == bool) and (rnorm): |
| 353 | + # In accordance with how the Fortran code might be normally used, |
| 354 | + # and mathematical notation, grabbing the last dimension allows |
| 355 | + # rnorm to be passed as a column vector instead of a flat vector. |
342 | 356 | rnorm = np.zeros(shape=(1), dtype=ctypes.c_double, order='F') |
343 | | - rnorm_dim_1 = ctypes.c_int(rnorm.shape[0]) |
| 357 | + rnorm_dim_1 = ctypes.c_int(rnorm.shape[-1]) |
344 | 358 | elif (not np.asarray(rnorm).flags.f_contiguous): |
345 | 359 | raise(Exception("The numpy array given as argument 'rnorm' was not f_contiguous.")) |
346 | 360 | else: |
347 | | - rnorm_dim_1 = ctypes.c_int(rnorm.shape[0]) |
| 361 | + # In accordance with how the Fortran code might be normally used, |
| 362 | + # and mathematical notation, grabbing the last dimension allows |
| 363 | + # rnorm to be passed as a column vector instead of a flat vector. |
| 364 | + rnorm_dim_1 = ctypes.c_int(rnorm.shape[-1]) |
348 | 365 | rnorm_local = np.asarray(rnorm, dtype=ctypes.c_double) |
349 | 366 |
|
350 | 367 | # Setting up "ibudget" |
@@ -630,7 +647,10 @@ def delaunaysparsep(d, n, pts, m, q, simps, weights, ierr, interp_in=None, inter |
630 | 647 |
|
631 | 648 | # Setting up "ierr" |
632 | 649 | ierr_local = np.asarray(ierr, dtype=ctypes.c_int) |
633 | | - ierr_dim_1 = ctypes.c_int(ierr_local.shape[0]) |
| 650 | + # In accordance with how the Fortran code might be normally used, |
| 651 | + # and mathematical notation, grabbing the last dimension allows |
| 652 | + # ierr to be passed as a column vector instead of a flat vector. |
| 653 | + ierr_dim_1 = ctypes.c_int(ierr_local.shape[-1]) |
634 | 654 |
|
635 | 655 | # Setting up "interp_in" |
636 | 656 | interp_in_present = ctypes.c_bool(True) |
@@ -690,11 +710,17 @@ def delaunaysparsep(d, n, pts, m, q, simps, weights, ierr, interp_in=None, inter |
690 | 710 | rnorm = np.zeros(shape=(1), dtype=ctypes.c_double, order='F') |
691 | 711 | elif (type(rnorm) == bool) and (rnorm): |
692 | 712 | rnorm = np.zeros(shape=(1), dtype=ctypes.c_double, order='F') |
693 | | - rnorm_dim_1 = rnorm.shape[0] |
| 713 | + # In accordance with how the Fortran code might be normally used, |
| 714 | + # and mathematical notation, grabbing the last dimension allows |
| 715 | + # rnorm to be passed as a column vector instead of a flat vector. |
| 716 | + rnorm_dim_1 = rnorm.shape[-1] |
694 | 717 | elif (not np.asarray(rnorm).flags.f_contiguous): |
695 | 718 | raise(Exception("The numpy array given as argument 'rnorm' was not f_contiguous.")) |
696 | 719 | else: |
697 | | - rnorm_dim_1 = ctypes.c_int(rnorm.shape[0]) |
| 720 | + # In accordance with how the Fortran code might be normally used, |
| 721 | + # and mathematical notation, grabbing the last dimension allows |
| 722 | + # rnorm to be passed as a column vector instead of a flat vector. |
| 723 | + rnorm_dim_1 = ctypes.c_int(rnorm.shape[-1]) |
698 | 724 | rnorm_local = np.asarray(rnorm, dtype=ctypes.c_double) |
699 | 725 |
|
700 | 726 | # Setting up "ibudget" |
|
0 commit comments