G
first, a little background...
i have a C program which preprocesses some data, and then outputs the
results into a text file. that text file, in turn, is used as input
to a FORTRAN computational fluid dynamics (CFD) program. the FORTRAN
program goes to work on the provided data, and outputs a text file
which i read back in with another C program to postprocess the data
and analyze the results of the CFD run.
now on to the problem. the input file to the FORTRAN CFD program is
in the following format (which may look familiar to folks well versed
in FORTRAN, which i'm not):
(ronin)$ cat boundedmatrix.in
1.0D0 ! Ratio
1.5D0 ! AXMAX
1 ! NPNAX
1D-1 ! B
0.5D0 ! GAM
18 ! NKMAX
1.7D0 ! EPS
-1 ! NP
0.6283D0 ! LAM (wavelength)
1.50D0 ! MRR (real part of the refractive index)
0.02D0 ! MRI (imag part of the refractive index)
0.00001D0 ! DDELT
181 ! NPNA (number of angles)
2 ! NDGS
the format of the FORTRAN input parameters, as you can see, carries
the precision of the value with it. e.g., 1.0D0 is a double precision
value X 10^0. and, 1D-1 is a double precision value X 10^-1.
now then, i'm a complete novice when it comes to FORTRAN, and denoting
the value precision in the input file in this way seems, to this C
programmer, to be a little odd. but nevertheless that's the way it
is.
does anyone have any ideas on how i might get my fprintf()'s to output
these kinds of values without a lot of gymnastics? i've taken a
couple of simplistic runs at it but i haven't gotten anywhere except
really-frustrated-ville. it appears that it should be easy to do but
i haven't found a clever way yet. of course i know ahead of time
which of my C variables are double precision and so forth. for that
matter i know a priori which variables the FORTRAN program are
expected to be in double precision.
note that it is no way possible for me to modify the FORTRAN program,
it's a NSF-sourced CFD code and if i touch it i can look forward to
about 10 years of verification tests. each CFD run is taking about 6
hours on a 512 processor SGI Origin box as it is. so the solution can
not include "tweaking" the FORTRAN code in any way. i have to treat
the CFD program as an immutable black box.
ideas, thoughts, catalysts, FORTRAN-conversion.c source, hate mail,
etc are all welcome.
thanks
jim
i have a C program which preprocesses some data, and then outputs the
results into a text file. that text file, in turn, is used as input
to a FORTRAN computational fluid dynamics (CFD) program. the FORTRAN
program goes to work on the provided data, and outputs a text file
which i read back in with another C program to postprocess the data
and analyze the results of the CFD run.
now on to the problem. the input file to the FORTRAN CFD program is
in the following format (which may look familiar to folks well versed
in FORTRAN, which i'm not):
(ronin)$ cat boundedmatrix.in
1.0D0 ! Ratio
1.5D0 ! AXMAX
1 ! NPNAX
1D-1 ! B
0.5D0 ! GAM
18 ! NKMAX
1.7D0 ! EPS
-1 ! NP
0.6283D0 ! LAM (wavelength)
1.50D0 ! MRR (real part of the refractive index)
0.02D0 ! MRI (imag part of the refractive index)
0.00001D0 ! DDELT
181 ! NPNA (number of angles)
2 ! NDGS
the format of the FORTRAN input parameters, as you can see, carries
the precision of the value with it. e.g., 1.0D0 is a double precision
value X 10^0. and, 1D-1 is a double precision value X 10^-1.
now then, i'm a complete novice when it comes to FORTRAN, and denoting
the value precision in the input file in this way seems, to this C
programmer, to be a little odd. but nevertheless that's the way it
is.
does anyone have any ideas on how i might get my fprintf()'s to output
these kinds of values without a lot of gymnastics? i've taken a
couple of simplistic runs at it but i haven't gotten anywhere except
really-frustrated-ville. it appears that it should be easy to do but
i haven't found a clever way yet. of course i know ahead of time
which of my C variables are double precision and so forth. for that
matter i know a priori which variables the FORTRAN program are
expected to be in double precision.
note that it is no way possible for me to modify the FORTRAN program,
it's a NSF-sourced CFD code and if i touch it i can look forward to
about 10 years of verification tests. each CFD run is taking about 6
hours on a 512 processor SGI Origin box as it is. so the solution can
not include "tweaking" the FORTRAN code in any way. i have to treat
the CFD program as an immutable black box.
ideas, thoughts, catalysts, FORTRAN-conversion.c source, hate mail,
etc are all welcome.
thanks
jim