RESTORE-like function using H5 [message #93970] |
Fri, 09 December 2016 15:47  |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
I made save- and restore-like functions using H5 instead of the xdr format. To resolve input variable names in saveh5, I used SCOPE_VARNAMES and that works fine. On the other hand, my restoreh5 is a function returning a structure. Just for curiosity, what is the trick with the native RESTORE procedure? How does it make the loaded variables available in memory after the execution? It behaves like a batch file that takes some input (filename, keywords) or as a procedure with a silent STOP before the END.
|
|
|
|
Re: RESTORE-like function using H5 [message #93972 is a reply to message #93970] |
Fri, 09 December 2016 20:30   |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 12/9/16 4:47 PM, Nikola Vitas wrote:
> I made save- and restore-like functions using H5 instead of the xdr
> format. To resolve input variable names in saveh5, I used
> SCOPE_VARNAMES and that works fine. On the other hand, my restoreh5
> is a function returning a structure. Just for curiosity, what is the
> trick with the native RESTORE procedure? How does it make the loaded
> variables available in memory after the execution? It behaves like a
> batch file that takes some input (filename, keywords) or as a
> procedure with a silent STOP before the END.
>
You can use SCOPE_VARFETCH on the restore side to insert a variable into
a particular variable name in a particular scope. You can do something
like the following on the command line:
IDL> (scope_varfetch('data', /enter, level=1)) = findgen(10)
IDL> help, data
DATA FLOAT = Array[10]
You'll just have to set LEVEL correctly, check out the docs.
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
|
|
|
Re: RESTORE-like function using H5 [message #93973 is a reply to message #93972] |
Sat, 10 December 2016 01:21   |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
On Saturday, December 10, 2016 at 4:31:04 AM UTC, Michael Galloy wrote:
> On 12/9/16 4:47 PM, Nikola Vitas wrote:
>> I made save- and restore-like functions using H5 instead of the xdr
>> format. To resolve input variable names in saveh5, I used
>> SCOPE_VARNAMES and that works fine. On the other hand, my restoreh5
>> is a function returning a structure. Just for curiosity, what is the
>> trick with the native RESTORE procedure? How does it make the loaded
>> variables available in memory after the execution? It behaves like a
>> batch file that takes some input (filename, keywords) or as a
>> procedure with a silent STOP before the END.
>>
>
> You can use SCOPE_VARFETCH on the restore side to insert a variable into
> a particular variable name in a particular scope. You can do something
> like the following on the command line:
>
> IDL> (scope_varfetch('data', /enter, level=1)) = findgen(10)
> IDL> help, data
> DATA FLOAT = Array[10]
>
> You'll just have to set LEVEL correctly, check out the docs.
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Many thanks for the reply, Michael. It's the first time I'm using any of the scope functions. They seem to be my new favorites of IDL.
|
|
|
|
|
Re: RESTORE-like function using H5 [message #93978 is a reply to message #93976] |
Mon, 12 December 2016 07:37  |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
On Sunday, December 11, 2016 at 6:42:00 PM UTC, Michael Galloy wrote:
> A word of warning: these routines are useful for some things (like
> command line use or "Import to commandline" functionality), but overuse
> can make code difficult to deal with.
>
Thanks for the warning, Michael! I'll keep it in mind.
> Such functions can be useful for other people. Do you plan to make them publicly available?
Sergey, if I make them reliable enough, I will certainly make them public. But don't expect anything fancy. The only motivation is to combine easy-to-use of save/restore in IDL with a file format that I can easily read from MPI/Fortran.
|
|
|