- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have simplified my problem,but still I have a problem with interfaces.
milenko@milenkons:~/primeri/a8$ ifort -O2 -g -heap-arrays -traceback -check all -c pr2.f90
pr2.f90(21): error #6285: There is no matching specific subroutine for this generic subroutine call. [DFPMIN]
call dfpmin(v,func,dfunc)
-----^
compilation aborted for pr2.f90 (code 1)
dfpmin is located in dkd module.
milenko@milenkons:~/primeri/a8$ ifort -O2 -g -heap-arrays -traceback -check all -c pr2.f90
pr2.f90(21): error #6285: There is no matching specific subroutine for this generic subroutine call. [DFPMIN]
call dfpmin(v,func,dfunc)
-----^
compilation aborted for pr2.f90 (code 1)
dfpmin is located in dkd module.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, we still can't see attachments due to a forum bug. Remember that there has to be a matching specific that has all the arguments in the same order and which match in type, kind and rank. In the code you provided earlier, you had a DFPMIN routine with six. arguments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, bug is fixed and I can see your attachment.
You have the following call to DFPMIN:
v is declared in cons.f90 and is real, dimension(4). Right away there is a mismatch, as the corresponding dummy, p, is real(kind(1d0)) or real(8). But func and dfunc have problems as well. These are actually functions, not variables, and as such you can't simply put the type in. You can use an interface block or procedure declarations. Here's a version with INTERFACE:
I tried to unravel all of this. I got as far as defining a single module funcs that has all of the functions and subroutines, using a PROCEDURE declaration for the function arguments. This gets close, but I get to the line:
fp=func(p)
in function dfpmin. Here, p is real(8) but func (which I renamed func1 to avoid conflict) takes a single precision argument. I am not sure what you intended here so I stopped. I have attached my funcs.f90 and keep in mind the declaration of v in cons.f90. I hope this helps.
I think you're making things too hard by creating all these tiny modules.
You have the following call to DFPMIN:
[plain]call dfpmin(v,func,dfunc)[/plain]and the generic interface for it is defined in module if3:
[plain]interface dfpmin subroutine dfpmin(p,func,dfunc) real(kind(1d0)), dimension(4), intent(inout) :: p real(kind(1d0)) func real(kind(1d0)),dimension(4) :: dfunc end subroutine end interface[/plain]The number of arguments is right, but what about the type, kind and rank? Let's see:
v is declared in cons.f90 and is real, dimension(4). Right away there is a mismatch, as the corresponding dummy, p, is real(kind(1d0)) or real(8). But func and dfunc have problems as well. These are actually functions, not variables, and as such you can't simply put the type in. You can use an interface block or procedure declarations. Here's a version with INTERFACE:
[plain]module if3 interface dfpmin subroutine dfpmin(p,func,dfunc) real(kind(1d0)), dimension(4), intent(inout) :: p interface function func (p) real,dimension(4),intent(in) :: p real(kind(1d0)) func end function func end interface interface function dfunc(p) implicit none real(kind(1d0)),dimension(4),intent(in) :: p real(kind(1d0)),dimension(4) :: dfunc end function dfunc end interface end subroutine end interface end module[/plain]But this gets sort of messy, and goes against my recommendation of not writing interfaces for Fortran routines. Still, it should work - and it does get you past the problem you had with the generic. (I'm not sure why you are using a generic interface here - it seems unnecessary.) But then a new problem comes up, one you've had before. You declare an interface for DFPMIN in module if3, but also declare a procedure DFPMIN in module dkd, which is also visible to the caller. This is not allowed. (Oh, and you have also misdeclared the arguments to DFPMIN in dkd.)
I tried to unravel all of this. I got as far as defining a single module funcs that has all of the functions and subroutines, using a PROCEDURE declaration for the function arguments. This gets close, but I get to the line:
fp=func(p)
in function dfpmin. Here, p is real(8) but func (which I renamed func1 to avoid conflict) takes a single precision argument. I am not sure what you intended here so I stopped. I have attached my funcs.f90 and keep in mind the declaration of v in cons.f90. I hope this helps.
I think you're making things too hard by creating all these tiny modules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve,I have made a couple versions of programe and made just lot of copy paste.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have now finished the whole code,compiled all suboutines but still have problem in main code.
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c cons.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c nrtype.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c funcs.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c pr2.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -o pr2 pr2.o cons.o funcs.o nrtype.o
pr2.o: In function `pr2':
/home/milenko/primeri/b1/pr2.f90:24: undefined reference to `dfunc1_'
/home/milenko/primeri/b1/pr2.f90:24: undefined reference to `func1_'
I have declared them exactly the same way.
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c cons.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c nrtype.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c funcs.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -c pr2.f90
milenko@milenkons:~/primeri/b1$ ifort -O2 -g -heap-arrays -traceback -check all -o pr2 pr2.o cons.o funcs.o nrtype.o
pr2.o: In function `pr2':
/home/milenko/primeri/b1/pr2.f90:24: undefined reference to `dfunc1_'
/home/milenko/primeri/b1/pr2.f90:24: undefined reference to `func1_'
I have declared them exactly the same way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In pr2.f90, remove the procedure declarations of func1 and dfunc1. Those were needed only inside procedures that took functions as arguments. Then change the references in the call to dfpmin to func and dfunc instead of func1 and dfunc1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This works,thanks a lot.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page