Published online by Cambridge University Press: 04 August 2010
Before we can discuss how to call FORTRAN functions from C++, we need first to look at some of the differences.
The most important difference is that FORTRAN passes variables by reference, while C++, like C, passes by value. This in turn means that any FORTRAN routine expects to get a reference, so you have to make sure your program passes the variables appropriately.
When you use arrays in your program, you have to take into account that the first array element in FORTRAN is a(1), while in C++ it would be a[0]. Multi-dimensional arrays are stored differently in memory. Array A(3,5) in FORTRAN would be A(1,1), A(2,1), A(3,1), A(1,2), while in C++ the corresponding arrangement would be A(0,0), A(0,1), A(0,2), A(0,3), A(0,4), A(1,0) and so on.
C++ is a strongly typed language; if you do not define a variable your program will not compile. FORTRAN has by default an implicit type convention: any variable which starts with letters i through n is an integer, while any other variable is a real variable. Unless the programmer has used the “implicit none” statement any FORTRAN compiler will adhere to the standards.
FORTRAN is case insensitive, while C++ clearly distinguishes between Dummy and dummy.
[…]
To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.