Re: Assignment Type Mismatch

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 10 2013 - 14:33:02 MDT

[1]

NCL is a 'strongly typed language'

You declared

cc = 0 ; integer

later, you do

cc=cc+tarea(j,i) ; tarea is 'float' , should be error

later,

cc=cc/1.e4 ; this is where your error occurred
              ; because the 'cc/1.e4' is float and the lhs 'cc'
              ; is integer

integer = float is not allowed in a 'strongly' typed language.

Easy solution:

cc = 0.0 ; float

===
[2] Given that there was no error in 'cc=cc+tarea(j,i)'
     I speculate that this was never executed.

On 6/10/13 11:31 AM, Taylor Hughlett 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/csm/shea_util.ncl"
>
> ;****************************************************************
> begin
> ;**************************
> ; open file and read in monthly data
> ;**************************
>
> path = "/glade/scratch/hughlett/csm/b30yd.013_1fwDVT/ocn/tavg/"
> f = addfile(path+"b30yd.013_1fwDVT.pop.h.1790.nc","r")
> tarea = f->TAREA
> ht = f->HT
> tlat = f->TLAT
> tlon = f->TLONG
>
> printVarSummary(ht)
> printVarSummary(tarea)
>
> popmask=new((/384,320/),integer)
>
> ;define a mask for the north Atlantic basin which is the area between
> ;50N-70N and 14E-80W
> popmask=0
> do i=0,99
> do j=0,115
> if (ht(j,i).gt.0).and.(tlat(j,i).ge.50.).and.(tlat(j,i).le.70.) then
> if (tlon(j,i).le.14).or.(tlon(j,i).ge.280) then
> popmask(j,i)=0
> end if
> end if
> end do
> end do
>
> ; array for the 1 SV fresh water flux
> ; compute area of ocean for fresh water flux
> icc=116*100
> freshflux=new(icc,double)
> cc=0
> do i=0,99
> do j=0,115
> if (popmask(j,i).eq.5) then
> cc=cc+tarea(j,i)
> end if
> end do
> end do
>
> print(tarea)
>
> ; area in cm^2 units- convert to m^2
> cc=cc/1.e4
>
> ; fresh water flux value for 1 Sv
> fresh=1.0e6*1.e3/cc ;m/s --> kg/m^2/s
>
> print(cc)
> print(fresh)
>
> mask0=tarea
> mask1=mask(mask0,(ht.gt.0.),True)
> mask2=mask(mask1,(tlat.ge.50.),True)
> mask3=mask(mask2,(tlat.le.70.),True)
> mask4=mask(mask3,(tlon.le.14.),True)
> mask5=mask(mask3,(tlon.ge.280.),True)
>
> printVarSummary(mask4)
> printVarSummary(mask5)
>
> wks=gsn_open_wks("ps","ccsm_pop_na_mask1")
> res = True
> res@cnFillOn = True ; turn on color
> res@gsnSpreadColors = True ; use full color map
> res@cnLinesOn = False ; no contour lines
> res@cnLineLabelsOn = False ; no line labels
> cmap = "temp_19lev"
> gsn_define_colormap(wks,cmap)
> plot=gsn_csm_contour(wks,tlat,res)
> plot=gsn_csm_contour(wks,tlon,res)
> plot=gsn_csm_contour(wks,mask1,res)
> plot=gsn_csm_contour(wks,mask5,res)
> plot=gsn_csm_contour(wks,popmask,res)
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 10 14:32:50 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT