[gradsusr] A Faulty IF Loop

James T. Potemra jimp at hawaii.edu
Tue Jun 16 17:12:54 EDT 2015


Hi Ryne,

I think you need the "lag =" in each conditional, e.g.,

if ( lag = 1 | lag = 5 | lag = 9 | lag = 13 )

Jim

On 6/16/15 11:06 AM, Noska, Ryne wrote:
> I have written a very simple code for the purpose of creating one 
> image with sixteen figures (four rows and four columns). 
> Unfortunately, the loop I have designed to change the location of the 
> next figure is broken. Instead of only executing the "if" statement if 
> lag = 1 or 5 or 9 or 13, this portion of the loop is ALWAYS executed. 
> The "else" statement is NEVER executed, causing the figures to run off 
> the page after figure 4 since only ymin and ymax change. Below is a 
> portion of my code; again, the problematic portion is the IF loop:
>
> ---------------------------------------
>
> xmin = 0.25
> xmax = 2.50
> ymin = 6.25 + 2.00
> ymax = 8.00 + 2.00
>
> lag = 1
> while (lag <= 16)
>   numlag = lag - 1
>
> * if (lag = 1 | 5 | 9 | 13)*
> *    xmin = 0.25*
> *    xmax = 2.50*
> *    ymin = ymin - 2.00*
> *    ymax = ymax - 2.00*
> *  else *
> *    xmin = xmin + 2.50*
> *    xmax = xmax + 2.50*
> *  endif*
>
>   xlab = ((xmax - xmin)/2) + 0.25
>   ylab = ymax + 0.125
>
>   'set parea 'xmin' 'xmax' 'ymin' 'ymax
>   'set xlopts 1 1 0.10'
>   'set ylopts 1 1 0.10'
>   'set xlint 10'
>   'set ylint 10'
>   'set xlab off'
>   'set ylab off'
>   'set grid on'
>   'set grads off'
>   'set map 1 1 5'
>   'set clevs -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0.1 0.2 0.3'
>   'set ccols 9   14   4    11   5   13    3    10   0   7  12  8'
>   'set t 'lag
>   'd corr_grdons'
>   'set strsiz 0.15'
>   'set string 1 c 8'
>   'draw string 'xlab' 'ylab' lag='numlag'days'
>
>   lag = lag + 1
> endwhile
>
> -------------------------------
>
> Any suggestions?
>
> Thank you,
> Ryne
>
>>
>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150616/cdc3fabd/attachment.html 


More information about the gradsusr mailing list