Wednesday, August 24, 2005

Fortran, C# and a very large Stack requirement

I was recently evaluating the Silverfrost Fortran 95 compiler compiler for .NET. This appears to be a capable implementation of a fortran compiler for the .NET platform. One of my main test piece of code was a smallish fortran routine (approx 360 lines) that calculated a geodetic height. The fortran functions were provided with an input latitude and longitude and calculated the geodetic height above the earths surface.

Not much of real interest there, apart from the fact that the front end was written in C# and the back end which was all fortran was compiled into a DLL which was referenced from the front end project. However, to perform the calculation, the fortran function had to open and read coefficient data into memory from a file containing 65338 records and each record contained 2 integers and 4 doubles.

Thats 2*4 + 4*8 bytes per record = 40 Bytes per record.
65338 records * 40 bytes = 2, 613, 520 bytes or 2552Kb or 2.5Mb

Both projects (client and backend) compiled ok, as expected. The Client was run and some data was entered. Once the C# code called the Fortran backend, an unhandled exception was immediately raised of type "System.StackoverflowException"

The help text for System.StackoverflowException states that it is typically thrown in the case of very deep or unbounded recursion. However I had no recursion, so it must have been due to the amount of data that the fortran backend was allocating to store these large coefficient arrays.

A bit of research on the net did not really help very much, so a bit more searching around MSDN found a tool named EDITBIN. This tool (The Microsoft COFF Binary file Editor) allows you to modify certain characteristics of COFF binary files, including executables and DLL's.

It has an associated tool named DUMPBIN to obtain information about COFF files.

After examination of my .NET generated fortran backend DLL, the size of stack reserve was shown to be 100000.This number is in hex and is therefore 1048576 bytes or 1024Kb.

I ran the editbin command on my 2 files in my assembly

editbin/stack:3000000 GEOIDBackEnd.DLL
editbin/stack:3000000 GEOIDFrontEnd.EXE

So I have now increased my default stacksize on my 2 executables and am able to run my magnificent fortran coefficient mathematical engine.

To automate this process if you are debugging, you can create a .BAT file containing the above lines and reference that from within the Visual Studio .NET project Options/Build Events/Post Build Step field.

10 Comments:

At 4:38 AM, Blogger Andrew said...

Thanks for your blog.

In VS2005, the batch file you create does not automatically get the PATH that includes the editbin program, or its required libraries. So this is what I wrote for the batch file to make it work:

@echo off
call %1vcvarsall.bat
editbin /stack:3000000 %2

Then in the post-build event I used this command line (all one line):
"$(ProjectDir)bigstack.bat" "$(DevEnvDir)..\..\VC\" "$(TargetPath)"

 
At 7:27 PM, Anonymous Anonymous said...

Thank you!
[url=http://oirgivyd.com/biqq/crso.html]My homepage[/url] | [url=http://pxquljis.com/ytbt/rvst.html]Cool site[/url]

 
At 7:27 PM, Anonymous Anonymous said...

Nice site!
My homepage | Please visit

 
At 7:27 PM, Anonymous Anonymous said...

Well done!
http://oirgivyd.com/biqq/crso.html | http://gbglrvpn.com/fenm/ghhc.html

 
At 8:23 PM, Anonymous Anonymous said...

Hi there!
I didn’t want to waste any more time teasing her either, though. Instead, when I went down for what she thought would be another tantalising lick, I ran my lips as well as my tongue over her pussy, stretching the muscles in my jaw to try and encompass as much of her as I could. With my mouth clamped over her private parts like a suction cup, I settled down and began to eat. I tried just about everything I could think of; I stuck my tongue as far up her vaginal passage as I could, I took the loose skin on her clitoral hood into my mouth and sucked it out over and over again, I delved so deep and hard that my nose was pushed into her passage. I inhaled again - always inhale, I told myself flippantly.

I don’t know how much of what I did was me trying to imitate something I’d seen in porn, but it seemed to work. Holly settled down into a pattern of soft, subdued moans which made me tingle inside, punctuated by an occasional sharper cry when I switched to something different. She held my head firmly in place, running her fingers through my hair, and that sensation was doing good things to me as well.
I love sex :)
Young lolita it is a best !!!
__________________
http://www.xxx-01.com - New Teen Tgp Site! Visit it and have fun! Enjoy it!
http://www.xxx-01.com/index1.html - Free XXX photo and video
I am not kidding) xxx-01.com - is super hot )

 
At 3:19 PM, Anonymous Anonymous said...

ACNE MEDICINE ONLINE
accutame
WHAT IS ANTHELMINTICS
BUY online Albenza cheapest
ANTIBACTERIAL MEDICINE & CARE
buy low-cost amoxil
AMPICILLIN ONLINE
buy cheap ampicillin
BUY CHEAP BACTRIM
BUY CHEAP BACTRIM ONLINE
NEW DRUGS & PILLS… SUPER-VIAGRA…
HALF-PRICE CIALIS
BUY CIPRO ONLINE
BUY CIPRO ONLINE
BUY CHEAP DIFLUCAN ONLINE
Low-COST DIFLUCAN ONLINE

 
At 1:53 AM, Anonymous Anonymous said...

LOW-COST CIALIS
CIALIS - THE BEST TREATMENT IMPOTENCE
WOMAN VIAGRA
ORDER VIAGRA ONLINE AND SAVE MORE THEN 60% of your MONEY...!!!

 
At 5:45 PM, Anonymous Anonymous said...

HALF-PRICE VIAGRA ! CHEAP LEVITRA
PURCHASE CHEAP CIALIS ONLINE & GET SPECIAL GIFT....
WOMAN VIAGRA
BUY CHEAP VIAGRA.LOW-COST CIALIS.HALF-PRICE LEVITRA ONLINE
HALF-PRICE VIAGRA ! CHEAP LEVITRA

BUY LOW-PRICES CIALIS LEVITRA VIAGRA ANTIDEPRESSANTs...!!!
WHAT IS VIAGRA
DISCOUNT CHEAP VIAGRA.DYSFUNCTION ERECTILE NEW MEDS
ACNE MEDICINE ONLINE
buy accutane online
WHAT IS ANTHELMINTICS
order Albenza
ANTIBACTERIAL MEDICINE & CARE
buy amoxil low-cost
AMPICILLIN ONLINE
amicillin
BUY CHEAP BACTRIM
bactrim no prescription
NEW DRUGS & PILLS… SUPER-VIAGRA…
HALF-PRICE CIALIS
BUY CIPRO ONLINE
cipro side effects
BUY CHEAP DIFLUCAN ONLINE
ONLINE DIFLUCAN ONLINE
BUY CHEAP SUPER VIAGRA ONLINE AND SAVE 70 % OF MONEY...
FIND CHEAP CIALIS ONLINE HALF-PRICE PHARMACY
CREDIT CARDS.AMERICAN EXPRESS MASTER CARD

 
At 2:00 AM, Blogger Santiago Padilla said...

I have a site acne creams
is new and I'd like recive any kind of comments, is related to acne creams
match with your so any help is welcome. Thanks

 
At 11:57 AM, Anonymous Anonymous said...

Hi, glom me on lisachu

http://drumbeatinsight.com/forums/profile.php?mode=viewprofile&u=71821 www.heroescorner.de/hcboard/profile.php?mode=viewprofile&u=6888

 

Post a Comment

<< Home