?
Solved

how to call C function in Fortran?

Posted on 2003-10-21
5
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Accepted Solution

by:
Ajar earned 225 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

718 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