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

NINT in Fortran

JohnNichols
Honored Contributor I
349 Views

The data from sensors is often read in C# and not Fortran.  

There is no NINT function in C#.  Instead to mimic it we need:

public static class Fortran
{
    public static int Nint(double a)
    {
        if (a > 0)
        {
            return (int)(a + 0.5);
        }
        else
        {
            return (int)(a - 0.5);
        }
    }
}

As histogram data is only a > 0, then the function is simple.  I had three outside histogram routines that did not return the same data.  In the end you check it with Intel Fortran and then fix the others or discard them.  

Ultimately the output ends up in an Intel Fortran program that will do an overnight MC analysis.  It will yield a single number that is either > 2.5 or less than 2.5.  If it is less than the structure has problems if it is more than you can move to the next problem structure.   When a new structure is built it should have a number that is from 4 to 5.  If a structure has a design life of 100 years then the number can drop (4-2.5)/100 = 0.015 per annum.  The eigen value equation will tell you this rate with a lot of work.  So far I have not found another method to solve it.  To solve it I use Fortran code that has been greatly assisted by the group here.   But sometimes there are computer programming questions that are language neutral. 

It does not matter how the data gets to the Intel Fortran, it just has to be repeatable.  If you are going to do a histogram it is faster with nint.   It is always faster in Fortran, and I do not use anything but Intel carrying over from Microsoft Fortran, but sometimes it is much human time faster to use the code for the sensor.  

There is one place one can ask sensible questions and get sensible answers, it is here.  If anyone knows another one I would be keen to hear it.  Ok, the MKL Forum, but the critical person is in both locations.  Fortran discourse, ah.  these are a bunch of boffins, nice people, great read, but for most stuff this is faster. 

 

There is a reason this forum has the most listed responses, last time I looked, and it is not because of Intel.  

-----------------------------------------------------------------------------------------------------------

James Phillips wrote a tremendous academic article on Joan of Arc.  It is worth a read, it is a masterful academic exercise.  Sometimes we need to step outside Fortran.  I am saying that in a really quiet study with no one else present.  

-----------------------------------------------------------------------------------------------------------

 

0 Kudos
0 Replies
Reply