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

## .ne.

Valued Contributor II
425 Views
``if(Yb + YT .ne. D) then``

If D is the depth, then YB is the calculated distance to the centroid from the bottom and YT is the calculated distance to the centroid from the top and YB+YT should exactly equal D.

But YB and YT come from a lot of calculations, there is no way the real representations of YB and YT do not contain some minor errors.  There must be limits on the .ne. analysis to determine nearness,  can some one enlighten me as to the value?

I will use a delta in the real program.

4 Replies
Black Belt
415 Views

The designer of the program may very well have known that Vb+YT ought to be D, and that the then clause contains corrective code to select/derive a best value for Yb and/or YT. IOW this may be part of a convergence procedure.

Jim Dempsey

Valued Contributor II
373 Views

Jim:

Sorry - poor explanation.

I am using some old DXF drawing routines I wrote in Fortran in the last 1980s, to draw the bridge beams and the check the member properties are correct.  The manuals do not give drawings of all of the beams.  I can plot things like the Center of gravity and the neutral axis and do an engineering sanity check.  You learn this in doing FEM models.

One of the critical dimensions is the depth D, followed by the Bottom Centroid Yb and the Top centroid Yt-  ie the middle in real terms in tensor analysis.  Aside :: The problem is the teaching of geometry is to tightly tied to rules, and not to the underlying mathematics, the determinant is an area function etc...  Try to teach students to use this stuff and engineering students look at you like you are crazy.

So I put in a check to see if  D = Yb + Yt.  It is easy to mistype a number and this is a simple quick check.

As I was looking at the Fortran code I thought of the great book, how round is your circle.   So from there, if YB = Yb +- error1 and YT = Yt +- error2

and d = D +- error3

then if d = YB + YT,  what happens in the .ne. equation with random numerical errors, 1.00000000478  is that really one when the 478 is a rounding error.

The Intel manual does not tell me how the ne works.  Is it a bit by bit comparison of two registers, say or is "A"  the same as " A ". The humans says they are the same the computer says first is character*1 and the second is character*3.   What is true and false, so in some languages true is any number that is not zero, popped to that little problem the other day.

The intel manual does not tell me the rules, practical experience tells me what generally happens, but my mental interest was the actual algorithm.  The people who know this are the FORTRAN language people and the compiler writers, the boffins who inhabit this space.

boffin

• a person with knowledge or a skill considered to be complex, arcane, and difficult.
"he had a reputation as a tax boffin, a learned lawyer"

We small band of brothers?

Novice
368 Views

This usage is a common source of bugs.

Comparison operators on floating point values use exact (all bits) comparisons (after any necessary automatic type conversions). So unless you have full knowledge/control over the full-bit values of the floats you should not use them when you need comparisons with some tolerance. Write/find a set of "near" comparisons with relative and absolute tolerances for such purposes.

Valued Contributor II
366 Views

Thanks, that is what I thought, but it is nice that it is confirmed.

Conte and deBoore in 1979 taught me the small delta trick, but as @mecej4 noted there are some issues using IV code and one can add writing code on the fly.