convert f77 code from mixed case to lower case
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
convert f77 code from mixed case to lower case         


Author: Lynn McGuire
Date: Jul 23, 2007 09:42

I would like to convert our 550,000 lines of f77 code from mixed case
(mostly upper) to lower case. Does anyone know of a tool to do this ?
Obviously, the tool would need to skip all comment lines, character
strings and hollerith. Our code looks something like:

SUBROUTINE EQUI12 (IGO,NIN,NOUT,IEQP,EXTNUM,EQNAM,NSTRMS,KPM)
C Update the bank pointers
CALL EQBK55 (JEQNO,NNAMI,JNAMU,JNAME,JNAM1,JNAM2,KEQIND,NWTOT,
* KPSCP,NWSCP,KPIN,NWIN,KPOUT,NWOUT,KPCMP,NWCMP,
* KPDSP,NWDSP,KPEQP,NWEQP,EQNAM)

I would like it to look like:

subroutine equi12 (igo, nn, nout, ieqp, extnum, eqnam, nstrms, kpm)
C Update the bank pointers
call eqbk55 (jeqno, nnami, jnamu, jname, jnam1, jnam2, keqind, nwtot,
* kpscp, nwscp, kpin, nwin, kpout, nwout, kpcmp, nwcmp,
* kpdsp, nwdsp, kpeqp, nweqp, eqnam)

Thanks,
Lynn
44 Comments
Re: convert f77 code from mixed case to lower case         


Author: tianyf
Date: Jul 23, 2007 18:32

On Jul 24, 12:42 am, "Lynn McGuire" nospam.com> wrote:
> I would like to convert our 550,000 lines of f77 code from mixed case
> (mostly upper) to lower case. Does anyone know of a tool to do this ?
> Obviously, the tool would need to skip all comment lines, character
> strings and hollerith. Our code looks something like:
>
> SUBROUTINE EQUI12 (IGO,NIN,NOUT,IEQP,EXTNUM,EQNAM,NSTRMS,KPM)
> C Update the bank pointers
> CALL EQBK55 (JEQNO,NNAMI,JNAMU,JNAME,JNAM1,JNAM2,KEQIND,NWTOT,
> * KPSCP,NWSCP,KPIN,NWIN,KPOUT,NWOUT,KPCMP,NWCMP,
> * KPDSP,NWDSP,KPEQP,NWEQP,EQNAM)
>
> I would like it to look like:
>
> subroutine equi12 (igo, nn, nout, ieqp, extnum, eqnam, nstrms, kpm)
> C Update the bank pointers
> call eqbk55 (jeqno, nnami, jnamu, jname, jnam1, jnam2, keqind, nwtot,
> * kpscp, nwscp, kpin, nwin, kpout, nwout, kpcmp, nwcmp,
> * kpdsp, nwdsp, kpeqp, nweqp, eqnam)
> ...
Show full article (1.35Kb)
no comments
Re: convert f77 code from mixed case to lower case         


Author: Terence
Date: Jul 23, 2007 18:42

On Jul 24, 2:42 am, "Lynn McGuire" nospam.com> wrote:
> I would like to convert our 550,000 lines of f77 code from mixed case
> (mostly upper) to lower case.

Whenever I see this type of code I look for a routine to go the other
way.
Then the comments and message strings literals are in normal lanuage
mixed case and the code is more readable (to me).

Since I already have a program to re-write Fortran programs, re-
numbering the labels and format statements (and usage) sequentially,
perhaps I should now add that extra touch!
no comments
Re: convert f77 code from mixed case to lower case         


Author: Fly Away
Date: Jul 23, 2007 19:50

Or you could write a simple Fortran code to do this
> by using char/ichar functions. There is an fixed offset of ichar()
> value between lowercase and uppercase letters.

It would be strange to see someone use Fortran for such a task. Perl
would be a much better choice. Or even a bash script.
no comments
Re: convert f77 code from mixed case to lower case         


Author: glen herrmannsfeldt
Date: Jul 23, 2007 20:14

Lynn McGuire wrote:
> I would like to convert our 550,000 lines of f77 code from mixed case
> (mostly upper) to lower case. Does anyone know of a tool to do this ?
> Obviously, the tool would need to skip all comment lines, character
> strings and hollerith.

With awk you could start with:

/^[^cC]/ { $0=tolower($0) }
{ print }

Which will change everything that isn't a comment.

/^[cC]/ {print; next }
/'/ {
for(i=1;i<=length($0);i++) {
if(substr($0,i,1)=="'") q=1-q;
if(!q) $0=substr($0,1,i-1) tolower(substr($0,i,1)) substr($0,i+1)
}
print
next
}
{ print tolower($0) }
Show full article (0.79Kb)
no comments
Re: convert f77 code from mixed case to lower case         


Author: nospam
Date: Jul 23, 2007 20:20

tianyf@gmail.com gmail.com> wrote:
> On Jul 24, 12:42 am, "Lynn McGuire" nospam.com> wrote:
>> I would like to convert our 550,000 lines of f77 code from mixed case
>> (mostly upper) to lower case.
...
> I believe there are so many approaches to do this. Some editors (such
> as Ultraedit, EmEditor) have the ability to convert all letters to
> upper/lower case. Or you could write a simple Fortran code to do this
> by using char/ichar functions.

You seem to have missed the OP's requirement that
>> Obviously, the tool would need to skip all comment lines, character
>> strings and hollerith.

That would seem to be the whole point of the question, as otherwise it
is trivial.

That makes it not such a "simple" Fortran code. It would also be a rare
editor that would have such a capability, as the editor would have to be
able to do at least minimal parsing of Fortran. There might possibly be
some editors with such a thing (Emacs comes to mind as a likely
candidate), but it isn't likely to be common.
Show full article (1.23Kb)
no comments
Re: convert f77 code from mixed case to lower case         


Date: Jul 23, 2007 20:23

On Jul 23, 9:42 am, "Lynn McGuire" nospam.com> wrote:
> I would like to convert our 550,000 lines of f77 code from mixed case
> (mostly upper) to lower case. Does anyone know of a tool to do this ?
> Obviously, the tool would need to skip all comment lines, character
> strings and hollerith. Our code looks something like:
>
> SUBROUTINE EQUI12 (IGO,NIN,NOUT,IEQP,EXTNUM,EQNAM,NSTRMS,KPM)
> C Update the bank pointers
> CALL EQBK55 (JEQNO,NNAMI,JNAMU,JNAME,JNAM1,JNAM2,KEQIND,NWTOT,
> * KPSCP,NWSCP,KPIN,NWIN,KPOUT,NWOUT,KPCMP,NWCMP,
> * KPDSP,NWDSP,KPEQP,NWEQP,EQNAM)
>
> I would like it to look like:
>
> subroutine equi12 (igo, nn, nout, ieqp, extnum, eqnam, nstrms, kpm)
> C Update the bank pointers
> call eqbk55 (jeqno, nnami, jnamu, jname, jnam1, jnam2, keqind, nwtot,
> * kpscp, nwscp, kpin, nwin, kpout, nwout, kpcmp, nwcmp,
> * kpdsp, nwdsp, kpeqp, nweqp, eqnam)
> ...
Show full article (1.16Kb)
no comments
Re: convert f77 code from mixed case to lower case         


Author: Steven G. Kargl
Date: Jul 23, 2007 22:12

In article <1185247380.223682.195070@57g2000hsv.googlegroups.com>,
robert.corbett@sun.com writes:
> On Jul 23, 9:42 am, "Lynn McGuire" nospam.com> wrote:
>> I would like to convert our 550,000 lines of f77 code from mixed case
>> (mostly upper) to lower case. Does anyone know of a tool to do this ?
>> Obviously, the tool would need to skip all comment lines, character
>> strings and hollerith. Our code looks something like:
>>
>> SUBROUTINE EQUI12 (IGO,NIN,NOUT,IEQP,EXTNUM,EQNAM,NSTRMS,KPM)
>> C Update the bank pointers
>> CALL EQBK55 (JEQNO,NNAMI,JNAMU,JNAME,JNAM1,JNAM2,KEQIND,NWTOT,
>> * KPSCP,NWSCP,KPIN,NWIN,KPOUT,NWOUT,KPCMP,NWCMP,
>> * KPDSP,NWDSP,KPEQP,NWEQP,EQNAM)
>>
>> I would like it to look like:
>>
>> subroutine equi12 (igo, nn, nout, ieqp, extnum, eqnam, nstrms, kpm)
>> C Update the bank pointers
>> call eqbk55 (jeqno, nnami, jnamu, jname, jnam1, jnam2, keqind, nwtot,
>> * kpscp, nwscp, kpin, nwin, kpout, nwout, kpcmp, nwcmp, ...
Show full article (1.54Kb)
no comments
Re: convert f77 code from mixed case to lower case         


Author: tianyf
Date: Jul 24, 2007 00:08

On Jul 24, 11:20 am, nos...@see.signature (Richard Maine) wrote:
> tia...@gmail.com gmail.com> wrote:
>> On Jul 24, 12:42 am, "Lynn McGuire" nospam.com> wrote:
>>> I would like to convert our 550,000 lines of f77 code from mixed case
>>> (mostly upper) to lower case.
> ...
>> I believe there are so many approaches to do this. Some editors (such
>> as Ultraedit, EmEditor) have the ability to convert all letters to
>> upper/lower case. Or you could write a simple Fortran code to do this
>> by using char/ichar functions.
>
> You seem to have missed the OP's requirement that
>
>>> Obviously, the tool would need to skip all comment lines, character
>>> strings and hollerith.
>
> That would seem to be the whole point of the question, as otherwise it
> is trivial.
>
> That makes it not such a "simple" Fortran code. It would also be a rare ...
Show full article (1.84Kb)
no comments
Re: convert f77 code from mixed case to lower case         


Author: tianyf
Date: Jul 24, 2007 05:14

On Jul 24, 3:08 pm, "tia...@gmail.com" gmail.com> wrote:
> On Jul 24, 11:20 am, nos...@see.signature (Richard Maine) wrote:
>
>
>
>> tia...@gmail.com gmail.com> wrote:
>>> On Jul 24, 12:42 am, "Lynn McGuire" nospam.com> wrote:
>>>> I would like to convert our 550,000 lines of f77 code from mixed case
>>>> (mostly upper) to lower case.
>> ...
>>> I believe there are so many approaches to do this. Some editors (such
>>> as Ultraedit, EmEditor) have the ability to convert all letters to
>>> upper/lower case. Or you could write a simple Fortran code to do this
>>> by using char/ichar functions.
>
>> You seem to have missed the OP's requirement that
>
>>>> Obviously, the tool would need to skip all comment lines, character
>>>> strings and hollerith.
> ...
Show full article (8.04Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Re: To convert or not to convert, that's the questioncomp.lang.clipper.visual-objects ·
1 2 3 4 5