Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Unions

fobermaier
Beginner
761 Views
Hello!

I'm having problems with a Structure/Union.
There is a program and a DLL who both have this
structure defined:

structure /T_ANF/
character(len=10) :: cBefehl
union
map
character(len = 32756) :: cParameter
end map
map
integer(4) :: iaParameter(8189)
end map
end union
end structure

The interface to the DLL is defined like this:

interface
subroutine ASSROU(ass1par)
!MS$Attributes DLLIMPORT :: ASSROU
structure /T_ANF/
character(len=10) :: cBefehl
union
map
character(len = 32756) :: cParameter
end map
map
integer(4) :: iaParameter(8189)
end map
end union
end structure
type (T_ANF) :: ass1par
end subroutine
end interface

The Structure is filled by this function
!
subroutine anfrage_schreiben(ANF, string)
!
! anfrage in string schreiben
type (T_ANFRAGE) :: ANF
type (T_ANF) :: string
integer(4) :: i, iPos

write(string%cBefehl,'(a5,f5.2)') 'ROU ', anf_release
string%iaParameter(1) = anf%anzStart
iPos = 1
do i = 1, anf%anzStart
string%iaParameter(iPos + 2 * i - 1) = anf%hsta(i)
string%iaParameter(iPos + 2 * i ) = anf%zeit(i)
end do
iPos = iPos + 2 * anf%anzStart + 1
string%iaParameter(iPos) = anf%anzZiel
do i = 1, anf%anzZiel
string%iaParameter(iPos + i) = anf%hste(i)
end do
end subroutine

The structure is read from by this function
!
subroutine anfrage_lesen(ANF, string)
!
! anfrage aus string lesen

type (T_ANFRAGE) :: ANF
type (T_ANF) :: string
integer(4) :: i, iPos

anf%anzStart = string%iaParameter(1)
iPos = 1
do i = 1, anf%anzStart
anf%hsta(i) = string%iaParameter(iPos + 2 * i - 1)
anf%zeit(i) = string%iaParameter(iPos + 2 * i)
end do
iPos = iPos + 2 * anf%anzStart + 1
anf%anzZiel = string%iaParameter(iPos)
do i = 1, anf%anzZiel
anf%hste(i) = string%iaParameter(iPos + i)
end do

end subroutine

Here are the first values of the Integer Array
in the program | in the DLL
1 #00000001 | #2fff0000
2 #00002fff | #00f00000
3 #000000f0 | #19ba0000
4 #000019ba | #2fff0000
5 #00002fff | #2ff80000

There are 3 bytes missing!

thanks in advance
Felix Obermaier
0 Kudos
0 Replies
Reply