Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Convert Fortran Code

Convert Fortran Code

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialc++java
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trupti Mehta
    wrote on last edited by
    #1

    Hi, I have a Fortran program which I have to convert into Java originally. I have converted the code completely but can't get appropriate resutls. The code contains lot of arithmetic calculations using double precision data type of Fortran. I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example:

    double precision d1 = 0.3648564D0;
    d1**2 // ** indicates exponent
    DSIN(d1) // sin of double precision
    DCOS(d1) // cos of double precision

    The above are my main concerns which I find very difficult to convert. I use sin & cos for DSIN & DCOS. But Fortran 77 deals somthing differntly with double precision. How to convert/translate that into our normal C++ application is what I am looking for. If you cna provide the same for Java that would be a plus for me, otherwise I will use the code accordingly of C++ in my Java application. Please help me out. Am stuck up very badly.

    Thanks Terry

    S C 2 Replies Last reply
    0
    • T Trupti Mehta

      Hi, I have a Fortran program which I have to convert into Java originally. I have converted the code completely but can't get appropriate resutls. The code contains lot of arithmetic calculations using double precision data type of Fortran. I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example:

      double precision d1 = 0.3648564D0;
      d1**2 // ** indicates exponent
      DSIN(d1) // sin of double precision
      DCOS(d1) // cos of double precision

      The above are my main concerns which I find very difficult to convert. I use sin & cos for DSIN & DCOS. But Fortran 77 deals somthing differntly with double precision. How to convert/translate that into our normal C++ application is what I am looking for. If you cna provide the same for Java that would be a plus for me, otherwise I will use the code accordingly of C++ in my Java application. Please help me out. Am stuck up very badly.

      Thanks Terry

      S Offline
      S Offline
      Saurabh Garg
      wrote on last edited by
      #2

      Do you mean IEEE-754? C++ do use IEEE-754 to store the floating point numbers. In fact the floating point number format are implemented at the hardware level and Intel processors use IEEE-754. -Saurabh

      1 Reply Last reply
      0
      • T Trupti Mehta

        Hi, I have a Fortran program which I have to convert into Java originally. I have converted the code completely but can't get appropriate resutls. The code contains lot of arithmetic calculations using double precision data type of Fortran. I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example:

        double precision d1 = 0.3648564D0;
        d1**2 // ** indicates exponent
        DSIN(d1) // sin of double precision
        DCOS(d1) // cos of double precision

        The above are my main concerns which I find very difficult to convert. I use sin & cos for DSIN & DCOS. But Fortran 77 deals somthing differntly with double precision. How to convert/translate that into our normal C++ application is what I am looking for. If you cna provide the same for Java that would be a plus for me, otherwise I will use the code accordingly of C++ in my Java application. Please help me out. Am stuck up very badly.

        Thanks Terry

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        <blockquote class="FQ"><div class="FQA">Trupti Mehta wrote:</div>IEEE756</blockquote> Never head about. Do you mean IEEE 754?

        Trupti Mehta wrote:

        I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example: double precision d1 = 0.3648564D0;d1**2 // ** indicates exponentDSIN(d1) // sin of double precisionDCOS(d1) // cos of double precision

        Even if the FORTRAN double precision would based on a different standard, I believe the results of both programs (i.e. the FORTRAN and the Java one) should be comparable. Are you sure the logic of your translation is correct? Have you made a test to compare the results (given by FORTRAN vs Java) of such simple functions as sin and cos? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups