How to Open a Command Window for Fortran 90

In summary, you can open the command window by starting it with Start>Run>cmd.exe. However, if you open the developer studio, you can write a program but you need to open a command window to run it.
  • #1
zandria
15
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
  • #2
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
 
  • #3
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?
 
  • #4
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.
 
  • #5
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.
 
  • #6
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
 

1. How do I open a command window for Fortran 90 on a Windows computer?

To open a command window for Fortran 90 on a Windows computer, you can first open the "Command Prompt" application by searching for it in the Start menu or by pressing the Windows key + R and typing "cmd" in the Run dialog box. Once the command window opens, you can navigate to the directory where your Fortran 90 program is located using the "cd" command, and then use the "gfortran" command to compile and run your program.

2. How do I open a command window for Fortran 90 on a Mac?

To open a command window for Fortran 90 on a Mac, you can use the Terminal application by searching for it in the Spotlight or by navigating to Applications > Utilities > Terminal. Once the terminal opens, you can use the "cd" command to navigate to the directory where your Fortran 90 program is located, and then use the "gfortran" command to compile and run your program.

3. What is the difference between a command window and an integrated development environment (IDE) for Fortran 90?

A command window is a text-based interface where you can enter commands to compile and run your Fortran 90 program. An IDE, on the other hand, is a software application that provides a graphical user interface (GUI) for writing, compiling, and debugging your Fortran 90 code. While a command window may be more suitable for simple programs, an IDE can offer more advanced features such as code completion and debugging tools.

4. Can I use a command window for Fortran 90 on Linux?

Yes, you can use a command window for Fortran 90 on Linux by opening the Terminal application and following the same steps as for a Mac or Windows computer. However, Linux also offers a variety of IDEs specifically designed for Fortran 90 programming, such as G95 and Code::Blocks, which may be more convenient and user-friendly for some users.

5. How can I check if I have Fortran 90 installed on my computer?

To check if you have Fortran 90 installed on your computer, you can open a command window (or Terminal on Mac/Linux) and type "gfortran -v" to see the version and information of your Fortran compiler. If you do not have Fortran 90 installed, you can download and install it from the GNU website or through a package manager on your operating system.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Programming and Computer Science
Replies
14
Views
2K
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
494
  • Programming and Computer Science
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
886
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
Back
Top