[gradsusr] A Faulty IF Loop
Jeff Duda
jeffduda319 at gmail.com
Tue Jun 16 17:14:29 EDT 2015
You need to be very explicit with your translation of human statements into
code. You might say, "if the lag is 1, 5, 9, or 13 I want to do one thing,
and do something different if otherwise." But to convert that to code you
need to explicitly spell out EACH logical expression:
if lag is 1
if lag is 5
if lag is 9
if lag is 13
Thus, your if statement should read:
*if (lag = 1 | lag = 5 | lag = 9 | lag = 13)*
Jeff
On Tue, Jun 16, 2015 at 4:06 PM, Noska, Ryne <rgn14c at my.fsu.edu> 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
>
>
--
Jeff Duda
Graduate research assistant
University of Oklahoma School of Meteorology
Center for Analysis and Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150616/441cee54/attachment-0001.html
More information about the gradsusr
mailing list