0

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?

AatG
  • 685
  • 8
  • 23
  • 1) Don't cast the result of `malloc` & friends in C. 2) Initialisers for compound types must be constant. – too honest for this site Mar 21 '16 at 01:32
  • I gave both of those a try, but am still getting a stall. the initializer makes sense (although here maxiter is a constant, so shouldn't be an issue), but why should I not cast the malloc to the correct types? – AatG Mar 21 '16 at 01:49
  • `maxiter` is definitively not a constant, but a variable. Even if it was qualified `const`, it would not be a constant. C is not C++, it has no symbolic constants other than the very limited _enum-constants_. – too honest for this site Mar 21 '16 at 02:08
  • I see. What about the casting? Thanks. – AatG Mar 21 '16 at 02:39
  • never mind, the issue was something to do with the way arpack was compiled. I got the same freezing when I tried to run their sample code. So I switched to arpack-ng and everything worked. – AatG Mar 21 '16 at 03:34

1 Answers1

1

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

AatG
  • 685
  • 8
  • 23