forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Linking C and FTN95 under Plato IDE
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Dec 23, 2014 12:40 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Tue Dec 23, 2014 10:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Tue Dec 23, 2014 10:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Dec 23, 2014 11:18 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Tue Dec 23, 2014 11:25 pm    Post subject: Reply with quote

Paul, thanks for the additional explanation. I will investigate that approach.

Thanks,
Bill
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Tue Dec 23, 2014 11:44 pm    Post subject: Reply with quote

Paul, yes, it does work! Thanks for the tip!

Moving on......
Bill
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Wed Dec 24, 2014 12:23 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Wed Dec 24, 2014 5:58 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Dec 26, 2014 4:17 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group