How to Open a Command Window for Fortran 90

  • Context: Comp Sci 
  • Thread starter Thread starter zandria
  • Start date Start date
  • Tags Tags
    Fortran Programming
Click For Summary

Discussion Overview

The discussion revolves around how to open a command window and run programs in Fortran 90, particularly for users transitioning from MATLAB. It includes aspects of installation, compilation, and execution of Fortran programs.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant expresses confusion about opening a command window for Fortran 90 after being accustomed to MATLAB's automatic command window.
  • Another participant clarifies that Fortran is a programming language and requires a compiler to run programs, suggesting the use of the command prompt.
  • A participant mentions downloading 'Compaq Visual Fortran 6' and seeks guidance on compiling and running a simple program they wrote.
  • One participant describes the process of compiling a program in the developer studio but remains uncertain about how to execute it afterward.
  • Another participant suggests looking for executable files generated after compilation and provides commands to potentially create an executable if it does not exist.
  • A later reply indicates that in Visual Fortran, there is a distinction between compiling and building, with a note on how to prevent the command prompt from closing immediately after execution.

Areas of Agreement / Disagreement

Participants generally agree on the need for a compiler and the steps to compile and run a program, but there is no consensus on the exact method to execute the program or the specifics of the command prompt usage.

Contextual Notes

Some participants assume familiarity with command-line operations and the specific features of Visual Fortran, which may not be universally applicable. There are also unresolved details regarding the linking process and the exact commands to use for different setups.

zandria
Messages
15
Reaction score
0
I feel very silly for asking this but I have just downloaded Fortran 90 and am trying to figure out how to open the command window. I am used to using MATLAB which automatically opens a command window when you open the program. I have the option of opening the developer studio or the command prompt.

If I open the command prompt it says the following:

Setting environment for using Visual Fortran tools

C:\Documents and Settings\Owner>

If I open the developer studio, I can write a program but I feel like I need to open a command window of some sort in order to run it.

I am familiar with MATLAB but am very lost and don't even know how to start if I can't even open a command window to write a program or assign a variable. I have been searching on the internet and in the library and I think my question is so basic that the authors don't even bother to answer it.

Any help would be much appreciated.
 
Physics news on Phys.org
By the phrase
zandria said:
I have just downloaded Fortran 90
do you mean that you installed a compiler? Fortran is simply a language, not unlike English, which doesn't need a word processor to be used. You do however need a compiler to convert the language into a usable program.

With that aside, you can open the command prompt by Start>Run > cmd.exe

Aside from that, I'm not real sure I understand your question/problem
 
I downloaded 'Compaque Visual Fortran 6'
This came with: WinDiff, VF reporter, Spy++, Process Viewer, OLE-COM object viewer, Fortran Module Wizard, Fortran Command Prompt, Error Lookup, Developer Studio, Dependency Walker.

I guess my question is how to run a program once it is written. I have opened developer studio and copied the following simple program from a tutorial I found online.

PROGRAM INVERT
IMPLICIT NONE
REAL :: Value, Inverse
PRINT *, "Type in a value to invert"
READ *, Value
Inverse = 1.0/Value
PRINT *, "Value", Value, " Inverse", Inverse
END PROGRAM INVERT

Now, I am stuck as in how to compile and how to run the program. If it is obvious that I have not downloaded a compiler, where do I go to do that?
 
I know that I can go to Build in the toolbar and click on "Compile invert.f90". And this comes up in the bottom window:

--------------------Configuration: myproj - Win32 Debug--------------------
Compiling Fortran...
C:\Program Files\Microsoft Visual Studio\MyProjects\myproj\invert.f90

invert.obj - 0 error(s), 0 warning(s)

yet, I am still at a loss in how to run my program.
 
zandria: This is a guess. After executing the command you described in post 4, look for a file named a.out, a.exe, or invert.exe in the same directory where invert.obj is located, and double-click that file, or enter its name (or enter just "a" or invert, without the extension) at the command prompt, to execute your compiled Fortran 90 program. If a.out, a.exe, or invert.exe was not created by the compile command you executed and does not exist in the same directory where invert.obj is located, then look for the "link" command in your Fortran application, or perhaps enter the command gfortran invert.obj, or gfortran invert.f90, which will hopefully create a.out or a.exe. If gfortran is not the correct name of the link command in your application, search your Fortran application Help for the "link" command.
 
I believe in Visual Fortran, aside from compile, there is Build, which actually links the object to an executable. There should also be an execute under the same tab which will let you run the program.

Note that if you are using this method the command prompt will close as soon as the program is finished running. So, if you have something like:
Code:
...
DO i=1,nPts
  WRITE(6,*) DATA(i,:)
END DO

END PROGRAM
And you're banking on being able to see your data, you won't. As soon as it writes the data it exits the program. In order to remedy this, either run the program directly from the command prompt, or insert a read statement before the program ends, e.g.
Code:
...
WRITE(6,*) DATA
WRITE(6,*) 'Press any key to exit program'
READ*, 

END PROGRAM
 

Similar threads

Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
14
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K