- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Well, it worked, didn't it. Of course it worked, it's perl. Ugly but usefull.
Admin
I once had to translate a geophysics program from Qbasic to Turbo Pascal. The QBasic program was a translation from FORTRAN and was littered with labels that were named after the original numerical labels in FORTRAN.
CAPTCHA: tastey -- no, definitely not.
Admin
The
m=0,D3=1,D4=xxx
part is only run once at the start of that inner loop (and as a result, run once per iteration of the outer loop), so m is always equal to zero, and D3 is always equal to 1.
n is the only thing changing in that assignment.
Admin
Admin
You guys should see the byte code my java compiler generates - total spaghetti, big ball of mud.
Admin
The inside code isn't show, but presumably n is referenced inside the loop. So the translator decided that it was not safe to use in the completion test. That is, that it's value might change, giving a different result than the FORTRAN loop.
As I recall, it used to be common for compilers to not differentiate between left-side references and right-side references, so it wouldn't suprise me that a mere translator might use a simple test.
Admin
I worked at NGDC for 5 years, and during that time did a complete rewrite of that geomagnetic modeling code from FORTRAN to C.
Apparently, my rewrite has either been lost by the bureaucracy, or has just never been put online, because that horrhendous F2C stuff is the same thing that they had online when I started working there in 2002.
Or, I guess, it's possible that the original submitter never found it. NGDC's web presence is a horrhendously disorganized mishmash of ancient dead-end links that have long been forgotten.
By the way, that original FORTRAN code contains some fairly severe bugs that were never found until the code was rewritten. NGDC now employs a talented geophysicist who's responsible for maintaining the codebase (in C) named Stefan Maus. If the original submitter wants the best, debugged, up-to-date stuff I'd recommend talking to him.
Admin
Oh, and one more thing... there's also JNI code for the rewritten library available. The web interface for this code is at http://www.ngdc.noaa.gov/seg/geomag/magfield.shtml and all runs atop those JNI interfaces.
Admin
Some code where I work is alive and well thanks to f2c. It is still in FORTRAN but the gcc FORTRAN compiler was buggy. So to keep it going it was all run through f2c and it works rather well. Yes the code is horrible but nobody cares as it is the FORTRAN that is maintained.
Admin
Yeah, but the problem is, that in FORTRAN the default is all local variables are equivalent to a static variable in C. F2C can't know if you're taking advantage of the staticness or not, so it has to make them static.
Admin
But what if a scientist NEEDS a c function to do this calculation. Say, he has thousands of lines of c code and it would be a real pain to link in a FORTRAN function. It doesn't matter if the c function is pretty, just as long as it's right. I see this all the time. Many scientists program only because the need to, not because they like to, so they don't care about stuff that we care about. They're perfectly happy to copy and paste that ugly c function into their source code and continue on with their work.
Admin
In order to unit test you need a unit to test, you don't need a spare planet, you are testing that your algorithm gives the expected result for an expected input set.
In this case you would write your code to address an interface for the "MagneticFieldMeasurisator" which you mock with a set of expected values and then assert a corresponding set of results.
Surely people involved in maths and physics can grasp the concept of simulation, some of them must be married.
Admin
The real real WTF the National Geophysical Data Center passing off code generated by f2c as C source. f2c is a "hail mary" for people who don't have a real FORTRAN compiler for their platform, not a universal translator.
As such, it only cares if the final compiled binary runs correctly as a unit, not if it's readable, efficient, or if an arbitrary chunk cut/pasted out of it works at all.
Admin
So coooool! I lover pointers. Gimme the link, I will use this code later.
Admin
So coooool! I love pointers. I hate arrays. Gimme the link, I will use this code later.
Btw, please delete my previous post( and please don't create a wtf entries about me)
Admin
Admin
[sarcasm] Ohhhhh, you mean a rehearsal. [/sarcasm] Seriously, mathematicians generally focus on proving that the math is valid, though it is a common practice to run through an example to help one understand how an algorithm works. Scientists in my understanding generally treat serious projects like wedding: Apollos 8 through 10 were rehearsals of Apollos 11-20; they rehearsed the repair of the HST literally hundreds of times in sims before doing it IRL; in fact, it is apparently the norm to work out the same results by several different means in order to rule out systematic error and I am sure it carries over into programming (systematic errors in this case are generally caused by misimplementation of the algorithm) where one would likely check several different results against previous algoritha and implementations of the algorithm and against results obtained by use of the theory directly.