Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29281 Discussions

Chaos on the stack using CVF 6.6B ???

muppets
Beginner
793 Views
Hi,

I wrote a program which computes properties of water and steam years ago using f2c under linux. Then I ported this program to Powerstation 1 and later to Powerstation 4. Each time everything worked fine.

Now I want to port to Compaq Visual 6.6 B and I get big problems. After calling a subroutine and a function within this subroutine a dummy parameter of the subroutine is changed without having accessed it.

I downloaded evaluation copy of Intel Fortran 7.1 compiled the program and everything is oK, no strange changing of dummy parameters occurs.

So I'm afraid there is some chaos and I wonder whether it is in CVF stack magament or in my head ;-).

Find attached the sources of this program. If you would find the time and have a look on it. Goto to the file ifc.for and look for the double precision function H2OProp. Inside this function there is a comment beginning with !=> HELP. Place breakpoints as described in the further comment lines.
After having started the prog you will be asked for a parameter p, just type e.g. 13. You will be then asked for a parameter t, just type s without any '. Prog stops at the above mentioned breakpoint. Watch dP. After calling the function sdtemp1, dP is changed, which is totally nonsense.

If you change the Argument Passing Conventions from Default to C, by reference the behauvour is correct. CVF 6.6B acts then like f2c, FPS1, FPS4 and Intel Fortran.

I lost about 12 hours and I didn't get a solution of my problem.


I would be very grateful for any help, hints, comments.

Muppets
0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
793 Views
I meant that you "reply" to yourself with zip file rather than create a new thread, but never mind.

You have in the calling chain:
double precision function thetak(beta,iErr)
...
call mnewt1(ntrial,h,n,tolx,tolf,utk,iErr)     
...
end 
!-------
SUBROUTINE MNEWT1(NTRIAL,X,N,TOLX,TOLF,usrfun,iErr)
external usrfun
CALL USRFUN(X,ALPHA,BETA,iErr)
but prototype of utk was wrong:
subroutine utk(h,a,b,ierr)
              --------^
iErr was missing
The "odd" error has gone when I added it to utk. Since in STDCALL (CVF Default) callee cleans the stack, it removed 12 bytes rather than 16 which were actually pushed by Mnewt1, "smashing the stack"; with C, by reference that wouldn't happen because caller cleans the stack. I didn't check for possible other similar situations.

I think you owe me a drink :-).

Jugoslav
0 Kudos
muppets
Beginner
793 Views
It's the truth: it should be a maxi jumbo drink!

Thank you very much! I'm afraid I would have searched another two years without having success. You see: chaos was in my head.

Thank you agaim

M;uppets
0 Kudos
gfthomas8
Novice
793 Views
Jugoslav, have one on me for the jargon link, :-).

Ciao,
Gerry T.
0 Kudos
Reply