Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

huge integer number

Mike896
Beginner
412 Views

Hi

Following subroutine is adapted from Numerical Recipe.

SUBROUTINE LOCATE(XX,N,X,J)
DIMENSION XX(N)
JL=0
JU=N+1
10 IF(JU-JL.GT.1)THEN
JM=(JU+JL)/2
IF((XX(N).GT.XX(1)).EQV.(X.GT.XX(JM)))THEN
JL=JM
ELSE
JU=JM
ENDIF
GO TO 10
ENDIF
J=JL
RETURN
END

In fact, I create a static library to collect all of the subroutines/functions in Numerrical Recipe.

then I call this subroutine. When I run it and debug it,

SUBROUTINE LOCATE(XX,N,X,J)

here ^N=4, as debugger shows
DIMENSION XX(N)
JL=0
JU=N+1 <== here JU=0
Why?

......

J=JL <== J= huge integer number

I don't have this problem when I use CVF.

thanks a million.

Mike

0 Kudos
4 Replies
Steve_Nuchia
New Contributor I
412 Views
Nowhere near enough information, but I'm pretty sure there is a difference in compiler settings between the library build and the client code build. Like maybe default integer size?
If the compiler options are not identical, you are taking your chances.

0 Kudos
Mike896
Beginner
412 Views
Nowhere near enough information, but I'm pretty sure there is a difference in compiler settings between the library build and the client code build. Like maybe default integer size?
If the compiler options are not identical, you are taking your chances.

What does "default integer size" mean? Do you mean J, JU are not declared, so maybe have some unexpected values?

I have one LibAC.lib, whose Project->Property settings are:

Fortran->Command Line

/nologo /Zi /Od /gen-interfaces /warn:interfaces /module:"Debug" /object:"Debug" /traceback /check:bounds /libs:static /threads /dbglibs /c

Librarian->command line shows:

/OUT:"Debug/LibAC.lib" /NOLOGO

====================================

Numerical Recipe library (recipef.lib):

Fortran->Command Line

/nologo /Zi /Od /include:"Debug/" /Qsave /iface:cvf /module:"Debug/" /object:"Debug/" /traceback /check:bounds /libs:static /threads /dbglibs /c

Librarian->command line shows:

/OUT:"Debug/recipef.lib" /NOLOGO

==================================

The client code settings are:

Fortran->Command Line

/nologo /Zi /Od /include:"D:�26SLibACLibACDebug" /gen-interfaces /warn:interfaces /module:"Debug" /object:"Debug" /traceback /check:bounds /libs:static /threads /dbglibs /c

Linker->Command Line

/OUT:"Debugsdue2AE.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"D:�26Ssdue2AEdebugsdue2ae.exe.intermediate.manifest" /DEBUG /PDB:"D:�26Ssdue2AEdebugsdue2ae.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"D:�26Ssdue2AEdebugsdue2ae.lib" D:�26SLibACLibACDebugLibAC.lib D:�26Srecipef.lib

In fact, LibAC.lib callLOCATE (in recipef.lib) and then client code uses LibAC.lib.

Does recipef.lib used by LibAC.lib necessary to be linked in the Settings of LibAC.lib?

What is "/Qsave /iface:cvf"? It seems different from compiler's settings of LibAC.lib and client code.

It seems recipef.lib are converted from CVF's project and I do have an old recipef project.

Mike

0 Kudos
Mike896
Beginner
412 Views
Nowhere near enough information, but I'm pretty sure there is a difference in compiler settings between the library build and the client code build. Like maybe default integer size?
If the compiler options are not identical, you are taking your chances.

Subroutine LOCATE are in fortran 77 fixed format.

The caller code is in free format. Does it matter?

Mike

0 Kudos
Les_Neilson
Valued Contributor II
412 Views

quote "What does "default integer size" mean?"

In VS IDE Project-Properties->Fortran->Data there are three settings
Default Integer KIND, Default Real KIND and Default Double Precision KIND

Theyapply to the project as a whole but are over-ridden by what is in the code. For example if in the code you have
INTEGER K
then it will take the kind of the project default.
But INTEGER(2) K will be a two byte integer always.

Quote "What is /iface:cvf"
This is very important and I suggest you read the manual about "Calling Convention" cvf is the convention used by the Compaq Fortran compiler. From the docs :
"By default, /iface:cvf passes arguments by reference. /iface:cvf sets the /iface:mixed_str_len_arg option. This causes CHARACTER variables to be passed as address/length pairs."

It is important to be consistent especially in mixed language programs.

Quote " What is /Qsave?"
From the docs :
"This option saves all variables in static allocation (ie not on the run time stack)except local variables within a recursive routine and variables declared as AUTOMATIC."
Italics mine.

Les

0 Kudos
Reply