×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Looking for a Fortran 77 or newer compiler fo PC

Looking for a Fortran 77 or newer compiler fo PC

Looking for a Fortran 77 or newer compiler fo PC

(OP)
Hi I'm new here and hope this isn't a question beaten to death. I'm thinking about getting back into Fortran and would like to find a compiler that works on Windows 64 bit. By compiler, I mean something that compiles the source, generates binaries and then an executable. I would prefer something that does all of that without having to pass code to a C compiler or using Microsoft Visual Studio, etc. Of a course high level debugger would be important. Oh, and free (or cheap) would be great. Years ago I did lots of programming in Fortran IV, Data General Fortran 5, Fortran 77 and Lahey Fortran 77. I'd kinda like to revisit a language I really enjoyed. A major project I did was a program for data entry and graphic display of property parcel info for a large county in Arizona. Still have the source. Maybe I can get it to work again.smile Another language I had fun with was Algol (Data General DG/L) but we won't go there now.

RE: Looking for a Fortran 77 or newer compiler fo PC

I made a similar decision a few months ago, to attempt to resuscitate a very Fortran 4 / Fortran 77 program so it would run on a 64-bit Windows 10 computer.  As per Mikrom's suggestion above, I went with GFortran, and it did the job fine.  No "high level debugger" though (or not that I could find).  I ported the .EXE file that GFortran produced to a 32-bit Windows 7 machine, and it worked fine "out of the box".

RE: Looking for a Fortran 77 or newer compiler fo PC

If you need a debugger, you could try the IDE Code::Blocks, where you can step through your code and watch variables.
It looks like this:



I have it on Linux, but it is available for Windows too.

RE: Looking for a Fortran 77 or newer compiler fo PC

I tried Code::Blocks on Windows. Debugging C works well, but debugging Fortran unfortunately does not work for me.
Trying to step to the next line of code i get this error

CODE

[debug]>>>>>>cb_gdb:
[debug]> next
[debug]Cannot find bounds of current function 
I downloaded from here http://www.codeblocks.org/downloads/binaries/ the package codeblocks-20.03mingw-nosetup.zip which contains compilers and debugger but does not require running setup - only extracting and setting path variable. So my advice is, if you want to try it, maybe try rather any other package.


RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Thanks all for the info. I installed the gfortran compiler and am using it via command line. I'm getting strange errors using gfortran -std=legacy. It looks like the compiler is building an exe by default and wants all subroutines specified. That means all modules must be specified on the command line. Any way to just compile a single module to object? Maybe another command option? My program has 61 source modules and 14 include files.

RE: Looking for a Fortran 77 or newer compiler fo PC

> Any way to just compile a single module to object?

For example these commands
gfortran -c module1.f
gfortran -c module2.f
gfortran -c module3.f 
create object files module1.o, module2.o, module3.o
and this command links then all object files together into executable program.exe
gfortran module1.o module2.o modul3.o -o program.exe 




RE: Looking for a Fortran 77 or newer compiler fo PC

I took a different approach to having a large number of code modules.  I wrote a simple batch file to concatenate all the modules into the one file, compiled that composite file, then linked the resulting object file.  I then deleted the single object file (but retained the composite concatenated file because it was useful for text searching purposes).

RE: Looking for a Fortran 77 or newer compiler fo PC

To build programs which consists of many sources, makefiles are used. Write once and use many times.

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Thanks mikrom et al. The -c switch does the trick. I looked all over for that kind of info but no luck. I ask here when I hit a wall. I bet there are other switches like error output redirect. Can you point me to a document that covers this? I just found a man page for gfortran but I don't see -c in it.

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Aha! With a little poking I found gfortran --help. The trick is two dashes... The -S switch (option) lets me keep the assembler code - yum!

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Still don't see how to direct compiler error reporting to a file...

RE: Looking for a Fortran 77 or newer compiler fo PC

Quote (ksqr)


Still don't see how to direct compiler error reporting to a file...
For me on Linux this works:

$ gfortran myprog.f95 -o myprog 2> compiler_errors.txt 

I currently don't have a Windows PC nearby to try it, but according to this Microsoft document it should work in windows as well. Try it.

RE: Looking for a Fortran 77 or newer compiler fo PC

Windows does support redirection of reporting of output from screen to a file, using the > operator like in Mikrom's Linux example. Using >> instead will append the output to an existing file (if one exists).

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Hey that worked! Thanks. That business with 2 kinda rings a bell with me. Standard out & standard error? Used to manage a bunch of Unix servers back in the 90's. Been a long time. I made a batch file (macro) to compile in DOS.
echo off
gfortran -c -S -ffixed-line-length-none -std=legacy %1 2> %1.err

RE: Looking for a Fortran 77 or newer compiler fo PC

For debugging, you really need the -g switch. That adds the debug symbols.

If you're using linux or WSL with X-windows client, you could try the old ddd debugger. It is a bit dated - uses X-Motif. You move the pane sizes by using the button on the separating line.

Failing everything else, you could go back to command line debugging using gdb.

Another alternative which works on both Linux and Windows is Visual Studio Code (Microsoft Freeware) which works with gfortran.

RE: Looking for a Fortran 77 or newer compiler fo PC

> Failing everything else, you could go back to command line debugging using gdb

Funny that in the past I've only ever looked for the graphical user interface of GDB, as I always thought it would be damn difficult to learn. Now I've finally tried it, and after about an hour of hands-on debugging, I think I've already mastered the basics of GDB.

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
My old F77 source has comments on individual lines like:

DELIM = DELIM_LIST(K) ! Get delimiter

Not possible with gfortran? No big deal but if there is another magic switch, yay!

RE: Looking for a Fortran 77 or newer compiler fo PC

I have just run a small test.
My GFortran, version 6.3.0 running on a 64-bit Windows-10 computer, happily allows in-line comments that are commenced with an exclamation mark!
The only significant option I used in the compile/link operation was -static.  Thus
GFORTRAN  -o TestProg  -static  TestProg.for

RE: Looking for a Fortran 77 or newer compiler fo PC

i tried it too and everything works fine:

CODE

$ cat hello.f
      program hello
c       comment line with c in column 1
*       comment line with * in column 1
!       comment line with ! in column 1
        write (*, '(A)') 'Hello, world !' ! inline comment
      end

$ gfortran hello.f -o hello

$ ./hello
Hello, world !

$ gfortran --version
GNU Fortran (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

RE: Looking for a Fortran 77 or newer compiler fo PC

For the gfortran compiler the source file extension is important.
All type of comments (c, *, !) work with the file extension *.f and *.for.
@ksqr: what source file extension are you using ?

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
I'm using .for for a source file extension.
The error message I get is:
COMPASS.IN:12:20:

12 | DATA DRA/Z'5F'/ ! Down right angle
| 1
Error: BOZ literal constant near (1) cannot be assigned to a 'CHARACTER(1)' variable
COMPASS.IN:11:20:

11 | DATA DLA/Z'5E'/ ! Down left angle
| 1
Error: BOZ literal constant near (1) cannot be assigned to a 'CHARACTER(1)' variable

Source is:
SUBROUTINE GSIDINDX (WORK_BUFF, IP)

C Subroutine to get index of sides string delimiter.

C Called from: DEFAPNTS
C DEFLPNTS
C OFSTDISP

INTEGER*2 IP
CHARACTER*(*) WORK_BUFF
CHARACTER*1 TEMP
LOGICAL GOT_IT

INCLUDE 'COMPASS.IN'

C Determine index of next delimiter...

IP = 1 ! Initialize
GOT_IT = .FALSE.

10 TEMP = WORK_BUFF(IP:IP) ! Get character

IF (TEMP .GE. UP) THEN
IF (TEMP .LE. DOWN) THEN
GOT_IT = .TRUE.
END IF
END IF

IF (TEMP .GE. ULA) THEN
IF (TEMP .LE. DRA) THEN
GOT_IT = .TRUE.
END IF
END IF

IF (GOT_IT) THEN
GO TO 99
ELSE
IP = IP + 1 ! Bump index pointer
GO TO 10
END IF

99 RETURN

END

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Sorry - COMPASS.IN contains:
CHARACTER*1 UP, DOWN, LLEFT, RRIGHT
CHARACTER*1 ULA, URA, DLA, DRA, ESCAPE

DATA ESCAPE/Z'1B'/
DATA UP/Z'17'/
DATA DOWN/Z'1A'/
DATA LLEFT/Z'19'/
DATA RRIGHT/Z'18'/
DATA ULA/Z'5C'/ ! Up left angle
DATA URA/Z'5D'/ ! Up right angle
DATA DLA/Z'5E'/ ! Down left angle
DATA DRA/Z'5F'/ ! Down right angle

RE: Looking for a Fortran 77 or newer compiler fo PC

Quote (ksqr)


I'm using .for for a source file extension.
The error message I get is:
COMPASS.IN:12:20:
Then try to rename compass.in to compass.for
and in other sources instead of using
INCLUDE 'COMPASS.IN'
use rather
INCLUDE 'COMPASS.FOR'

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Nope. Rename didn't help. I found that the error is due to the data assignment, not the ! comment.

CHARACTER*1 ULA, URA, DLA, DRA, ESCAPE
DATA ESCAPE/Z'1B'/

The above is supposed to assign the hex value for Escape which is 1B (or 33 octal or 27 decimal) to the variable ESCAPE.
Instead I get:
Error: BOZ literal constant near (1) cannot be assigned to a 'CHARACTER(1)' variable

Must need another switchdazed

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Nope. Distilled to simple program:
PROGRAM FOO
CHARACTER*1 ESCAPE
DATA ESCAPE/Z'1B'/
END

Compile with:
gfortran -c -g -S -ffixed-line-length-none -fno-align-commons -fallow-invalid-boz -std=legacy

Still get:
Error: BOZ literal constant cannot be assigned to a 'CHARACTER(1)' variable

RE: Looking for a Fortran 77 or newer compiler fo PC

(OP)
Well it looks like only integer variables are allowed in DATA statements. I guess maybe what I had was an extension to the F77 standard? Oh well I can work around it. An it's probably time to let this topic expire. Thanks very much for the help offered here! smile

RE: Looking for a Fortran 77 or newer compiler fo PC

This problem can be fixed with a parameter statement but it is a bit long winded

CODE

PROGRAM FOO
      CHARACTER*1 ESCCH
      PARAMETER (ESCCH = CHAR(Z'1B'))
      CHARACTER*1 ESCAPE /ESCCH/
      END 

Unless you are going to change ESCAPE, you may as well just use the parameter statement

CODE

PROGRAM FOO
      CHARACTER*1 ESCAPE
      PARAMETER (ESCAPE = CHAR(Z'1B'))
      END 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close