Re: [Rd] .Call and Segmentation Fault

From: Ricardo Luiz Andrade Abrantes <rabrantes82_at_gmail.com>
Date: Tue 30 Aug 2005 - 16:37:30 GMT

Hi Simon!
You are right!
Ok, here it is (a little resumed):

#include <stdio.h>
#include <math.h>
#include <time.h>
#include <sys/times.h>
#include "interface.h"

SEXP main() {

int gtype, inform, m, n, maxoutit, maxtotit, maxtotfc, outiter, totcgcnt, totfcnt, totgcnt, totiter, iprint, ncomp, i;

double f,nalpsupn,epsfeas,epsopt,snorm;

int *wi;
int *equatn, *linear;

double *l, *lambda, *rho, *u, *wd1, *wd2, *wd3, *wd4, *wd5, *wd6, *wd7, *wd8, *wd9, *wd10, *wd11, *wd12, *wd13, *x;

FILE *fileOutput;
clock_t clock;
double time;
struct tms buffer;

/* SOME LINES TO SET UP PROBLEM DATA */ /* SOME LINES TO MEMORY ALLOCATION */ /* SOME LINES TO SET SOME ALGENCAN ARGUMENTS */ /* TRANSFORMS THE TYPE INT OF C IN THE TYPE LOGICAL OF FORTRAN * FOR THE ARRAYS equatn AND linear */

C2FLOGICALV(equatn, m);
C2FLOGICALV(linear, m);

clock = times(&buffer);

/* CALL OPTIMIZATION PACKAGE */ fortran_optimization_package (n, x, l, u, m, lambda, rho, equatn, linear, epsfeas,
epsopt, maxoutit, maxtotfc, maxtotit, iprint, ncomp, gtype,

f, snorm, nalpsupn, outiter, totiter, totfcnt, totgcnt,
totcgcnt, inform, wi, wd1, wd2, wd3, wd4, wd5, wd6, wd7,
wd8, wd9, wd10, wd11, wd12, wd13)

return R_NilValue
}

All the variables passed to fortran_optimization_package are allocated an initialized correctly, that's why I resumed those lines with a comment.

Thanks,

Ricardo

> You still didn't even supply your declaration of the function you're
> calling, so there is not much we can help you with. Hopefully your
> function looks like this:
>
> #include <R.h>
> #include <Rinternals.h>
>
> SEXP foo() {
>
> [... you code goes here..]
>
> return R_NilValue;
> }
>
> If you're constructing the returned object then you should consider
> posting the whole code, because you're likely making a mistake
> somewhere in that part.
>
> Cheers,
> Simon
>
>

        [[alternative HTML version deleted]]



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Aug 31 02:48:48 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:19 GMT