[Thread Prev][Thread Next][Index]

Re: [ferret_users] how to do embedded expression inside an embedded expression with grave accent



I'm not sure I understand your question exactly, but I think a defined symbol has highest priority. Ferret will simply drop that symbol into any command. And note that symbols can be embedded (see example).

If you only have 7 of these then the symbols can be defined manually:

def sym root "/home/xbai1/Tracmip/family1/"
def sym f1 "whatever_your_first_filename_is.nc"
def sym f2 "whatever_your_second_filename_is.nc"
...
def sym f7 "whatever_your_last_filename_is.nc"

repeat/range=1:7:1/name=fnum (let dummy=`fnum`; def sym sfnum `dummy`; use "($root)($f($sfnum))"; ... )

I'm not sure why, but this kind of syntax inside a repeat loop requires defining a new dummy variable to use for symbol definition.

Billy
 

> On Oct 10, 2018, at 9:36 AM, Xiaoyu Bai <xbai1@xxxxxxxx> wrote:
> 
> repeat/range=1:7/name=aa (use file_name_`aa`.nc) is a good idea. I have a handicap that I use let files_CNRM=spawn("ls -1 /home/xbai1/Tracmip/family1/*CNRM*.nc") to identify my files before I read them in. Ferret doesn't let me to use syntax `spawn("ls -1 /home/xbai1/Tracmip/family1/*CNRM*.nc")` because grave accent has the highest priority. 😹 
> 
> Thanks a lot. 
> Xiaoyu
> 
> On Wed, Oct 10, 2018 at 11:52 AM Satyesh Ghetiya <satyeshghetiya@xxxxxxxxx> wrote:
> Hi,
> 
> 
> On Wed, Oct 10, 2018 at 9:05 PM Xiaoyu Bai <xbai1@xxxxxxxx> wrote:
> Hi Ghetiya,
> 
> Yes, I wan to read all the files in through the repeat loop. When you say nested loop, do you mean let datset=0; repeat/range=1:8 (let datset=`datset+1`; use `files_CNRM[X=datset]`)? It didn't work.
> 
> ^ Yes, you are correct, I also encountered similar problem, it seems ferret is not taking nested definition of variable.
> The error message is like **ERROR: command syntax: DATSET // SET DAT/FORM=CDF `files_CNRM[X=datset]`. I feel datset needs a pair of grave accent to make it as an variable. However, ferret considers the nearest two grave accents as a pair. 
> I might need to read my files in one by one instead of using repeat loop.
> 
> ^ But once I used syntax like this which worked: repeat/range=1:7/name=aa (use file_name_`aa`.nc;) 
> Anyway if not, then yes for now, you may have to use one by one.
> Thank you very much and have a nice day. 
> 
> Welcome. 
> 
> On Wed, Oct 10, 2018 at 12:53 AM Satyesh Ghetiya <satyeshghetiya@xxxxxxxxx> wrote:s
> Hi,
> I also faced similar problem, but every time I am by passing using two grave accent by using some other repeat loop (nested) or by using some other variable.
> Are you wanting to use, in loop, 7 data sets ?  
> 
> On Wed, Oct 10, 2018 at 1:53 AM Xiaoyu Bai <xbai1@xxxxxxxx> wrote:
> Dear ferreters,
> 
> I have a syntax that's like repeat/range=1:7/name=datset use `files_CNRM[x=`datset`]`. However, ferret reads it like  `files_CNRM[x=` and `]`. So I am wondering how to make this syntax work.
> 
> Thank you very much.
> -- 
> Xiaoyu
> 
> 
> -- 
> G Satyesh
> 
> 
> 
> -- 
> Xiaoyu
> 
> 
> -- 
> G Satyesh
> 
> 
> 
> -- 
> Xiaoyu




[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement