Is there a way to declare a C variable and call it from Fortran? I need to call this function to compute some point products between vectors marked as a string. My idea was to declare something like the following, where the variable argument list contains string literals. If the variable argument list is empty, I would search among the standard labels and do the calculations. If the user specified two labels, I would extract these two vectors and get their point product:
extern "C" void compute_dot_product(double * dot_product, ...) { va_list args; va_start(args, NULL); char * label1 = va_arg(args, char *); if (!label1) {
The only problem is that I can compile my C library and link it to the Fortran executable, but I get a runtime error when I try to access the list of variable arguments. Any idea if what I'm trying to do is possible? A possible solution would be to divide into two functions: one that performs a standard label search (argument 0 arguments), the other handles a non-standard label search (2 arguments). However, I would rather avoid this solution.
source share