|
|
Up |
|
|
  |
Author: relaxmikerelaxmike Date: Apr 15, 2008 07:16
Hi all fortran gurus !
I would like to discuss the current methods to manage
templates in fortran, following the thread
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/f055f870774d98a0/110fa05197d7b709...#110fa05197d7b709
which was very interesting, but showed no details on
how to pratically manage the source code.
This feature is very well-known by C++ developers as "templates".
One example of the problems solved by C++ templates is to
have a sorting source code which is able to manage for any
data type, including integers, reals, or even abstract data
types.
I currently know 3 ways of dealing with templates in fortran,
even if none of them is included in any fortran norm
(and none of them is detailed in a fortran book, to my knowledge) :
- pre-processing macros,
- clever use of the "include" statement,
- m4 macros.
|
| Show full article (5.57Kb) |
|
| | 60 Comments |
|
  |
Author: Arjen MarkusArjen Markus Date: Apr 15, 2008 07:30
On 15 apr, 16:16, relaxmike gmail.com> wrote:
> Hi all fortran gurus !
>
> I would like to discuss the current methods to manage
> templates in fortran, following the thread
>
> http://groups.google.com/group/comp.lang.fortran/browse_thread/thread...
>
> which was very interesting, but showed no details on
> how to pratically manage the source code.
> This feature is very well-known by C++ developers as "templates".
>
> One example of the problems solved by C++ templates is to
> have a sorting source code which is able to manage for any
> data type, including integers, reals, or even abstract data
> types.
>
> I currently know 3 ways of dealing with templates in fortran,
> even if none of them is included in any fortran norm
> (and none of them is detailed in a fortran book, to my knowledge) : ...
|
| Show full article (6.13Kb) |
|
| | no comments |
|
  |
Author: Bil KlebBil Kleb Date: Apr 15, 2008 09:33
relaxmike wrote:
> Hi all fortran gurus !
Hi.
> Are there other well-known methods ?
|
| |
| no comments |
|
  |
Author: TerenceTerence Date: Apr 15, 2008 16:46
I wrote a commercial general sort/merge program (still in general
public use) that just reads in a text control file with :-
a) the input file name
b) the second input file name (for merges) or blank
c) the output file name
d) record length in bytes
e) then pretty much as many fields as you want, coded as
type,bytestart,bytelength,A/D [,and repeat]
You can also request a tag sort, where the file byte offeset addresses
of the sorted records are left in the output file (for cases where you
don't have twice the original data size available).
Of course it can't deal with arbitary fields beyond the expected
strings, integers, reals and T/F, nor does it sort variable length
records (but could easily changed to do so, nor does it cater for non-
MS byte order and FP formatting), but I see no need for the formal
route suggested.
I always prefer simple and practical.
|
| |
| no comments |
|
  |
Author: DamianDamian Date: Apr 15, 2008 22:25
On Apr 15, 7:16 am, relaxmike gmail.com> wrote:
> Hi all fortran gurus !
>
> I would like to discuss the current methods to manage
> templates in fortran, following the thread
>
> http://groups.google.com/group/comp.lang.fortran/browse_thread/thread...
>
> which was very interesting, but showed no details on
> how to pratically manage the source code.
> This feature is very well-known by C++ developers as "templates".
>
> One example of the problems solved by C++ templates is to
> have a sorting source code which is able to manage for any
> data type, including integers, reals, or even abstract data
> types.
>
> I currently know 3 ways of dealing with templates in fortran,
> even if none of them is included in any fortran norm
> (and none of them is detailed in a fortran book, to my knowledge) : ...
|
| Show full article (6.36Kb) |
| no comments |
|
  |
Author: Gerry FordGerry Ford Date: Apr 15, 2008 23:10
"Arjen Markus" wrote in message
news:0a01dacb-fcd7-4279-8d60-833a9ce60c14@b5g2000pri.googlegroups.com...
In Fortran 2003 you can use the class facilities and unlimited
polymorphic variables to solve these problems, but material
showing how to do that is limited so far.
--->Would you consider these class facilities and unlimited polymorphic
variables as "object-oriented?"
--
"Shopping for toilets isn't the most fascinating way to spend a Saturday
afternoon. But it beats watching cable news."
~~ Booman
|
| |
| no comments |
|
  |
Author: Arjen MarkusArjen Markus Date: Apr 15, 2008 23:50
On 16 apr, 08:10, "Gerry Ford" wrote:
> "Arjen Markus" wrote in message
>
> news:0a01dacb-fcd7-4279-8d60-833a9ce60c14@b5g2000pri.googlegroups.com...
>
> In Fortran 2003 you can use the class facilities and unlimited
> polymorphic variables to solve these problems, but material
> showing how to do that is limited so far.
>
> --->Would you consider these class facilities and unlimited polymorphic
> variables as "object-oriented?"
>
They can certainly be used in that way - for a suitable
definition of "object-oriented". But the main point is
that they give you the possibility to define interfaces
that allow a wide range of actual types.
Regards,
Arjen
|
| |
| no comments |
|
  |
Author: Arjen MarkusArjen Markus Date: Apr 15, 2008 23:57
On 16 apr, 07:25, Damian rouson.net> wrote:
> On Apr 15, 7:16 am, relaxmike gmail.com> wrote:
>
>
>
>
>
>> Hi all fortran gurus !
>
>> I would like to discuss the current methods to manage
>> templates in fortran, following the thread
>
>
>> which was very interesting, but showed no details on
>> how to pratically manage the source code.
>> This feature is very well-known by C++ developers as "templates".
>
>> One example of the problems solved by C++ templates is to
>> have a sorting source code which is able to manage for any ...
|
| Show full article (7.82Kb) |
| no comments |
|
  |
Author: Arjen MarkusArjen Markus Date: Apr 15, 2008 23:59
On 15 apr, 18:33, Bil Kleb NASA.gov> wrote:
> relaxmike wrote:
>> Hi all fortran gurus !
>
> Hi.
>
>> Are there other well-known methods ?
I often use Tcl scripts or Fortran programs to
generate the specific code, if other methods
fail - fairly ad hoc, but it works splendidly.
Regards,
|
| Show full article (0.46Kb) |
| no comments |
|
  |
|
|
  |
Author: relaxmikerelaxmike Date: Apr 16, 2008 01:15
On 16 avr, 07:25, Damian rouson.net> wrote:
> At least one text describes an approach equivalent to your pre-
> processing approach: Object-Oriented Programming via Fortran 90/95 by
> Ed Akin, Cambridge University Press, 2003. I don't have my copy at
> hand but I'm pretty sure it's in Chapter 6.
I have the book in my hands : "Object oriented programming
via fortran 90/95" by Ed Akin.
In fact, I was very enthousiast about the title, but the content
was very disappointing to me.
For me, the single article "Object-based programming in Fortran 90"
by Gray and Roberts is much more interesting, because it gives
the essence of OO :
http://www.ccs.lanl.gov/CCS/CCS-4/pdf/obf90.pdf
|
| Show full article (2.31Kb) |
| no comments |
|
RELATED THREADS |
  |
|
|
|
|
|