Thanks to all of you. You helped me a lot with these very annoying programming problems.

Now it is working. To summarize I compile with

ifort -c tn.f

ifort -c blas.f

gcc -m32 -g -c test1.c

gcc -g -m32 test1.o tn.o blas.o -L/opt/intel/fc/9.0/lib/ -lifcore -lg2c

and to pass in a function another fortran function as argument one as to write someting like that

Code:

#include <stdlib.h>
#include <math.h>
void SFUN(int *N, double *X, double *F, double *G)
{
int i;
double T;
*F=0.0;
for (i = 0 ; i < *N ; i++)
{
T = 2*X[i] - i;
*F = *F +T*T;
G[i] = 2.0 * T;
}
}
int main(void)
{
int N=200;
double F=-1000.0;
double G[300],X[300];
extern void pseudolmqn_(int *N, double X[], double *F, double G[], void (*SFUN)(int *N, double X[], double *F, double G[]));
printf("F before test is %lf\n",&F);
pseudolmqn_(&N, X, &F, G, SFUN);
printf("F after test is %lf\n",&F);
}

where pseudolmqn.f is

Code:

SUBROUTINE pseudolmqn(N, X, F, G, SFUN)
IMPLICIT NONE
INTEGER N
DOUBLE PRECISION X(N), G(N), F, FNEW
EXTERNAL SFUN
CALL SFUN(N,X,FNEW,G)
F=FNEW+1.0
RETURN
END

AND THIS WORKS !!!!