Silverfrost Forums

Welcome to our forums

compiling ok but function undefined

21 Jun 2011 3:51 #8444

Hello,

I'm not sure if that's something regarding Plato or FTN95, I think it's the first case so I'm writing here, but please correct me in case I'm wrong!

I created a project that involves a main fortran file and a series of other .f files that contain functions used in the main program. I have no problems in compiling and linking the files (at least it returns no errors). But when I launch the resulting .exe file, when the program encounters the first call function, the run stops with the 'Error 112: reference to undefined variable, array element or function result (/UNDEF)'.

Does someone have an idea of the reason, or what should I check? I'm still a newbie for FTN95/Plato so think also at stupid explanations 😃

Thanks

21 Jun 2011 9:53 #8446

The error report means what is says. You have used a variable before it has been given a value.

If you run the exe using the debugger then it will fail at the first offending line of your program and you will be able to see the variable that has been used before being given a value.

Standard Fortran does not automatically initialise unset values to zero. See also the /ZEROISE option on the FTN95 command line.

1 Jul 2011 9:27 #8493

Hmmm.

Yes and no.

The variables may be declared in the sense that they have been declared in the start of the program, e.g. ponzi is declared in this program start.

PROGRAM FRAUD


INTEGER i, j, counter, . . . REAL acoeff, bcoeff, ccoeff, ponzi . . . .


Yet we could still have the error that you have found. The trouble arises if we have an assignment statement below this where we need to use the value of ponzi before we've actually given it a value. This can happen as a result of an error in a branching statement that causes the program to enter a part of the code which expects us to have already a value within the variable, ponzi.

So, to find the cause of your problem, you need to place print*, <var> statements along the program from the top down and run it.

I''m assuming you've taken a hardcopy listing and work from that rather than off the PC screen . . . 😃

Please login to reply.