home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / fortran / 3060 < prev    next >
Encoding:
Text File  |  1992-08-16  |  1.8 KB  |  64 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!informatik.tu-muenchen.de!wahler
  3. From: wahler@Informatik.TU-Muenchen.DE (Bernhard Wahler (D MS))
  4. Subject: C to Fortran , Character Strings
  5. Originator: wahler@hpzenger1.informatik.tu-muenchen.de
  6. Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem)
  7. Organization: Technische Universitaet Muenchen, Germany
  8. Date: Mon, 17 Aug 1992 08:29:30 GMT
  9. Message-ID: <1992Aug17.082930.22597@Informatik.TU-Muenchen.DE>
  10. Lines: 52
  11.  
  12.  
  13.  
  14.  
  15. Hello everybody, I've got a problem with character strings 
  16. in FORTRAN.  I have to translate a C-prg into a FORTRAN-prg.
  17. and everything is working fine so far.
  18. On a HP there is the ALIAS-Directive to tell the fortran-compiler
  19. how to pass parameters. I tried this and it worked.
  20.  
  21. But how can I get
  22. get a C-character string, which is returned by my C-function 
  23. "msys_rcv()" ( see below ) into a fortran-type and work with it
  24. ( print it ). 
  25.  
  26. Any help would be appreciated. Thanks in advance,
  27.  
  28. Bernhard Wahler
  29.  
  30. wahler@dszenger10.informatik.tu-muenchen.de
  31.  
  32.  
  33.  
  34. ---------------- C-Code --------------------------
  35.  
  36. char *RECEIVE( long *size, long *channel )
  37. {
  38.    char *mess;
  39. ->   if ((mess = msys_rcv( WAIT, size, channel ))!=NULL) {
  40.      printf("Msg-Laenge : %ld\t", *size );
  41.      printf("Channel : %ld\t", *channel );
  42.      printf("Erstes Byte : %c\n", mess[0] );
  43.      printf("Letztes Byte : %c\n", mess[*size-1] );
  44.      msys_free(mess);
  45.    }
  46.    return mess;
  47. }
  48.  
  49. -------------- FORTRAN-Code ----------------------
  50.  
  51. $ALIAS CC3 = 'msys_rcv' (%val,%ref,%ref)
  52.  
  53.         subroutine RECEIVE( mess )
  54.           character mess*(*)
  55.           integer*4 size, channel
  56.           integer MSYS_NOWAIT
  57.           parameter( MSYS_NOWAIT = 1 )
  58. ---->     mess =  CC3( MSYS_NOWAIT, size, channel )
  59.         end
  60.  
  61.  
  62. Keywords: 
  63.  
  64.