Executing a compiled program in Unix

In summary, the program is compiling and running properly, but after compiling it asks for input and then the bash shell disappears. After talking to the supervisor, it was found that the program needs to have the nag library installed in order to compile. Once the library is installed, the user can try to compile the program by using the make command and then running the program by typing ./blub.
  • #1
Arjani
21
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
  • #2
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.
 
  • #3
Thanks! It seems you are correct. Is there any way to see what kind of commands I can put in?
 
  • #4
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.
 
  • #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:
  • #6
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.
 
  • #7
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.
 
  • #8
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: 494
  • #9
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
 

1. What is a compiled program in Unix?

A compiled program in Unix is a program that has been translated from high-level programming language into machine code that can be directly executed by the computer's processor. This process is done through a compiler and results in a binary file that can be run on a Unix operating system.

2. How do I execute a compiled program in Unix?

To execute a compiled program in Unix, you need to first navigate to the directory where the program's binary file is located using the "cd" command. Then, type "./" followed by the name of the program's binary file and press enter. This will run the program and any output or errors will be displayed in the terminal.

3. What are the benefits of executing a compiled program in Unix?

Executing a compiled program in Unix offers several benefits, including faster execution speed, platform independence, and the ability to distribute the program without revealing its source code. Additionally, compiled programs are less prone to errors and can be optimized for specific hardware.

4. Can a compiled program in Unix be executed on any Unix system?

In most cases, a compiled program in Unix can be executed on any Unix system. However, there may be compatibility issues if the program was compiled for a specific hardware architecture or if the required libraries or dependencies are not available on the system.

5. What should I do if I encounter errors when trying to execute a compiled program in Unix?

If you encounter errors when trying to execute a compiled program in Unix, you should first check if all the necessary libraries and dependencies are installed on your system. If not, you may need to install them before trying again. Additionally, you can try recompiling the program or seeking help from the program's developer or online forums.

Similar threads

  • Programming and Computer Science
Replies
29
Views
2K
  • Programming and Computer Science
Replies
14
Views
2K
Replies
6
Views
1K
  • Programming and Computer Science
2
Replies
65
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
5
Views
986
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
32
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
Back
Top