Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

%VAL() on 64bit Intel64

ZlamalJakub
New Contributor III
1,108 Views
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.



0 Kudos
1 Solution
JVanB
Valued Contributor II
1,108 Views
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]

View solution in original post

0 Kudos
4 Replies
TimP
Honored Contributor III
1,108 Views
As you must modify it, best change it to use standard Fortran. f2003 came in several years ago.
0 Kudos
Steven_L_Intel1
Employee
1,108 Views
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.
0 Kudos
JVanB
Valued Contributor II
1,109 Views
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]
0 Kudos
ZlamalJakub
New Contributor III
1,108 Views
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.
0 Kudos
Reply