Quit Fortran dependencies, using own f2c'd version of amos.

TODO doc; submodule init needed


Former-commit-id: 761fc06adffebb05d28a389243771f0bdde70cc0
This commit is contained in:
Marek Nečada 2020-04-10 23:19:18 +03:00
parent ba06abe13f
commit 231a76529d
6 changed files with 67 additions and 15 deletions

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "camos"]
path = camos
url = https://github.com/texnokrates/zbessel.git
branch = purec

View File

@ -1,10 +1,17 @@
cmake_minimum_required(VERSION 3.0.2) cmake_minimum_required(VERSION 3.0.2)
option(QPMS_USE_FORTRAN_AMOS "Use the original AMOS Fortran libraries instead of the C ones" OFF)
if (QPMS_USE_FORTRAN_AMOS)
include(CMakeAddFortranSubdirectory) include(CMakeAddFortranSubdirectory)
endif (QPMS_USE_FORTRAN_AMOS)
include(version.cmake) include(version.cmake)
include(GNUInstallDirs) include(GNUInstallDirs)
project (QPMS) project (QPMS)
macro(use_c99) macro(use_c99)
if (CMAKE_VERSION VERSION_LESS "3.1") if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU") if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
@ -22,10 +29,19 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set (QPMS_VERSION_MAJOR 0) set (QPMS_VERSION_MAJOR 0)
#set (QPMS_VERSION_MINOR 3) #set (QPMS_VERSION_MINOR 3)
cmake_add_fortran_subdirectory (amos
if (QPMS_USE_FORTRAN_AMOS)
cmake_add_fortran_subdirectory (amos
PROJECT amos PROJECT amos
LIBRARIES amos LIBRARIES amos
NO_EXTERNAL_INSTALL) NO_EXTERNAL_INSTALL)
set(QPMS_AMOSLIB amos)
else (QPMS_USE_FORTRAN_AMOS)
set(CAMOS_BUILD_STATIC ON)
add_subdirectory (camos)
set(QPMS_AMOSLIB camos)
endif (QPMS_USE_FORTRAN_AMOS)
add_subdirectory (qpms) add_subdirectory (qpms)

30
amos/camos.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef CAMOS_H_
#define CAMOS_H_
#include "amos.h"
// TODO what about all the INTEGER_t and DOUBLE_PRECISION_t?
static inline int camos_zbesh(double zr, double zi, double fnu, int kode, int m,
int n, double *cyr, double *cyi, int *nz) {
int ierr;
amos_zbesh(&zr, &zi, &fnu, &kode, &m, &n, cyr, cyi, nz, &ierr);
return ierr;
}
static inline int camos_zbesj(double zr, double zi, double fnu, int kode, int n, double *cyr,
double *cyi, int *nz) {
int ierr;
double cwrkr[n], cwrki[n];
amos_zbesj(&zr, &zi, &fnu, &kode, &n, cyr, cyi, nz, &ierr);
return ierr;
}
static inline int camos_zbesy(double zr, double zi, double fnu, int kode, int n, double *cyr,
double *cyi, int *nz, double *cwrkr, double *cwrki) {
int ierr;
amos_zbesy(&zr, &zi, &fnu, &kode, &n, cyr, cyi, nz, cwrkr, cwrki, &ierr);
return ierr;
}
#endif // CAMOS_H_

1
camos Submodule

@ -0,0 +1 @@
Subproject commit aafab167ffb4ed498945518d59fc7042f7a8e527

View File

@ -21,11 +21,12 @@ use_c99()
set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES}) set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES})
target_link_libraries (qpms target_link_libraries (qpms
gsl gsl
lapack lapack
blas blas
amos ${QPMS_AMOSLIB}
) )
target_include_directories (qpms PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories (qpms PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -7,7 +7,7 @@
#include <gsl/gsl_sf_bessel.h> #include <gsl/gsl_sf_bessel.h>
#include <complex.h> #include <complex.h>
#include "qpms_error.h" #include "qpms_error.h"
#include <amos.h> #include <camos.h>
#include <math.h> #include <math.h>
#ifndef M_LN2 #ifndef M_LN2
@ -94,30 +94,30 @@ qpms_errno_t qpms_sph_bessel_fill(qpms_bessel_t typ, qpms_l_t lmax, complex doub
else { else {
try_again: ; try_again: ;
int retry_counter = 0; int retry_counter = 0;
const DOUBLE_PRECISION_t zr = creal(x), zi = cimag(x), fnu = 0.5; const double zr = creal(x), zi = cimag(x), fnu = 0.5;
const INTEGER_t n = lmax + 1, kode = 1 /* No exponential scaling */; const int n = lmax + 1, kode = 1 /* No exponential scaling */;
DOUBLE_PRECISION_t cyr[n], cyi[n]; double cyr[n], cyi[n];
INTEGER_t ierr, nz; int ierr, nz;
unsigned int kindchar; // Only for error output unsigned int kindchar; // Only for error output
const complex double prefac = csqrt(M_PI_2/x); const complex double prefac = csqrt(M_PI_2/x);
switch(typ) { switch(typ) {
case QPMS_BESSEL_REGULAR: case QPMS_BESSEL_REGULAR:
kindchar = 'j'; kindchar = 'j';
amos_zbesj(&zr, &zi, &fnu, &kode, &n, cyr, cyi, &nz, &ierr); ierr = camos_zbesj(zr, zi, fnu, kode, n, cyr, cyi, &nz);
break; break;
case QPMS_BESSEL_SINGULAR: case QPMS_BESSEL_SINGULAR:
kindchar = 'y'; kindchar = 'y';
{ {
DOUBLE_PRECISION_t cwrkr[lmax + 1], cwrki[lmax + 1]; double cwrkr[lmax + 1], cwrki[lmax + 1];
amos_zbesy(&zr, &zi, &fnu, &kode, &n, cyr, cyi, &nz, cwrkr, cwrki, &ierr); ierr = camos_zbesy(zr, zi, fnu, kode, n, cyr, cyi, &nz, cwrkr, cwrki);
} }
break; break;
case QPMS_HANKEL_PLUS: case QPMS_HANKEL_PLUS:
case QPMS_HANKEL_MINUS: case QPMS_HANKEL_MINUS:
kindchar = 'h'; kindchar = 'h';
{ {
const INTEGER_t m = (typ == QPMS_HANKEL_PLUS) ? 1 : 2; const int m = (typ == QPMS_HANKEL_PLUS) ? 1 : 2;
amos_zbesh(&zr, &zi, &fnu, &kode, &m, &n, cyr, cyi, &nz, &ierr); ierr = camos_zbesh(zr, zi, fnu, kode, m, n, cyr, cyi, &nz);
} }
break; break;
default: default: