[SOLVED] Argument disparity in function declaration in Fortran's ScaLAPACK
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.
BUT, since I am not good with Fortran, I have to ask: CAN YOU, IN FORTRAN, DECLARE ONE PARAMETER TO BE OF ONE TYPE WHEN DEFINING A FUNCTION, AND THEN CALL THE FUNCTION WITH A DIFFERENT TYPE?
Notice in the FIRST file, that the 26th parameter is an array of integer:
DOES THIS MAKE SENSE?!? I am trying to translate this code to C, BUT this keeps the code from compiling properly, and furthermore, the driver from the SECOND file works 0k! It actually works great! It passes the numerical tests, and it scales in terms of execution times when increasing the number of processors.
My common sense is being tested here
Thanks!
Last edited by ejspeiro; 03-19-2013 at 09:33 PM.
Reason: Increasing clarity and concision within redaction
FORTRAN Does the type casting, So I think thats what is happening and you don't get any error.
One more thing to remember is that in FORTRAN the memsize is always in terms of number of elements. while in C/C++ the memsize is provided in bytes. So in your C code while passing the memory size don't multiply by sizeof(whatever).
One more thing to remember is that in FORTRAN the memsize is always in terms of number of elements. while in C/C++ the memsize is provided in bytes. So in your C code while passing the memory size don't multiply by sizeof(whatever).
Wow Mo! I believe this statement right here is just as important as the "three well-known differences" between C and Fortran, that we all keep in mind when interacting between them:
Column- versus row-major arrays
Always passing by references versus MAYBE passing by reference
1-based indexing versus 0-based indexing
Which btw, as far as the last one goes, as I read more and more about Fortran, I'm discovering is not as important!
Dude thanks! I already know what to try for in my code! Come back home quickly!
As you pointed out I think the first one is the most important, that is row/col major
On C you always loop like this
loop over I
loop over J
a[I][J] ...
while in FORTRAN you loop
loop over J
loop over I
a(I,J) ...
For array numbers it starts by default from 1. You can actually tell fortran what should be the range of arrays.
So if you do
REAL, dimension(10) :: A
the 'A' would be an array of 10 element and the first element would be A(1) (not zero).
However, if you define
REAL, dimension(0:9) :: A
the 'A' would be an array of 10 element and the first element would be A(0).
something that I like, particularly when we use dummy/ghost nodes in PDE you can define
REAL, dimension(-2:7) :: A
the 'A' would be an array of 10 element and the first element would be A(-2).
So pretty much I use the negative indices for ghost nodes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.