Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

how to call C function in Fortran?

How a function written in C-language can be called in Digital Fortran?
cancermcs
0
cancermcs
Asked:
cancermcs
1 Solution
 
AjarCommented:
cancermcs ,

 Are you working on  Digital / VAX-VMS platform ?

The principal steps involved are :

1. Define the funciton in a C file   with the arguments  passed as pointers
    the reason is that fortran uses variables by reference always.
    e.g  a  c function for fortran programs

void  functin_xx(char * text, int * number)
{
    printf("The text is %s  and the number is   %d",text,number);
}



in your fortran program use (i am not very sure of the syntax !!)
---
txt  CHARACTER*16  = 'abced\n\0'
numb  INTEGER

--
--
CALL   FUNCTION_XX(txt,numb)



Compile these programs sepreatly

then link  them together to form an executable .

you can run the executable..


==================
If your os is other than VAX then the c function should have '_'  prefixed to its signature e.g
_function_xx







0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now