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

GFORTRANdealing without CONOUT$

  1. Jun 25, 2013 #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?



    program test_con
    character(10) a,b,c


    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
  2. jcsd
  3. Jun 25, 2013 #2
    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.
  4. Jun 26, 2013 #3

    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.
  5. Jun 26, 2013 #4
    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
  6. Jun 26, 2013 #5
    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.
  7. Jun 26, 2013 #6


    Staff: Mentor

    What version of gfortran are you using? It says here (http://gcc.gnu.org/wiki/GFortran) that conout$ is supported in gfortran v4.5.
  8. Jun 26, 2013 #7
    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,,

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook