View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Dec 23, 2014 12:40 pm Post subject: |
|
|
I have had a quick look at this and this is as far as I have got.
You can ignore most of my comments above. Your code is basically OK.
You should write your C code and test it from a C main program using CHECKMATE but do not use CHECKMATE (for the C code) when accessing C from Fortran.
FTN95 adds one or more hidden arguments (and/or it modifies the assembler) when using CHECKMATE and these changes are probably causing the failure. The name of the function becomes PDFCreate__C but this change alone is not sufficient. You need to know the form of the hidden argument(s) etc and this is undocumented.
You can use /DEBUG for the C and /CHECKMATE for the Fortran (whilst testing) if this helps. Naturally release mode is always used after testing.
In situations where you need to add a null terminator in the Fortran then it usually requires trim(var)//char(0). |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Dec 23, 2014 10:12 pm Post subject: |
|
|
Good catch jalih!
Not the source of the crash, but a good catch! I'll update that ASAP.
The issue with the actual code (not this test case) is that the filename strinc is not statically defined. It can be any name, or any length. And, as the documentation so states, one shouldn't have to add a NULL to the string in the FTN code. Itr is supposed to automatic.
And, why does it fail in CHECKMATE, yet work in RELEASE? Makes no sense (yet!). |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Dec 23, 2014 10:16 pm Post subject: |
|
|
Paul, thanks for the reply.
I really hate to have conditional compilation to support what should be transparent to the code, so will look into what I might be able to do to get past the inconsistency. The usage of REF might work, but will surely require changes in the calling sequence (which, I guess, I am willing to do). |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Dec 23, 2014 11:18 pm Post subject: |
|
|
I think that you may not have understood my last post.
As I understand it you don't need to change anything. Just avoid using /CHECKMATE or /CHECK when compiling the C code. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Dec 23, 2014 11:25 pm Post subject: |
|
|
Paul, thanks for the additional explanation. I will investigate that approach.
Thanks,
Bill |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Dec 23, 2014 11:44 pm Post subject: |
|
|
Paul, yes, it does work! Thanks for the tip!
Moving on......
Bill |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Wed Dec 24, 2014 12:23 am Post subject: |
|
|
Oops, spoke too soon. Not quite what was intended, although it didn't crash, it didn't work (my first try was under RELEASE, dumb mistake).
I'll post the details later. Too much going on for the Holidays!
Bill |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Wed Dec 24, 2014 5:58 pm Post subject: Re: |
|
|
wahorger wrote: | Oops, spoke too soon. Not quite what was intended, although it didn't crash, it didn't work (my first try was under RELEASE, dumb mistake).
|
I just tested and it should work as Paul said. Just compile your external code without checkmate. You can still use checkmate on your Fortran code that calls external code without problems. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Dec 26, 2014 4:17 pm Post subject: |
|
|
jalih,
I did as you confirmed and Paul suggested with removing the /CHECKMATE option for the "C" code and all compiles fine.
I am continuing on in run/debug to find those little things that were fine in FTN77, but don't pass muster for FTN95!
Thanks for your help, and Happy New Year,
Bill |
|
Back to top |
|
|
|