- #DOES SIMPLY FORTRAN SUPPORT FORTRAN 2003 SERIES#
- #DOES SIMPLY FORTRAN SUPPORT FORTRAN 2003 WINDOWS#
Historical note: in the past, these thunks were built on the stack, which was very convenient. (If it were being called directly, the caller would establish the context first.) The internal routine then uses the context to find the local variables of the “invocation” that created the thunk. It is this address that is passed as an actual argument, so when the routine is called through the reference, the stack frame context is loaded into a register and then the real routine executes, knowing that the context has been set up. It then constructs a mini-procedure that does something like this (pseudocode ahead): LOAD Register1,SFĪnd then saves the address of this mini-procedure, the “thunk”. Let’s call this address SF (for Stack Frame).
![does simply fortran support fortran 2003 does simply fortran support fortran 2003](http://simplyfortran.com/images/EN_W8_Comp_Blk_2_rgb_trim.png)
It arranges these variables in a section of stack (usually) and generates the address to the start of the section. The concept is the same, though.įirst, the compiler has to know that it needs to set things up so that some routine called later can access its local variables. The actual implementation of thunks varies – what I will describe here is a generic method that may or may not match what actually happens. The answer is what is popularly called a “thunk”. Now, you may be asking, how does this work? How can a single address contain both the actual entry point and the “dynamic context” needed to get at the specific invocation’s variables. Intel Fortran (and DEC/Compaq Fortran before that) supports this as an extension, and this feature is part of the upcoming Fortran 2008 standard, so I felt it was ok to use the feature.
![does simply fortran support fortran 2003 does simply fortran support fortran 2003](https://images-na.ssl-images-amazon.com/images/I/41YokhLOfmL._SX384_BO1,204,203,200_.jpg)
The standard does say, however, that if an implementation supports this, it must do it so that the internal procedure uses the dynamic context of the “invocation” that passed the routine as an argument. In Fortran 2003, it’s not allowed to pass an internal procedure as an actual argument as the simple method of doing this, just passing the address of the routine’s entry point, doesn’t provide the context necessary for up-level references to the caller’s variables. This is done by passing LOC(routine-name) to the API routine, or in some cases, assigning that value to a member of a data structure.
#DOES SIMPLY FORTRAN SUPPORT FORTRAN 2003 WINDOWS#
Since it is a “Windowing application”, it needs to “register” with Windows the addresses of various routines that handle dialogs and Windows “messages”, for example, “create a window”, “repaint window”, etc. This means that all the interfaces were explicit without the need for INTERFACE – great! It built fine on all platforms and ran ok, so it seemed, at least on IA-32, so I checked it in.
![does simply fortran support fortran 2003 does simply fortran support fortran 2003](https://d1w82f5xc78wju.cloudfront.net/uploads/targetware/image/file/25845/simply-fortran.master.png)
#DOES SIMPLY FORTRAN SUPPORT FORTRAN 2003 SERIES#
As I’ve written elsewhere, I consider this poor Fortran style – if you think you need to write an INTERFACE block for a Fortran routine, you’re doing it wrong – so I rewrote this as a single WinMain entry function and a series of contained routines. The original coding style had used a series of external procedures and multiple copies of INTERFACE blocks to declare other routines. The Windows Fortran samples are a mixed lot some came to us from Microsoft Fortran Powerstation (with or without extensive modification) and some were developed by us (mostly, yours truly.)įor version 11.0, I took one of the old Microsoft samples, a Win32 program called Angle, and tried to clean it up. For Intel Visual Fortran, we have a lot of samples – for the other compilers, fewer. One of the various responsibilities I have is for the compiler samples (both Fortran and C++).