Solved

how to call C function in Fortran?

Posted on 2003-10-21
5
235 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
zeroFront challenge 7 80
sumHeights2  challenge 7 88
Not needed 13 94
Interview question Javascript, database 12 32
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

896 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

16 Experts available now in Live!

Get 1:1 Help Now