Hello World Fails

Hi - I can’t seem to compile a simple “hello” program as shown in pgiug.pdf page 2:

[user1@mymachine clustertest]$ cat hello.f
print *, “hello”
end
[user1@mymachine clustertest]$ pgf95 hello.f
PGF90-S-0018-Illegal label field (hello.f: 1)
PGF90-S-0034-Syntax error at or near * (hello.f: 1)
PGF90-S-0018-Illegal label field (hello.f: 2)
PGF90-S-0022-Unexpected end of file - missing END statement (hello.f: 2)
0 inform, 0 warnings, 4 severes, 0 fatal for MAIN
[user1@mymachine clustertest]$

Any ideas? I’m stumped…with “:set invlist” in vi on the hello.f file, I get:

print *, “hello”$
end$
~
~
~

Is this correct? I was concerned about non-printing characters but this seems normal.

Thanks,
Phil

…ok, I’d like to register a complaint with documentation. If I do nothing but rename the file hello.f90, the compilation works:

[user1@mymachine clustertest]$ mv hello.f hello.f90
[user1@mymachine clustertest]$ cat hello.f90
print *, “hello”
end
[user1@mymachine clustertest]$ pgf95 hello.f90
[user1@mymachine clustertest]$ ls
a.out array.f hello.f90 mpi-hello.f
[user1@mymachine clustertest]$ ./a.out
hello
[user1@mymachine clustertest]$

The documentation (http://www.pgroup.com/doc/pgiug.pdf) on page 2, states clearly:

Step 2: Compile the program.
When you created your program, you called it hello.f. In this example, we compile it from a shell
command prompt using the default pgf95 driver option. Use the following syntax:
PGI$ pgf95 hello.f
PGI$
By default, the executable output is placed in the file a.out, or, on Windows platforms, in a filename based
on the name of the first source or object file on the command line. However, you can use the –o option to
specify an output file name. To place the executable output in the file hello, use this command:
PGI$ pgf95 -o hello hello.f
PGI$
Step 3: Execute the program.
To execute the resulting hello program, simply type the filename at the command prompt and press the Return
or Enter key on your keyboard:
PGI$ hello
hello
PGI$

…no mention of the apparent requirement to name the file *.f90

Thanks,
Phil

Hi,

The error comes from your program itself. Please consult PGI Fortran Reference Manual on how to program in Fortran.

When you name your program .f, the compiler assume you use Traditional Fortran, meaning fixed format that is you must leave 6 columns before your actual code. If you put any letters the first 6 columns it must be meaningful such as labe. Fortran syntax are not the same as C where you can write at any column.

When you rename your file name ends with .f90 and use pgf90. Tt is obvious that you tell the compiler that it is F90 Fortran.

For F90 Fortran, it supports free format and for free format column are not significant.

Hongyon

It might be prudent to put a reminder in the documentation…for example, to remind system administrators who do NOT use the PGI compiler daily (or at all).

At my site, I merely install, update, etc. I do not use the compiler. I haven’t used Fortran in a few decades. Now that you mention it, I do recall the 6 column requirement (doesn’t that originate from reserved spacings on the old punch cards?)

Anyway, I (a system administrator) was reading the user manual to verify that the installation was successful and usable. The documentation makes no mention of the six column requirement near the listing of the program. It was this confusion that led me to post the issue.

Thanks,
Phil

Hi,

I will ask to add some kinds of install verification in Installation Notes.

Hongyon