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

Proper INTERFACE Syntax for CVF6.6 When Using C Subroutines

jkrob
Beginner
371 Views
All,

I am attempting to do some mixed-language programming (something which I know extreamly little about) and I need some help. Below is the Fortran routine which calls a C subroutine dec_jpeg2000 and to make it work properly, I know it needs an INTERFACE section to describe how the arguments are passed. I don't know what all is required within the INTERFACE section for this routine because a CHARACTER array (cpack) is being passed to the subroutine and an INTEGER array is being returned. If someone could give me some answers as to how the INTERFACE section is to be constucted, it would be most helpful.

Thanks in advance,
Jeff Krob

FORTRAN ROUTINE -

subroutine jpcunpack(cpack,len,idrstmpl,ndpts,fld)
!$$$ SUBPROGRAM DOCUMENTATION BLOCK
! . . .
! SUBPROGRAM: jpcunpack
! PRGMMR: Gilbert ORG: W/NP11 DATE: 2002-12-17
!
! ABSTRACT: This subroutine unpacks a data field that was packed into a
! JPEG2000 code stream
! using info from the GRIB2 Data Representation Template 5.40 or 5.40000.
!
! PROGRAM HISTORY LOG:
! 2002-12-17 Gilbert
!
! USAGE: CALL jpcunpack(cpack,len,idrstmpl,ndpts,fld)
! INPUT ARGUMENT LIST:
! cpack - The packed data field (character*1 array)
! len - length of packed field cpack().
! idrstmpl - Contains the array of values for Data ! ! !- Representation
! Template 5.40 or 5.40000
! ndpts - The number of data values to unpack
!
! OUTPUT ARGUMENT LIST:
! fld() - Contains the unpacked data values
!
! REMARKS: None
!
! ATTRIBUTES:
! LANGUAGE: XL Fortran 90
! MACHINE: IBM SP
!
!$$$

character(len=1),intent(in) :: cpack(len)
integer,intent(in) :: ndpts,len
integer,intent(in) :: idrstmpl(*)
real,intent(out) :: fld(ndpts)



integer :: ifld(ndpts)
integer(4) :: ieee
real :: ref,bscale,dscale
integer :: dec_jpeg2000


INTERFACE
SUBROUTINE dec_jpeg2000(cpack,len,ifld)
!DEC$ ATTRIBUTES C, REFERENCE, ALIAS:'_dec_jpeg2000' :: dec_jpeg2000 ! ia32 systems

character(len=1),intent(in) :: cpack(len)
integer :: len
integer :: ifld(ndpts)
END SUBROUTINE dec_jpeg2000
END INTERFACE



ieee = idrstmpl(1)
call rdieee(ieee,ref,1)
bscale = 2.0**real(idrstmpl(2))
dscale = 10.0**real(-idrstmpl(3))
nbits = idrstmpl(4)
!
! if nbits equals 0, we have a constant field where the reference value
! is the data value at each gridpoint
!
if (nbits.ne.0) then
! call gbytes(cpack,ifld,0,nbits,0,ndpts)
! iret=dec_jpeg2000(cpack,len,ifld)
call dec_jpeg2000(cpack,len,ifld)

do j=1,ndpts
fld(j)=((real(ifld(j))*bscale)+ref)*dscale
enddo
else
do j=1,ndpts
fld(j)=ref
enddo
endif
return
end
0 Kudos
0 Replies
Reply