[gradsusr] writing some defined variables in ASCII file

hachelaf rabah r.hachelaf at gmail.com
Thu Mar 10 06:35:09 EST 2011


Hello Muhamed,
your script help me , but it doesn't work fine
i have this warning when i run it :
ga-> test.gs
Data Request Error:  File number out of range
  Variable = tdif0.00353409
  Error ocurred at column 1
DISPLAY error:  Invalid expression
  Expression = tdif0.00353409
Data Request Error:  File number out of range
  Variable = sumxtdif1.84828
  Error ocurred at column 1
DISPLAY error:  Invalid expression
  Expression = sumxtdif1.84828
Data Request Error:  File number out of range
  Variable = sumttdif663.954
  Error ocurred at column 1
DISPLAY error:  Invalid expression
  Expression = sumttdif663.954
Data Request Error:  File number out of range
  Variable = eqmtr8500.173326
..............................
However i need to write just some variables from all screened by taping " q
define "
so i don't know who to filtered just desired variables.


2011/3/10 Muhammad Rahiz <muhammad.rahiz at ouce.ox.ac.uk>

> Dear Rabah,
>
> EQMVR850,EQMVR500 (& others) are objects which you've defined earlier in
> your original calculation. If you want to add the defined variables
> automatically, you can use the 'q define' and 'sublin' command.
>
> **********
> 'set gxout print'
>
> n1 = 5 # assuming you have 5 defined variables/objects
> n2 = 1
> while (n2 <=n1)
>
> 'q define'
> var = sublin(result,n2)
> 'd 'var''
>
> ret = result
> res = write("output.txt",ret,append)
> res = close("output.txt)
>
> n2 = n2 + 1
> endwhile
> **********
>
> What the code does is to create a while loop and select each of the defined
> variables in 'sublin(result,n2)' where n2 = 1,2,3,4,5 and print it to
> output.txt. The following illustrates what 'q define' and 'sublin' does;
>
> 'q define'
>
> EQMVR850 = 1.58
> EQMVR500 = 1.89
> EQMVR700 = 1.98
>
> sublin(result,1) # EQMVR850 = 1.58
> sublin(result,2) # EQMVR500 = 1.89
> sublin(result,3) # EQMVR700 = 1.98
>
>
>
> --
> Muhammad Rahiz
> Researcher & DPhil Candidate (Climate Systems & Policy)
> School of Geography & the Environment
> University of Oxford
>
> On Wed, 9 Mar 2011, hachelaf rabah wrote:
>
>  Dear Muhamaad,
>> Thank you for help , your suggestion works correctely
>> could you tell me who can i add the name of parameter to write it, with
>> the
>> value like that :
>> exemple :
>> EQMVR850 = 1.58
>> EQMVR500 = 1.89
>> EQMVR700 =1.98
>> .......
>> .........
>>
>> 2011/3/9 Muhammad Rahiz <muhammad.rahiz at ouce.ox.ac.uk>
>>      Dear Rabah,
>>
>>      Could you try the following?
>>
>>      ...
>>      ...
>>
>>      'set gxout print'
>>      'd eqmVr850'
>>      ret = result
>>      res = write("output.txt",ret,append)
>>      res = close("output.txt)
>>
>>
>>      --
>>      Muhammad Rahiz
>>      Researcher & DPhil Candidate (Climate Systems & Policy)
>>      School of Geography & the Environment
>>      University of Oxford
>>
>>
>> On Wed, 9 Mar 2011, hachelaf rabah wrote:
>>
>>      Hello all GRADS users,
>>
>>      My problem is that i can not find a solution to write some
>>      defined parameters like result of
>>      summing some parameters.
>>      or others statistical operations between variables.
>>      i have this part of my script :
>>      ......................................
>>      'define VV1=mag(UGRDprs.1,VGRDprs.1)'
>>      'define VV2=mag(UGRDprs.2,VGRDprs.2)'
>>      'define VV3=mag(UGRDprs.3,VGRDprs.3)'
>>      'define VVdif=(VV2-VV1)*(VV2-VV1)'
>>      'define sumxVVdif=sum(VVdif,x=1,x=139)'
>>      'define sumtVVdif=sum(sumxVVdif,y=1,y=159)'
>>      'define eqmVr850=sqrt(sumtVVdif/22101)'
>>      'd eqmVr850'
>>      'define VVdif3=(VV3-VV1)*(VV3-VV1)'
>>      'define sumxVVdif3=sum(VVdif3,x=1,x=139)'
>>      'define sumtVVdif3=sum(sumxVVdif3,y=1,y=159)'
>>      'define eqmVs850=sqrt(sumtVVdif3/22101)'
>>      'd eqmVs850'........
>>      ..........................................
>>      so i need to write the result of eqmVr850 and eqmVs850
>>      ....and other variables like that in a ASCII
>>      file.
>>      i tried that with the fprintf.gs script but it each
>>      time,just the last value is wrote because this
>>      script erase preceding values wrote in the ASCII file.
>>
>>      Thank you advance for any suggestions.
>>
>>
>>
>>      --
>>      Cordialement,
>>      Best regards,
>>      Rabah Hachelaf
>>
>>           ______
>>          (          )
>>         (            )
>>        (________)
>>           /////////
>>
>>
>>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>>
>>
>> --
>> Cordialement,
>> Best regards,
>> Rabah Hachelaf
>>
>>      ______
>>     (          )
>>    (            )
>>   (________)
>>      /////////
>>
>>
>>
>>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Cordialement,
Best regards,
Rabah Hachelaf

     ______
    (          )
   (            )
  (________)
     /////////
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110310/365be4e1/attachment-0003.html 


More information about the gradsusr mailing list