comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: change values of structure variable
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: change values of structure variable [message #81930] Thu, 08 November 2012 22:06
sid is currently offline  sid
Messages: 50
Registered: January 1995
Member
On Friday, November 9, 2012 10:07:23 AM UTC+5:30, wlandsman wrote:
> There is no common block in the program read2datmos.pro as you wrote it below. The COMMON statement must be in every program that uses its variables or it will not "work".
>
>
>
>> FUNCTION read2datmos, fileName, BFILE=Bfile
>
>>
>
>> Nx = 0L & Nz = 0L & NHydr = 0L
>
>>
>
>>
>
>>
>
>> openr, unit, fileName, /GET_LUN, /XDR
>
>>
>
>>
>
>>
>
>> readu, unit, Nx, Nz, NHydr
>
>>
>
>> point_lun, unit, 0
>
>>
>
>>
>
>>
>
>> atmos = {Nx: Nx, Nz: Nz, NHydr: NHydr, $
>
>>
>
>> boundary: lonarr(3), dx: dblarr(Nx), z: dblarr(Nz), $
>
>>
>
>> T: dblarr(Nx, Nz), n_elec: dblarr(Nx, Nz), $
>
>>
>
>> vturb: dblarr(Nx, Nz), vx: dblarr(Nx, Nz), $
>
>>
>
>> vz: dblarr(Nx, Nz), $
>
>>
>
>> nH: dblarr(Nx, Nz, NHydr)}
>
>>
>
>>
>
>>
>
>> test1 (I have called the program here).
>
>>
>
>>
>
>>
>
>> But still it is not working.
>
>>
>
>>
>
>>
>
>> Will please let me know if there is any mistake.
>
>>
>
>> thanking you
>
>>
>
>> sid

Sir,
Two functions are using the common block. One is read2datmos.pro and another is readatmos.pro
So in this readatmos.pro
There is a statement like "@atom.common" and this atom.common is the common block as I mentioned earlier.
But I need to use the test1.pro(I have mentioned earlier) in order to change the values of atmos.vturb(where atmos is common block variable).
But I dont know where to use this test1.pro in order to make it work.
thanking you
Sid
Re: change values of structure variable [message #81931 is a reply to message #81930] Thu, 08 November 2012 20:37 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
There is no common block in the program read2datmos.pro as you wrote it below. The COMMON statement must be in every program that uses its variables or it will not "work".

> FUNCTION read2datmos, fileName, BFILE=Bfile
>
> Nx = 0L & Nz = 0L & NHydr = 0L
>
>
>
> openr, unit, fileName, /GET_LUN, /XDR
>
>
>
> readu, unit, Nx, Nz, NHydr
>
> point_lun, unit, 0
>
>
>
> atmos = {Nx: Nx, Nz: Nz, NHydr: NHydr, $
>
> boundary: lonarr(3), dx: dblarr(Nx), z: dblarr(Nz), $
>
> T: dblarr(Nx, Nz), n_elec: dblarr(Nx, Nz), $
>
> vturb: dblarr(Nx, Nz), vx: dblarr(Nx, Nz), $
>
> vz: dblarr(Nx, Nz), $
>
> nH: dblarr(Nx, Nz, NHydr)}
>
>
>
> test1 (I have called the program here).
>
>
>
> But still it is not working.
>
>
>
> Will please let me know if there is any mistake.
>
> thanking you
>
> sid
Re: change values of structure variable [message #81932 is a reply to message #81931] Thu, 08 November 2012 19:56 Go to previous message
gunvicsin11 is currently offline  gunvicsin11
Messages: 93
Registered: November 2012
Member
On Thursday, November 8, 2012 8:00:08 PM UTC+5:30, wlandsman wrote:
> I don't see a common block in your read2datatmos.pro program. --Wayne
>
>
>
> On Wednesday, November 7, 2012 11:58:28 PM UTC-5, sid wrote:
>
>> On Tuesday, November 6, 2012 11:53:57 PM UTC+5:30, wlandsman wrote:
>
>>
>
>>> On Tuesday, November 6, 2012 10:23:40 AM UTC-5, David Fanning wrote:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>> You can't change anything about a structure once you create
>
>>
>
>>>
>
>>
>
>>>> it in the IDL session.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> You can't change dimensions or data types, but you should be able to change structure tag values. So I don't know why the code is not working for the OP (we don't see his common block). But the following works
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> pro test1
>
>>
>
>>>
>
>>
>
>>> common var,a
>
>>
>
>>>
>
>>
>
>>> a.b(*,*) = 2500
>
>>
>
>>>
>
>>
>
>>> return
>
>>
>
>>>
>
>>
>
>>> end
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> pro test
>
>>
>
>>>
>
>>
>
>>> common var,a
>
>>
>
>>>
>
>>
>
>>> a = {b:dblarr(3,5)}
>
>>
>
>>>
>
>>
>
>>> test1
>
>>
>
>>>
>
>>
>
>>> print,a.b
>
>>
>
>>>
>
>>
>
>>> return
>
>>
>
>>>
>
>>
>
>>> end
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> IDL> test
>
>>
>
>>>
>
>>
>
>>> 2500.0000 2500.0000 2500.0000
>
>>
>
>>>
>
>>
>
>>> 2500.0000 2500.0000 2500.0000
>
>>
>
>>>
>
>>
>
>>> 2500.0000 2500.0000 2500.0000
>
>>
>
>>>
>
>>
>
>>> 2500.0000 2500.0000 2500.0000
>
>>
>
>>>
>
>>
>
>>> 2500.0000 2500.0000 2500.0000
>
>>
>
>>
>
>>
>
>> Hi sir,
>
>>
>
>> I tried this method but still it is not working,
>
>>
>
>> His common block is,
>
>>
>
>> atom.common(common block)-COMMON atmosCommon, atmos, H, metals, molecules, nHmin
>
>>
>
>>
>
>>
>
>> I have written a program as you said like this,
>
>>
>
>> pro test1
>
>>
>
>> common atmosCommon,atmos
>
>>
>
>> atmos.vturb(*,*)=2500.0000
>
>>
>
>> return
>
>>
>
>> end
>
>>
>
>>
>
>>
>
>> I have called this in the function(read2datmos.pro),
>
>>
>
>>
>
>>
>
>> FUNCTION read2datmos, fileName, BFILE=Bfile
>
>>
>
>> Nx = 0L & Nz = 0L & NHydr = 0L
>
>>
>
>>
>
>>
>
>> openr, unit, fileName, /GET_LUN, /XDR
>
>>
>
>>
>
>>
>
>> readu, unit, Nx, Nz, NHydr
>
>>
>
>> point_lun, unit, 0
>
>>
>
>>
>
>>
>
>> atmos = {Nx: Nx, Nz: Nz, NHydr: NHydr, $
>
>>
>
>> boundary: lonarr(3), dx: dblarr(Nx), z: dblarr(Nz), $
>
>>
>
>> T: dblarr(Nx, Nz), n_elec: dblarr(Nx, Nz), $
>
>>
>
>> vturb: dblarr(Nx, Nz), vx: dblarr(Nx, Nz), $
>
>>
>
>> vz: dblarr(Nx, Nz), $
>
>>
>
>> nH: dblarr(Nx, Nz, NHydr)}
>
>>
>
>>
>
>>
>
>> test1 (I have called the program here).
>
>>
>
>>
>
>>
>
>> But still it is not working.
>
>>
>
>>
>
>>
>
>> Will please let me know if there is any mistake.
>
>>
>
>> thanking you
>
>>
>
>> sid

Sir,
atom.common is the common block program
and this is the content of the common block,
"COMMON atmosCommon, atmos, H, metals, molecules, nHmin"
read2datmos.pro is the function which uses common block variable.
thanking you
Sid
Re: change values of structure variable [message #81935 is a reply to message #81932] Thu, 08 November 2012 06:30 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I don't see a common block in your read2datatmos.pro program. --Wayne

On Wednesday, November 7, 2012 11:58:28 PM UTC-5, sid wrote:
> On Tuesday, November 6, 2012 11:53:57 PM UTC+5:30, wlandsman wrote:
>
>> On Tuesday, November 6, 2012 10:23:40 AM UTC-5, David Fanning wrote:
>
>>
>
>>
>
>>
>
>>> You can't change anything about a structure once you create
>
>>
>
>>> it in the IDL session.
>
>>
>
>>
>
>>
>
>> You can't change dimensions or data types, but you should be able to change structure tag values. So I don't know why the code is not working for the OP (we don't see his common block). But the following works
>
>>
>
>>
>
>>
>
>> pro test1
>
>>
>
>> common var,a
>
>>
>
>> a.b(*,*) = 2500
>
>>
>
>> return
>
>>
>
>> end
>
>>
>
>>
>
>>
>
>> pro test
>
>>
>
>> common var,a
>
>>
>
>> a = {b:dblarr(3,5)}
>
>>
>
>> test1
>
>>
>
>> print,a.b
>
>>
>
>> return
>
>>
>
>> end
>
>>
>
>>
>
>>
>
>> IDL> test
>
>>
>
>> 2500.0000 2500.0000 2500.0000
>
>>
>
>> 2500.0000 2500.0000 2500.0000
>
>>
>
>> 2500.0000 2500.0000 2500.0000
>
>>
>
>> 2500.0000 2500.0000 2500.0000
>
>>
>
>> 2500.0000 2500.0000 2500.0000
>
>
>
> Hi sir,
>
> I tried this method but still it is not working,
>
> His common block is,
>
> atom.common(common block)-COMMON atmosCommon, atmos, H, metals, molecules, nHmin
>
>
>
> I have written a program as you said like this,
>
> pro test1
>
> common atmosCommon,atmos
>
> atmos.vturb(*,*)=2500.0000
>
> return
>
> end
>
>
>
> I have called this in the function(read2datmos.pro),
>
>
>
> FUNCTION read2datmos, fileName, BFILE=Bfile
>
> Nx = 0L & Nz = 0L & NHydr = 0L
>
>
>
> openr, unit, fileName, /GET_LUN, /XDR
>
>
>
> readu, unit, Nx, Nz, NHydr
>
> point_lun, unit, 0
>
>
>
> atmos = {Nx: Nx, Nz: Nz, NHydr: NHydr, $
>
> boundary: lonarr(3), dx: dblarr(Nx), z: dblarr(Nz), $
>
> T: dblarr(Nx, Nz), n_elec: dblarr(Nx, Nz), $
>
> vturb: dblarr(Nx, Nz), vx: dblarr(Nx, Nz), $
>
> vz: dblarr(Nx, Nz), $
>
> nH: dblarr(Nx, Nz, NHydr)}
>
>
>
> test1 (I have called the program here).
>
>
>
> But still it is not working.
>
>
>
> Will please let me know if there is any mistake.
>
> thanking you
>
> sid
Re: change values of structure variable [message #81941 is a reply to message #81935] Wed, 07 November 2012 20:58 Go to previous message
gunvicsin11 is currently offline  gunvicsin11
Messages: 93
Registered: November 2012
Member
On Tuesday, November 6, 2012 11:53:57 PM UTC+5:30, wlandsman wrote:
> On Tuesday, November 6, 2012 10:23:40 AM UTC-5, David Fanning wrote:
>
>
>
>> You can't change anything about a structure once you create
>
>> it in the IDL session.
>
>
>
> You can't change dimensions or data types, but you should be able to change structure tag values. So I don't know why the code is not working for the OP (we don't see his common block). But the following works
>
>
>
> pro test1
>
> common var,a
>
> a.b(*,*) = 2500
>
> return
>
> end
>
>
>
> pro test
>
> common var,a
>
> a = {b:dblarr(3,5)}
>
> test1
>
> print,a.b
>
> return
>
> end
>
>
>
> IDL> test
>
> 2500.0000 2500.0000 2500.0000
>
> 2500.0000 2500.0000 2500.0000
>
> 2500.0000 2500.0000 2500.0000
>
> 2500.0000 2500.0000 2500.0000
>
> 2500.0000 2500.0000 2500.0000

Hi sir,
I tried this method but still it is not working,
His common block is,
atom.common(common block)-COMMON atmosCommon, atmos, H, metals, molecules, nHmin

I have written a program as you said like this,
pro test1
common atmosCommon,atmos
atmos.vturb(*,*)=2500.0000
return
end

I have called this in the function(read2datmos.pro),

FUNCTION read2datmos, fileName, BFILE=Bfile
Nx = 0L & Nz = 0L & NHydr = 0L

openr, unit, fileName, /GET_LUN, /XDR

readu, unit, Nx, Nz, NHydr
point_lun, unit, 0

atmos = {Nx: Nx, Nz: Nz, NHydr: NHydr, $
boundary: lonarr(3), dx: dblarr(Nx), z: dblarr(Nz), $
T: dblarr(Nx, Nz), n_elec: dblarr(Nx, Nz), $
vturb: dblarr(Nx, Nz), vx: dblarr(Nx, Nz), $
vz: dblarr(Nx, Nz), $
nH: dblarr(Nx, Nz, NHydr)}

test1 (I have called the program here).

But still it is not working.

Will please let me know if there is any mistake.
thanking you
sid
Re: change values of structure variable [message #81953 is a reply to message #81941] Tue, 06 November 2012 10:23 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Tuesday, November 6, 2012 10:23:40 AM UTC-5, David Fanning wrote:

> You can't change anything about a structure once you create
> it in the IDL session.

You can't change dimensions or data types, but you should be able to change structure tag values. So I don't know why the code is not working for the OP (we don't see his common block). But the following works

pro test1
common var,a
a.b(*,*) = 2500
return
end

pro test
common var,a
a = {b:dblarr(3,5)}
test1
print,a.b
return
end

IDL> test
2500.0000 2500.0000 2500.0000
2500.0000 2500.0000 2500.0000
2500.0000 2500.0000 2500.0000
2500.0000 2500.0000 2500.0000
2500.0000 2500.0000 2500.0000
Re: change values of structure variable [message #81955 is a reply to message #81953] Tue, 06 November 2012 07:23 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
sid writes:

> Please help in changing values stored in structure variable.
> What I tried is,
>
> IDL> help,/str,atmos
> ** Structure <911e87c>, 11 tags, length=22780, data length=22780, refs=1:
> NHYDR LONG 6
> NELEM LONG 99
> MOVING LONG 0
> T DOUBLE Array[3, 82]
> N_ELEC DOUBLE Array[3, 82]
> VTURB DOUBLE Array[3, 82]
> NH DOUBLE Array[3, 82, 6]
> ID STRING 'FALC_03x82.atmos (Tue Nov 6 10:32:22 2012'...
> ELEMENTS STRUCT -> <Anonymous> Array[99]
> BACKGRFLAGS STRUCT -> <Anonymous> Array[284]
> BACKGRRECNO LONG Array[284]
>
> Here I want to change the values of VTURB to 2500.0000
> SO I did,
> IDL> atmos.vturb(*,*)=2500.0000
> now temporarily it changes to 2500.0000, This is in a common block. So while running the main program the vturb value goes back to the original value instead of the changed 2500.0000.
>
> Please help me in changing the value.

You can't change anything about a structure once you create
it in the IDL session. If you have a field that is changing,
as this one is, you should make that field a pointer to the
value you want to store there.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: attractive base map for animation
Next Topic: Re: Save some plots

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:42:55 PDT 2025

Total time taken to generate the page: 0.00769 seconds