- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have following code
[bash]... pointer (p1,i1) ! i1 is only dummy variable p1=LOC(value) ! in p1 is address of value call sub(%VAL(p1)) ! and pass address to routine ... subroutine sub(i1) use ifwinty integer(LPVOID) i1 ! in i1 should be address of value ... end subroutine[/bash]
It works correctly on win32 architecture but when I tried to compile code for Intel64 I obtained:
error #6633: The type of the actual argument differs from the type of the dummy argument. [%VAL]
So I expect that %VAL is passing only 32bit value instead 64bit value of pointer p1 because subroutine sub parameter i1 is defined as 64bit integer.
My question is how can I find what I am doing wrong.
[bash]... pointer (p1,i1) ! i1 is only dummy variable p1=LOC(value) ! in p1 is address of value call sub(%VAL(p1)) ! and pass address to routine ... subroutine sub(i1) use ifwinty integer(LPVOID) i1 ! in i1 should be address of value ... end subroutine[/bash]
It works correctly on win32 architecture but when I tried to compile code for Intel64 I obtained:
error #6633: The type of the actual argument differs from the type of the dummy argument. [%VAL]
So I expect that %VAL is passing only 32bit value instead 64bit value of pointer p1 because subroutine sub parameter i1 is defined as 64bit integer.
My question is how can I find what I am doing wrong.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What he said:
[fortran]module resolve implicit none interface print_kind module procedure pk1,pk2,pk4,pk8 end interface print_kind contains subroutine pk1(x) integer(1) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk1 subroutine pk2(x) integer(2) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk2 subroutine pk4(x) integer(4) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk4 subroutine pk8(x) integer(8) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk8 end module resolve program test use resolve use ifwin implicit none integer i1 pointer(p1,i1) integer, target :: value p1 = LOC(value) call print_kind(%val(p1)) write(*,'(a,i0)') 'LPVOID = ',LPVOID end program test [/fortran]
Output:
[plain]Kind = 8 LPVOID = 8[/plain]
[fortran]module resolve implicit none interface print_kind module procedure pk1,pk2,pk4,pk8 end interface print_kind contains subroutine pk1(x) integer(1) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk1 subroutine pk2(x) integer(2) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk2 subroutine pk4(x) integer(4) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk4 subroutine pk8(x) integer(8) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk8 end module resolve program test use resolve use ifwin implicit none integer i1 pointer(p1,i1) integer, target :: value p1 = LOC(value) call print_kind(%val(p1)) write(*,'(a,i0)') 'LPVOID = ',LPVOID end program test [/fortran]
Output:
[plain]Kind = 8 LPVOID = 8[/plain]
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you must modify it, best change it to use standard Fortran. f2003 came in several years ago.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried a test case based on your incomplete paraphrase of the actual code, and it worked fine with generated interface checking. My guess is that your actual code looks different. Please post a small but complete example that demonstrates the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What he said:
[fortran]module resolve implicit none interface print_kind module procedure pk1,pk2,pk4,pk8 end interface print_kind contains subroutine pk1(x) integer(1) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk1 subroutine pk2(x) integer(2) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk2 subroutine pk4(x) integer(4) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk4 subroutine pk8(x) integer(8) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk8 end module resolve program test use resolve use ifwin implicit none integer i1 pointer(p1,i1) integer, target :: value p1 = LOC(value) call print_kind(%val(p1)) write(*,'(a,i0)') 'LPVOID = ',LPVOID end program test [/fortran]
Output:
[plain]Kind = 8 LPVOID = 8[/plain]
[fortran]module resolve implicit none interface print_kind module procedure pk1,pk2,pk4,pk8 end interface print_kind contains subroutine pk1(x) integer(1) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk1 subroutine pk2(x) integer(2) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk2 subroutine pk4(x) integer(4) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk4 subroutine pk8(x) integer(8) x write(*,'(a,i0)') 'Kind = ',kind(x) end subroutine pk8 end module resolve program test use resolve use ifwin implicit none integer i1 pointer(p1,i1) integer, target :: value p1 = LOC(value) call print_kind(%val(p1)) write(*,'(a,i0)') 'LPVOID = ',LPVOID end program test [/fortran]
Output:
[plain]Kind = 8 LPVOID = 8[/plain]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for code example.
I have found problem. My code is more complicated that I previously posted: [bash] ... pointer (p1,i1) ! i1 is only dummy variable character*10 name integer*4 iLen name="String" p1=LOC(name) ! in p1 is address of value
iLen=LEN(name) call sub(%VAL(p1),...,%VAL(iLen)) ! and pass address to routine , length of character last and by value ... subroutine sub(i1,....,i7) use ifwinty integer(LPVOID) i1 ! in i1 should be address of value ... integer(LPVOID) i7 ... end subroutine [/bash]
and problem is caused by length of string passed as last parameter because %VAL(iLen) is integer*4 (32 bit) and not INTEGER(HANDLE) (64bit)
So i will need to modify my routine "sub" which I use to call functions from external dll in this specific case.
I am sorry to disturb You.
I have found problem. My code is more complicated that I previously posted: [bash] ... pointer (p1,i1) ! i1 is only dummy variable character*10 name integer*4 iLen name="String" p1=LOC(name) ! in p1 is address of value
iLen=LEN(name) call sub(%VAL(p1),...,%VAL(iLen)) ! and pass address to routine , length of character last and by value ... subroutine sub(i1,....,i7) use ifwinty integer(LPVOID) i1 ! in i1 should be address of value ... integer(LPVOID) i7 ... end subroutine [/bash]
and problem is caused by length of string passed as last parameter because %VAL(iLen) is integer*4 (32 bit) and not INTEGER(HANDLE) (64bit)
So i will need to modify my routine "sub" which I use to call functions from external dll in this specific case.
I am sorry to disturb You.

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