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