What is Fortran in C?
Some programming languages support interoperability by enabling libraries written in another programming language to be used.
As such, Fortran-C interfaces exist to aid programmers in this regard. However, compatibility issues may arise, so it is essential for some of these interfaces to be agreeable in the following ways:
-
Function/subroutine
-
Datatypes
-
Arguments
-
Procedure
-
Libraries
Basic syntax
When FORTRAN calls C function
- If the called C function returns a value, call it from Fortran as a function.
- If the called C function does not return a value, call it a subroutine.
When C function calls FORTRAN subprogram
- If the FORTRAN subprogram is a function, then call it a function from C to return a compatible data type.
- If the called FORTRAN subprogram is a subroutine, call it as a function from C that returns a value of int (compatible to Fortran INTEGER*4) or void if otherwise.
Basic code
program testimplicit nonecharacter*13 temp //declaration of a variabletemp = "Hello World!"write (*,*) temp //printend program test
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved