Here is a question a student sent about the final:


Great question, Anna!  

  We did an example of something like this in the lecture, but I'm not sure that anything about this showed up in the powerpoint presentations that you are studying from.   Remember, NCL has the idea that you can work with whole arrays at one time -- you don't have to work with them "element by element" like you do in C.  

For example, if you had an array of temperatures in K called tempK (the array has NUMROWS rows and NUMCOLS columns), to convert this to Celsius in C we would have to do something like this:   for(i=0;i<NUMROWS;i++) {      

for(j=0;j<NUMCOLS;j++) {
          tempC[i][j] = tempK[i][j] - 273.15;
     }
}   

And, of course, various variables like i and j would have to be defined correctly as integers, tempC and tempK would have to be defined correctly as arrays of floating point numbers (with the right number of rows and columns)... In total, this is a lot of work and sort of error-prone.   

In NCL, you would just do something like this:   

tempC = tempK - 273.15   

NCL would understand here (given that tempK is already an array of floating point numbers with a number of rows and columns) that tempC will also need to be an array with the same number of rows and columns, so NCL will go ahead and declare tempC for you -- preventing a source of error.  NCL will then look at this statement and see that you are subtracting a single floating point number (273.15) from the array -- the only legitimate thing that can mean is that you are subtracting that number from each element of the array, so it will go ahead and do all of that for you, again saving you programming time and preventing possible errors.   Pretty slick, right?   Jon  
From: Weber, Anna E.
Sent: Mon 5/2/2011 7:48 PM
To: Schrage, Jon M.
Subject: RE: final review


Hi Dr. Schrage,

I am wondering how you convert temperature from Kelvin to Celsius in NCL. I couldn't find anything on it in the powerpoint and I looked on the NCL website a bit and couldn't come up with anything.

Anna


-----Original Message-----
From: Schrage, Jon M.
Sent: Sun 5/1/2011 1:18 PM
To: Cato, Mallory K.
Cc: Reynolds, Rhonda S.; Sedlacek, William T.; Dusselier, Hallie E.; Austerberry, Michael J.; Weber, Anna E.; MacCarron, Jacob R.; Huddleston, Lucas M.; Happe, Nathan E.; Wright, Nathan F.

Subject: RE: final review
 
Here is the review sheet for the ATS 315 final, for those of you who either misplaced it or never got it at class on Friday.


Jon Schrage
 

________________________________

From: Cato, Mallory K.
Sent: Sat 4/30/2011 8:25 PM
To: Schrage, Jon M.
Subject: final review




Dr. Schrage,

I seem to have misplaced my review sheet for the final exam. If you could please email me a copy of it so that I may start studying, that would be great!

Thanks,

Mallory


 


Comments




Leave a Reply