Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cunixf.cc.columbia.edu!shenkin From: shenkin@cunixf.cc.columbia.edu (Peter S. Shenkin) Newsgroups: comp.lang.fortran Subject: Re: Cheating on the types Message-ID: <1991Mar21.201340.3271@cunixf.cc.columbia.edu> Date: 21 Mar 91 20:13:40 GMT References: <1991Mar20.195732.15376@appmag.com> <10146@exodus.Eng.Sun.COM> <8421@mentor.cc.purdue.edu> Reply-To: shenkin@cunixf.cc.columbia.edu (Peter S. Shenkin) Organization: Columbia University Lines: 23 In article <8421@mentor.cc.purdue.edu> hrubin@pop.stat.purdue.edu (Herman Rubin) writes: >I have, using Fortran, deliberately set up subroutines which >"cheated" on types. How else would one read multiple precision >reals in or out?.... Another application: suppose in a large program you want to write your own routing routines to do IO, which will write to one or more files, and/or the screen, etc., depending on the setting of various control variables. You might want to pass a format string plus a variable or two to the routine. But the variable's type might vary from invocation to invocation. If you can't cheat on types, I don't think you can do this in Fortran. But if you can declare the variable as an INTEGER, but actually pass a REAL, with an appropriate format string, this is easily done. Admittedly, you can't pass a DOUBLE PRECISION variable, and you still might need different routines for passing one, two, three, etc., variables, but still life would be much more complicated if the compiler didn't let you lie about INTEGER/REAL. -P. ************************f*u*cn*rd*ths*u*cn*gt*a*gd*jb************************** Peter S. Shenkin, Department of Chemistry, Barnard College, New York, NY 10027 (212)854-1418 shenkin@cunixf.cc.columbia.edu(Internet) shenkin@cunixf(Bitnet) ***"In scenic New York... where the third world is only a subway ride away."***