Photran: 4.1 Introduction To Using Photran
Photran: 4.1 Introduction To Using Photran
2. If the screen contains only some logos, select the curved ar-
row labelled Workbench to start running some Fortran pro-
grams.
1. Select the File tab at the upper left corner of the screen,
then New, then Standard Make Project. If you see a screen
asking you to select a wizard, expand the Make option and
select Standard Make Project.
3. On the next screen, select the Error Parsers tab. Check the
following parsers and uncheck the rest:
CDT GNU Make Error Parser
CDT GNU C/C++ Error Parser
CDT GNU Assembler Error Parser
CDT GNU Linker Error Parser
Photran Error Parser for G95 Fortran
FT_LIB = /usr/local/fortrantools/lib
all:
perl $(FT_LIB)/mkmf.pl \
-t $(FT_LIB)/mkmf_args -p RUN \
-m f_Makefile -x
clean:
rm -f *.mod *.o RUN* f_Makefile
Note that the lines executing perl and rm begin with a tab
character, not spaces.
This process can be modified in a few simple ways by edit-
ing the file mkmf_args (make makefile arguments) located in
/usr/local/fortrantools/lib. The one provided is:
FC = g95
FFLAGS = -g -Wall -fbounds-check \
-I/usr/local/fortrantools/lib
LD = g95
LDFLAGS = -L/usr/local/fortrantools/lib \
-lfortrantools -lslatec -lmatrix -lg2c
The first and third lines indicate that g95 is to be used to com-
pile and load the program. The second line provides options to
the compiler. -g is used for debugging, -Wall says to check for
as many errors as possible (subscripts out of bounds, for exam-
ple), and -I tells the compiler where to find some modules
provided with Fortran Tools. When the program is ready for
production use, this line might be changed to
FFLAGS = -O -I/usr/local/fortrantools/lib
4.11 Debugging
Programs can be debugged using the same Photran interface
that is used to edit, build, and run the programs. The debugger
has a lot of features, some of which take some effort to learn,
but if all you use it for is a replacement for debugging by in-
serting print statements, learning just the simplest features to
do that will be well worth the effort.
Let’s learn about some of the features with an example.
6. Select the project name; select the RUN tab near the top of
the screen; then Debug. If you see a window with Create,
manage, and run configurations. Select the Debugger tab.
Then uncheck the box labelled Stop at main(0) on start-
up.
8. Select the project name; select the RUN tab near the top of
the screen; then Debug As; then Debug Local Fortran Ap-
plication. If a list pops up, select GDB Debugger. The ar-
rangement of views changes significantly.
12. Use Step Over or Step Into to run to the first if statement.
check the value of the variables i and j by examining the
Variables view in the upper right portion of the screen.
13. Perform Step Over several times to watch the loop get exe-
cuted three or four times. Look at the Variables view and
notice that each time j changes, it turns red. In fact, since
the loop exits only when i > n, and i never changes during
the loop, that explains the problem. Fix it by changing the
test to use j instead of i. Probably the easiest way to do
this is to terminate the program by selecting the red
square, edit the source file, and rebuild the project.
14. We have fixed the bug, but let’s try a few more things with
the debugger to see how they work. After rebuilding the
project, set a breakpoint at the first print statement and
start the debugger again
16. Use Step Into until you get to the call statement. Be sure
to use Step Into again (maybe a couple of times) to enter
the subroutine SubA.
right click in the open space in the window and select Run
To Line. Note that the variables local to the subroutine
have been added to the bottom of the list. Also, there are
variables i with two different values; one is the i declared
local to the subroutine and the other is the i in the main
program.
18. Step Into FuncB. Notice that the variables local to the
function (e.g., xx and B_result) have been added to the
Variables view.
i > 357
21. Select the array zed to look at some of its values. Note that
you can select portions of the array, which is very conve-
nient if the array is large.