Question

I was looking at some code in the tinker molecular dynamics package from ponder lab: http://dasher.wustl.edu/tinker/.

And I saw this statement in one of the files alchemy.f:

    program alchemy
     ...
     ...
     some statements here and there
     ...
     ...
     integer ixyz
     integer freeunit
     ...

then later on there is this puzzling statement

    ixyz = freeunit ()

   ...

Since both variables are scallars of the type integer I'm not sure what the parenthesis means.

Thanks,

Was it helpful?

Solution

The statement

integer freeunit

may, especially in old code, not declare a scalar integer variable but a function that returns an integer. Typically then the function would be defined in another compilation unit and its declaration in the program provides enough for the linker to do its work.

If this is the case then

ixyz = freeunit ()

would be construed as a call to that function with no arguments.

Scour your source files for a line containing

integer function freeunit 

Note that I'm making educated guesses here, I never follow links away from the safety of SO. I'll go further and hazard a guess that the function freeunit returns an i/o unit number which is not already in use.

OTHER TIPS

A more complete answer has already been provided by the other user. In your question, the parenthesis means a function. Specifically of integer type. An external function declares the type and name of the function, as well as listing the arguments.

 type FUNCTION fname(arg11, arg2, …, argn)

The data type of the function type designates the data type of the value returned by the external function. If it is omitted, then the data type returned is determined by the first letter of the symbolic name fname.

In your code, freeunit () is an integer function that returns a value that is an integer. And integer ixyz means a variable has been declared of the type integer.

The statement

    ixyz=freeunit ()

means that the integer value returned by freeunit () is assigned to ixyz.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top