home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / ultrix / 8225 < prev    next >
Encoding:
Text File  |  1992-11-10  |  3.4 KB  |  120 lines

  1. Xref: sparky comp.unix.ultrix:8225 comp.sys.dec:5876
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!ut-emx!trillium!brook
  3. From: brook@trillium.BOTANY.UTEXAS.EDU (Brook Milligan)
  4. Newsgroups: comp.unix.ultrix,comp.sys.dec
  5. Subject: fortran complex*16 for RISC
  6. Message-ID: <1403@trillium.BOTANY.UTEXAS.EDU>
  7. Date: 10 Nov 92 23:19:00 GMT
  8. Followup-To: poster
  9. Organization: Dept. of Botany, Univ. of Texas, Austin
  10. Lines: 108
  11.  
  12. I am trying to compile a program that uses fortran functions involving
  13. complex numbers.  I have compiled the mathematical functions using f77
  14. and the c interface functions using gcc.  When I link the object files
  15. I get the following message:
  16.  
  17.      /usr/lib/cmplrs/cc/ld:
  18.      Undefined:
  19.      math_div_dc_
  20.  
  21. This error is a result of trying to do a complex division (as the
  22. following two functions will illustrate; if you compile and link them
  23. you will get the same message).  If instead the types are complex*8,
  24. the same message is generated with a `fc' rather than a `dc' in the
  25. above function name.
  26.  
  27. Presumably I need to include a library that provides complex
  28. arithmetic functions for fortran.  What is the library that I need?
  29. This is on a decstation running ultrix 4.2 with the fortran 3.0
  30. compiler.
  31.  
  32. Thanks for your help.
  33.  
  34. Brook G. Milligan               Internet:  brook@trillium.botany.utexas.edu
  35. Department of Botany            Bitnet:    bohk313@utaivc
  36. University of Texas at Austin   UUCP:      ...!ut-emx!brook
  37. Austin, Texas  78713   U.S.A.   (512) 471-3530  |  FAX: (512) 471-3878
  38.  
  39. ==================================== l.c ===========================================
  40.  
  41. #include <math.h>
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44.  
  45. /*
  46.  * ----------------------------------------------------------------------
  47.  *
  48.  *     COMPLEX*16 type - for fortran interface
  49.  *
  50.  * ----------------------------------------------------------------------
  51.  */
  52.  
  53. struct _complex_16_info
  54. {
  55.   double r;            /* real component */
  56.   double i;            /* imaginary component */
  57. };
  58.  
  59. typedef struct _complex_16_info COMPLEX_16;
  60.  
  61. /*
  62.  * ----------------------------------------------------------------------
  63.  *
  64.  *     z - declare fortran function
  65.  *
  66.  * ----------------------------------------------------------------------
  67.  */
  68.  
  69. #define z z_            /* fortran external symbol name */
  70.  
  71. extern void z (COMPLEX_16 * c, COMPLEX_16 * a, COMPLEX_16 * b);
  72.  
  73. /*
  74.  * ----------------------------------------------------------------------
  75.  *
  76.  *     main
  77.  *
  78.  * ----------------------------------------------------------------------
  79.  */
  80.  
  81. int main (int argc, char * argv [])
  82. {
  83.   COMPLEX_16 a;
  84.   COMPLEX_16 b;
  85.   COMPLEX_16 c;
  86.  
  87.   printf ("l() -- test of complex arithmetic\n");
  88.  
  89.   a . r = 1.0;
  90.   a . i = 0.0;
  91.   b . r = 2.0;
  92.   b . i = 1.0;
  93.  
  94.   printf ("a:  %f + i%-f\n", a . r, a . i);
  95.   printf ("b:  %f + i%-f\n", b . r, b . i);
  96.  
  97.   z (&c, &a, &b);
  98.  
  99.   printf ("c = a+b:  %f + i%-f\n", c . r, c . i);
  100.  
  101.   return 0;
  102. }
  103.  
  104. =================================== z.f =============================================
  105.  
  106.       subroutine z(c,a,b)
  107.       complex*16 a,b,c
  108.  
  109.       c = a/b
  110.  
  111.       return
  112.       end
  113.  
  114. ================================================================================
  115. -- 
  116. Brook G. Milligan               Internet:  brook@trillium.botany.utexas.edu
  117. Department of Botany            Bitnet:    bohk313@utaivc
  118. University of Texas at Austin   UUCP:      ...!ut-emx!brook
  119. Austin, Texas  78713   U.S.A.   (512) 471-3530  |  FAX: (512) 471-3878
  120.