/usr/share/ncarg/nclscripts/utilities.ncl is in libncarg-data 6.1.2-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ;--------------------------------------------------------------------------------
; This function convert input variable x to type specified by type.
; Wei Huang
; May 21, 2012
;--------------------------------------------------------------------------------
undef("totype")
function totype( varin, type:string )
local varout
begin
;printVarSummary(varin)
;print(type)
;Convert to float
if(type .eq. "float") then
varout = tofloat(varin)
return(varout)
end if
;Convert to double
if(type .eq. "double") then
varout = todouble(varin)
return(varout)
end if
;Convert to uint
if(type .eq. "uint") then
varout = touint(varin)
return(varout)
end if
;Convert to integer
if(type .eq. "int" .or. type .eq. "integer") then
varout = toint(varin)
return(varout)
end if
;Convert to char
if(type .eq. "char" .or. type .eq. "character") then
varout = tochar(varin)
return(varout)
end if
;Convert to byte
if(type .eq. "byte") then
varout = tobyte(varin)
return(varout)
end if
;Convert to short
if(type .eq. "short") then
varout = toshort(varin)
return(varout)
end if
;Convert to ushort
if(type .eq. "ushort") then
varout = toushort(varin)
return(varout)
end if
;Convert to long
if(type .eq. "long") then
varout = tolong(varin)
return(varout)
end if
;Convert to ulong
if(type .eq. "ulong") then
varout = toulong(varin)
return(varout)
end if
;Convert to int64
if(type .eq. "int64") then
varout = toint64(varin)
return(varout)
end if
;Convert to uint64
if(type .eq. "uint64") then
varout = touint64(varin)
return(varout)
end if
;Convert to string
if(type .eq. "string") then
varout = tostring(varin)
return(varout)
end if
print("")
print("WARNING:")
print("CANNOT convert input variable type: <" + typeof(varin) + "> to type: <" + type + ">")
print("The original type: <" + typeof(varin) + "> is returned.")
print("")
varout = varin
return(varout)
end
|