Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

Function sees variables incorrectly.


Hi everybody,

My function sees variables that I give to it incorrectly. This is the
part of the main program:
spectr(2,i) = lin_interp(line_shape_new(1,:), line_shape_new(2,:),
freq)

here I call the function lin_interp. The first two arguments are
arrays containing several hundred elements. However, if I print this
arrays form the function I can see that one element of the first array
is wrong and one element of the second array (with another index) is
also wrong. All other elements are OK.

Do anybody can some ideas why it can happens?

What is the declaration of the function lin_interp? I expect you're using the
wrong arguments.

Kurda Yon <kurda@yahoo.com> wrote:
> My function sees variables that I give to it incorrectly. This is the
> part of the main program:
> spectr(2,i) = lin_interp(line_shape_new(1,:), line_shape_new(2,:),
> freq)

> here I call the function lin_interp. The first two arguments are
> arrays containing several hundred elements. However, if I print this
> arrays form the function I can see that one element of the first array
> is wrong and one element of the second array (with another index) is
> also wrong. All other elements are OK.

> Do anybody can some ideas why it can happens?

Many possibilities - too many to enumerate. Showing an isolated line of
code isn't enough to be useful. Odds are that the problem is in
something that you haven't shown or given much in the way of hints
about.

My first guess would be that the array got corrupted, possibly by
exceeding bounds somewhere, before you even call the function. But there
are other possibilities as well.

To get more constructive help, you'll need to show a *LOT* more of the
code than just an isoletaed line like that. Odds are low that the line
you showed actually has much to do with the problem.

--
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain

A likely error when you are passing array sections is that you
must have an explicit interface in the calling program.  The
easiest way to do that is to put lin_interp in a module and then USE
that module in the calling routine.

Dick Hendrickson

Dick Hendrickson <dick.hendrick@att.net> wrote:
> A likely error when you are passing array sections is that you
> must have an explicit interface in the calling program.

No, that's not directly a requirement for passing an array section. It
is a requirement for some things that are likely to go along with
passing array sections. For example, it is reasonably plausible that if
you are passing array sections as actual arguments, then the dummy
arguments might be assumed shape (in fact, that is likely to be a good
idea), which does trigger the requirement.

I'm a big fan of having explicit interfaces even where they aren't
required. And it is possible that something unshown in the OP's code
does trigger such a requirement. But I felt it necessary to correct the
claim that you "must" have an explicit interface in order to pass an
array section.

--
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc