[IMSL] QDAGI using a module?

[IMSL] QDAGI using a module?

Hi, I'm trying to use QDAGI http://www.roguewave.com/Portals/0/products/imsl-numerical-libraries/for...

I'm following the example in the webpage but I want to do it in a module.

When I try to compile it I get this error:

$ make clean && make
rm -f modulo.X modulo1.o programa.o *.mod
ifort -openmp -I/common/vni/imsl/fnl700/rdhin111x64/include -c modulo1.f90
modulo1.f90(22): error #6632: Keyword arguments are invalid without an explicit interface. [ERRABS]
 CALL QDAGI (F, BOUND, INTERV, RESULT, ERRABS=ERRABS, &
--------------------------------------------^
modulo1.f90(23): error #6632: Keyword arguments are invalid without an explicit interface. [ERREST]
 ERREST=ERREST)
-----------------^
compilation aborted for modulo1.f90 (code 1)
make: *** [modulo1.o] Error 1

This is the module I wrote:

module modulo1
 USE UMACH_INT
 USE CONST_INT
 IMPLICIT NONE
CONTAINS
SUBROUTINE INTEGRATE (VALUE, LOWER_BOUND)
 INTEGER :: INTERV, NOUT
 DOUBLE PRECISION :: VALUE, LOWER_BOUND
 DOUBLE PRECISION :: ABS, DLOG, BOUND, ERRABS, ERREST, &
 ERROR, ERRREL, EXACT, F, PI, RESULT
 INTRINSIC :: ABS, DLOG
 EXTERNAL :: F
! Get output unit number
 CALL UMACH (2, NOUT)
! Set limits of integration
 BOUND = 0.0
 INTERV = 1
! Set error tolerances
 ERRABS = 0.0
 CALL QDAGI (F, BOUND, INTERV, RESULT, ERRABS=ERRABS, &
 ERREST=ERREST)
! Print results
 PI = CONST('PI')
 EXACT = -PI*ALOG(10.)/20.
 ERROR = ABS(RESULT-EXACT)
 VALUE = RESULT
 WRITE (NOUT,99999) RESULT, EXACT, ERREST, ERROR
99999 FORMAT (' Computed =', F8.3, 13X, ' Exact =', F8.3//' Error ', &
 'estimate =', 1PE10.3, 6X, 'Error =', 1PE10.3)
END SUBROUTINE INTEGRATE
FUNCTION F (X)
DOUBLE PRECISION :: X
DOUBLE PRECISION :: F
DOUBLE PRECISION DLOG
INTRINSIC DLOG
 F = DLOG(X)/(1.+(10.*X)**2)
END FUNCTION F
end module modulo1

Any idea of what I'm doing wrong?

Thanks for the help!

5 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

When calling Mathematics and Statistical library routines from a Fortran program, you should use the numerical_libraries module to provide interface blocks and parameter definitions for the routines. Including the following USE statement in your calling program will verify the correct usage of the IMSL routines at compile time:

USE numerical_libraries

When you add the USE numerical_libraries line to your program, you should not declare the called routines as external with the EXTERNAL statement.

When calling Mathematics and Statistical library routines, you do not need to declare the functions or subroutines separately.

When also calling Fortran 90 MP library routines, you should instead use the imslf90 module to provide interface blocks and parameter definitions for all the Fortran 90 MP routines and the MATH and STAT library routines. Including the following USE statement in your calling program will verify the correct usage of the IMSL routines at compile time:
USE IMSLF90

For more information about calling the Fortran 90 MP routines, see the IMSL Libraries online PDF file.
The free-form Fortran 95/90 example program below invokes the function AMACH and the subroutine UMACH from the IMSL Libraries. The AMACH function retrieves real machine constants that define the computer's real arithmetic. A value for positive machine infinity is returned (Infinity). The subprogram UMACH retrieves the output unit number.

! This free-form example demonstrates how to call
! IMSL routines from Visual Fortran.
!
! The module numerical_libraries includes the Math and
! Stat libraries; these contain the type declarations
! and interface statements for the library routines.

PROGRAM SHOWIMSL

USE NUMERICAL_LIBRARIES
INTEGER NOUT
REAL RINFP

! The AMACH function and UMACH subroutine are
! declared in the numerical_libraries module

CALL UMACH(2,NOUT)
RINFP = AMACH(7)
WRITE(NOUT,*) 'REAL POSITIVE MACHINE INFINITY = ',RINFP
END PROGRAM

Thanks for your answer.
I'm having some troubles following :_(
I understood that I should add "USE numerical_libraries" to my main program.


PROGRAM programa

USE numerical_libraries

USE modulo1

implicit none

DOUBLE PRECISION           :: VALUE, LOWER_BOUND

LOWER_BOUND = 0.0D0

CALL INTEGRATE (VALUE, LOWER_BOUND)

PRINT *, VALUE

END PROGRAM programa

I think you also said that I should not declare "F" as external in my module. This is how my module looks like now


module modulo1

      USE UMACH_INT

      USE CONST_INT

      IMPLICIT   NONE

CONTAINS
SUBROUTINE INTEGRATE (VALUE, LOWER_BOUND)

      INTEGER                          :: INTERV, NOUT

      DOUBLE PRECISION                 :: VALUE, LOWER_BOUND

      DOUBLE PRECISION                 :: ABS, DLOG, BOUND, ERRABS, ERREST, &

                                          ERROR, ERRREL, EXACT, F, PI, RESULT

      INTRINSIC                        :: ABS, DLOG

!                                 Get output unit number

      CALL UMACH (2, NOUT)

!                                 Set limits of integration

      BOUND  = 0.0d0

      INTERV = 1

!                                 Set error tolerances

      ERRABS = 0.0d0

      CALL QDAGI (F, BOUND, INTERV, RESULT, ERRABS,  &

                 ERREST)

!                                 Print results

      PI    = CONST('PI')

      EXACT = -PI*DLOG(10.0d0)/20.0d0

      ERROR = ABS(RESULT-EXACT)

      VALUE = RESULT

      WRITE (NOUT,99999) RESULT, EXACT, ERREST, ERROR

99999 FORMAT (' Computed =', F8.3, 13X, ' Exact =', F8.3//' Error ', &

            'estimate =', 1PE10.3, 6X, 'Error =', 1PE10.3)

END SUBROUTINE INTEGRATE 
FUNCTION F (X)

DOUBLE PRECISION                 :: X

DOUBLE PRECISION                 :: F

DOUBLE PRECISION                 :: DLOG

INTRINSIC                        :: DLOG

   F = DLOG(X)/(1.0d0+(10.0d0*X)**2)

END FUNCTION F

end module modulo1

Now when I run the program I get segmentation fault. Could you explain me what I'm doing wrong?


$ ./program.X

forrtl: severe (174): SIGSEGV, segmentation fault occurred

Image              PC                Routine            Line        Source

libimsl.so         00002B91327DA38C  Unknown               Unknown  Unknown

libimsl.so         00002B91327D0823  Unknown               Unknown  Unknown

libimsl.so         00002B913280DCAE  Unknown               Unknown  Unknown

program.X          0000000000400D54  Unknown               Unknown  Unknown

program.X          0000000000400F3C  Unknown               Unknown  Unknown

program.X          0000000000400CBC  Unknown               Unknown  Unknown

libc.so.6          000000333781D994  Unknown               Unknown  Unknown

program.X          0000000000400BC9  Unknown               Unknown  Unknown

Thanks for your help and time!

Your source code contains numerous errors, and there are indications that you are not sufficiently familiar with default variable types, declaration scope and calling subprograms with optional arguments.
The attached compressed archive contains two source files that show how to call the IMSL quadrature routine with the integrand function defined in a module, as you required.
The program gives the output


 Computed =-0.36169              Exact =-0.36169
 Error  3.253E-14

 -0.361689220620806

Anlagen: 

AnhangGröße
Herunterladen qagi.tgz603 Bytes

Thanks a lot!

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen