0

In fortran I can use Class (*) in a subroutine and use

Select Type (ir)
Type Is (Integer (Int8)) 
Type Is (Integer (Int16)) 
End Select

Does there exist any way to pass a numeric value rather than using Class (*), by using Class (Integer) for example or something similar.

Zeus
  • 1,485
  • 1
  • 17
  • 33

1 Answers1

0

Intrinsic types are not extended types, they have no common ancestor, nothing like that exist. You can use the unlimited polymorphism (class(*)) or you must indicate exact type and kind (real(dp)). You can also write type(real) in Fortran 2008, but that does not change anything, it is just a different syntax for the same.

Have a look at some common techniques for generic programming with different kinds like, for example, How to make some generic programming in fortran 90/95 working with intrinsic types , STL analogue in Fortran and others. You normally make a separate procedure for each kind and paste the code body from an include file.

Community
  • 1
  • 1