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
SUMMARY

This discussion focuses on how to open a command window and run programs in Fortran 90, specifically using the Compaq Visual Fortran 6 environment. Users must first ensure they have a Fortran compiler installed, as Fortran is a programming language that requires compilation to execute. To open the command prompt, users can navigate to Start > Run > cmd.exe. After compiling a Fortran program, executable files such as a.out or invert.exe can be run from the command prompt or by double-clicking them in the file explorer.

PREREQUISITES
  • Understanding of Fortran 90 programming language
  • Familiarity with Compaq Visual Fortran 6 development environment
  • Basic knowledge of command prompt operations in Windows
  • Experience with compiling and linking programs
NEXT STEPS
  • Learn how to use the "link" command in Compaq Visual Fortran 6
  • Research the differences between compiling and linking in Fortran
  • Explore the use of gfortran for compiling Fortran programs
  • Investigate methods to prevent command prompt from closing immediately after program execution
USEFUL FOR

This discussion is beneficial for novice Fortran programmers, students learning Fortran 90, and developers transitioning from MATLAB to Fortran environments.

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
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K