Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

FORTRAN 95 (G95) Serial Port

  1. Apr 12, 2013 #1
    Does FORTRAN support use of hardware serial ports? I need to write and read to a COM port.
    If so, can you configure the port as well? (ie baud rate , parity ,data bits, stop bits )

    Thanks,

    Jim
     
  2. jcsd
  3. Apr 12, 2013 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    What operating system are you using?
     
  4. Apr 12, 2013 #3
  5. Apr 12, 2013 #4
    Win7 64b
     
  6. Apr 16, 2013 #5
    So, you can't configure the port from G95?
     
  7. Apr 17, 2013 #6
    Fortran, like many other languages, offers the possibility to call functions of whatever libraries, e.g. system libraries for port access in your case; how that can be implemented has been shown in the thread gsal pointed you to. Of course, I cannot tell for sure without trying myself with g95 on your platform, but from that pov it should be theoretically possible to get suffcient port access from g95 code by the measures described there.

    Theoretically.

    Personally speaking I would not even think about using such a flavor of interfacing.

    In doubt I would simply get myself a fancy little C or C++-library, e.g. Boost.Asio, add a lightweight C-interface callable from Fortran, link that with main program and carry on.

    It could even be considered delegating the serial stuff completely to a C/C++ MPI 2 program and having Fortran spawning that and gathering the data via that MPI only.

    The latter would be my approach.
     
  8. Apr 17, 2013 #7
    I am already doing that. I am using a VB6 program to configure the port, read(by event) and write data to the serial port and passing strings to the FORTRAN program for number crunching.

    Thanks anyway,

    Jim
     
  9. Apr 18, 2013 #8
    No, you don't...

    ...because both architectures I mentioned neither utilize extensive string processing nor system calls for file or pipe ops but work memory-based with binary data. And for good reasons.

    But your VB prog is a good starting point - VB supports COM, thus it'd be seamless to plugin a lightweight in-process (dll) COM component which simply exposes an interfaces to a shared memory chunk.

    That shared memory could on the client side be accessed by a lightweight C-library linked with the Fortran executable.
     
  10. Apr 18, 2013 #9
    No, I am done. This already works fine. I have written many COM, client and server programs with VB6. It does fine with this. What I wrote was basically a VB GUI and I/O for the FORTRAN program. The VB does the I/O and the FORTRAN does the number crunching.

    My question was whether G95 supports the hardware to the point where I didn't need the VB app at all. In this case, there is no need to use C or anything else. My VB app works fine for this purpose.

    Thanks,

    Jim
     
  11. Apr 19, 2013 #10
    That's fortunate, but besides the point.
    The point is architecture.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: FORTRAN 95 (G95) Serial Port
  1. Fortran 95 (Replies: 12)

Loading...