Re: Undefined variable

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sat May 05 2012 - 10:29:52 MDT

The only way that 'nome' is set is when
'ncoluna' is 4 or 5 or 7

You have
    do coluna = 1,3
     if ( coluna .eq. 1) ncoluna = 10 end if
     if ( coluna .eq. 2) ncoluna = 11 end if
     if ( coluna .eq. 3) ncoluna = 13 end if

===
You can debug these types of errors by using 'print'

On 5/5/12 7:58 AM, Guilherme Martins wrote:
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/ut_string.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
>
> lin = 105120
> col = 14
>
> ctrl =
> asciiread("single_point-output-ctrl.txt",(/lin,col/),"float")
> var1 =
> asciiread("single_point-output-vmax60.txt",(/lin,col/),"float")
> var2 =
> asciiread("single_point-output-vmax120.txt",(/lin,col/),"float")
> var3 =
> asciiread("single_point-output-vmax240.txt",(/lin,col/),"float")
>
> do coluna = 1,3
> if ( coluna .eq. 1) ncoluna = 10 end if
> if ( coluna .eq. 2) ncoluna = 11 end if
> if ( coluna .eq. 3) ncoluna = 13 end if
>
> if (ncoluna .eq. 4) then
> titulo = "Net Primary Productivity (NPP)"
> eixoy = "NPP (tonC ha~S~-1~N~)"
> nome = "NPP"
> end if
>
> if (ncoluna .eq. 7) then
> titulo = "Net Ecosystem Exchange (NEE)"
> eixoy = "NEE (tonC ha~S~-1~N~)"
> nome = "NEE"
> end if
>
> if (ncoluna .eq. 5) then
> titulo = "Heterotrofic Respiration (RH)"
> eixoy = "RH (tonC ha~S~-1~N~ )"
> nome = "RH"
> end if
>
> print("Variavel --> " + nome)
>
> nt1=0
> nt2=743
>
> x = ctrl(nt1:nt2,0)
> yctrl = ctrl(nt1:nt2,ncoluna)
> yvar1 = var1(nt1:nt2,ncoluna)
> yvar2 = var2(nt1:nt2,ncoluna)
> yvar3 = var3(nt1:nt2,ncoluna)
>
> data1 = new((/4,dimsizes(x)/),float )
>
> data1(0,:) = yctrl
> data1(1,:) = yvar1
> data1(2,:) = yvar2
> data1(3,:) = yvar3
>
> wks_type = "ps" ; "pdf" "eps" "epsi" "ps" "x11"
> wks_type@wkOrientation = "portrait"
> ; wks_type@wkPaperSize = "A4"
> wks_type@wkPaperWidthF = 10.5 ; in inches
> wks_type@wkPaperHeightF = 14.0 ; in inches
> wks = gsn_open_wks(wks_type,"FIG.")
>
> res = True
> ; res@gsnMaximize = True
> res@tiMainString = titulo
> res@gsnLeftString = ""
> res@gsnCenterString = ""
> res@gsnRightString = ""
> res@tiXAxisString = "Month"
> res@tiYAxisString = eixoy
> res@tmYLMinorOn = True ; desabilita (False) o
> minortick do eixo y
> res@gsnYRefLine = 0.0 ; linha de referência
> no valor zero
> ; res@trYMinF = -0.040 ; valor mínimo do eixo y
> ; res@trYMaxF = 0.060 ; valor máximo do eixo y
> ; res@tmYLMode = "Explicit"
> ; res@tmYLLabels =
> (/"-0.030","-0.020","-0.010","0.0","0.010","0.020","0.030","0.040","0.050","0.060","0.070"/)
> ; res@tmYLValues =
> (/-0.030,-0.020,-0.010,0.0,0.010,0.020,0.030,0.040,0.050,0.060,0.070/)
>
>
> res@pmLegendDisplayMode = "Always" ; liga a legenda
> res@xyExplicitLegendLabels =
> (/"CTRL","VMAX60","VMAX120","VMAX240"/)
> res@xyLineThicknesses = (/4.0,2.0,2.0,2.0/) ; espessura
> das linhas
> res@xyLineColors = (/"black","red","green","purple"/)
> res@xyDashPattern = 0 ; força todas
> as linhas para estilo sólida
> res@xyMarkLineMode = "MarkLines"
> ; res@xyMarkers = (/12,11,16,3/)
> res@xyMarkers = (/1,1,1,1/)
> res@xyMarkerColors =
> (/"black","red","green","purple"/) ; 3 different colors
> res@gsnFrame = False
> ; avança (True) ou nao (False) as figuras
> res@pmLegendParallelPosF = 0.87
> ; desloca legenda em x
> res@pmLegendOrthogonalPosF = -1.17
> ; desloca legenda em y
> res@pmLegendWidthF = 0.3
> ; largura da linha da legenda
> res@pmLegendHeightF = 0.15
> ; altura entre as palavras da legenda
> res@lgBoxMinorExtentF = 0.15
> ; Shorten the legend lines
> res@lgLabelFontHeightF = 0.015
> ; altera o tamanho da fonte da legenda
> res@lgPerimOn = False
> ; True = liga caixa da legenda
> res@lgItemOrder = (/3,2,1,0/)
> ; Reorder the legends
> res@tmXBLabelAngleF = 0.0
> ; rotaciona os valores do eixo x
> res@tmXBLabelConstantSpacingF = 0.90
> ; espaçamento horizontal das palavras do eixo x
> res@tmXBFormat = "f"
> ; remove os pontos decimais do eixo x
> res@tmXBLabelStride = 1
> res@txFontHeightF = 0.01
> ; modifica texto esquerdo, central e direito
> res@tmYROn = True
> ; retira o tickmark da direita da figura
> res@tmXTOn = True
> ; retira o tickmark da esquerda da figura
> res@tmXBLabelFontHeightF = 0.02
> ; tamanho da fonte do eixo y
> ; res@tmXBMode = "Explicit"
>
> ; res@tmXBValues = (/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, \
> ;
> 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, \
> ;
> 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60/)
> ; res@tmXBLabels = (/"Jan~C~2001"," "," "," "," "," "," "," "," "," ",
> " ", " " , \
> ; "Jan~C~2002"," "," "," "," "," "," "," "," "," ",
> " ", " " , \
> ; "Jan~C~2003"," "," "," "," "," "," "," "," "," ",
> " ", " " , \
> ; "Jan~C~2004"," "," "," "," "," "," "," "," "," ",
> " ", " " , \
> ; "Jan~C~2005"," "," "," "," "," "," "," "," "," ",
> " ", " "/)
>
> plot = gsn_csm_xy(wks,x,data1,res)
>
> system("convert -trim FIG."+nome+".ps FIG."+nome+".png ; rm -f
> FIG."+nome+".ps *~ ")
>
> ; delete(wks) ; apaga o pdf
>
> end do
>
> end
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat May 5 10:30:01 2012

This archive was generated by hypermail 2.1.8 : Thu May 10 2012 - 16:57:50 MDT