Fortran GFORTRANdealing without CONOUT$

  • Thread starter Thread starter jelanier
  • Start date Start date
AI Thread Summary
The discussion revolves around the challenges of rewriting old FORTRAN programs to work with GFORTRAN, particularly the issue with the CONOUT$ feature. The main problem highlighted is that GFORTRAN does not allow reinitializing unit 6 to output to the console after it has been redirected to a file, a functionality that G77 and G95 support. Users express frustration with GFORTRAN's limitations and bugs, including syntax errors being flagged in comment lines. There is some back-and-forth about whether the programs should be cleaned up during the rewriting process, with one participant suggesting that if unit 6 is problematic, it should be avoided. The conversation also touches on the version of GFORTRAN being used, with one user noting they are on version 4.7.0, which reportedly has issues with CONOUT$. Overall, the thread emphasizes the difficulties faced when transitioning legacy code to modern compilers and the varying support for standard output functionalities.
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
Views
5K
Replies
12
Views
1K
Replies
22
Views
5K
Replies
4
Views
2K
Replies
13
Views
5K
Replies
19
Views
6K
Back
Top