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

Home » Public Forums » archive » Is there a work around to save multiple variables with same head but different tails without listing all of them?
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
Is there a work around to save multiple variables with same head but different tails without listing all of them? [message #77891] Thu, 29 September 2011 02:10
voidspace is currently offline  voidspace
Messages: 4
Registered: September 2011
Junior Member
Hello folks,

I have a question at beginner's level. When I saved multiple variables
with same head but different tails in IDL, I found it is tedious to
type all of them in as follows.

SAVE, sst_cccma_cgcm3_1, sst_cnrm_cm3, sst_csiro_mk3_0,
sst_gfdl_cm2_0, sst_gfdl_cm2_1, $
sst_iap_fgoals1_0_g, sst_inmcm3_0, sst_ipsl_cm4,
sst_miroc3_2_medres, sst_mpi_echam5, $
sst_mri_cgcm2_3_2a, sst_ncar_ccsm3_0, sst_ncar_pcm1,
sst_ukmo_hadcm3, sst_ukmo_hadgem1, $
FILENAME='sst_cmip3_20c3m.sav'

The '/All' keyword may help, but there are more variables that I don't
want to save in. This aroused my curiosity, so I post my question here
to know whether there is a workaround.

In fact, I tried to find an advanced way by myself, but found it's
difficult to know without an expert's guidance.

An attempt with my best knowledge is as follows. As all model names
from 'cccma_cgcm3_1' to 'ukmo_hadgem1' are saved in a string array
'model', I considered the 'EXECUTE' command.

One prior step I did was saving 15 variable names in one single string
array 'sst'.

IDL> sst=STRARR(N_elements(model))
IDL> FOR i=0, N_elements(model)-1 DO sst[i]='sst_'+model[i]

Now, 'sst' contains 15 different variable names that I want to save
in. Then, tried the following

IDL> result=EXECUTE("SAVE, FILENAME='sst_cmip3_20c3m.sav', "+sst[i] )

but in stuck because I have no idea how to make an implicit loop for
'sst[i]'.

My attempt seems not a right way. I also thought it would be
convenient if there is implicit do-loop like (sst(i),i=1,15) in
Fortran, but I immediately got that it's nothing but a stupid idea.

I thought over and googled as well but all were in vain.

Can anybody suggest me a nice way to simplify the tedious command
aforementioned?

Best,
John
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: compile and execute from the command line
Next Topic: Using PS_START to create A4 Landscape postscript?

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

Current Time: Wed Oct 08 15:06:12 PDT 2025

Total time taken to generate the page: 0.00488 seconds