home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sgi / 13099 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.0 KB  |  64 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!munnari.oz.au!mips!mips!odin!bananapc.csd.sgi.com!ciemo
  3. From: ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz)
  4. Subject: Re: Problem with "chdir"
  5. Message-ID: <1992Aug31.194941.25918@odin.corp.sgi.com>
  6. Sender: news@odin.corp.sgi.com (Net News)
  7. Nntp-Posting-Host: bananapc.csd.sgi.com
  8. Organization: Silicon Graphics, Customer Support Division
  9. References:  <1992Aug31.161656.1@vaxa.strath.ac.uk>
  10. Date: Mon, 31 Aug 1992 19:49:41 GMT
  11. Lines: 51
  12.  
  13. In article <1992Aug31.161656.1@vaxa.strath.ac.uk>, cbas25@vaxa.strath.ac.uk writes:
  14. |> C-------------------------------cut here------------------------
  15. |>       PROGRAM CHANGEDIR
  16. |> 
  17. |> C  To test the fortran subroutine chdir
  18. |>       I = 999
  19. |>       write (*,*) I
  20. |>       I = chdir ('notthere')    !  This directory is not there
  21. |>       write (*,*) I             !  Should return -1
  22. |>       call system ('pwd')       !  No change in directory
  23. |>       I = chdir ('..')          !  Go to parent directory 
  24. |>       write (*,*) I             !  Should return 0
  25. |>       call system ('pwd')       !  Should now be parent directory
  26. |>       stop
  27. |>       end
  28. |> C-------------------------------cut here------------------------
  29. |> 
  30.  
  31. The problem with above program is that you have not declared the chdir
  32. function as one which returns INTEGER*4.  Using Fortran's intrinsic
  33. typing rules, it f77 will assume that chdir is REAL, not INTEGER*4 thus
  34. you get bogus answers.  If you change the code to:
  35.  
  36.     PROGRAM CHANGEDIR
  37.  
  38.     EXTERNAL CHDIR
  39.     INTEGER*4 CHDIR
  40.  
  41.     ...
  42.  
  43.     I = chdir('notthere')
  44.  
  45. the example will work correctly:
  46.  
  47. bananapc 1807$ chdir
  48.       999
  49.        -1
  50. /disk2/tmp/hypot
  51.         0
  52. /disk2/tmp
  53.  
  54. No bug in the compiler under 4.0.x.  In fact, it was a bug in the old versions
  55. of the compiler if it ever worked without specifying INTEGER*4 CHDIR.
  56.  
  57. -- 
  58.  
  59.     __   * __   _  __  ___            
  60.    /  \ / / /  / \/  \/   \     He was a man like any other man, however, not
  61.   /    /  \/  /  /\  /    /    quite like any other man.
  62.   \___/\__/\_/  /_/ / \__/    
  63.                *        
  64.