![]() This means changing “pa” to be a “double **” in the C code and adjusting accordingly. “b” needs to be passed by reference in order to be used in the Fortran routine. However, I got the following results… Did I do something stupid again :( I slightly modified the previous C code and F code which passing the c_ptr variable “b” by value. Void f2c_func_( bool1, letter1, numint1, numint2, numfloat1,\ For example, you can use the isocbinding intrinsic. It states There are other solutions to calling C from Fortran. bool1, letter1, numint1, numint2, numfloat1,numdoub1, numshor1 When reading the manual PGI User’s Guide to find example demonstrating how can I call the C function in my Fortran code, I got the example 12.3 and also noticed that paragraph above it. Finally, you should not increment “pa” since you want it pointing to the starting address of “a”, not the end.īy the way, I noticed that the number of arguments passed between Example 12.3 and Example 12.4 (on the document “PGI User’s Guide”) are different! Is there any key point I missed?Ĭall f2c_func_(bool1, letter1, numint1, numint2, numfloat1, numdoub1, numshor1) You need to dynamically allocate “a” so that it can be used in the Fortran routine. Secondly, “a” is a local array being allocated on the stack who’s lifetime will end once the routine returns. First, by default Fortran passes by reference, so you need to be passing “**pa” not “*pa”. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |