Re: Having problem with tangent calculation

From: <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 05 2012 - 11:56:29 MDT

This is a common issue that has been mentioned numerous times on ncl-talk.

Speculation: variable is type double.
  lat = in->lat
  printVarSummary(lat)

Speculation: variable 'tans' is type float.
  printVarSummary(tans)

NCL does not allow a double to be placed into a variable of float.
That is exactly what the error message is telling you.

The right hand side is double, the left hand side is float.
If it was reversed, NCL would not complain

Perhaps above, you have defined

    tans = new ( nlat, "float") change that to "double"

---
Actually, you need not decalre a 'new' variable
    lat  = in->lat
    tans = tan(lat)  ; automatically create an array named tans
Also, please look at the units of 'lat'.
If they are (say) 'degrees_north' then the above
will not give the correct answer!!! *All* the trigonometric
functions require *radians* as noted in the documentation.
> Hi,
>
> I am trying to calculate term like tan(phi) where phi is the latitude.
> But when I am using the function "tan" it is giving me this error
> message.
>
> fatal:Assignment type mismatch, right hand side can't be coerced to
> type of left hand side
>
> I tried reading the lat from the model file and pass it to the function
> as an array.
>
>    lat  = in->lat
>
>    do k = 0,nlat-1
>
>    tans(k) = tan (lat(k))
>
>    end do
>
> Can anybody please suggest what did I need to do make it work.
>
> Thanks,
> Soumik
>
> --
> "Numbing the pain for a while will make it worse when you finally feel
> it.
>   ~J.K. Rowling"
> *****************************************
> Soumik Basu
> Graduate Student, Research Assistant
> International Arctic Research Center
> University of Alaska Fairbanks
> Fairbanks,Alaska,USA
> *****************************************
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 5 11:56:39 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT