Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

I was perusing the web and found - in effect - source code to convert fortran code to C. Unfortunately i'm having difficulties compiling source.

The question. Does anyone have an f90 to C or f2C (basically a fortran to C converter - preferably fortran 90 to C/C++?) converter that works in a PC enviornment (Unsure how much difference it make, nonetheless, I'm ruinning XP) that I could obtain? I've got lots of fortran code to convert.

My 'outside' email would be forums_mp@hotmail.com

Thanks in advance

The question. Does anyone have an f90 to C or f2C (basically a fortran to C converter - preferably fortran 90 to C/C++?) converter that works in a PC enviornment (Unsure how much difference it make, nonetheless, I'm ruinning XP) that I could obtain? I've got lots of fortran code to convert.

My 'outside' email would be forums_mp@hotmail.com

Thanks in advance

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Consider the example referenced in the manual for f2c

--------------------------

FUNCTION DOT(N,X,Y)

INTEGER N

REAL X(N),Y(N)

DOT = 0

DOT 10 I = 1, N

10 DOT = DOT + X(I)*Y(I)

END

using f2c per the above

Error on line 1 of test2.F: illegal continuation card (starts "FUNCTI")

Error on line 2 of test2.F: illegal continuation card (starts "INTEGE")

Error on line 3 of test2.F: illegal continuation card (starts "REAL X")

Error on line 4 of test2.F: nondigit in statement label field "DOT ="

Error on line 5 of test2.F: nondigit in statement label field "DOT 1"

Error on line 4 of test2.F: unclassifiable statement (starts "0")

Error on line 6 of test2.F: labeled continuation line (starts "10 DO")

Error on line 7 of test2.F: nondigit in statement label field "END "

MAIN:

Error on line 5 of test2.F: syntax error

Warning on line 7: missing final end statement

--------------------------

What all this means is beyond me and cant find anything per the documentation highlighting a fix.

Any ideas?

1) You must start FORTRAN statements in COLUMN 7! FORTRAN considers column 1 as "special" and you're not following the rules.

2) You must have a final END since you start with a FUNCTION. This is not really a valid FORTRAN program but it's still translatable.

Starting with the following LEGAL FORTRAN:

FUNCTION DOT(N,X,Y)

INTEGER N

REAL X(N),Y(N)

DOT = 0

DO 10 I = 1, N

10 DOT = DOT + X(I)*Y(I)

END

END

I issued the following:

F2C <TEST.F

And the expected response:

/* -- translated by f2c (version 19970805).

You must link the resulting object file with the libraries:

-lf2c -lm (in that order)

*/

#include "f2c.h"

doublereal dot_(n, x, y)

integer *n;

real *x, *y;

{

/* System generated locals */

integer i__1;

real ret_val;

/* Local variables */

static integer i__;

/* Parameter adjustments */

--y;

--x;

/* Function Body */

ret_val = (float)0.;

i__1 = *n;

for (i__ = 1; i__ <= i__1; ++i__) {

/* L10: */

ret_val += x[i__] * y[i__];

}

return ret_val;

} /* dot_ */

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialTruly appreaciate the timely responses. I have to apologize, I now have a fotran book. Simply put i've never used fortran in the past. with some general clean ups, I sense this function should look like.

integer *n;

// real *x, *y;

float *x, *y;

float dot_(int *n, float* x, float* y)

{

/* System generated locals */

integer i__1;

// real ret_val;

float ret_val;

/* Local variables */

static integer i__;

/* Parameter adjustments */

--y;

--x;

/* Function Body */

// ret_val = (float)0.;

ret_val = 0.0;

i__1 = *n;

for (i__ = 1; i__ <= i__1; ++i__) {

/* L10: */

ret_val += x[i__] * y[i__];

}

return ret_val;

} /* dot_ */

Programming Languages-Other

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.