ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
PROGRAM MAIN
integer :: i,j,k
i = 12
j = 43
k = 0
print *, 'Before: i,j,k=',i,j,k
call sub(i,j,k)
print *, 'After: i,j,k=',i,j,k
stop
end
Obviously the fortran part needs compiling, but do I use sub.c or sub.o (or something else). What would be the command to run them? Also, am I likely to need USE and/or INCLUDE, I intend to build them into a line-plotting program later. Many thanks
Hello.
I didn't use Lahey fortran since early 90s, however I remember well that an issue in multiple language programming is related to how the procedures/subroutines communicate their arguments: by reference or by value. You have to use the same on both parts.
Please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.
Quote:
Originally Posted by sailschooner
Obviously the fortran part needs compiling, but do I use sub.c or sub.o (or something else). What would be the command to run them?
norobro has provided the answer - build the object files separately from fortran and C source files, then build the application from the object files.
Hello.
I didn't use Lahey fortran since early 90s, however I remember well that an issue in multiple language programming is related to how the procedures/subroutines communicate their arguments: by reference or by value. You have to use the same on both parts.
A traditional problem with FORTRAN is both "pass by value or reference" and the in-memory layout of arrays. Some FORTRANs use a "column-major format" where most languages use "row-major."
Naturally, you must also get the "calling sequence" right – exactly how parameters are passed to-and-from the subroutine. But that's true of any language implementation.
The documentation of any compiler should contain a substantial section discussing exactly how to call to or from its subroutines, how to build and use binary libraries of various kinds (dynamic or static), and so on. Probably giving examples.
Last edited by sundialsvcs; 02-27-2018 at 08:00 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.