Clicky

Fortran Wiki
Generic programming (Rev #5, changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #4 to #5: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

Generic programming is a method for reusing a single piece in different contexts, such as with multiple data types. For example, the main body of a single numerical procedure can be reused for both single and double precision real variables or the code for a linked list can be reused for lists of integers, reals, or strings.

Generic programming is not available in Fortran 95 and it is only available in the form of parametrized user-defined types in Fortran 2003. However, the use of a preprocessor can assist with generic programming.

(追記)

Some kinds of generic programming can be achieved using the transfer intrinsic, which copies bit patterns from one datatype to another without casting the value. Using this process, many data structures such as lists, stacks, queues, etc can be implemented by making the routines accept arrays of characters, and then using the transfer intrinsic to convert values before and after they are stored in the structure.

(追記ここまで)
(追記) (追記ここまで)

Examples

See McGavin and Young (2001) and FLIBS for generic linked list implementations.

James Van Buskirk has written a generic version of BLAS available here: http://home.comcast.net/~kmbtib/Fortran_stuff/GENERIC_BLAS.ZIP

See Also

References

Revision from March 11, 2012 09:51:10 by Anonymous Coward
Forward in time (to current) | Back in time (4 more) | See current | Hide changes | History | Rollback | View: Source | Linked from: HomePage, Code, 2009, Linked list, FLIBS, Hash tables, Forpedo, Preprocessors, gen_list, hash table example

AltStyle によって変換されたページ (->オリジナル) /