clinkerfortranhpcarpack

calling fortran 77 from c for arpack


I'm trying to call the fortran function dsaupd from ARPACK. I used the C declaration from netlib-java

  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);

then i defined numcols as an int earlier in the program before calling dsaupd with

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");
}

The code compiles and makes it to the first "Here" printout, but stalls after that. Any idea what I'm doing wrong, or how to debug this call?


Solution

  • I think even though arpack was compiling on my system, it was linking incorrectly. Switching to arpack-ng fixed the issue.