home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / compiler / 1284 < prev    next >
Encoding:
Text File  |  1992-07-29  |  2.5 KB  |  65 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!gatech!news.byu.edu!eff!world!iecc!compilers-sender
  3. From: lacey@cps.msu.edu
  4. Subject: Problems with f2c
  5. Reply-To: lacey@cps.msu.edu
  6. Organization: Compilers Central
  7. Date: Wed, 29 Jul 1992 04:23:15 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-07-105@comp.compilers>
  10. Keywords: C, Fortran, question
  11. Sender: compilers-sender@iecc.cambridge.ma.us
  12. Lines: 51
  13.  
  14. I am unhappy with how f2c hands PARAMETER statements, and I am wondering
  15. if there is anybody out there that has written a patch to make it somewhat
  16. more sane, if such a patch could be written easily, and if neither of
  17. those, if anybody has a suggestion on how to work around it.  The problem
  18. is, if you have:
  19.     PARAMETER (MAXXI=100)
  20.     ...
  21.     INTEGER XI(MAXXI)
  22.  
  23. it gets translated to:
  24.     integer xi[100];
  25.  
  26. What I would _like_ to see is:
  27.  
  28.     #define MAXXI 100
  29.  
  30.     integer xi[MAXXI];
  31.  
  32. The project I am currently working on consists of building an X-windows
  33. interface onto an old Fortran program, which is converted to C with f2c,
  34. and then portions are modified.  There are 55,000 lines of Fortran, in
  35. around 45 files, along with another 12 common block files, in which the
  36. PARAMETER statements appear.  The optimum result would be for each .F file
  37. to be translated to a .c file, each .CBK (common block) file translated
  38. into a .c file (this can be done with the -E option, I think it is), and
  39. then a .h file created fopr each common block with the #define's for
  40. PARAMETER statements, along with extern's for all of the common block
  41. data.
  42.  
  43. I can't think of a work-around that actually works.  One approach I tried
  44. was to replace each of the values in a PARAMETER statement with some
  45. unique prime number, and then use 'sed' to replace occurances of the value
  46. with a string.  This didn't work because of the fact that these parameters
  47. are often multiplied together by f2c, and the result is a different
  48. number, which often contains a substring of another number.  I could get
  49. this to work if I could figure out how to make sed replace a string of
  50. digits, strictly surrounded by non-digits, with a string (i.e. not replace
  51. sub-strings of digits).  The parameters also, of course, show up in the
  52. Fortran source code (if they didn't I could solve things pretty easily, by
  53. hand).
  54.  
  55. Any help would be appreciated.  Please send e-mail rather than posting.
  56.  
  57. Thanks,
  58.  
  59. Mark M. Lacey
  60. [lacey@cps.msu.edu]
  61. [Try sed 's/\([^0-9]\)1234\([^0-9]\)/\1 MAXXI \2/' -John]
  62. -- 
  63. Send compilers articles to compilers@iecc.cambridge.ma.us or
  64. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  65.