Announcement

Collapse
No announcement yet.

Coding in Fortran

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Coding in Fortran

    Does anyone know anything about user-defined types in a Fortran dll? I'm supposed to be calling some Fortran subroutines from VB.NET, but I can't seem to get the subroutine to recognise my type declaration.

  • #2
    Fortran still exists?
    Now the trouble about trying to make yourself stupider than you really are is that you very often succeed.

    Comment


    • #3
      Quoth HYHYBT View Post
      Fortran still exists?
      I was going to say the same thing! I first heard of that about 40+ years ago! Don't you use cards with little holes punched out?
      Dull women have immaculate homes.

      Comment


      • #4
        irc://irc.freenode.net/fortran

        They'll be able to help you here.

        Comment


        • #5
          Fortran is still in decent use. Its very good for handling math operations. I'm more surprised that VB.NET is in use though.

          Comment


          • #6
            Hey, I had to work hard to get this moved to VB.NET from VB 6.0, so I'm not complaining more than 50% of the time. And my dad's response was "sorry, PC's didn't exist back when I used Fortran"... engineers *shakes head*

            Comment


            • #7
              You really have one of two situations from what you've described. I'll answer each individually.

              1. Your VB.Net code has user defined types that you wish to pass to Fortran when you call the Fortran DLL. You very likely will be unable to do so, and will need to convert your code to produce C compatible types to pass into the DLL.

              2. The Fortran DLL is defining some types within the DLL, and exposing them to be used by your code. You will (very likely) need to make your code translate from C compatible types.

              I hope it's the first case, since that's likely to be easier. In either case, though, you're likely to need to dig into something that, if your preferred language is VB.Net, you are not likely to enjoy: Memory mapping. Each language represents data in memory differently. However, when the data is being exposed via a DLL, it is expected to conform (normally) to a C style memory mapping.

              Now, if you're not able to do that, you've got a bumpy road ahead of you. I can only wish you luck, as doing that sort of work is something I don't enjoy doing myself. I can, but it tends to be a slow process to get it completely correct.

              Comment


              • #8
                My problem, right now, is actually that I can't get the dll to use UDTs in the first place. I just get an error saying that I never defined the type. I haven't been able to run into the problems you're describing yet. I was going to just define an identical type in my visual basic and pass that. I can find information online about making DLLs and about passing UDTs to DLLs, but nothing about the problem I'm having, so I suspect I'm missing something obvious enough that no one thinks it's worth explaining how to do.

                (I'm not really a Fortran programmer, in case you couldn't tell. If it were up to me I'd be perfectly happy using C++ for the rest of my life).

                Comment


                • #9
                  Every single user defined type is nothing more than re-definition of existing basic types. Nothing more. It either consists of a raw memory pointer (which is then dereferenced and evaluated by your code to have some meaning), or is a composition/redefinition of existing types. The trick is that you must know what those types actually are.

                  Another way to view the problem: In order for you to be receiving an error message about incompatible types (which I assume you are, as opposed to getting a GPF), some code, somewhere, must be evaluating what you are sending, and comparing that to what the DLL is expecting. When the mismatch occurs, you get the error message.

                  As such, your goal right now is not actually "Figure out how to pass a UDT into a Fortran-based DLL", but rather "Figure out what the type-enforcement code is expecting in a block of memory, and pass that in". Once you get past that first block, the rest is easy.

                  For you, for now, the first goal should be "get past the type-enforcement code. Make the block of memory I'm passing in match what it is expecting". Right now, it's not.

                  Comment


                  • #10
                    No, my first goal is to get the DLL to compile. I've been working on passing the various types back and forth to figure out how they match, but I'm trying step two, and getting stuck there.

                    Comment


                    • #11
                      Quoth Magpie View Post
                      No, my first goal is to get the DLL to compile.
                      Wait... your first post says something else entirely:

                      Quoth Magpie View Post
                      Does anyone know anything about user-defined types in a Fortran dll?
                      This makes it sound like you have a DLL that was handed to you. DLLs are already compiled. You do not compile them again. You link against them, but you don't compile them. So, either you have one (and therefore do not need to compile it), or you do not have one, in which case trying to tell VB.Net to compile Fortran code would be akin to telling a Turkish speaking individual to translate from Spanish to Navajo.

                      Without some sort of actual error message, I'm not going to guess any further. Right now, I'm being given about 20 pixels worth of a 30 megapixel image. State the problem in clear, unambiguous terms, and I'll try.

                      Comment


                      • #12
                        Problem one: I don't know enough about what I'm doing to describe the problem in the right terms.

                        I have Fortran code. I need to call it from visual basic. Having been told that the best way to do this is to make a DLL (this may be where the problem is), I'm working on making DLL's from Fortran so I can make sure I have all the steps down.

                        I have successfully created DLL's that will allow me to pass integers, floating point numbers and strings/character arrays. I am now trying to do one which will let me pass a UDT. Up until this morning it would not compile (says type is not defined). The first one I wrote still will not compile. I am in the process of cursing the semi-case sensitive nature of Fortran. trying to figure out what I did differently between the two versions I wrote. (This is still failing miserably).
                        Last edited by Magpie; 05-31-2010, 07:12 PM.

                        Comment

                        Working...
                        X