home *** CD-ROM | disk | FTP | other *** search
- 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
- From: acmeyer@hpfcso.FC.HP.COM (Alan C. Meyer)
- Newsgroups: comp.sys.hp
- Subject: Re: "sleep" and "fdate" on the hp workstations?
- Message-ID: <7371238@hpfcso.FC.HP.COM>
- Date: 20 Aug 92 00:20:25 GMT
- References: <1992Aug19.184947.20518@portal.vpharm.com>
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Lines: 62
-
- In comp.sys.hp, dap@portal.vpharm.com (David A. Pearlman) writes:
-
- > I have a piece of code that has successfully compiled on a large variety
- > of Unix workstations that makes use of "SLEEP()" and "FDATE()" calls.
- > This is Fortran code.
- >
- > On the hp's, I have problems:
- >
- > 1) FDATE doesn't appear to exist. Does anyone know of a suitable
- > replacement?
- >
- > 2) SLEEP() compiles OK, but then it seems to just hang. According to the
- > man page (and by analogy to all the other Unix systems I've ported to),
- > SLEEP(ITIME) should suspend the process for ITIME seconds. On the
- > hp, the process just hangs, seemingly indefinitely.
- >
- > Any advice?
-
- In an upcoming release of the Fortran compiler, both of these functions
- will be available as intrinsics. In the meantime, here are workarounds.
-
- For FDATE, you can write your own C routine that will perform the desired
- operation:
-
- File fdate.c:
-
- fdate(str, strlen)
- char *str;
- long strlen;
- {
- char *ctime(), *timestr;
- long time(), curtime;
-
- curtime = time(0);
- timestr = ctime(&curtime);
- timestr[24] = '\0';
- strncpy(str, timestr, strlen);
- }
-
- The corresponding Fortran file might look like:
-
- CHARACTER*30 S
- CALL FDATE(S)
- PRINT *, S
- END
-
- For SLEEP, you can directly call the libc sleep routine, but you need
- to be careful to pass the argument by value:
-
- $alias sleep(%val)
- ...
- call sleep(10)
-
- Without the $alias directive, the argument is passed by reference and
- sleep will receive a stack address as the number of seconds to pause.
- This might explain the behavior you are seeing.
-
- Alan Meyer
- Colorado Language Lab
- acmeyer@fc.hp.com
-
- "These are my own opinions ..."
-