TweetFollow Us on Twitter

Volume Number:9
Issue Number:7
Column Tag:Jörg's Folder

Absoft MacFORTRAN 3.2

An interface to match the quality of its code optimizer

By Jörg Langowski, MacTech Magazine Regular Contributing Author

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Those of you who have followed this column may have noticed that there are two major Fortran compilers for the Macintosh available: Absoft and Language Systems Fortran. And, for a long time, the main difference between the two products was that Absoft offered better performance - for typical programs, the code executed of the order of 25-40% faster than Language Systems, depending on the program and on the machine. Language Systems, on the other hand, had by far the superior Macintosh user interface, with easy assignment of subroutines to menu items, with Apple Events support and Publish/Subscribe possibilities. Absoft’s Macintosh support was only very rudimentary compared to that.

Well, some weeks ago I received an evaluation copy of MacFortran 3.2 by Absoft, and I must say that the situation has completely changed. Here is a version of MacFortran that finally comes with a Macintosh interface that matches the undeniable quality of Absoft’s code optimizer It is like someone at Absoft has read my columns (really! I’m flattered!) and incorporated each and every suggestion how to improve their Macintosh support, and then some. Of course, the general quality of the compiler and the performance of the code generated has not changed. So in this column I’d like to present you the main features of Absoft’s MRWE (MacFortran Runtime Window Environment), and show you an example program that uses them.

The MacFortran runtime window environment

Absoft’s MRWE is a library of Fortran routines that is usually linked into an application, unless you decide to build an MPW tool or create your own application framework around an event loop. At first glance, the new MRWE offers about the same possibilities as Language System’s runtime environment: one can associate a subroutine pointer to a menu item, and when the item is selected, the subroutine is executed; one can use the standard file dialog for opening a file, by specifying an empty filename string in the OPEN statement; the output window is a scrollable Text Edit window, fonts and font sizes can be changed and the text saved to a file. An application generated using MRWE will be Apple Event aware; you can easily add handlers for your own Apple Events, and send those events out. You can also open a file and publish it to other applications that support the subscribe/publish mechanism of System 7.

But Absoft has gone farther, and added features that the LS Fortran runtime package does not support (not yet - but we can be sure that they won’t be sleeping either. I am curious about their next upgrade ). One very important new addition is the possibility to assign an input/output window to any Fortran file unit - thus you can have multiple I/O windows, all scrollable and with custom font settings, and with the text saved to a file. The way to do this is simply to use OPEN (unit, ACCESS=’window’, ), and the window title will be the filename given in the OPEN statement. Up to 32 windows can be opened simultaneously this way, which gives you ample opportunity to confuse the user.

The OPEN statement is also used for implementing the publish/subscribe support. For creating a new edition of a file (which other programs can then subscribe to), you open the file by OPEN (unit, ACTION=’publish’, ); on the other hand, by using OPEN (unit, ACTION= ’subscribe’, ) you may read an edition generated by another program. In both cases, the files will be sequential and typically text files.

Finally, in the OPEN statement one can also define the filetype and creator of the newly opened file (which was already possible in LS Fortran).

A big new issue in Absoft MacFortran is the Apple Event support. This was not included at all in previous versions of MacFortran, and has been implemented now by adding a couple of powerful routines. Other than LS Fortran, where the only event class supported is ‘aevt’, here you may now define the class and the type of the event, and in addition supply two parameters which tell the Apple event sending routine whether there is any additional data to be sent and of what kind, and the data itself. In practice, you set up a call like this:

c          1


where target is a character expression specifying the application receiving the event, which may be specified by its name, its creator ID or selected by the PPC browser; it can be the calling program itself, or one can just have the event sent to the target that the last event was sent to. extraKind may be 0, 1, or 2; 0 means there is no extra data, 1 means extraInfo specifies a document name (e.g., to be opened), and 2 specifies an arbitrary character string in extraInfo. This Apple Event sending routine gives you therefore the possibility to exchange data (e.g., between Fortran programs using any arbitrary event class and type), without all the contortions that I had to go through when I wrote the first example routines for arbitrary Apple Event support in LS Fortran (see V8#2, June 1992). Again, I wouldn’t bet my life on it, but I’m pretty sure that Language Systems won’t hesitate to follow up with an extension to their Fortran that implements Apple Events support in a more general way.

Handlers for Apple Events that your application wants to receive are installed through a routine mrwe_AddAppleEvent(class,eventID,extraKind,extraInfo), where the parameters have the same meaning as in the Send routine. Finally, together with the Apple Event support you also get a routine that allows you to launch another program, or put your own application in the foreground when it needs attention. Very useful.

Distributed processing shell

When I browsed through the examples that come with MacFortran, I came across a folder called ‘DPShell’; I looked at some files inside, and voila! there was a complete set of shell applications that implemented exactly the type of Apple Event based ‘distributed processing’ mechanism proposed in my V8#2 column! Seems like someone at Absoft is really reading us, thank you. In essence, you have here a small application that can turn in the background on different Macs on a network and accept small tasks when the machine is not used too much, and send the result back to a parent application that turns on another machine. The whole housekeeping task, that is to keep track of which requests were sent out to which machine, and which results have come back in, is implemented in the DPShell; it is up to you to fill this shell with some useful code. Lacking the time, I have not exploited this tool, but it makes a very valuable addition to the examples and will prove useful for anyone who wants to implement parallel processing on a Macintosh network.

Menu support

Adding new menus and items to existing ones is implemented similarly to the way LS Fortran does it; you write for example

c          2

iresult=mrwe_AddMenu(‘Display’,’List Data/L’,list_data)

which will add to the menu ‘Display’ the item ‘List Data’ with the keyboard equivalent -L, and call the routine list_data when the item is selected. In addition, you may remove any item from a menu, and by removing all the items, the whole menu is deleted. You are not restricted to your custom menus, but may also manipulate the standard File and Edit menus this way. When a menu response routine is called, a parameter is passed that contains the menu and item IDs; this way you can use the same response routine for different menu items and distinguish inside the routine from where it was called.

Full source for MRWE

I can’t give you a description of all the routines included in MRWE here. The points discussed up to here show you the main new features and important differences with the main competitor, LS Fortran. One last thing has to be said, however: you get the full source code for all the routines in the MRWE. That way, you can see exactly how they work (they are very well documented and easy to read), modify them if you need it, and swat that last bug that every good piece of software has although I still have to find it.


Absoft’s documentation has evolved quite a bit over the last version changes, and to my opinion it is now every bit as good as Language System’s. Differences between the two manuals are in style rather than in quality, both of them are easy to use and you find what you’re looking for (although I found no entry for Publish/Subscribe, or the Edition manager, in the Absoft index). As said, the documentation inside the source code for the Macintosh runtime environment is excellent, and so is the description of the distributed processing shell.

Compatibility libraries

Porting programs from other machines to Absoft Fortran is now very easy. Not only is VAX code now compiled without any compatibility problems (i.e., the compiler now accepts program text with parts in VAX tab-delimited format and other parts in ANSI format), but there are also compatibility libraries that implement a few VAX system calls such as date, ran, time, and a lot of UNIX system functions, e.g., malloc, qsort, rename and others.

There is also a whole set of support libraries for AppMaker, the application prototyper that you’ve read about in earlier issues of this journal. I won’t go into details, because this deserves another column, but you can now create AppMaker application templates for Absoft MacFortran as well.


MacFortran’s debugging support is still only possible using SANE. A debugging library like it is included with LS Fortran is unfortunately missing here, and you have to run SANE - or SourceBug - on the side. It would be nice to have some quick and dirty means of tracing variables or displaying the names of routines as they are entered. Anyway, my crashes are usually of the kind where nothing seems suspicious until the machine almost explodes, debugger or not; so I think I’ll have to keep on living with the old method of scattering WRITE statements through my code for debugging.


With this upgrade, MacFortran has finally treated itself to a comfortable and very powerful Macintosh runtime environment. Compared to LS Fortran it also creates the fastest-running code. So is this a clear winner? In my opinion, I think both systems can have their advantages. For running Fortran code on a Mac with FPU support, I’d prefer Absoft 3.2 with its faster speed and its - at the moment - superior Macintosh interface. For lots of inter-language calling, LS Fortran may be offering a performance advantage because it supports the Macintosh register-saving conventions by default. If you want your program to run on a machine without an FPU (LC, Classic II, Centris 610), you’ll need LS Fortran unless the machine has an INIT installed that emulates the FPU instructions (such an INIT exists).


Before we end this column, let me briefly explain this month’s example. It shows how to use the Absoft Macintosh runtime routines in a Fortran program that reads a file with (x,y) data pairs and creates an edition out of it that can be subscribed to by Excel. Also, you can set some parameters through a dialog and create a theoretical curve that is also published, and Excel can subscribe to it.

Here we go: The main program sets some parameters, adds a custom menu with menu items and corresponding routine references, and drops into the Macintosh runtime environment. The first routine, Read_Data, opens a file using the SF dialog, and then calls a Lister routine that lists the contents of the file to a second output window, and publishes the (x,y) data pairs into an edition file ‘data.ed’. I have not provided any safety for bad number formats in the input file, so make sure this file looks correct. An example, ‘data1’, is included in the source code.

Draw_Curve will read the data pairs from the edition file ‘data.ed’ and use the x values to calculate ‘theoretical’ y-values through a function defined by three parameters a, b, c. The theoretical (x,y) data pairs are then published into a ‘curve.ed’ edition file.

Set_Pars, finally, puts up a modal dialog in which you can enter the three parameter values. They are converted from strings to real numbers using the Fortran ‘internal file’ READ statement. In this routine you find examples how to call toolbox routines from Absoft Fortran, where some parameters have to be passed by value.

The DLOG and DITL resources (ID=2000) are contained in a separate resource file (‘display.rsrc’ on the source code disk), which has to be merged into the compiled and linked application by using the MPW Rez tool or ResEdit.

Also included in the source code are two edition files ‘data.ed’ and ‘curve.ed’, and an Excel worksheet and a graph which subscribe to these edition files. Happy hacking; I hope you find the new Absoft MacFortran environment as useful as I have found it.

Example: Fortran program using ABsoft’s Macintosh Runtime Window Environment


 EXTERNAL Draw_Curve
 RECORD /Str255/  mrwe_PasSTR

 program display
creads data (x,y) from file and displays it
csuperimposes theoretical curve whose parameters 
care entered into a dialog box
cf(x) = a + b*exp(-c*x)
cJ. Langowski/MacTutor May 1993
 implicit none
 integer*4 ReadID, DrawID, ParsID
cinteger*4 AEresult

 INTEGER*4 window, unit
 COMMON /flags/ window,unit
 data unit /10/ ! initial unit # of windows to be opened

 ! note which window was in front at startup
 window = FrontWindow()
 ! move main window with Toolbox calls
 call MoveWindow(VAL4(window),
 1 VAL2(20),VAL2(50),VAL2(0))
 call SizeWindow(VAL4(window),
 1 VAL2(300),VAL2(200),VAL2(-1))
 ! Set up the menus
 ReadID  = mrwe_AddMenu('Display',
 1 'Read Data /R', Read_Data)
 DrawID  = mrwe_AddMenu('Display', 
 1 'Draw curve/D', Draw_Curve)
 ParsID  = mrwe_AddMenu('Display', 
 1 'Set Params/O', Set_Pars)
 write (*,*) 'Hello World'
 ! Pass control to MRWE "forever" (or until told to quit)
 CALL mrwe_EventLoop(0,0) ! should never return

 integer function Read_Data(itemID)
 CHARACTER filename*256
 INTEGER*4 status, Lister
 1 IOSTAT=status, STATUS='OLD')
 IF (status == 0) THEN
   INQUIRE (1, NAME=filename)
   Read_Data = Lister(TRIM(filename))
          Read_Data = status

! List a file with line numbers + open publisher

 INTEGER*4 FUNCTION Lister(filename)
 CHARACTER*(*) filename
 CHARACTER*132 line
 INTEGER*4 status, num
 real x,y
 OPEN(2, FILE=TRIM(filename)//' Listing', 
 1 ACCESS='WINDOW,200,300,50,20',
 WRITE(2,10) TRIM(filename)
 open (3, FILE='data.ed',ACTION='PUBLISH',
 num = 0
   READ (1,20,IOSTAT=status) line
          IF (status <> 0) EXIT
          num = num + 1
          WRITE(2,30) num, TRIM(line)
   read (line,*) x,y
   write(3,35) x,char(9),y

 10FORMAT ('*** Listing and publishing: "', a, '" ***', //)
 20FORMAT (a)
 30FORMAT (i4.4, ': ', a)
 35format (1xg15.5,1a,g15.5)
 40FORMAT (//,'*** End of listing ***',
 1 /,'To close window, press return')

 integer function Draw_Curve(itemID)
 implicit none
 integer status
 real a,b,c,x,y
 common /params/ a,b,c
 open (2, FILE='data.ed',ACTION='READ',
 open (3, FILE='curve.ed',ACTION='PUBLISH',
   READ (2,*,IOSTAT=status) x,y
          IF (status <> 0) EXIT
   y = a*exp(-b*x) + c
 WRITE(3,35) x,char(9),y
 Draw_Curve = 0
35 format (1xg15.5,1a,g15.5)

 integer function Set_Pars(itemID)
 implicit none
 real a,b,c
 common /params/ a,b,c
 integer*2 paramsDLOG,atext,btext,ctext
 1 atext=3,btext=4,ctext=5)

 INTEGER*4 savePort

 ! Dialog variables

 INTEGER*4    theDialog,itemType,hItem,Box
 INTEGER*2    itemHit
 RECORD /Str255/     itemaText,itembText,itemcText

 CALL GetPort(savePort)
 theDialog = GetNewDialog(VAL2(paramsDLOG),
 1 VAL4(0),VAL4(-1))
 CALL SetPort(VAL4(theDialog))
 itemHit = 0
    CALL ModalDialog(VAL4(0), itemHit)
    select case  (itemHit)
   case (ok)
 CALL GetDItem(VAL4(theDialog),
 1 VAL2(btext),itemType,hItem,Box)
 CALL GetIText(VAL4(hItem),itembText)
 CALL GetDItem(VAL4(theDialog),
 1 VAL2(ctext),itemType,hItem,Box)
 CALL GetIText(VAL4(hItem),itemcText)
 CALL GetDItem(VAL4(theDialog),
 1 VAL2(atext),itemType,hItem,Box)
 CALL GetIText(VAL4(hItem),itemaText)
 read (itemaText.chars(1:INT(itemaText.len)),*) a
 read (itembText.chars(1:INT(itembText.len)),*) b
 read (itemcText.chars(1:INT(itemcText.len)),*) c
 case (cancel)
 case default
    end select
 CALL DisposDialog(VAL4(theDialog))

 CALL SetPort(VAL4(savePort))
 Set_Pars = 0
 write (*,*) a,b,c



Community Search:
MacTech Search:

Software Updates via MacUpdate

Live Home 3D Pro 3.6.2 - $49.99
Live Home 3D Pro is powerful yet intuitive home design software that lets you build the house of your dreams right on your Mac, iPhone or iPad. It has every feature of Live Home 3D, plus some... Read more
RapidWeaver 8.2 - Create template-based...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
Opera 60.0.3255.109 - High-performance W...
Opera is a fast and secure browser trusted by millions of users. With the intuitive interface, Speed Dial and visual bookmarks for organizing favorite sites, news feature with fresh, relevant content... Read more
DEVONthink Pro 3.0beta2 - Knowledge base...
DEVONthink Pro is your essential assistant for today's world, where almost everything is digital. From shopping receipts to important research papers, your life often fills your hard drive in the... Read more
Tunnelblick 3.7.9 - GUI for OpenVPN.
Tunnelblick is a free, open source graphic user interface for OpenVPN on OS X. It provides easy control of OpenVPN client and/or server connections. It comes as a ready-to-use application with all... Read more
Carbon Copy Cloner 5.1.9 - Easy-to-use b...
Carbon Copy Cloner backups are better than ordinary backups. Suppose the unthinkable happens while you're under deadline to finish a project: your Mac is unresponsive and all you hear is an ominous,... Read more
Dropbox 73.4.118 - Cloud backup and sync...
Dropbox is an application that creates a special Finder folder that automatically syncs online and between your computers. It allows you to both backup files and keeps them up-to-date between systems... Read more
Postbox 6.1.18 - Powerful and flexible e...
Postbox is a new email application that helps you organize your work life and get stuff done. It has all the elegance and simplicity of Apple Mail, but with more power and flexibility to manage even... Read more
Wireshark 3.0.2 - Network protocol analy...
Wireshark is one of the world's foremost network protocol analyzers, and is the standard in many parts of the industry. It is the continuation of a project that started in 1998. Hundreds of... Read more
BetterTouchTool 2.856 - Customize multi-...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom... Read more

AFK Arena guide - Everything you need to...
Ok, so if you're like me, you've been playing (and sometimes waiting) your way through AFK Arena, only to learn there's a lot more to it than there appears on the surface. There's guilds, a PvP arena, and all sorts of other systems and game modes... | Read more »
Explore an epic fantasy world in MMORPG...
Webzen have just announced the official launch date for its stunning MMORPG ‘MU Origin 2’ which will arrive for iOS and Android on May 28th. It will be the second spinoff from the classic PC-based MU Online, and it looks to further refine the... | Read more »
Solar Explorer: New Dawn guide - Tips an...
Solar Explorer: New Dawn is a lunar lander game that really ratchets the intensity up to 11. With all of the asteroids flying around as you fly around at seemingly breakneck speeds, it can be easy to feel overwhelmed bythe whole thing. | Read more »
The Dalaran Heist - How Hearthstone...
I am someone who wrote Hearthstone off a while ago. It was hard not to try and stick with it. The game has incredible production values and a core of really great talent working on the game continuously to keep it feeling fresh and fun (full... | Read more »
Steam Link App - Everything You Need to...
Steam Link has finally released for iOS! That’s right, you can play your epic backlog of PC games on the go now. Well… sort of. While the Steam Link app was announced seemingly ages ago, it only got actual approval for release last night. Check out... | Read more »
Pre-register now for endless superhero r...
Talking Tom Hero Dash is set to take the ever-popular Talking Tom and Friends franchise in a brand new direction as it opens pre-registration to players worldwide. Not only does it promise to be a beautifully rendered, fast-paced, action-packed... | Read more »
AFK Arena - Guild Wars guide
Ok, so if you're like me, you've been playing (and sometimes waiting) your way through AFK Arena, only to learn there's a lot more to it than there appears on the surface. There's guilds, a PvP arena, and all sorts of other systems and game modes... | Read more »
Superhero-themed Talking Tom Hero Dash i...
One of the exciting releases that we’re looking forward to is Talking Tom Hero Dash, an upcoming superhero-themed runner created by Outfit7. This new game is an action-packed endless runner that takes you on an epic adventure to assemble the... | Read more »
Kingdom Rush Vengeance Update Guide 2 -...
Kingdom Rush: Vengeance just got updated once again to add more content to the game. This addition, called The Frozen Nightmare, adds three new levels, five new enemies, two new heroes, and some new achievements. | Read more »
Save the world with SCIENCE in the upcom...
Previous versions of space colonization game TerraGenesis encouraged you to explore the galaxy and settle its planets. The eagerly-awaited 5.0 update will try to smash them to bits. Yep, with a new "world killers" setting, you can unleash... | Read more »

Price Scanner via

12″ 1.2GHz MacBooks on sale for $999, $300 of...
Amazon has current-generation 12″ 1.2GHz Retina MacBooks on sale for $300 off Apple’s MSRP. Shipping is free: 12″ 1.2GHz Space Gray MacBook: $999.99 $300 off MSRP 12″ 1.2GHz Silver MacBook: $999.99 $... Read more
Here’s how to save $200 on Apple’s new 8-Core...
Apple has released details of their Education discount associated with the new 2019 15″ 6-Core and 8-Core MacBook Pros. Take $200 off the price of the new 8-Core model (now $2599) and $150 off the 15... Read more
Price drops! 2018 15″ 2.2GHz 6-Core MacBook P...
Amazon has dropped prices on clearance 2018 15″ 2.2GHz 6-Core Touch Bar MacBook Pros by $300 with models now available for $2099. These are the same models sold by Apple in their retail and online... Read more
Apple drops prices on 2018 13″ 2.3GHz Quad-Co...
Apple has dropped prices on Certified Refurbished 2018 13″ 2.3GHz 4-Core Touch Bar MacBook Pros with prices now starting at $1489. Apple’s one-year warranty is included, shipping is free, and each... Read more
Apple drops prices on 2018 Certified Refurbis...
Apple has dropped prices on clearance 2018 15″ 6-Core Touch Bar MacBook Pro, Certified Refurbished, with models available starting at only $1999. Each model features a new outer case, shipping is... Read more
Price drops! Clearance 2018 13″ Quad Core Mac...
Amazon has dropped prices on 2018 13″ Apple Quad-Core MacBook Pros with models now available for $250 off original MSRP. Shipping is free. Select Amazon as the seller, rather than a third-party, to... Read more
How Much Is ‘Solace’ Of Mind Worth When Buyin...
COMMENTARY: 05.22.19- Smartphone cases give us peace of mind by providing ample protection for such a fragile gadget and the sky’s the limit as far as choices go with a plethora of brands, styles,... Read more
Get a 13″ Touch Bar MacBook Pro for the lowes...
Apple has Certified Refurbished 2017 13″ 3.1GHz Dual-Core i5 Touch Bar MacBook Pros available starting at $1439, ranging up to $390 off original MSRP. Each MacBook features a new outer case, shipping... Read more
Apple adds new 15″ 8-Core MacBook Pro to line...
Apple has added a new 15″ MacBook Pro to its lineup featuring a 9th generation 2.3GHz 8-Core Intel i9 processor, 16GB of RAM, a 512GB SSD, and a Radeon Pro 560X with 4GB of GDDR5 memory for $2799.... Read more
21″ 2.3GHz iMac available for $999 at B&H...
B&H Photo has the 2018 21″ 2.3GHz Apple iMac on sale for $100 off MSRP. This is the same model offering by Apple in their retail and online stores. Shipping is free: – 21″ 2.3GHz iMac (MMQA2LL/A... Read more

Jobs Board

Best Buy *Apple* Computing Master - Best Bu...
**690427BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Location Number:** 000860-Charlottesville-Store **Job Description:** **What Read more
*Apple* Mobile Master - Best Buy (United Sta...
**696430BR** **Job Title:** Apple Mobile Master **Job Category:** Store Associates **Location Number:** 001012-Bismarck-Store **Job Description:** **What does a Best Read more
Manager - *Apple* Team - SHI International...
…opportunity available in the Hardware & Advanced Solutions Department as the Manager of the Apple Team The Manager must be familiar with all aspects of Apple Read more
Best Buy *Apple* Computing Master - Best Bu...
**696375BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Location Number:** 000203-North Austin-Store **Job Description:** **What does a Read more
Geek Squad *Apple* Master Consultation Agen...
**696286BR** **Job Title:** Geek Squad Apple Master Consultation Agent **Job Category:** Services/Installation/Repair **Location Number:** 000172-Rivergate-Store Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.