-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine_structs.pro
46 lines (41 loc) · 1.11 KB
/
combine_structs.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
pro combine_structs,str1,str2,strsum,structyp=structyp
;+
; NAME:
; COMBINE_STRUCTS
;
; PURPOSE:
; takes two arrays of structures str1,str2 which have the
; same number of elements but possibly different tags
; and makes another structure which has the same number of elements
; but the tags of both str1,str2 and has their respective tags
; values copied into it
;
; CALLING SEQUENCE
; combine_structs, struct1, struct2, newstruct, structyp=structyp
;
; INPUTS:
; struct1,struc2: The two structures to be combined. If structure arrays,
; Must contain the same number of structs.
;
; KEYWORD PARAMETERS:
; structyp: a string with the name of the new structure.
; if already defined the program will crash.
;
; Author Dave Johnston UofM
;-
if n_params() LT 2 then begin
print,'-syntax combine_structs,str1,str2,strsum,structyp=structyp'
return
endif
s1=size(str1)
s2=size(str2)
if s1(1) ne s2(1) then begin
print,'structure sizes are different'
return
endif
str=create_struct(name=structyp,str1(0),str2(0))
strsum=replicate(str,s1(1))
copy_struct,str1,strsum
copy_struct,str2,strsum
return
end