C++, Fortran and Matlab
My current CFD codes are in Fortran 77 but I would like to write codes in C++ and Matlab. Does anyone know associated advantages or disadvantages.?. Thanks for your help.

Re: C++, Fortran and Matlab
I tryied to write poisson solvers in Matlab, but finally give up because it was too slow to run. For 2d ADI solver, you may need one hour to get results. In FORATRAN, you only need few seconds. I never tried to compile Matlab code, perhaps, that will speed up code.
Advantages: 1) easy to draw nice figure of all the variables you are interested in. 2) Many functions you can use, no need to rewrite. Disavantages: 1) Too much CPU time. 2) Memory limitations. 
Re: C++, Fortran and Matlab
there is another matlablike software called omatrix that is pretty quick and relatively easy to use, its graphing capabilities are limited, so you might to plot in tecplot or sigmaplot or something, you can find info at harmonicsoftware.com

Re: C++, Fortran and Matlab
I like MATLAB! MATLAB is a brilliant environment for prototyping (and sometimes even implementing) numerical solvers and data processing schemes.
Unfortunately it is all to easy for newcomers to write really inefficient loopbased code rather than take advantage of the inbuilt vectorization in MATLAB. If you lurk around on the comp.softsys.matlab news group, you'll find a fair number of "how do you vectorize this code" questions, along with numerous answers. Basically, anything can be vectorized if you know what you're doing. I tend to prototype a numerical scheme directly in MATLAB, then implement it standalone in FORTRAN/C/C++, then put a MATLAB MEX wrapper around it. That way I can pre and postprocess my data in MATLAB and hand it off directly to my own code. Best of both worlds. The MATLAB compiler is basically for people who aren't confident (skilled?) enough to go wholehog and write MEX files. Just my 2 cents' worth.  Steve 
Re: C++, Fortran and Matlab
I used to program in F77, but for the last 5 years all my new code was developped in C++: 1) Advantages: a) portable b) reusability c) flexibility d) It is easier to make use of dynamic memory allocation than F90 (you can't in f77) e) When you build good classes, the main code becomes easier to write and manipulate. f) If you take advantages of pointers when doing loops, the code can become faster than F77.
I don't see any disavantages. Just a few weeks ago, I had to work on a project for an industry. The code they use is written in F77. Even though I only had to make small changes, thi wasn't easy. We might have to do major changes in the future, if we do so, th whole code will ported using f2c. 
Re: C++, Fortran and Matlab
Hi all,
I like MATLAB for visualizing directly of graphic solutions. However, it's take a many memory to run, if we can't organizing a simple or economic code. I think, we may develope CFD code in F77 or F90, so we visualize graphic solution in Matlab code directly or tecplot. In my opinion, it is a simple. 
Re: C++, Fortran and Matlab
i completely endorse the views of Sebastien Perron as far as coding in c++ goes.
fortran codes tend to be very stiff. even small changes need good amount of code touching. on the other hand, c++ allows for clean and neat incremental development. the only difficulty you will face is to learn c++. this can be quite a task as the language is pretty complex. but once you are in it, you won't feel like getting out of it ;) one way to go at your fortran codes quickly is to translate them to c (using f2c, say) and encapsulate them in c++ code. you can return at your leisure and code them incrementally in c++. 
Re: C++, Fortran and Matlab
where do I get this f2c. i have an old f77 CFD code and it'd be nice to have it in C, since I know C and not f77

Re: C++, Fortran and Matlab
Matlab is a great environment for code development because: 1)almost every function you could want is already there including doing stuff like taking derivatives etc. 2)F90 style array masking and other vectorised operations not only is your code compact but it's faster 3)for code prototyping there is automatic dynamic allocation. you don't have to allocate arrays you can just add to them as needed. this is poor programming in general but is usefull when writing small blocks of code to check things out 4)Matlab code is totally and completely portable. 5)quick and easy postprocessing even for unstructured meshes as I only just recently discovered. 6)you can compile matlab code to make it run fast. 7)as Steve said you can incorporate MEX files to take advantage of existing fortran and C code. this is a good way to do multilanguage programming although I'vve never done this myself. i've had to develop code that had C++ and fortran subroutines and let me tell you it's not easy. 8)you can be come a very competent Matlab programmer in a short time particularly if you remember to avoid loops and ifs
also I'd say that the combination of Matlab and C++ will do you pretty good. the inability to use dynamic allocation in F77 often leads to codes that use too much memory or that need frequent compiling when parameters have to be changed. as a result this encourages code with too many separate subroutines to avoid long compiles with modification while I prefer to goup my subroutines into larger code files. 
Re: C++, Fortran and Matlab
This is the address for the main web site: www.netlib.org
(I don't know why this site seems to be down tonight, first time it happens) You can also try for linux ftp://ftp.freesoftware.com/pub/linux.../lang/fortran/ For other OS try to look in ftp://ftp.freesoftware.com/pub 
Re: C++, Fortran and Matlab
I notice a number of people suggest C++ is very good. I agree, however, I often wonder whether the extra levels of abstraction in going to Object Orientated style, vs structured methods in plain C results in slower code. Does anybody know??
I suspect C++ will be slower but is this really the case? If so and if speed is important, perhaps using straight C is a good compromise between speed and flexibility. Greg 
Re: C++, Fortran and Matlab
(1). There are books available on the efficiency of C++ programming. (2). For example, the use of the class and object requires the construction and the destruction (initialization and cleanup) of the objects, it takes time to perform such operations each time you need to create an object(s). (3). The speed in cfd is really not an issue, if you know how to obtain the converged solution accurately. (4). If you are just looking for cfd solutions, then most of the time, you are getting the wrong answers. So, most people like to have faster codes to obtain the wrong solution as soon as possible. In other words, most of the time, we are doing the parameter study and looking for the possible optimum solution. (5). I would say that the best place to check the trend of the language is in the computer games programming. The trend has been from assembly language, to c, to C++. Even the computer graphics programming is being taught in C++. So, the speed alone is relative. In Internet, a lot of people are still using VB, Java, which are rather slow when compared with Fortran, c or C++.

All times are GMT 4. The time now is 22:31. 