|
|
 |
 |
 |
 |
Fortran Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
qsort problem with module
Hi, I'm trying to use the "portability function" qsort in CVF 6.6 (in module dfport). The code below gives a compile error: test_qsort.obj : error LNK2001: unresolved external symbol _CMP_REAL4 If I do not use the module qmod (i.e. remove the first 3 lines and the 'end module' line, then in the main program replace 'use qmod' with 'use dfport') it compiles and runs OK. Is this the expected behaviour? !----------------------------------------------- ! test_qsort.f90 !----------------------------------------------- module qmod use dfport contains !----------------------------------------------- integer(2) function cmp_real4(arg1,arg2) real(4) :: arg1,arg2 cmp_real4 = arg1 - arg2 end function !----------------------------------------------- subroutine qtester integer, parameter :: N = 20 real(4) :: a(N) integer(2),external :: cmp_real4 integer :: i,len=4 do i = 1,N a(i) = N-i enddo call qsort(a,N,len,cmp_real4) write(*,*) a end subroutine end module !----------------------------------------------- program main use qmod call qtester end ------------ And now a word from our sponsor ---------------------- For a quality mail server, try SurgeMail, easy to install, fast, efficient and reliable. Run a million users on a standard PC running NT or Unix without running out of power, use the best! ---- See http://netwinsite.com/sponsor/sponsor_surgemail.htm ----
Gib Bogle wrote: > Hi, > I'm trying to use the "portability function" qsort in CVF 6.6 (in module > dfport). The code below gives a compile error: > test_qsort.obj : error LNK2001: unresolved external symbol _CMP_REAL4 > If I do not use the module qmod (i.e. remove the first 3 lines and the > 'end module' line, then in the main program replace 'use qmod' with 'use > dfport') it compiles and runs OK. Is this the expected behaviour? > !----------------------------------------------- > ! test_qsort.f90 > !----------------------------------------------- > module qmod > use dfport > contains > !----------------------------------------------- > integer(2) function cmp_real4(arg1,arg2) > real(4) :: arg1,arg2 > cmp_real4 = arg1 - arg2 > end function > !----------------------------------------------- > subroutine qtester > integer, parameter :: N = 20 > real(4) :: a(N) > integer(2),external :: cmp_real4 > integer :: i,len=4 > do i = 1,N > a(i) = N-i > enddo > call qsort(a,N,len,cmp_real4) > write(*,*) a > end subroutine > end module > !----------------------------------------------- > program main > use qmod > call qtester > end
Delete the line integer(2),external :: cmp_real4 in subroutine "qtester"; cmp_real4 is already a predeclared routine in the module. -- mecej4
On May 16, 5:56 am, Gib Bogle <g.bo@auckland.no.spam.ac.nz> wrote:
> Hi, > I'm trying to use the "portability function" qsort in CVF 6.6 (in module > dfport). The code below gives a compile error: > test_qsort.obj : error LNK2001: unresolved external symbol _CMP_REAL4 > If I do not use the module qmod (i.e. remove the first 3 lines and the > 'end module' line, then in the main program replace 'use qmod' with 'use > dfport') it compiles and runs OK. Is this the expected behaviour? > !----------------------------------------------- > ! test_qsort.f90 > !----------------------------------------------- > module qmod > use dfport > contains > !----------------------------------------------- > integer(2) function cmp_real4(arg1,arg2) > real(4) :: arg1,arg2 > cmp_real4 = arg1 - arg2 > end function > !----------------------------------------------- > subroutine qtester > integer, parameter :: N = 20 > real(4) :: a(N) > integer(2),external :: cmp_real4 > integer :: i,len=4 > do i = 1,N > a(i) = N-i > enddo > call qsort(a,N,len,cmp_real4) > write(*,*) a > end subroutine > end module > !----------------------------------------------- > program main > use qmod > call qtester > end > ------------ And now a word from our sponsor ---------------------- > For a quality mail server, try SurgeMail, easy to install, > fast, efficient and reliable. Run a million users on a standard > PC running NT or Unix without running out of power, use the best! > ---- Seehttp://netwinsite.com/sponsor/sponsor_surgemail.htm ----
The declaration integer(2),external :: cmp_real4 in subroutine QTESTER is redundant. cmp_real4 is a module procedure, not an external procedure. Its interface is automatically visible from qtester.
highegg <high @gmail.com> wrote: > The declaration > integer(2),external :: cmp_real4 > in subroutine QTESTER is redundant. cmp_real4 is a module procedure, > not an external procedure. Its interface is automatically visible from > qtester. Except that I'd dispute the term "redundant". I'd say it was contradictory rather than redundant. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain
On May 16, 7:27 am, nos@see.signature (Richard Maine) wrote: > highegg <high @gmail.com> wrote: > > The declaration > > integer(2),external :: cmp_real4 > > in subroutine QTESTER is redundant. cmp_real4 is a module procedure, > > not an external procedure. Its interface is automatically visible from > > qtester. > Except that I'd dispute the term "redundant". I'd say it was > contradictory rather than redundant. > -- > Richard Maine | Good judgement comes from experience; > email: last name at domain . net | experience comes from bad judgement. > domain: summertriangle | -- Mark Twain
I meant the term redundant in the sense "If you remove it, it's OK". That could have been a misuse, though, I'm not a native speaker.
highegg wrote: > On May 16, 7:27 am, nos @see.signature (Richard Maine) wrote: >> highegg <high @gmail.com> wrote: >> > The declaration >> > integer(2),external :: cmp_real4 >> > in subroutine QTESTER is redundant. cmp_real4 is a module procedure, >> > not an external procedure. Its interface is automatically visible from >> > qtester. >> Except that I'd dispute the term "redundant". I'd say it was >> contradictory rather than redundant. >> -- >> Richard Maine | Good judgement comes from experience; >> email: last name at domain . net | experience comes from bad judgement. >> domain: summertriangle | -- Mark Twain > I meant the term redundant in the sense "If you remove it, it's OK". > That could have been a misuse, though, I'm not a native speaker.
In that case, a fox in a henhouse is merely "redundant", rather than an "unlawful combatant" :) . -- -- mecej4
highegg wrote: > On May 16, 5:56 am, Gib Bogle <g.bo @auckland.no.spam.ac.nz> wrote: >>Hi, >>I'm trying to use the "portability function" qsort in CVF 6.6 (in module >>dfport). The code below gives a compile error: >>test_qsort.obj : error LNK2001: unresolved external symbol _CMP_REAL4 >>If I do not use the module qmod (i.e. remove the first 3 lines and the >>'end module' line, then in the main program replace 'use qmod' with 'use >>dfport') it compiles and runs OK. Is this the expected behaviour? >>!----------------------------------------------- >>! test_qsort.f90 >>!----------------------------------------------- >>module qmod >>use dfport >>contains >>!----------------------------------------------- >>integer(2) function cmp_real4(arg1,arg2) >>real(4) :: arg1,arg2 >>cmp_real4 = arg1 - arg2 >>end function >>!----------------------------------------------- >>subroutine qtester >>integer, parameter :: N = 20 >>real(4) :: a(N) >>integer(2),external :: cmp_real4 >>integer :: i,len=4 >>do i = 1,N >> a(i) = N-i >>enddo >>call qsort(a,N,len,cmp_real4) >>write(*,*) a >>end subroutine >>end module >>!----------------------------------------------- >>program main >>use qmod >>call qtester >>end >>------------ And now a word from our sponsor ---------------------- >>For a quality mail server, try SurgeMail, easy to install, >>fast, efficient and reliable. Run a million users on a standard >>PC running NT or Unix without running out of power, use the best! >>---- Seehttp://netwinsite.com/sponsor/sponsor_surgemail.htm ---- > The declaration > integer(2),external :: cmp_real4 > in subroutine QTESTER is redundant. cmp_real4 is a module procedure, > not an external procedure. Its interface is automatically visible from > qtester.
Thanks to everyone. Gib ------------ And now a word from our sponsor --------------------- For a secure high performance FTP using SSL/TLS encryption upgrade to SurgeFTP ---- See http://netwinsite.com/sponsor/sponsor_surgeftp.htm ----
I realize that the OP was using CVF; however just for information, the following code works with Intel Fortran (ifort). SIZEOF_SIZE_T is defined in IPORT (and here will have the value 8). Source: Intel Fortran Libraries Reference (on-line at http://www.intel.com/cd/software/products/asmo-na/eng/279831.htm (see the example QSORT driver program there). Skip Knoble module qmod use ifport contains !----------------------------------------------- integer(2) function cmp_real4(arg1,arg2) real(4) :: arg1,arg2 cmp_real4 = arg1 - arg2 end function !----------------------------------------------- subroutine qtester integer (SIZEOF_SIZE_T) N, len real(4) :: a(26) integer :: i N=26 len=4 do i = 1,N a(i) = N-i enddo call qsort(a,N,len,cmp_real4) write(*,*) a end subroutine end module !----------------------------------------------- program main use qmod call qtester end On Wed, 16 May 2007 15:56:41 +1200, Gib Bogle <g.bo @auckland.no.spam.ac.nz> wrote: -|Hi, -| -|I'm trying to use the "portability function" qsort in CVF 6.6 (in module -|dfport). The code below gives a compile error: -|test_qsort.obj : error LNK2001: unresolved external symbol _CMP_REAL4 -| -|If I do not use the module qmod (i.e. remove the first 3 lines and the -|'end module' line, then in the main program replace 'use qmod' with 'use -|dfport') it compiles and runs OK. Is this the expected behaviour? -| -|!----------------------------------------------- -|! test_qsort.f90 -|!----------------------------------------------- -|module qmod -|use dfport -|contains -| -|!----------------------------------------------- -|integer(2) function cmp_real4(arg1,arg2) -|real(4) :: arg1,arg2 -|cmp_real4 = arg1 - arg2 -|end function -| -|!----------------------------------------------- -|subroutine qtester -|integer, parameter :: N = 20 -|real(4) :: a(N) -|integer(2),external :: cmp_real4 -|integer :: i,len=4 -|do i = 1,N -| a(i) = N-i -|enddo -|call qsort(a,N,len,cmp_real4) -|write(*,*) a -|end subroutine -| -|end module -| -|!----------------------------------------------- -|program main -|use qmod -|call qtester -|end -|------------ And now a word from our sponsor ---------------------- -|For a quality mail server, try SurgeMail, easy to install, -|fast, efficient and reliable. Run a million users on a standard -|PC running NT or Unix without running out of power, use the best! -|---- See http://netwinsite.com/sponsor/sponsor_surgemail.htm ----
|
 |
 |
 |
 |
|