Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
IDL crashes when calling DLL from FORTRAN
HI, everyone IDL do loops quit slow so I try to use fortran to speed up. here is my code in Fortran SUBROUTINE NMC_ENS_BOX_AVERAGING_IDL(argc, argv) !Called by IDL INTEGER*8 argc, argv(*) !Argc and Argv are integers j = LOC(argc) !DEC$ ATTRIBUTES DLLEXPORT :: NMC_ENS_BOX_AVERAGING_IDL CALL NMC_ENS_BOX_AVERAGING_F90(%VAL(argv(1)), %VAL(argv(2)), %VAL(argv(3)), & %VAL(argv(4)), %VAL(argv(5)), %VAL(argv(6)), & %VAL(argv(7)), %VAL(argv(8)), %VAL(argv(9)), & %VAL(argv(10)), %VAL(argv(11))) RETURN END Subroutine NMC_ENS_BOX_AVERAGING_F90(obs, nobs, obsX, obsY, & lons, lats, NX, NY, & maskGrid, firstGuess, & gValue) implicit none integer*8 :: nobs integer*4 :: NX, NY real*4, dimension(nobs) :: obs, obsX, obsY integer (kind=1) :: maskGrid(NX,NY) real*4 :: firstGuess(NX,NY) real*4 :: lons(NX,NY), lats(NX,NY) real*4 :: gValue(NX,NY) integer :: ix, iy, istn real*4 :: sCount(NX,NY) real*4 :: dist(NX,NY) integer :: mindex(2) ! define grid values gValue = 0.0 Return !////// IF i return here , nothing happend sCount = 0.0 Return !////// IF i return, IDL crash What looked like in IDL is FORTRAN_Status = CALL_EXTERNAL(FORTRAN_DLL, 'NMC_ENS_BOX_AVERAGING_IDL', $ reform(data_out[t,*]), nObs, stationLon, stationLat, $ maskLon, maskLat, FIX(NLON), FIX(NLAT), $ mask_GRID, firstGuess, $ data_output, /F_VALUE) FORTRAN_DLL STRING = 'nmc_ens_box_averaging_f90.dll' <Expression> STRING = 'NMC_ENS_BOX_AVERAGING_IDL' <Expression> FLOAT = Array[40532] NOBS LONG = 40532 STATIONLON FLOAT = Array[40532] STATIONLAT FLOAT = Array[40532] MASKLON FLOAT = Array[1261, 721] MASKLAT FLOAT = Array[1261, 721] <Expression> INT = 1261 <Expression> INT = 721 MASK_GRID BYTE = Array[1261, 721] FIRSTGUESS FLOAT = Array[1261, 721] DATA_OUTPUT FLOAT = Array[1261, 721] I am aware that number of arguments and their types could cause crash. If someone could help me on that...Thanks verymuch I have been debuging all night...... Best Jian