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

Executing a compiled program in Unix

  1. May 22, 2012 #1
    I am using a makefile and the file is compiling without any errors. After compiling I try to execute the output file by typing ./output, but then the bash shell thing disappears and I can only type text but not give commands anymore. Anyone know what could be going on?
     
  2. jcsd
  3. May 22, 2012 #2

    I like Serena

    User Avatar
    Homework Helper

    Welcome to PF, Arjani! :smile:

    I expect your program is running properly and is asking the user for input.
    If you type Ctrl+C or Ctrl+D your program will end and the bash shell should reappear.
     
  4. May 22, 2012 #3
    Thanks! It seems you are correct. Is there any way to see what kind of commands I can put in?
     
  5. May 22, 2012 #4

    jtbell

    User Avatar

    Staff: Mentor

    Did that program come with any documentation?

    If not, you might try to read the source code and figure out what the program tries to do when it starts executing.
     
  6. May 22, 2012 #5
    I got it from my supervisor without any documentation. Given that I really don't have any experience with Fortran, looking at the source code will probably be pointless for me. I guess the only way out is to ask my supervisor, though I was hoping to figure it out on my own.

    Edit: I remember he said something about NAG library, but I don't recall what. Could that be a clue? The program in question is a model of El Nino by the way (Zebiak and Cane).
     
    Last edited: May 22, 2012
  7. May 23, 2012 #6

    I like Serena

    User Avatar
    Homework Helper

    It doesn't sound very good that your program asks for input, without showing you beforehand what kind of input it expects.
    So for that it seems you should ask your supervisor.

    Alternatively you can try to identify the main module of your program.
    It's probably called "main.for" or something like that.
    It should contain a "program" statement.
    If you simply take a look at this module, chances are that it shows in readable form what it expects.
     
  8. May 23, 2012 #7

    Borek

    User Avatar

    Staff: Mentor

    What files do you have? Chances are some of them are documentation.

    If not, it is possible program is documented within code, look for comment lines.
     
  9. May 23, 2012 #8
    Thanks for the help. I haven't figured it out yet so I'll show what I have, maybe you have an idea.
     

    Attached Files:

  10. May 23, 2012 #9

    jtbell

    User Avatar

    Staff: Mentor

    I would look at the .f files (the source code) with a text editor (or just use the 'cat' or 'more' command in the shell) and see if they contain comments that explain the operation of the program. I can't tell which one has the main program, but there are only seven files to look through.
     
  11. May 31, 2012 #10
    I talked to my supervisor and he explained that you simply have to run the program (./blub) and then the output will appear in output.f and a file called fort.51. The list of data that appears in fort.51 is what I need, but I just can't get it to work, the file remains empty. Before running back to my supervisor again, could anyone maybe test this program to see if they can get it work?

    It comes with a makefile, so the only thing you need to do is use the make command and then ./blub. After that a list of data should appear in the file fort.51 The settings can be changed in continue.f, but it should work as is. Could anyone please try it?

    http://www.students.science.uu.nl/~3418138/ZC.tar [Broken]
     
    Last edited by a moderator: May 6, 2017
  12. May 31, 2012 #11
    Arjani:

    If anyone should attempt to compile such program, they would need to have nag library installed.

    Anyway...

    If you are really going to take on this project, I recommend that you stop postponing on learning a little fortran.

    You should go ahead and start placing a few "write" statements just to standard output and see how far in the program you get and see where it is that the program is stalling.

    A few 'grep' commands on your files reveal quite a few things...

    • first, it shows that the main program is continue.f
    • that *.com files are variable declaration along with common blocks and are included here and there
    • that the 'read' command shows up only half a dozen times and it attempts to read from unit number 4
    • and it does not look like unit 4 is ever initialized
    • in my book, typical standard channel in fortran are 0, 5, and 6...no 4
    • could it be that by default it attempts to read from fort.4? Is that a file that needs to pre-exist to program execution...I could test that, but I won't...maybe you should.
    • I would put a 'write' statement BEFORE every "read(4," command to see if I get there and see if that is the reason why the program is waiting for something that is not getting.

    good luck
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Executing a compiled program in Unix
  1. C Programming Compiler (Replies: 11)

Loading...