Learn to Compile 'Hello World' in Open Watcom F77: Step-by-Step Guide

  • Thread starter solarblast
  • Start date
In summary, this conversation discusses creating a "Hello World" program using Open Watcom Fortran-77. It provides detailed instructions for creating the program using the Open Watcom Text Editor and Notepad, as well as using command line operations. The conversation also mentions issues with the Open Watcom IDE and possible errors encountered while compiling the program. The individual also asks about other free Windows Fortran compilers.
  • #1
solarblast
152
2
Open watcom f77--Hello World

Is there a document for watcom (fortran) f77 that uses the famous "Hello World" program through the steps of compiling it? Step by step. Illustrating the IDE, the editor, use of a target, compile.
 
Technology news on Phys.org
  • #2


I wrote an Open Watcom Fortran-77 "Hello World" Program, but I did not use the Open Watcom IDE.

Assuming Open Watcom Fortran-77 has been installed on your computer and properly setup you
should be able to follow my detailed instructions for creating a "Hello World" program.



>>>>>>>>>>>>>>>>>>>>>>>>>>> OPEN WATCOM TEXT EDITOR <<<<<<<<<<<<<<<<<<<<<<<<<<<<

Step 1: Start the Open Watcom Text Editor by Clicking the "Start" button and then
click on "All Programs" then click on "Open Watcom Fortran" and then select "Text Editor".

Step 2: Using the Open Watcom Text Editor, click on "File" and select "New".

Step 3: Click on "File" and select "Save As"

Step 4: Provide a name for your program (Hello.For).

Step 5: Choose "Fortran Files" from the "Save As Type" Drop Down.

Step 6: Click on the "Save" button.

Step 7: Copy the following program below into your "Open Watcom Text Editor":

  1. ******************************************************************​
  2. ** AUTHOR: SAM MANIOTES​
  3. ** PROGRAM: HELLO.FOR​
  4. ** DATE: 10/25/2011​
  5. ** LANGUAGE: OPEN WATCOM FORTRAN-77​
  6. ** DESCRIPTION: This program displays the words "Hello World" in a windows dialog box.​
  7. ******************************************************************​
  8. **​
  9. *$include winapi.fi​
  10. *$noreference​
  11. INTEGER*2 FUNCTION FWINMAIN( hInstance, hPrevInstance,​
  12. & lpszCmdLine, nCmdShow)​
  13. *$reference​
  14. IMPLICIT NONE​
  15. INTEGER*2 hInstance, hPrevInstance, nCmdShow​
  16. INTEGER*4 lpszCmdLine​
  17. include 'windows.fi'​
  18. CHARACTER*11 FORM​
  19. CHARACTER*80 BUFFER​
  20. PARAMETER (FORM='(A,I5,A,I5)')​
  21. WRITE(BUFFER, FORM) 'Hello World!'​
  22. CALL MessageBox( 0, BUFFER,​
  23. & 'Sam Maniotes - Open Watcom Fortran-77'c,​
  24. & MB_OK .OR. MB_TASKMODAL )​
  25. end​
********************************************************************************

***NOTE: Remember the Fortran-77 Continue Statements must begin in Column 6,
and Continue Statements start with the ampersand (&) Character.

Step 8: Click on "File" and then select "Save", to save your program.

Step 9: Click on "File" and then select "Exit" to exit the Text Editor.

***NOTE: You could download the program from the "hello.txt" file I attached below and rename it to "hello.for".


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> NOTEPAD <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Step 10: Using Notepad copy the following commands:



wfl386 -l=win386 hello.for
wbind hello -n



Step 11: Click on "File" and then select "Save As" and name the file "Make.Bat".

***Note: Save this file in the same location as your "Hello World" (Hello.For) program is located.

Step 12: Click on the "Save" button

Step 13: Click on "File" and the select "Exit" to exit Notepad.

***NOTE: You could just download the file "make.txt", that I attached below and rename it to "make.bat".



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MAKE HELLO WORLD <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Step 14: Using Windows Explorer navigate to the location of your "Hello World" program and double click on the "Make.Bat" file.

Step 15: After the "Make.Bat" script executes, you should notice a "hello.exe" file in the same location as your "Hello World" Fortran program.

Step 16: Double Click on the "Hello.exe" file, and you should notice a Windows Dialog Box display with the words "Hello World!" inside of it.

I hope this helps...
 

Attachments

  • Hello.txt
    1.5 KB · Views: 619
  • make.txt
    42 bytes · Views: 590
  • #3


Nicely done. I did write a Hello World program with the IDE, and executed it. I find the doc for the IDE a bit odd. Muliple targets? They barely mention command line ops. The whole thing looks incomplete. Then overall, they have no Help on the IDE. One must dig it out of the hlp files in the binnt folder.

Recently, I decided to see if I could make a library. I couldn't work it out in the IDE, so happened to notice through ftools.hlp that OW f77 is loaded with command line ops. It got stuck on a 3033 error when I tried building the lib. From a msg on the web, it appears that it is in error. I'm not quite sure it's fixed. It's beginning to look as though the IDE may not be all that useful.

I'm not that up to date on f77. It's been decades since I used ftn, but it looks like you might have created a window to put "Hello, World" in? If so, where do I find out more about that?

I've just discovered wfl386 and a few other cmds. I'd prefer not to use the command line
approach, but it may be inevitable.

Are there any other freebie Win fortran compilers out there?
 
  • #4


I gave this a try but get a bunch of errors. Maybe things have changed since 2011 or maybe there is some path I have to setup. Can someone please advise me?

c:\temp>make

c:\temp>wfl386 -l=win386 hello.for
Open Watcom F77/32 Compile and Link Utility Version 1.9
Portions Copyright (c) 1990-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
wfc386 hello.for
Open Watcom FORTRAN 77/32 Optimizing Compiler Version 1.9
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
hello.for(9): *ERR* SM-02 error opening file winapi.fi - No such file or direct
ory
hello.for(17): *ERR* SM-02 error opening file windows.fi - No such file or dire
ctory
hello.for(23): *ERR* TY-06 column 7, type of MB_OK has not been declared
hello.for(24): *ERR* TY-06 column 18, type of MB_TASKMODAL has not been declare
d
hello.for: *WRN* VA-07 in FWINMAIN, MB_TASKMODAL has been used but not defined
hello.for: *WRN* VA-07 in FWINMAIN, MB_OK has been used but not defined
hello.for: 11 statements, 0 bytes, 7 extensions, 2 warnings, 4 errors
Error: Compiler returned a bad status compiling 'hello.for'

c:\temp>wbind hello -n
'wbind' is not recognized as an internal or external command,
operable program or batch file.

c:\temp>
 
  • #5
You need to have the WFL386 environment variables declared. They can be used to specify commonly used WFL options.

Example:
C:\> set wfl=/d1 /ot
C:\> set wfl386=/dl /ot

The above example defines the default options to be "d1" (include line number debugging information in the object file),
and "ot" (time optimizations over size optimizations).

Once the appropriate environment variable has been defined, those options listed become the default each time the WFL or WFL386 command is used.

You will also need to include the SOURCE folder of your program and Windows Libraries:
C:\>set finclude=c:\watcom\src\fortran\dos;c:\WATCOM\LIB386\DOS;C:\WATCOM\LIB386\WIN

Use the "System" icon in the Control Panel to define Environment Variables.

If you are still having problems getting your program to compile, please try reading the Open Watcom FORTRAN 77 - User's Guide ftp://openwatcom.mirrors.pair.com/manuals/current/fuguide.pdf

Let me know if you are still having problems getting your environment setup.

Yours truly,

Sam Maniotes
 
Last edited:
  • #6


Thanks, I'll give that a shot.

Unrelated ... how do I create a new post? I am logged in but don't see a link for "new post".
 
  • #7


eddyq said:
Unrelated ... how do I create a new post? I am logged in but don't see a link for "new post".

Go to the page that shows the list of threads in a subforum. There is a "new thread" button near the top of that page.

You can't start a new thread while you are viewing the posts in an existing thread (i,e. from the page where you looking at right now).
 

FAQ: Learn to Compile 'Hello World' in Open Watcom F77: Step-by-Step Guide

1. What is Open Watcom f77?

Open Watcom f77 is a free open-source Fortran 77 compiler and development environment that allows for the creation of programs using the Fortran programming language. It is commonly used for scientific and engineering applications.

2. How do I install Open Watcom f77?

You can download the Open Watcom f77 compiler and development environment from the official website. The installation process is simple and straightforward, and detailed instructions can be found in the user manual provided on the website.

3. What is the "Hello World" program?

"Hello World" is a simple program that is commonly used to demonstrate the basic syntax and structure of a programming language. It typically prints the text "Hello World" to the screen, and is often the first program that beginners learn to write in a new language.

4. How do I write a "Hello World" program in Open Watcom f77?

To write a "Hello World" program in Open Watcom f77, you can use the WRITE statement to print the text "Hello World" to the screen. You will also need to include the STOP statement to end the program. The code will look something like this:

PROGRAM HELLO
WRITE(6,*) 'Hello World'
STOP
END

5. Can I use Open Watcom f77 for commercial purposes?

Yes, you can use Open Watcom f77 for commercial purposes as it is a free and open-source software released under the Sybase Open Watcom Public License. However, it is always recommended to review the license agreement for any specific restrictions or requirements.

Back
Top