Home > Archive > Fortran > December 2005 > C to FTN90 conversion
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
C to FTN90 conversion
|
|
| Ftn 90 2005-12-12, 7:16 pm |
| Hi Everyone:
Is there a freeware package around that will convert basic C code to
Fortran 90? I don't need anything too fancy, just something that will take
simple code snippits like:
int i = 0;
if (x <= xtab[0])
i = 0;
else if (x >= xtab[ntab-1])
i = ntab-2;
else {
while (x > xtab[i]) i++;
i--;
}
and convert them to their Fortran 90 equivalent. I'm working on a progect
that requires I convert some fairly simple C algorithms to Fortran and, while I
can do it all by hand, life would be easier if there was a utility that would
take care of the mundane things.
I see a C2F program referenced when I do an Internet search for this, but
all the links to it are dead . . .
Thanks, Paul
| |
| David Frank 2005-12-12, 7:16 pm |
|
"Ftn 90" <ftn90@fortran.com> wrote in message
news:1pjnf.138306$Ph4.4233776@ursa-nb00s0.nbnet.nb.ca...
> Hi Everyone:
>
> Is there a freeware package around that will convert basic C code to
> Fortran 90? I don't need anything too fancy, just something that will
> take
> simple code snippits like:
>
> int i = 0;
>
> if (x <= xtab[0])
> i = 0;
> else if (x >= xtab[ntab-1])
> i = ntab-2;
> else {
> while (x > xtab[i]) i++;
> i--;
> }
>
>
> and convert them to their Fortran 90 equivalent. I'm working on a
> progect
> that requires I convert some fairly simple C algorithms to Fortran and,
> while I
> can do it all by hand, life would be easier if there was a utility that
> would
> take care of the mundane things.
>
> I see a C2F program referenced when I do an Internet search for this,
> but
> all the links to it are dead . . .
>
> Thanks, Paul
>
>
>
http://home.earthlink.net/~dave_gemini/c2f.zip
| |
| David Frank 2005-12-12, 7:16 pm |
| Below is the translation output for your simple C source processed by
C2F.EXE
! --------------------------------------------------
MODULE SIMPLE_1 ! global declarations
! --------------------------------------------------
INCLUDE 'C2F.FD'
INCLUDE 'C2F.FI'
INTEGER :: i=0
IF (x <= xtab(0+1)) THEN
i = 0
ELSE IF (x >= xtab(ntab-1+1)) THEN
i = ntab-2
ELSE
DO WHILE (x > xtab(i+1))
i = i+1
END DO
i = i-1
END IF
END MODULE
INCLUDE 'C2F_LIB.F90'
! 0 Errors detected
>
>
> http://home.earthlink.net/~dave_gemini/c2f.zip
>
>
>
| |
| Ftn 90 2005-12-13, 8:14 am |
| In article <ILlnf.3015$3Z.2205@newsread1.news.atl.earthlink.net>,
dave_frank@hotmail.com says...[color=darkred]
>
>Below is the translation output for your simple C source processed by
>C2F.EXE
>
>! --------------------------------------------------
>MODULE SIMPLE_1 ! global declarations
>! --------------------------------------------------
>INCLUDE 'C2F.FD'
>INCLUDE 'C2F.FI'
> INTEGER :: i=0
> IF (x <= xtab(0+1)) THEN
> i = 0
> ELSE IF (x >= xtab(ntab-1+1)) THEN
> i = ntab-2
> ELSE
> DO WHILE (x > xtab(i+1))
> i = i+1
> END DO
> i = i-1
> END IF
>
>END MODULE
>INCLUDE 'C2F_LIB.F90'
>! 0 Errors detected
>
Many thanks for this, Frank. It is exactly what I was looking for. I
realise there are a lot of things that will have to be checked manually
(especially array indices, etc.), but it takes care of the routine syntax
changes . . . seems to be a pretty good implementation as well. This will save
me a lot of work.
Hopefully one of these days I can return the favour!
- Paul (in Nova Scotia, Canada)
|
|
|
|
|