DOM interface return number of data elements for array

32 views
Skip to first unread message

bherman

unread,
Jul 18, 2013, 11:52:49 AM7/18/13
to fox-d...@googlegroups.com
Can the DOM interface return the number of data elements it will read into an array beforehand so that it can be allocated appropriately when using extractData? Or, is it just best to read in a separate scalar that states the number of points.

Andrew Walker

unread,
Jul 18, 2013, 1:37:35 PM7/18/13
to fox-d...@googlegroups.com
Hi,

There is nothing in the "extra bits" of the DOM interface for this but you can use the countrts() function from the FoX_common module will work out the array size you will need. I would do something like the following:

allocate( l_array(countrts(getTextContent(p), .true.))
call extractDataContent(p, l_array)

which is assuming you want to read logical data into an allocatable array 'l_array' and the pointer 'p' points the the node you want to get the data out of. Change '.true.' to 0.0d0 if you want double precision real data, etc. 

For what it's worth, extractDataContent and friends are really just wrappers around rts from the common module. Although I could imagine I countExtractDataContent function that wraps countrts in a similar way I'm not sure that it would be very useful. countrts is a pure function so it can be used in specification statements, but getTextContent is not pure (I don't think it can be: it uses pointers) and so you'll always need to pass the result into allocate or similar. 

I hope this helps,

Andrew 
 


On 18 July 2013 16:52, bherman <herm...@gmail.com> wrote:
Can the DOM interface return the number of data elements it will read into an array beforehand so that it can be allocated appropriately when using extractData? Or, is it just best to read in a separate scalar that states the number of points.

--
You received this message because you are subscribed to the Google Groups "FoX-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fox-discuss...@googlegroups.com.
To post to this group, send email to fox-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/fox-discuss.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Andrew Walker
School of Earth Sciences
University of Bristol

bherman

unread,
Jul 20, 2013, 3:06:55 PM7/20/13
to fox-d...@googlegroups.com
Thanks a lot Andrew, that worked for me!

-Bryan
Reply all
Reply to author
Forward
0 new messages