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 

Parameters of subroutines

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Martin Schulz



Joined: 30 Jul 2007
Posts: 8

PostPosted: Tue Jan 29, 2008 7:36 pm    Post subject: Parameters of subroutines Reply with quote

Hi, if a call the NAG-subroutine D01AJF directly from the main program it works well. But an "Access Violation" is accured if D01AJF called from Qd-sig. The problem is to give the name of the function "Fst" via Qd-sig to D01AJF.

Code:
 PROGRAM MAINEW             
     IMPLICIT NONE
! --- Input / Output ---
     Real*8      Fst, a, b ,RESU      ! I: Integrand & Grenzen
! --- Locals of D01AJF ---
     Real*8      EPSAB, EPSRE           ! Abs.&Rel. Genauigk.: sig
     Parameter   ( EPSAB = 0.D0, EPSRE = 1.D-4 )
      Integer     LW, LIW, IFAIL
     Parameter   ( LW = 800, LIW = LW/4 )
     Real*8      W(LW), ABSE
      Integer     IW(LIW)
! --- External ---
     External    Fst, D01AJF, Qd_sig                     ! Integrand
! --- Settings ---
     IFAIL = 1
      a = 0.D0
      b = 2 * 3.14D0
! --- Integration ---
     Call D01AJF(Fst, a, b, EPSAB, EPSRE, RESU, ABSE, W, LW, IW, LIW, IFAIL)
      PRINT*,'D01AJF-RESU =',RESU
     Call Qd_sig(Fst, a, b, EPSAB, EPSRE, RESU)
      PRINT*,'Qd_sig-RESU =',RESU

      END


Code:
Subroutine Qd_sig (Fkt, a, b, EPSAB, EPSRE, RESU)             

     IMPLICIT NONE
     Real*8       Fkt, a, b        ! I: Integrand & Grenzen
     Real*8       EPSAB, EPSRE     ! I: Abs.& Rel. Genauigk.
     Real*8       RESU             ! O: Integrations Resultat
! --- Locals of D01AJF ---
     Integer     LW, LIW, IFAIL
     Parameter   ( LW = 800, LIW = LW/4 ) !Zu Testzwecken
     Real*8      W(LW), Fkt, ABSE
      Integer     IW(LIW)
! --- External ---
     External    Fkt, D01AJF                     ! Integrand
! --- Settings ---
     IFAIL = 1
     Call D01AJF(Fkt, a, b, EPSAB, EPSRE, RESU, ABSE, W, LW, IW, LIW, IFAIL)
 
      Return
     END


How can I solve my problem?
Thanks in advance for any idea.

regards Martin
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jan 29, 2008 8:03 pm    Post subject: Reply with quote

The NAG routines will use STDCALL.

Most users use /import_lib on the FTN95 command line and link together using the NAG DLL.

You will need to do something like this for the main program and any libraries that call the NAG routines.

In a Plato project you can use the Properties of a DLL Reference for this purpose.
Back to top
View user's profile Send private message AIM Address
Martin Schulz



Joined: 30 Jul 2007
Posts: 8

PostPosted: Thu Jan 31, 2008 7:30 pm    Post subject: Parameters of subroutines Reply with quote

Hello Paul,

I tried all your suggestions and also your sugesstions from my posted "Problem of two libraries".
I have examinate Qd-sig from my Fortran library to focus the problem. The main problem is to give a name of a function (Fst) via a subroutine (Qd_sig) to the NAG-subroutine.
If I examinate Fst from the parameter list in Qd-sig and give the name dircet to the NAG-subroutine, then it works.

I use /import_lib for any compilation.

Thanks in advance or any idea

regards Martin
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Feb 01, 2008 9:25 am    Post subject: Reply with quote

If you are passing an FTN95 subroutine to a NAG library routine then I would expect that it should be declared as F_STDCALL in your code.
I have never tried to do this but logically it is what one would expect.

It would look like this in your code...

F_STDCALL SUBROUTINE foo(x)
REAL x
...
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
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