home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sgi / 13141 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  3.9 KB

  1. Path: sparky!uunet!olivea!sgigate!odin!dinkum!calvin
  2. From: calvin@dinkum.wpd.sgi.com (Calvin H. Vu)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: Fortran problem on going from 4.0.1 to 4.0.5
  5. Message-ID: <1992Sep1.160945.6058@odin.corp.sgi.com>
  6. Date: 1 Sep 92 16:09:45 GMT
  7. References: <1992Aug31.161432.1@vaxa.strath.ac.uk>
  8. Sender: news@odin.corp.sgi.com (Net News)
  9. Organization: Silicon Graphics, Inc.  Mountain View, CA
  10. Lines: 102
  11. Nntp-Posting-Host: dinkum.wpd.sgi.com
  12.  
  13. In <1992Aug31.161432.1@vaxa.strath.ac.uk> cbas25@vaxa.strath.ac.uk writes:
  14.  
  15. | The following fortran program illustrates a problem which has arisen on
  16. | going from IRIX 4.0.1 to IRIX 4.0.5.
  17.     I don't think it will work in any releases without the -static
  18.     flag.
  19. | C-------------------------------cut here-------------------------
  20. |       PROGRAM TESTPRO
  21. |       COMMON/A/XA(10)
  22. |       COMMON/B/XB(10)
  23. |       DO 100 I = 1,10
  24. |            XA(I) = FLOAT(I)
  25. |            XB(I) = 10.0 - FLOAT(I)
  26. | 100   CONTINUE
  27. |       WRITE (*,1000)
  28. | 1000  FORMAT ('Enter to numbers between 1 and 10 inclusive')
  29. |       READ  (*,*) K,L
  30. |       CALL DIFF1 (XA)
  31. |       CALL DIFF2 (XB)
  32. |       CALL DIFF3 (K,L,RESULT)
  33. |       WRITE (*,*) RESULT
  34. |       CALL ONCE (XA,XB,K,L,RESULT)
  35. |       WRITE (*,*) RESULT
  36. |       STOP
  37. |       END
  38. |       SUBROUTINE ONCE (XR,XS,I,J,D)
  39. |       DIMENSION XR(10)
  40. |       DIMENSION XS(10)
  41. |       write (*,*) i,j,xr(i),xs(j)
  42. |       D = XR(I) - XS(J)
  43. |       RETURN
  44. |       END
  45. |       SUBROUTINE DIFFER
  46. |       SAVE
  47. |       DIMENSION XR(10)
  48. |       DIMENSION XS(10)
  49. |       ENTRY DIFF1 (XR)
  50. |       RETURN
  51. |       ENTRY DIFF2 (XS)
  52. |       RETURN
  53. |       ENTRY DIFF3 (I,J,D)
  54. |       write (*,*) i,j,xr(i),xs(j)  !Program fails here when '-static' not used
  55. |       D = XR(I) - XS(J)
  56. |       RETURN
  57. |       END 
  58.  
  59.     Everything Dave Ciemewics said regarding the Fortran standard
  60. applies.  However, the reason your program works with -static is because
  61. that flag (which is almost a must for any programs written for the VMS
  62. environment and use its extensions liberally) is because the -static flag
  63. also triggers a VMS extension which saves the dummy arguments in a 
  64. multiple-entry subroutine in a static location.  Therefore, with the
  65. -static flag your program will have these system-dependent non-ANSI 
  66. side effects:
  67.  
  68.        CALL DIFF1 (XA)    ! save the address of XA in a static location
  69.             ! reserved for the dummy argument XR
  70.             ! of the multiple-entry subroutine DIFFER
  71.        CALL DIFF2 (XB)    ! save the address of XB in a static location
  72.             ! reserved for the dummy argument XS
  73.             ! of the multiple-entry subroutine DIFFER
  74.        CALL DIFF3 (K,L,RESULT)    ! calling DIFF3 assuming that the dummy
  75.                 ! arguments XR and XS have been saved
  76.                 ! by the previous two calls to contain the
  77.                 ! addresses of XA and XB
  78.  
  79.     If we just look at this simple example then it could be much
  80. improved by adding two more dummy argument XR and XS to the argument list
  81. of DIFF3 (and call it with the proper actual arguments of course).  In that
  82. way, you only need one call to DIFF3 instead of three (to DIFF1, DIFF2, and
  83. DIFF3) and it is also portable across all platforms.
  84.  
  85.     I guess this side effect of the -static flag could have been 
  86. implemented as a separate option, e.g. -vms_entry, to avoid the confusion
  87. why it works with -static and not with SAVE statement.  But, since it has
  88. already done that way I'll make a point to document this side-effect
  89. in the man f77 page so it won't cause this confusion.
  90.  
  91. | Has anyone had similar problems.
  92. | Peter Bladon
  93. | University of Strathclyde
  94. | Department of Pure and Applied Chemistry
  95. | Glasgow G1 1XL      
  96. | e-mail  cbas25%vaxa.strath.ac.uk
  97.  
  98. Hope it helps,
  99.  
  100. - calvin
  101. --
  102. -----------------------------------------------------------------------------
  103. Calvin H. Vu               | "We are each of us angels with only one
  104. Silicon Graphics Computer Systems  | wing.  And we can only fly embracing
  105. calvin@sgi.com   (415) 962-3679       | each other."
  106.