# Fortran Programming

• Comp Sci
zandria
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.

By the phrase
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

zandria
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"
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?

zandria
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.

Homework Helper
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'
END PROGRAM