GFORTRANdealing without CONOUT$

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

Discussion Overview

The discussion revolves around issues encountered when using GFORTRAN to compile old FORTRAN programs, particularly focusing on the handling of unit 6 and the lack of support for CONOUT$. Participants explore the implications of this limitation, share experiences, and seek solutions to the problem.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • Jim expresses frustration with GFORTRAN's lack of support for CONOUT$, which affects his ability to write to the console after unit 6 has been redirected to a file.
  • Some participants suggest that unit 6 should be avoided altogether if it causes issues, questioning the necessity of using it in the first place.
  • Jim clarifies that the programs do work but require more effort with GFORTRAN, emphasizing the need to reinitialize unit 6 to the console after it has been used for file output.
  • Another participant mentions that CONOUT$ is supported in GFORTRAN version 4.5, prompting Jim to confirm he is using version 4.7.0, which he believes has bugs related to this issue.
  • Jim notes past experiences with GFORTRAN, including bugs that flag syntax errors in comment lines, indicating a broader concern about the compiler's reliability.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to handle unit 6 in GFORTRAN. There are differing opinions on whether to continue using it or to avoid it, and the discussion remains unresolved regarding a definitive solution to the problem.

Contextual Notes

There are mentions of specific versions of GFORTRAN and their features, but the discussion does not clarify the implications of these features on the problem at hand. Additionally, the limitations of GFORTRAN regarding CONOUT$ and unit 6 are acknowledged but not fully explored.

jelanier
Messages
67
Reaction score
1
I have been re-writing several old FORTRAN programs to compile with G77 G95 and GFORTRAN.

G77 and G95 have been good to me. I can't say the same for GFORTRAN. The fact that it does not support CONOUT$ is the biggest issue. Some of these old programs liberally use unit 6 and unit 5. When CONOUT$ is available, you can simply open unit 6 with file=CONOUT$ to write to the con again.

While it is possible to write to the con by using write(6,xx) a,b , it does not work if unit 6 has already been used. Even if you close(6), you can not write to the con again. the print *,a,b will not work either.

Play with his test code by commenting out lines and you will see what I mean. Is there a solution?

Thanks,

Jim

program test_con
character(10) a,b,c

a="hello"
b="goodbye"

open (6,file="conout.txt")
write (6,10) a,b
C close(6)

C open (6,file="conout$")
print *,"hello"
write (*,10) a,b


10 format(a10,a10)

end program test_con
 
Technology news on Phys.org
I am not sure I fully understand the problem.

First, I read that you re-writing this old programs...why won't you clean them up as you go so they actually work?

I have never tried to open unit 6 and I have never used it for myself...as far as I knew, it was reserved for standard out, just like units 5 and 0 are...

So, if you are having problems with unit 6 just stay away from it, simple.
 
gsal said:
I am not sure I fully understand the problem.

First, I read that you re-writing this old programs...why won't you clean them up as you go so they actually work?

I have never tried to open unit 6 and I have never used it for myself...as far as I knew, it was reserved for standard out, just like units 5 and 0 are...

So, if you are having problems with unit 6 just stay away from it, simple.


So in other words...you don't know the answer.
You said :"clean them up as you go so they actually work?" They do work. I don't know what you are talking about with that comment. It just takes more effort with GFORTRAN. Every time you execute a program from the aforementioned compilers, unit 6 is opened. The question is how to initialize unit 6 to con after it has been re-directed to a file. G77 and G95 provide that feature.
 
Well, I may not be a computer expert, but I have been programming happily for a couple of decades and helping other people, too, and I am yet to find a problem I cannot programmed...that is not to say that I have solved all the problems that I have found, but there is more than one way to skin a cat...so...

...while you may not like the answer or advice I have given to you, it would allow you to stop wasting time on that issue and move on...

good luck
 
gsal said:
Well, I may not be a computer expert, but I have been programming happily for a couple of decades and helping other people, too, and I am yet to find a problem I cannot programmed...that is not to say that I have solved all the problems that I have found, but there is more than one way to skin a cat...so...

...while you may not like the answer or advice I have given to you, it would allow you to stop wasting time on that issue and move on...

good luck

My point is, if you don't know the answer don't reply. Especially if you are going to be a smart-***. I am a design engineer and have been programming in various languages for 39 years. I don't waste time..I learn and find new ways to resolve issues. Smart-*** replies have no place in technical forums.
 
jelanier said:
So in other words...you don't know the answer.
You said :"clean them up as you go so they actually work?" They do work. I don't know what you are talking about with that comment. It just takes more effort with GFORTRAN. Every time you execute a program from the aforementioned compilers, unit 6 is opened. The question is how to initialize unit 6 to con after it has been re-directed to a file. G77 and G95 provide that feature.

What version of gfortran are you using? It says here (http://gcc.gnu.org/wiki/GFortran) that conout$ is supported in gfortran v4.5.
 
Mark44 said:
What version of gfortran are you using? It says here (http://gcc.gnu.org/wiki/GFortran) that conout$ is supported in gfortran v4.5.

Thanks for the reply Mark44. I read that as well while I was searching for a solution. I am running version 4.7.0 on this machine and 4.7 on my Linux Box. I can't remember which version I have on my work computer. One of the versions I had supported CONIN$ but not CONOUT$. Surely that was a bug. GFORTRAN has loads of bugs (too numerous to mention here). My favorite bug is when it flags syntax errors in comment lines :)

Thanks again,,

Jim
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
8K
  • · Replies 22 ·
Replies
22
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 13 ·
Replies
13
Views
5K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K