home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / fortran / 4279 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  2.1 KB

  1. Xref: sparky comp.lang.fortran:4279 comp.sys.hp:12793
  2. Newsgroups: comp.lang.fortran,comp.sys.hp
  3. Path: sparky!uunet!utcsri!helios.physics.utoronto.ca!alchemy.chem.utoronto.ca!system
  4. From: system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
  5. Subject: Re: Weird HP compiler warning
  6. Message-ID: <1992Nov11.174048.2873@alchemy.chem.utoronto.ca>
  7. Organization: University of Toronto Chemistry Department
  8. References: <1992Nov10.193635.2736@alchemy.chem.utoronto.ca> <1992Nov10.210300.2732@leland.Stanford.EDU>
  9. Date: Wed, 11 Nov 1992 17:40:48 GMT
  10. Lines: 33
  11.  
  12. In article <1992Nov10.210300.2732@leland.Stanford.EDU> ungar@leland.Stanford.EDU (Jeffrey Ungar) writes:
  13. >In article <1992Nov10.193635.2736@alchemy.chem.utoronto.ca> mroussel@alchemy.chem.utoronto.ca (Marc Roussel) writes:
  14. >>
  15. >>      double precision h,nexth,err,d2fex
  16. >>      h = 1.d0
  17. >>      err = 10.d0
  18. >>      d2fex = 123.d0
  19. >>          nexth = min(h,sqrt(12.d0*err/d2fex))
  20. >>      write(*,*)nexth
  21. >>      END
  22. >>
  23. >>For this piece of code, the compiler produces the warning
  24. >>
  25. >>Warning on line 5 of weird.f: Argument has same name as INTRINSIC function
  26. >
  27. >That's because it looks (almost) like you are trying to pass a function,
  28. >namely the intrinsic function SQRT, to the MIN() function. Of course, if
  29. >you *really* wanted to use SQRT as a subprogram argument, you would
  30. >declare it in an INTRINSIC statement, and just write the name "SQRT" in
  31. >the argument list (but not, I would suggest, to the MIN routine!)
  32.  
  33. If the compiler thinks that an expression in a argument list (even if
  34. it involves a function call) is going to pass anything but the returned
  35. value, then the compiler is truly confused - you can't pass things like
  36. that. The code should be precisely equivalent to
  37.     xjunk = sqrt(12.d0*err/d2fex)
  38.     nexth = min(h,xjunk)
  39. To pass a function name to a called routine, you can't have any
  40. arguments, and you better have declared it EXTERNAL so the compiler
  41. knows you are passing a subprogram name, not a variable.
  42. -- 
  43. What are the chances that any HP computer system will ever "work" properly?
  44. ... and Slim just left town. -*- Mike Peterson, SysAdmin, U/Toronto Chemistry
  45.