Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > How to get numb...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 5477 of 6249
Post > Topic >>

How to get numbers into passed structure elements (pass-by-value/reference

by Paul van Delst <Paul.vanDelst@[EMAIL PROTECTED] > Feb 27, 2008 at 10:02 AM

Hello,

This subject comes around every now and again, but I can't find anything
useful searching.

I'm calling a function, CRTM_Read_Atmosphere_Record(), like so:


   Atm = PTRARR(n_Profiles)
   FOR m = 0, n_Profiles-1 DO BEGIN
     Atm[m] = PTR_NEW({CRTM_Atmosphere})
     result = CRTM_Read_Atmosphere_Record( FileID, *Atm[m], DEBUG=Debug )
     ...check result....
   ENDFOR


That function in turns calls another function, CRTM_Read_Cloud_Record(),
like so:


FUNCTION CRTM_Read_Atmosphere_Record, FileID     , $  ; Input
                                       Atm        , $  ; Output
                                       DEBUG=Debug     ; Optional input
   .....
   FOR n = 0, Atm.n_Clouds-1 DO BEGIN
     result = CRTM_Read_Cloud_Record( FileID, (*Atm.Cloud)[n], DEBUG=Debug
)
     ...check result....
   ENDFOR


And inside the CRTM_Read_Cloud_Record() function I do the following:


FUNCTION CRTM_Read_Cloud_Record, FileID           , $  ; Input
                                  Cloud            , $  ; Output
                                  DEBUG=Debug           ; Optional input
   .....
   Type = Cloud.Type
   READU, FileID, Type, $
                  *Cloud.Effective_Radius, $
                  *Cloud.Effective_Variance, $
                  *Cloud.Water_Content
   Cloud.Type = Type

(and similar for an Aerosol structure and I/O function. Also, assume the
pointer component 
allocation has been done to the correct array size))

As you have probably guessed, by the time I inspect all the data that is
returned in the 
original Atm pointer array, everything is fine *except* the cloud type
flag. It is zero.

So, I realise this is one of those pass-by-reference or pass-by-value
things, but how does 
one get around it? Do I:
   a) make the Type component of the Cloud structure a pointer? (Yuk!)
   b) change the way I pass the Cloud structure into the
CRTM_Read_Cloud_Record() fn?
      i.e. not reference the cloud structure array via the index [n].

I would much prefer (b), but will that entail copying entire structures?
The number of 
"Clouds" associated with any particular "Atm[m]" profile is variable.

Thanks for any info.

cheers,

paulv


p.s. FWIW, the structure definitions are:

PRO CRTM_Atmosphere__Define
   void = { CRTM_Atmosphere, $
            n_Layers       : 0L, $
            n_Absorbers    : 0L, $
            n_Clouds       : 0L, $
            n_Aerosols     : 0L, $
            Climatology    : 0L, $
            Absorber_ID    : PTR_NEW(), $
            Absorber_Units : PTR_NEW(), $
            Level_Pressure : PTR_NEW(), $
            Pressure       : PTR_NEW(), $
            Temperature    : PTR_NEW(), $
            Absorber       : PTR_NEW(), $
            Cloud          : PTR_NEW(), $
            Aerosol        : PTR_NEW()  }
END

and

PRO CRTM_Cloud__Define
   void = { CRTM_Cloud, $
            n_Layers           : 0L, $
            Type               : 0L, $
            Effective_Radius   : PTR_NEW(), $
            Effective_Variance : PTR_NEW(), $
            Water_Content      : PTR_NEW()  }
END
 




 10 Posts in Topic:
How to get numbers into passed structure elements (pass-by-value
Paul van Delst <Paul.v  2008-02-27 10:02:46 
Re: How to get numbers into passed structure elements (pass-by-v
David Fanning <news@[E  2008-02-27 08:25:42 
Re: How to get numbers into passed structure elements (pass-by-v
Paul van Delst <Paul.v  2008-02-27 10:56:22 
Re: How to get numbers into passed structure elements
lecacheux.alain@[EMAIL PR  2008-02-28 02:23:58 
Re: How to get numbers into passed structure elements (pass-by-v
Wox <nomail@[EMAIL PRO  2008-02-28 11:22:34 
Re: How to get numbers into passed structure elements (pass-by-v
Paul van Delst <Paul.v  2008-02-28 10:00:36 
Re: How to get numbers into passed structure elements (pass-by-v
David Fanning <news@[E  2008-02-28 08:07:01 
Re: How to get numbers into passed structure elements (pass-by-v
David Fanning <news@[E  2008-02-28 08:11:08 
Re: How to get numbers into passed structure elements (pass-by-v
Paul van Delst <Paul.v  2008-02-28 10:20:25 
Re: How to get numbers into passed structure elements (pass-by-v
Paul van Delst <Paul.v  2008-02-28 10:19:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 14:47:37 CDT 2008.