home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / hp / 9471 < prev    next >
Encoding:
Text File  |  1992-08-19  |  2.1 KB  |  73 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!swrinde!sdd.hp.com!hpscdc!cupnews0.cup.hp.com!hppad.waterloo.hp.com!hppad!hpfcso!acmeyer
  2. From: acmeyer@hpfcso.FC.HP.COM (Alan C. Meyer)
  3. Newsgroups: comp.sys.hp
  4. Subject: Re: "sleep" and "fdate" on the hp workstations?
  5. Message-ID: <7371238@hpfcso.FC.HP.COM>
  6. Date: 20 Aug 92 00:20:25 GMT
  7. References: <1992Aug19.184947.20518@portal.vpharm.com>
  8. Organization: Hewlett-Packard, Fort Collins, CO, USA
  9. Lines: 62
  10.  
  11. In comp.sys.hp, dap@portal.vpharm.com (David A. Pearlman) writes:
  12.  
  13. > I have a piece of code that has successfully compiled on a large variety
  14. > of Unix workstations that makes use of "SLEEP()" and "FDATE()" calls.
  15. > This is Fortran code.
  16. > On the hp's, I have problems:
  17. > 1) FDATE doesn't appear to exist. Does anyone know of a suitable
  18. >    replacement?
  19. > 2) SLEEP() compiles OK, but then it seems to just hang. According to the
  20. >    man page (and by analogy to all the other Unix systems I've ported to),
  21. >    SLEEP(ITIME) should suspend the process for ITIME seconds. On the
  22. >    hp, the process just hangs, seemingly indefinitely.
  23. > Any advice?
  24.  
  25. In an upcoming release of the Fortran compiler, both of these functions
  26. will be available as intrinsics.  In the meantime, here are workarounds.
  27.  
  28. For FDATE, you can write your own C routine that will perform the desired
  29. operation:
  30.  
  31.     File fdate.c:
  32.  
  33.     fdate(str, strlen)
  34.     char *str; 
  35.     long strlen;
  36.     {
  37.         char *ctime(), *timestr;
  38.         long time(), curtime;
  39.     
  40.         curtime = time(0);
  41.         timestr = ctime(&curtime);
  42.         timestr[24] = '\0';
  43.         strncpy(str, timestr, strlen);
  44.     }
  45.  
  46. The corresponding Fortran file might look like:
  47.  
  48.     CHARACTER*30 S
  49.     CALL FDATE(S)
  50.     PRINT *, S
  51.     END
  52.  
  53. For SLEEP, you can directly call the libc sleep routine, but you need
  54. to be careful to pass the argument by value:
  55.  
  56. $alias sleep(%val)
  57.     ...
  58.     call sleep(10)
  59.  
  60. Without the $alias directive, the argument is passed by reference and
  61. sleep will receive a stack address as the number of seconds to pause.
  62. This might explain the behavior you are seeing.
  63.  
  64. Alan Meyer
  65. Colorado Language Lab
  66. acmeyer@fc.hp.com
  67.  
  68. "These are my own opinions ..."
  69.