I am about to start rewriting a fortran program to ansi C++.
Would it be best to convert the variables that are 'real' to float?
double? long double? 5 6025
Al wrote: I am about to start rewriting a fortran program to ansi C++.
Step 1: use f2c, to translate Fortran source into complete C source that
compiles and runs. F2C is so stable that many use it as their Fortran
compiler. They never read the C intermediate.
Step 2: Read the C intermediate. It is not that bad, once you learn how
stereotypically it wraps all the Fortran nuances. But it won't be C++. Don't
ask it to be and you'l do fine. You can make minor tweaks to code in this
state.
Step 3: Write a billion unit tests that completely characterize this legacy
code. Many tests can pass sample data, collect sample results, and compare
them to golden references.
Step 4: Erase the source, and make each unit test pass by writing new
source.
Notice that at each step you can stop and have something useful to work
with.
--
Phlip http://www.c2.com/cgi/wiki?ZeekLand
Al wrote: I am about to start rewriting a fortran program to ansi C++.
Would it be best to convert the variables that are 'real' to float? double? long double?
It depends on the precision that you want. I would begin with double.
--
Ioannis Vranos http://www23.brinkster.com/noicys
"Al" <al********@hot mail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . I am about to start rewriting a fortran program to ansi C++.
Would it be best to convert the variables that are 'real' to float? double? long double?
To be on the safe side I'd go with double.
Cheers
Chris
Chris Theis wrote: "Al" <al********@hot mail.com> wrote in message news:11******** **************@ z14g2000cwz.goo glegroups.com.. .I am about to start rewriting a fortran program to ansi C++.
Would it be best to convert the variables that are 'real' to float? double? long double?
To be on the safe side I'd go with double.
I agree, but let me note that most Fortran compilers on 32-bit
platforms use 4-byte reals, which corresponds to a C/C++ float. If the
Fortran programmer thought 8 byte variables were necessary, he would
have declared them as DOUBLE PRECISION or the nonstandard, but common,
REAL*8. Many Fortran compilers have an option to "promote" REAL
variables to double precision. If one has a make file or build script
showing that this option was used, then the corresponding C++ variables
should be double.
Chris Theis wrote: "Al" <al********@hot mail.com> wrote in message news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I am about to start rewriting a fortran program to ansi C++.
Would it be best to convert the variables that are 'real' to float? double? long double?
To be on the safe side I'd go with double.
Actually, if you're lucky, then they're already declared in fortran as
either
REAL*4 or REAL*8, in which case the decision for float or double is made
for you. Otherwise, I'd agree with Chris and go with double.
It's been ages since I did FORTRAN (back in the ancient WATFOR/WATFIV
days), but didn't it also have an explicit DOUBLE PRECISION declaration? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Santosh |
last post by:
Hello all,
I am trying to interface c++ and fortran, the fortran code is already
there and I was successful
in calling the subroutines and functions, but was not able to send the
fortran module data into my C++ code and viceversa. I used gcc 3.3 and
g95 for c++ and fortran resp. Here is a little made up sample code so
that u could understand my problem.
$cat fort.f90
|
by: NM |
last post by:
Hello all,
I am supposed to do some mixed programming with c++ and fortran.
I was succeeful in exchanging the 2D arrays from fortran to c++ and the
other way, but was unable
to that same with the 3D arrays, the values passed are not all the
same. I am also pasting the fortran and c++ codes so that you could
have a look at them.
////C++ Code
|
by: Bigdakine |
last post by:
I don't know if this is the right forum for this, and if not please suggest one
which fits.
I have to call a fortran sub routine from a C main program.
The fortran subroutine statement is
wload(starttime, duration, station, component, dataray, nsamp, calib, srate,
samplength, datadir)
|
by: sam |
last post by:
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?
Thanks in advance.
Sam.
|
by: travisperkins03 |
last post by:
Hi,
I have read somewhere that C code sometimes cannot be compiled to be as
efficient as FORTRAN, eg for matrix multiplication, because a C
compiler cannot make the assumptions about arrays that a FORTRAN
compiler can. But I don't understand the example, not least because I
don't understand FORTRAN. I also don't understand why it is more
efficient in this case for a compiler to choose the order of evaluation
(or whatever it is that it...
| |
by: Holger (David) Wagner |
last post by:
Hi all,
we're currently developing an application in the .NET environment that
needs to access a DLL implemented in Fortran. There is one procedure
with about 17 parameters, most of them arrays. After some trial and
error experiments, we've found out that
a) the parameters must be ordered by type, i.e. we cannot mix double,
integers and Strings (char-Arrays) - instead, we first need to put
all the float-Arrays and Int32-Arrays, and...
|
by: David Dvali |
last post by:
Hello.
I have one small program which I need to convert in C#.
The original source codes are written in Fortran 77.
Can anybody advice me what is the easy way to do this task?
Or may be there is some tools for it?
Thank you.
|
by: Nomad.C |
last post by:
Hi
I've been thinking of learning Fortran as number crunching kinda
language for my Physics degree......but then looking around the
internet, people are saying that the libraries/ Algorithms once used
for number crunching is now slowly converting into C, so do you think
I should stick with C, since I know C already, or should I proceed
learning fortran??
Any advice??
Thanks
|
by: luis |
last post by:
I'm using ctypes to call a fortran dll from python. I have no problems
passing integer and double arryas, but I have an error with str arrys.
For example:
.....
StringVector = c_char_p * len(id) # id is a list of strings
Id_dat=StringVector()
for i in range(len(Id)):
....Id_dat=id
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |