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

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!pipex!warwick!str-ccsun!str-va!cbas25
  3. From: cbas25@vaxa.strath.ac.uk
  4. Subject: Fortran problem on going from 4.0.1 to 4.0.5
  5. Message-ID: <1992Aug31.161432.1@vaxa.strath.ac.uk>
  6. Lines: 78
  7. Sender: news@ccsun.strath.ac.uk (News account )
  8. Nntp-Posting-Host: vaxe
  9. Organization: Strathclyde University VAX Cluster
  10. Date: Mon, 31 Aug 1992 16:14:32 GMT
  11.  
  12. The following fortran program illustrates a problem which has arisen on
  13. going from IRIX 4.0.1 to IRIX 4.0.5.
  14. When compiled under the first version of the operating system the program 
  15. works correctly, and gives the correct results from both subroutines
  16. (ONCE and DIFFER).  When compiled under 4.0.5 the program core-dumps at line
  17. 42, unless the compilation is done with the keyword '-static'. 
  18.  
  19. A cutdown version in which the subroutine 'ONCE' is not called and the 
  20. routine itself is not present, does run without core-dumping (when compiled 
  21. without '-static') but it appears that the numbers in the second array (XS)
  22. are not correctly held (all are either zero or very small numbers). 
  23.  
  24. My reading of the the Fortran manual pages leads me to believe that use
  25. of the 'SAVE' directive in the subroutine DIFFER is the only requirement
  26. for values to be retained on exit from a subroutine.
  27.  
  28. I detected this anomaly in a larger program.  In this, the use
  29. of three entry points to a subroutine is used to allow calculations
  30. to be done on pairs of arrays selected from a much larger number than two.
  31. Thus if there are n arrays the number of subroutine calls is 2*n rather than
  32. n**2 (which is the case if both selected arrays are to be passed as 
  33. parameters together in a single subroutine call.  
  34.  
  35. C-------------------------------cut here-------------------------
  36.       PROGRAM TESTPRO
  37.       COMMON/A/XA(10)
  38.       COMMON/B/XB(10)
  39.       DO 100 I = 1,10
  40.            XA(I) = FLOAT(I)
  41.            XB(I) = 10.0 - FLOAT(I)
  42. 100   CONTINUE
  43.  
  44.       WRITE (*,1000)
  45. 1000  FORMAT ('Enter to numbers between 1 and 10 inclusive')
  46.       READ  (*,*) K,L
  47.  
  48.       CALL DIFF1 (XA)
  49.       CALL DIFF2 (XB)
  50.       CALL DIFF3 (K,L,RESULT)
  51.       WRITE (*,*) RESULT
  52.  
  53.       CALL ONCE (XA,XB,K,L,RESULT)
  54.       WRITE (*,*) RESULT
  55.  
  56.       STOP
  57.       END
  58.  
  59.       SUBROUTINE ONCE (XR,XS,I,J,D)
  60.       DIMENSION XR(10)
  61.       DIMENSION XS(10)
  62.       write (*,*) i,j,xr(i),xs(j)
  63.       D = XR(I) - XS(J)
  64.       RETURN
  65.       END
  66.  
  67.       SUBROUTINE DIFFER
  68.       SAVE
  69.       DIMENSION XR(10)
  70.       DIMENSION XS(10)
  71.       ENTRY DIFF1 (XR)
  72.       RETURN
  73.       ENTRY DIFF2 (XS)
  74.       RETURN
  75.       ENTRY DIFF3 (I,J,D)
  76.       write (*,*) i,j,xr(i),xs(j)  !Program fails here when '-static' not used
  77.       D = XR(I) - XS(J)
  78.       RETURN
  79.       END 
  80. C-------------------------------cut here-------------------------
  81.  
  82. Has anyone had similar problems.
  83.  
  84. Peter Bladon
  85. University of Strathclyde
  86. Department of Pure and Applied Chemistry
  87. Glasgow G1 1XL      
  88.  
  89. e-mail  cbas25%vaxa.strath.ac.uk
  90.