Silverfrost Forums

Welcome to our forums

Problem by use of two libraries

7 Jan 2008 4:11 #2575

Hello, several years ago my Fortran 77 programs runs on a convex under UNIX with use of NAG Fortran Mark 14. Two libraries were linked to generate the executable. The NAG-Library and a self created library. The self created library includs many subroutines, which used subroutines from the NAG Library. It has been worked very well.

Now I want to restart my 'old' programs again. But now I use a Notebook (AMD-Prozessor), the command line version of the FTN95 compiler and a NAG Fortran library specially for this enviroment.

I use this batch file under DOS: @echo off rem Batch Datei rem Compilieren: FTN95 *.f95 /import_lib 'C:\Program Files\NAG\FL21\fldll214zl\bin\FLDLL214Z_nag.dll' rem Linken: SLINK *.obj 'C:\DISS\lib_dir\mslib.lib' 'C:\Program Files\NAG\FL21\fldll214zl\bin\FLDLL214Z_nag.dll' -FILE:mainew rem Löschen der Obj's: del *.obj rem RUN Excecutable: mainew.exe

Compiling and Linking works very nice. But I became the following runtime error:

'Access Violation' 'The instruction at adress 036e6dd8 attemped to write to location 00000002' ' .....'

This runtime error if only occurred, when the program used a subroutine of the self created library an these subrountine called a subroutine form NAG library. If I change my programs so that the subroutine of the NAG library is directly called from the program then no error is indicated.

I want use again the structure with the two libraries, because it is an very complex program. What can I do with the libraries so that they work like serveral years ago.

Thanks for any Information

Martin[/img]

7 Jan 2008 7:51 #2577

Two thoughts...

  1. Is mslib.lib your own library. Is it Fortran? You may need to recompile using FTN95.

  2. In any case I suggest you add /CHECKMATE to the FTN95 command line whilst testing then at least you should get more information when it crashes. Also try starting the executable up in the debugger SDBG.

8 Jan 2008 9:14 #2581

mslib.lib is a Fortran library and includes Fortran obj's. mslib.lib was generated through the FTN95 command 'SLINK -archive:mslib.lib'.

13 Jan 2008 6:33 #2630

Hello Paul,

thanks for your answer and your ideas. I apply your ideas but I didn't have success. I give your same more information, so I hope you have other suggestions.

This is a file in my self created Fortran library: mslib.lib. The subroutine Qd_sig use the subroutine D01AJF of the NAG library.

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

	  IMPLICIT NONE
! --- Input / Output ---
	  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 ---
	  Real*8	   ABSE 
	  Integer     LW, LIW, IFAIL
	  Parameter   ( LW = 2000, LIW = LW/2 )
	  Real*8      W(LW), IW(LIW)

! --- External ---
	  External    Fkt                     ! Integrand 
      External    D01AJF
! --- Settings ---
	  IFAIL = 1

! --- Integration ---
	  Call D01AJF(Fkt, a, b, EPSAB, EPSRE, RESU, ABSE, W, LW, IW, LIW, IFAIL)

RETURN
END 

Thanks in advance for any helpfull information.

Martin

14 Jan 2008 8:03 #2632

It looks like you are calling NAG routines from your library.

  1. Are you using /import_lib when you build your library?

  2. Try testing to see if you can call a NAG routine directly from your main program.

15 Jan 2008 11:12 #2639

Hello Paul,

thanks for your answer.

to 1.) The library mslib.lib is created without /import_lib.

to 2.) Yes, I can call NAG routines and functions from the main program.

Martin

15 Jan 2008 12:26 #2641

You need to use /import_lib when creating your library because the compiler needs to know that the NAG routines use the STDCALL protocol.

22 Jan 2008 2:41 #2687

Hello Paul,

thanks for your idea. I will test your idea, but I can't find the right command for the command line.

In the past I have used 'SLINK -archive:mslib.lib'. How can I creating my library with use of /import_lib?

Thanks in advance for help.

Martin

22 Jan 2008 5:00 #2688

You need to use /import_lib when you compile your library with FTN95 just as in your initial post but there is was for the main application. You will also need to reference the NAG dll when you apply SLINK to create the library.

Please login to reply.