[1] Why are you using 'stringtochar' if your input is a string ???
function chkvName3D(vName:string)
begin
if ( (vName .eq. "MEANTAU") .or. \
:
:
end
--- [2] Whatever you did foo = tf = chkvName3D(foo) NCL is telling you the the variable (argument) 'foo' could not be converted to type string. What is 'foo' ? --- [3] Another way to determine the rank is ... f = addfile(....) vName = "..." rank = dimsizes( getfilevardimsizes(f,vName) ) http://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevardimsizes.shtml --- If you are new to NCL, please read the Mini-Language manual at: http://www.ncl.ucar.edu/Document/Manuals/ On 4/24/13 6:27 AM, Marston Johnston wrote: > Hi, > > I'm trying to compare some strings in a function: > > function chkvName3D(vName:string) > > > > begin > > nme = stringtochar(vName) > > if ( (nme(0:8) .eq. "MEANTAU") .or. \ > > (nme(0:6) .eq. "CLDLOW") .or. \ > > (nme(0:6) .eq. "CLDMED") .or. \ > > (nme(0:6) .eq. "CLDTOT") .or. \ > > (nme(0:3) .eq. "Z3") .or. \ > > (nme(0:5) .eq. "PREC") .or. \ > > (nme(0:3) .eq. "FSN") .or. \ > > (nme(0:3) .eq. "FLN") .or. \ > > (nme(0:2) .eq. "PS") .or. \ > > (nme(0:3) .eq. "SOL") ) > > print(nme+" is a 3D variable!") > > return(True) > > else > > return(False) > > end if > > end > > if the vName = "CLDICE" then I get the error: > > warning:Argument 0 of the current function or procedure was coerced to the > appropriate type and thus will not change if the function or procedure > modifies its value > fatal:Subscript out of range, error in subscript #0 > fatal:An error occurred reading nme > > I'm struggling to understand why this keeps failing? > > What is a good way to compare all of a string or only part of the string? > > Thanks, > /M > > > > > _______________________________________________ > 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-talkReceived on Wed Apr 24 07:17:32 2013
This archive was generated by hypermail 2.1.8 : Fri Apr 26 2013 - 17:10:25 MDT