Executing a compiled program in Unix

  • Thread starter Thread starter Arjani
  • Start date Start date
  • Tags Tags
    Program Unix
Click For Summary

Discussion Overview

The discussion revolves around executing a compiled Fortran program in a Unix environment, specifically addressing issues related to program execution, input requirements, and troubleshooting. Participants explore the behavior of the program when run, the lack of documentation, and potential debugging strategies.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant experiences an issue where the bash shell becomes unresponsive after executing the program, suggesting it may be waiting for user input.
  • Another participant proposes that the program is likely functioning correctly and is simply prompting for input, recommending the use of Ctrl+C or Ctrl+D to regain control of the shell.
  • A participant inquires about finding commands or documentation for the program, noting the absence of any provided materials.
  • Some participants suggest examining the source code for insights into expected input, although one expresses concern about their lack of Fortran experience making this difficult.
  • Discussion includes the mention of the NAG library as a potential clue related to the program's functionality.
  • One participant advises checking for documentation within the source files, particularly looking for comment lines that may explain the program's operation.
  • Another participant shares that after consulting their supervisor, they learned that the program should generate output in specific files, but they are encountering issues with the output file remaining empty.
  • There are suggestions to add "write" statements in the code to debug where the program might be stalling, and to check for the initialization of input units.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the exact cause of the issues with the program. There are multiple competing views on how to approach troubleshooting, and the discussion remains unresolved regarding the specific input requirements and the program's behavior.

Contextual Notes

Limitations include the lack of documentation for the program, uncertainty about the initialization of input units, and the potential need for specific files to exist prior to execution. The discussion reflects varying levels of familiarity with Fortran and Unix commands among participants.

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: 593
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
 

Similar threads

  • · Replies 29 ·
Replies
29
Views
4K
Replies
14
Views
4K
Replies
6
Views
3K
Replies
65
Views
5K
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
4
Views
5K
Replies
3
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 3 ·
Replies
3
Views
7K