Hi all, I am a beginner in programming in C, C++ as well as fortran.

I am trying to call a fortran subroutine from a c program. I found documentation on how to do that when the arguments of the subroutine are classical, such as integer...but how do you pass a fortran subroutine that has itself a function or another subroutine as an argument to a c program ?

Here is the c code

Code:
 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "f77.h"


extern "C"{
void LMQN_(int *IERROR, int *N, double X[], double *F, double G[], double W[], int *LW, double *SFUN_, int *MSGLVL
, int *MAXIT, int *MAXFUN, double *ETA, int *STEPMX, double *ACCRCY, double *XTOL);
}


int
main(void)
{
int IERROR,i;
int N=200,LW=4000,MSGLVL,MAXIT,MAXFUN,STEPMX=10;
double F=-1000.0,SFUN_;
double G[300],W[4000],X[300],tipo[300];
double ETA=0.25,ACCRCY=1.0e-15,XTOL;
FILE *inputFPtr;

XTOL=sqrt(ACCRCY);
MAXIT=N/2;
MAXFUN=150*N;


  if((inputFPtr=fopen("conf1_deform.dat","r"))==NULL){
    printf("can't read conf1_deform.dat.dat\n");
    exit(1);
  }


  for(i=0;i<100;i++) {
    fscanf(inputFPtr,"%lf%lf%lf",&tipo[i],&X[i],&X[i+100]);
  }


LMQN_(&IERROR, &N, X, &F, G, W, &LW, SFUN_, &MSGLVL, &MAXIT, &MAXFUN, &ETA, &STEPMX, &ACCRCY, &XTOL);
              
}
Thanks all

Mike