Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone recognize "fac"?

Status
Not open for further replies.

alptatum

Electrical
Jun 18, 2003
4
US
Ok, I'm looking through some fortran code and there is a variable "tk2" in it. Then there is a "tk2fac" that is used in an equation computing "tk2". However, "tk2fac" is not being used or initialized anywhere else in the program. I just wanted to know if anyone knows if 'fac' after the tk2 is some sort of fortran syntax. Thanks for any input.
 
Replies continue below

Recommended for you

it is
a.) error
b.) incomplete source code


<nbucska@pcperipherals.com>
 
Sometimes, during calculation, the developer must be looking some factor which might be interested to him/her. Myself is using Fortran more than a decade, and I can assure there is special syntax which can be concatenated to existing variable
and used it in the calculation. May be your variable is redefined as
TK2fac = TK2*xyz/pqr
One quick check you can do is the following:

If TK2fac is in a subroutine, at the end of the subroutine (where it says:
Return
End)

write TK2fac=0.0, and see how the program behaves. I am assuming there is no conditional &quot;Return&quot; in the subroutine.
 
The line of code looks something like this:
tk2 = tk2fac * xyz and it is not in a subroutine. It is in the main program.
 
If this is the only occurence of the &quot;tk2fac&quot; in the main
program and it is not in a common statement, it is an error
and undefined ( Fortran doesn't initiate variables )

<nbucska@pcperipherals.com>
 
Also, in addition as Nbucska suggested, Fortran doesnot initiate variable. You do one thing, check the following:

In COMMON statement
In EQUIVALENCE statement

If it is the Main program, it might be calling any Subroutine before that. Check the Argument list passing through all the LIST. Check all the COMMON statement, and finally do the following:

In the Fortran program, wirte the following statement:
(Exact syntax just copy from here, if old program then put it
leveaing first six column)

write(*,*)' Here is tk2,tk2fac, xyz ', tk2,tk2fac,xyz


Then compile the program, and use the same input file is was designed for. What you will see the value of each tk2, tk2fac, and xyz.

Hope you will find answer

Jbando@ureach.com
 
As already stated, Fortran does not initialize variables. If the code you have has worked in the past and the tk2fac variable was not specifically given a value prior to it's usage.... then the program likely has a bug that no one has noticed.

However... a lot of compilers will initialize variables to 0.0. So... it may have a value of zero when it is first used. Of course.... Is that what was intended??? I certainly wouldn't count on it.

It's now up to you to decide what the program &quot;should&quot; be doing and what is correct.

Have fun,
Dan :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top