- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I’m getting an error, which is really strange and i don’t understand why.
I have attached a reduced version, so that only the relevant code lines are included. I have also attached a screenshot of the error message.
I’m using the intel fortran compiler: 12.1.4.325 Build 20120410 with the Microsoft visual studio 2010.
The compile flags: ifort /debug:full /Zi /Od /traceback /free /w /check:all MultivariateInterpolatorIDW.for
I have found some modifications, which don’t cause an error, but it makes no sense to me, that the attached one is not working. I hope someone can explain it to me. Do i violate a fortran specification without knowing? Thank you for reading.
Modification which are fine
delete the keyword: target
OR
Change
integer( kind=i18 ), intent(inout), target :: axisIntervalIds(:) to
integer( kind=i18 ), intent(in), target :: axisIntervalIds(:)
OR
Change
integer( kind=i18 ), intent(in) :: axisDataPointIntervalId(:) to
integer( kind=i18 ), intent(in) :: axisDataPointIntervalId(12)
OR
Change the line to
weights( 1:12:2 ) = dataPerAxis( axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 2:12:2 ) ) to
test(:) = axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 2:12:2 )
weights( 1:12:2 ) = dataPerAxis(test)
module MultivariateInterpolatorIDW implicit none private integer, parameter :: r15 = SELECTED_REAL_KIND( 15, 307 ) integer, parameter :: i18 = SELECTED_INT_KIND( 18 ) public :: MVI_interpolate contains subroutine MVI_interpolate() real( kind=r15 ) :: interpolatedValueV(1) ! local real( kind=r15 ) :: dataPerAxis(12) integer( kind=i18 ) :: axisDataPointIntervalId(12) integer( kind=i18 ), target :: axisIntervalIds(12) dataPerAxis(:) = 10 axisDataPointIntervalId( : ) = 1 axisIntervalIds(:) = 1 interpolatedValueV( 1 ) = MVI_interpolateSub( dataPerAxis, axisDataPointIntervalId, axisIntervalIds ) end subroutine function MVI_interpolateSub( dataPerAxis, axisDataPointIntervalId, axisIntervalIds ) ! in real( kind=r15 ), intent(in) :: dataPerAxis(12) integer( kind=i18 ), intent(in) :: axisDataPointIntervalId(:) ! inout integer( kind=i18 ), intent(inout), target :: axisIntervalIds(:) ! return real( kind=r15 ) :: MVI_interpolateSub ! local real( kind=r15 ) :: weights(12) weights( 1:12:2 ) = dataPerAxis( axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 2:12:2 ) ) MVI_interpolateSub = 0.0 end function end module program main use MultivariateInterpolatorIDW implicit none call MVI_interpolate( ) end program
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried compiling your program with Intel(R) Visual Fortran Compiler 18.0.2.185 and with gfortran (5.4.0) . In both cases it ran without crashing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I interpreted the identified line as:
weights( 1:12:2 ) = dataPerAxis( axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 2:12:2 ) ) ! ### write (*,*) 'weights :',weights write (*,*) ' ' write (*,*) 'weights :' do k = 1,12,2 kk = axisDataPointIntervalId( k ) - 1 + axisIntervalIds( k+1 ) weights(k) = dataPerAxis( kk ) ! ### write (*,*) k,kk, weights(k) end do
I may have it wrong, but is that what you intended ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler may have a question as to how to handle the scalar (which may or may not be a bug). Try
weights( 1:12:2 ) = dataPerAxis( (axisDataPointIntervalId( 1:12:2 ) - 1) + axisIntervalIds( 2:12:2 ) ) or weights( 1:12:2 ) = dataPerAxis( (axisDataPointIntervalId( 1:12:2 ) - 1_i18) + axisIntervalIds( 2:12:2 ) )
If you continue to get the error, add a diagnostic print in front of the above line
print *,axisDataPointIntervalId( 1:12:2 ) print *,axisIntervalIds( 2:12:2 ) print *,axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 2:12:2 )
All three must produce a valid index into dataPerAxis (a value between 1:12, for use as an index into dataPerAxis)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
thanks for the replys.
@Roman: i have the feeling, it could be an bug with the older version. Unfortunately I have no access to a newer one, but I will try it out, if possible.
@John Campbell: You have identified the line correct. Your disassembled code is working, because it is the same way like storing the index into an array, before using. Actually it should make no difference from my point of view.
test(:) = axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 2:12:2 ) weights( 1:12:2 ) = dataPerAxis(test)
@Jim Dempsey: I tried both methods, unfortunately they don’t work. The printed index is always “1” for every three print cases.
I have the feeling, it could be an bug. I added this line
weights( 2:12:2 ) = dataPerAxis( axisDataPointIntervalId( 1:12:2 ) - 1 + axisIntervalIds( 1:12:2 ) )
before the critical one. It doesn’t cause an error, but the following one, which is strange to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is clearly a compiler bug. 12.x is very very old, the bug does not exist in current version!
I would not spend any time thinking about this! Either use a newer compiler or apply one of the many workarounds you already know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for the replys. i will try to get my hands on a newer version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Updating from V12.x may not be possible for youu.
In your sample code, the size of the array dataPerAxis is quite small, and can be indexed with standard INTEGER indexes. Your axisDataPointerIntervaID and axisIntervalIds are INTEGER(8) arrays. Some of the older compilers had issues with indexing an array with an integer type that was not the integer type used for allocation/declaration. With this in mind either:
a) Define axisDataPointerIntervaID and axisIntervalIds as INTEGER(4) arrays
or
b) Allocate/define dataPerAxis array using INTEGER(8) values (or literals)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Jim Dempsey: thank you for you suggestion. Unfortunately it didn’t work. I will try my luck with a newer version.
Is is possible to close this thread?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page