home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / vms / 20502 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  2.1 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!newsserver.jvnc.net!yale.edu!think.com!ames!agate!stanford.edu!rutgers!uwvax!zazen!psl.wisc.edu!chsra2.chsra.wisc.edu!DSPENCER
  2. From: dspencer@chsra2.chsra.wisc.edu
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Using C to read Fortran File
  5. Message-ID: <1993Jan7.142349.23336@pslu1.psl.wisc.edu>
  6. Date: 7 Jan 93 14:23:49 GMT
  7. Sender: news@pslu1.psl.wisc.edu (USENET News System)
  8. Reply-To: spencer@macc.wisc.edu
  9. Organization: CHSRA/UW-MADISON, MADISON, WI
  10. Lines: 57
  11.  
  12. In article <C0G1rw.81L@ccu.umanitoba.ca>, kaarts@ccu.umanitoba.ca (Kenneth John Aarts) writes:
  13. >In <C0Fyo3.70D@ccu.umanitoba.ca> kaarts@ccu.umanitoba.ca (Kenneth John Aarts) writes:
  14. >
  15. >
  16. >>I have a fortran program that does essentially
  17. >
  18. >>    open(unit=1,"test",status='new')
  19. >>    write(1,10) 'cArt'
  20. >>10    format(a4)
  21. >>    end
  22. >
  23. >>and then a C program that reads it:
  24. >
  25. >>    int d1,d2,d3,d4,d5;
  26. >>    FILE *fp;
  27. >>    fp=fopen("test","r");
  28. >>    fscanf(fp,"%c%c%c%c%c",&d1,&d2,&d3,&d4,&d5);
  29. >>    printf("%d %d %d %d %d\n",d1,d2,d3,d4,d5);
  30. >
  31. >>The output of the C program is:
  32. >
  33. >>  10  65  114  116   13
  34. >
  35. >>  LF  A    r   t    CR
  36. >
  37. >>However, a fortran program reading the test program does see cArt.
  38. >
  39. >>How do I get C to find the c in cArt?
  40. >
  41. >A little more information:
  42. >
  43. >This is all done on VMS.  The fortran created file has a 'fortran carriage
  44. >control' record attribute.
  45.  
  46. change the "r" fopen attribute to "rb".  The file Fortran writes out in this
  47. case has the RMS file attributes 
  48. RMS FILE ATTRIBUTES
  49.  
  50.         File Organization: sequential
  51.         Record Format: variable
  52.         Record Attributes:   fortran
  53.         Maximum Record Size: 0
  54.         Longest Record: 4
  55.         Blocks Allocated: 4, Default Extend Size: 0
  56.         End-of-File VBN: 1, Offset: %X'0006'
  57.         File Monitoring: disabled
  58.         Global Buffer Count: 0
  59.  
  60. Telling VAXC to do a read binary appears to override the interpretation of the
  61. 'fortran' record attribute, and I get the following output
  62.  
  63. 99 65 114 116 0
  64.  
  65. -----------------------------------------------
  66. Dan Spencer         spencer@vms.macc.wisc.edu
  67. Center for Health Systems Research and Analysis
  68. UW-Madison
  69.