Does FORTRAN 95 Support Hardware Serial Ports and Configuration?

  • Context: Fortran 
  • Thread starter Thread starter jelanier
  • Start date Start date
  • Tags Tags
    Fortran Serial
Click For Summary

Discussion Overview

The discussion revolves around whether FORTRAN 95 can support hardware serial ports and allow for their configuration, including parameters such as baud rate, parity, data bits, and stop bits. Participants explore the feasibility of using FORTRAN for serial communication, particularly in the context of the G95 compiler and its capabilities on Windows 7.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • Jim inquires about the ability of FORTRAN to read from and write to a COM port, as well as configure it.
  • One participant asks about the operating system being used, indicating that the environment may affect the solution.
  • Another participant suggests checking a different thread for potential solutions regarding port access.
  • It is proposed that FORTRAN can theoretically call system libraries for port access, but practical implementation with G95 on Windows 7 remains uncertain.
  • A participant expresses skepticism about using FORTRAN for this task and suggests using a C or C++ library, such as Boost.Asio, to handle serial communication instead.
  • Jim mentions that he is currently using a VB6 program to manage the serial port and pass data to the FORTRAN program for processing.
  • Another participant challenges Jim's approach, arguing that the architectures discussed do not support extensive string processing or system calls, and suggests using shared memory with a C library linked to FORTRAN.
  • Jim defends his use of VB6, stating that it effectively handles the I/O tasks and questions the necessity of switching to C or modifying his current setup.
  • A participant reiterates the importance of architecture in the discussion, implying that the choice of programming language and method affects the overall solution.

Areas of Agreement / Disagreement

Participants express differing views on the suitability of FORTRAN for serial communication tasks. While some suggest alternative approaches using C or VB6, Jim maintains that his current VB6 solution is adequate. The discussion remains unresolved regarding the capabilities of G95 in this context.

Contextual Notes

The discussion highlights limitations related to the specific capabilities of G95 and the practical implementation of serial communication in FORTRAN, which may depend on the operating system and the architecture of the programs involved.

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 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
19
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K