Solved

how to call C function in Fortran?

Posted on 2003-10-21
5
234 Views
Last Modified: 2013-11-08
How a function written in C-language can be called in Digital Fortran?
cancermcs
0
Comment
Question by:cancermcs
5 Comments
 
LVL 6

Accepted Solution

by:
Ajar earned 75 total points
ID: 9596627
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mirrorEnds challenge 6 83
sum13 challenge 24 77
isEverywhere  challenge 19 64
count7 challenge 12 70
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now