Fortran Does FORTRAN 95 Support Hardware Serial Ports and Configuration?

  • Thread starter Thread starter jelanier
  • Start date Start date
  • Tags Tags
    Fortran Serial
AI Thread Summary
FORTRAN can theoretically support hardware serial port access, but practical implementation may be limited, especially with the G95 compiler on Windows 7 64-bit. While it is possible to call system libraries for port access, many users recommend using a C or C++ library, such as Boost.Asio, to handle serial communication more effectively. This approach allows for better configuration of the COM port settings like baud rate and parity. Some users have successfully integrated VB6 applications to manage serial communication, passing data to FORTRAN for processing. However, there are concerns about the efficiency of using VB6 for this purpose, as it may not handle extensive string processing or system calls as effectively as a dedicated C/C++ solution. Ultimately, while G95 may provide some capability for direct serial port access, many find that leveraging other programming languages or libraries can yield better results.
jelanier
Messages
67
Reaction score
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
 
Technology news on Phys.org
What operating system are you using?
 
Win7 64b
 
So, you can't configure the port from G95?
 
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.
 
Solkar said:
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.

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
 
jelanier said:
I am already doing that.
No, you don't...

jelanier said:
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.
...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.
 
Solkar said:
But your VB prog is a good starting point -

.

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
 
  • #10
jelanier said:
I have written many COM, client and server programs with VB6.
That's fortunate, but besides the point.
The point is architecture.
 

Similar threads

Replies
2
Views
2K
Replies
2
Views
2K
Replies
2
Views
1K
Replies
1
Views
2K
Replies
6
Views
3K
Replies
4
Views
2K
Replies
5
Views
3K
Back
Top