2016-03-21 10 views
0

Ich versuche, die Fortran-Funktion dsaupd von ARPACK aufrufen. Ich benutzen die C-Deklaration von netlib-javaAufruf Fortran 77 von c für Arpack

extern void dsaupd_(int *ido, char *bmat, int *n, char *which, 
         int *nev, double *tol, double *resid, 
         int *ncv, double *V, int *ldv, 
         int *iparam, int *ipntr, double *workd, 
         double *workl, int *lworkl, int *info); 

dann definiert i numCols als ein int im Programm früher, bevor sie mit

int ido = 0; 
int ncv = 2*numeigs; 
int maxiter = 30; 
double tol = 1e-13; 
double * v = (double *) malloc(numcols * ncv *sizeof(double)); 
int iparam[11] = {1, 0, maxiter, 1, 0, 0, 1, 0, 0, 0, 0}; 
int ipntr[11]; 
double * workd = (double *) malloc(3*numcols*sizeof(double)); 
int lworkl = ncv*(ncv + 8); 
double * workl = (double *) malloc(lworkl*sizeof(double)); 
int arpack_info = 0; 

char bmat = 'I'; 
char which[2] = {'L', 'M'}; 
MPI_Barrier(comm); 
if (mpi_rank == 0) { 
    printf("Here!\n"); 
    dsaupd_(&ido, &bmat, &numcols, which, 
      &numeigs, &tol, vector, 
      &ncv, v, &numcols, 
      iparam, ipntr, workd, 
      workl, &lworkl, &arpack_info); 
    printf("Here!\n"); 
} 

Aufruf dsaupd Der Code kompiliert und macht es zum ersten „Hier“ Ausdruck, aber danach steht es still. Irgendeine Idee, was ich falsch mache, oder wie man diesen Anruf debuggt?

+0

1) Das Ergebnis von 'malloc' & friends sollte nicht in C umgewandelt werden. 2) Initiatoren für Verbindungstypen müssen konstant sein. – Olaf

+0

Ich gab beiden einen Versuch, aber ich bekomme immer noch einen Stand. Der Initialisierer macht Sinn (obwohl Maxiter hier eine Konstante ist, sollte also kein Problem sein), aber warum sollte ich das malloc nicht auf die richtigen Typen anwenden? – AatG

+0

'maxiter' ist definitiv keine Konstante, sondern eine Variable. Selbst wenn es als "const" bezeichnet würde, wäre es keine Konstante. C ist nicht C++, es hat keine anderen symbolischen Konstanten als die sehr begrenzten _enum-Konstanten_. – Olaf

Antwort

1

Ich denke, obwohl Arpack kompiliert wurde auf meinem System, es wurde falsch verlinkt. Die Umstellung auf arpack-ng behob das Problem.

Verwandte Themen