Skip to content

Commit 6efaf56

Browse files
authored
Merge pull request #321 from RuleWorld/fix/lapack-prototypes
Fix LAPACK/Fortran prototypes: add explicit prototypes for DGESV/DSYS…
2 parents 6abb92e + c85588e commit 6efaf56

21 files changed

Lines changed: 52 additions & 26 deletions

bng2/Network3/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 3.5)
44

55
project(Network3)
66

7+
set(CMAKE_CXX_STANDARD 11)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
710
add_definitions(-DRUN_NETWORK_VERSION=\"3.0\")
811
912
set(SUB_DIRS

bng2/Network3/src/util/mathutils/linsolve.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ int LINSOLVE(double **a, double **b, int nrhs, int dim){
1717
int *ipiv;
1818
int Nrhs, Dim;
1919
int info;
20-
extern void DGESV();
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
/* Fortran dgesv: SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) */
24+
void DGESV(int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info);
25+
#ifdef __cplusplus
26+
}
27+
#endif
2128

2229
/* calculate transpose of a-- this is done because matrices in Fortran */
2330
/* and C have row and column indices interchanged */
@@ -29,5 +36,3 @@ int LINSOLVE(double **a, double **b, int nrhs, int dim){
2936
free(ipiv);
3037
return(info);
3138
}
32-
33-

bng2/Network3/src/util/mathutils/norm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ double NORM( double *a, int dim){
1212
int n;
1313
int inca=1;
1414
double norm;
15-
extern double DNRM2();
16-
15+
extern double DNRM2(int *n, double *x, int *incx);
16+
1717
n=dim;
1818
return(DNRM2(&n, a, &inca));
1919
}

bng2/Network3/src/util/mathutils/normsq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ double NORMSQ( double *a, int dim)
1111
int n;
1212
int inca=1;
1313
double norm;
14-
extern double DNRSQ();
14+
extern double DNRSQ(int *n, double *a, int *inca);
1515

1616
n=dim;
1717

bng2/Network3/src/util/mathutils/sum_vector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ double SUM_VECTOR( double *a, int dim)
88
{
99
int n=dim;
1010
int inca=1;
11-
extern double DSUM();
11+
extern double DSUM(int *n, double *a, int *inca);
1212

1313
return(DSUM(&n, a, &inca));
1414
}

bng2/Network3/src/util/mathutils/sym_linsolve.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ int SYM_LINSOLVE(double **A, double **B, int nrhs, int dim){
2626
static int lwork;
2727
static int olddim;
2828
static int initflag=1;
29-
extern void DSYSV();
29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
/* Fortran dsysv: SUBROUTINE DSYSV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, LWORK, INFO ) */
33+
void DSYSV(char *uplo, int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, double *work, int *lwork, int *info);
34+
#ifdef __cplusplus
35+
}
36+
#endif
3037

3138
if(dim==2){
3239
a= A[0][0]; c=A[0][1]; b = A[1][1];
@@ -66,5 +73,3 @@ int SYM_LINSOLVE(double **A, double **B, int nrhs, int dim){
6673
free(ipiv);
6774
return(info);
6875
}
69-
70-

bng2/Network3/src/util/mathutils/sympos_linsolve.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ int SYMPOS_LINSOLVE(double **a, double **b, int nrhs, int dim){
1616
#endif
1717
int Nrhs, Dim;
1818
int info;
19-
extern void DPOSV();
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
/* Fortran dposv: SUBROUTINE DPOSV( UPLO, N, NRHS, A, LDA, B, LDB, INFO ) */
23+
void DPOSV(char *uplo, int *n, int *nrhs, double *a, int *lda, double *b, int *ldb, int *info);
24+
#ifdef __cplusplus
25+
}
26+
#endif
2027

2128
Dim= dim;
2229
Nrhs= nrhs;

bng2/Network3/src/util/mathutils/test_transpose.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "mathutils.h"
22

3-
main()
3+
int main(void)
44
{
55
double dat[]={1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
66
dcomplex **m;

bng2/Network3/src/util/mathutils/testdummy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "mathutils.h"
22

3-
main(){
3+
int main(void){
44
int i,n;
55
int incx=1;
66
double *x;

bng2/Network3/src/util/mathutils/testgram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "mathutils.h"
22

3-
main(int argc, char *argv[]){
3+
int main(int argc, char *argv[]){
44
int i,j,k;
55
int nr, n_run;
66
int n,m;

0 commit comments

Comments
 (0)