Re: using the value of a passed by reference variable (g77)



laurel wrote:

Hello all,

I have what I believe is a fairly simple problem, but I have not been
able to find a solution on the boards or elsewhere.

I have a simplified program that has two variables (var1 and var2) that
have been passed in by reference from IDL. I am working on a 64-bit sun
machine with g77 as my compiler. var1 goes on to bigger and better
things in another program, and that part works just fine. However, I
would like to print the value of var2 and use it in my simple code. My
code looks something like this:

*********************************
subroutine simple(argc,argv)
implicit none
integer*4 argc
real*8 argv(2),var1,var2

call another_subroutine(%val(argv(1)))
print*,argv(2)

IF (var2 lt. 55) THEN
*do something*
END IF

end
*********************************

Let's say that var2 had a value of 32 in IDL when it was passed into
'simple'. When I use the above command to print it in fortran I get a
value of something like 2.12288063E-314. If I use print*,var2 I get
another strange number like -2.14749086E+09 that is also not 32. I am
assuming that these numbers are a numerical representation of the
reference place of var2, but I just want to be able to get plain old 32
and do stuff with it.

If this is a common question on the board, could you please point me to
the relevant thread(s). If not, then suggestions and examples of how to
do this would be most welcome.

Thank you so much for your time,
Laurel

In your code snippet var1 and var2 are both declared as real(8), but neither is given a value. If this is really what your code looks like then you are printing out uninitialized variables, and it isn't surprising that you see those strange values. What are you really trying to do?


Gib
.



Relevant Pages

  • Re: refedit controls and Excel 2003 sp3
    ... The 2007 date and the 12.xxxx version are strange, ... Removing the reference doesn't cause any problems? ... Peltier Technical Services, Inc. - http://PeltierTech.com ... I had the problem when the SP3 was first installed, but removing the ...
    (microsoft.public.excel.programming)
  • Re: The Enigma has been unravled
    ... There's a similarly strange thing that happened with ... parameters passed by reference. ... "iterator adaptors", before folding them into my library. ... to wrap the default RasterIterator within a simple iterator adaptor. ...
    (comp.ai.philosophy)
  • Re: Black music, teen pop/dance ruining American taste
    ... "Cite" refers to a source or a reference to corroborate what's been ... strange way of apologizing. ... Waltz as 'vulger' and 'sinful'? ...
    (rec.arts.tv)
  • Re: Great, now I get the joke, but I lost it
    ... character standing in front of a bland background and singing, o/` Ed Sul-li-van o/` ... ... which I took to be one of those many strange things that just happens. ... And now I've got no idea which episode it was had the reference. ... at the beginning of "Santa Claus Conquers the Martians" ...
    (rec.arts.tv.mst3k.misc)
  • using the value of a passed by reference variable (g77)
    ... have been passed in by reference from IDL. ... var1 goes on to bigger and better ... would like to print the value of var2 and use it in my simple code. ... Let's say that var2 had a value of 32 in IDL when it was passed into ...
    (comp.lang.fortran)