Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • hamid3252September 20, 2010 3:51 AM PDT   
    Exception handling

    Hi,
     
    Would you please let me know how I can catch exceptions in Intel Fortran? I have been working with C++ and Java and I expect there should be a way similar to what exists in C++/Java to handle exceptions. Please let me know how to handle the situations.
     
    Thank you,
    Hamidreza,


    TimP (Intel)September 20, 2010 6:33 AM PDT
    Rate
     
    Exception handling

    Fortran doesn't have a complete signal handling facility parallel to C++.   I've seen applications which use Fortran and C++ in a highly intertwined way, with the objective of doing this.  The serious non-portabilities are mostly within the C++ portion.
    Fortran ieee_arithmetic facility provides for numerical exception handling.  An f2003 version of the examples in Reid's earlier paper is included in the textbook "Fortran 95/2003 explained."
    There are several good presentations at the top of my web search results; perhaps you could look at some and refine your extremely broad question.

    jimdempseyatthecoveSeptember 20, 2010 7:18 AM PDT
    Rate
     
    Exception handling

    I would suggest you write your Fortran code with assertions (for memory allocation errors, argument errors etc...), such that the assert sets an error condition known to your interface. Then have your C++/Java code call a shell C++/ Java function which then calls the Fortran function/subroutine and tests the known error condition and throws an error if necessary

    void YourExposedInterface()
    {
        hiddenExceptionCode = NoExceptionOccured;
        YourHiddenInterface();
        if(hiddenExceptionCode == NoExceptionOccured)
           return;
       throw(hiddenExceptionCode);
    }

    The degree of which errors are caught will depend upon the degree of your exception coding in your Fortran library.

    Note, you can also have your Fortran code call C++/Java support routines (via similar shell function technique) that then captures exception conditions that are otherwise difficult to handle in Fortran.

    Jim Dempsey



    Blog: The Parallel Void
    www.quickthreadprogramming.com

Forum jump:  

Intel Software Network Forums Statistics

17,025 users have contributed to 48,319 threads and 172,758 posts to date.

In the past 24 hours, we have 11 new thread(s) 54 new posts(s), and 47 new user(s).

In the past 3 days, the most popular thread for everyone has been Optimalization of sine function\'s taylor expansion The most posts were made to Most likely, the issue is that The post with the most views is Optimalization of sine function\'s taylor expansion

Please welcome our newest member redfruit83


For more complete information about compiler optimizations, see our Optimization Notice.