School of Computing

Standardized mixed language programming for Fortran and C

Bo Einarsson, Richard J. Hanson, and Tim Hopkins

SIGPLAN Fortran Forum, 28(3):182-196, December 2009 [doi].


Programmers have long practiced the matter of mixed language procedure calls. This is particularly true for the programming languages C and Fortran. The use of the alternate language often results in efficient running time or the effective use of human or other resources.

Prior to the Fortran 2003 standard there was silence about how the two languages interoperated. Before this release there existed a set of differing ad hoc methods for making the inter-language calls. These typically depended on the Fortran and C compilers. The newer Fortran standard provides an intrinsic module, iso_c_binding, that permits the languages to interoperate. There remain restrictions regarding interoperable data types.

This paper illustrates several programs that contain core exercises likely to be encountered by programmers. The source code is available from the first author's web site. Included is an illustration of a "trap" based on use of the ad hoc methods: A call from a C to a Fortran 2003 routine that passes a character in C to a character variable in Fortran results in a run-time error.

Download publication 318 kbytes (PDF)

Bibtex Record

author = {Einarsson, Bo and Hanson, Richard J. and Hopkins, Tim},
title = {Standardized mixed language programming for {Fortran} and {C}},
month = {December},
year = {2009},
pages = {182-196},
keywords = {determinacy analysis, Craig interpolants},
note = {},
doi = {10.1145/1667140.1667142},
url = {},
    publication_type = {article},
    submission_id = {28440_1267877974},
    ISSN = {1061-7264},
    journal = {SIGPLAN Fortran Forum},
    volume = {28},
    number = {3},
    publisher = {ACM},

School of Computing, University of Kent, Canterbury, Kent, CT2 7NF

Enquiries: +44 (0)1227 824180 or contact us.

Last Updated: 21/03/2014