Executing a compiled program in Unix

  • Thread starter Thread starter Arjani
  • Start date Start date
  • Tags Tags
    Program Unix
AI Thread Summary
The user is experiencing issues executing a compiled Fortran program, which appears to run but does not provide expected output, leaving the shell unresponsive. It is suggested that the program likely requires user input, and using Ctrl+C or Ctrl+D can terminate it to regain shell access. The user is encouraged to check the source code for documentation or comments that might clarify input requirements, particularly looking for the main module in the files. The program may also depend on the NAG library, and it is noted that the output file fort.51 remains empty, indicating potential issues with input initialization. Further exploration of the code, including adding write statements for debugging, is recommended to identify where the program might be stalling.
Arjani
Messages
20
Reaction score
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?
 
Technology news on Phys.org
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.
 
Thanks! It seems you are correct. Is there any way to see what kind of commands I can put in?
 
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.
 
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:
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.
 
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.
 
Thanks for the help. I haven't figured it out yet so I'll show what I have, maybe you have an idea.
 

Attachments

  • program.jpg
    program.jpg
    50.2 KB · Views: 571
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.
 
  • #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
 
Last edited by a moderator:
  • #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
 
Back
Top