 All right, in this first section, we're going to take a look at this Rapture toolkit. And to help you understand why, why we're bothering, let me take you on a little trip back through time. The year is 1985, back to the future was just out in the box office. Don Henley was singing The Boys of Summer and the Super Bowl was going on, it was the 49ers versus Miami back in the day. I'm sure you all remember, right? How many of you were born then? All right, hooray. So Tetris was really big, this is what video games look like back in the day, a little bit of a history lesson. And I was working on a program at Purdue at the time, which was called SQL 2.1, semi-conductor electrostatics with quantum analysis, that was my program. And it was written in Fortran, Fortran 77. It was supposed to simulate a resonant tunneling diode, which is actually what it is as a sandwich of material layers, really, really thin nanometer sized material layers. And it turns out if you make a sandwich of different materials like that and apply a bias to it, it does really funny things because there's quantum physics involved. And if you get the quantum physics right, you get some interesting characteristics out of this thing. So here's this program that I had. It was written in Fortran 77, look at all the ASCII art, nicely formatted output. I spent a lot of time doing that. Again, back in the day, that was what we called graphics. And these are the guys in the machine room, not really, but pretty close back in the day. And it turns out if you wanted to get a copy of that program, you could write to my advisor, you could send him a letter along with like a $10 bill and he would send you a magnetic tape, probably bled off by those guys that had the software on it. So when I graduated, that's what happened. They gave me a cap and gown and said congratulations and we set up this agreement that anybody that wanted the software could send in a $10 bill and get a tape. That was back in the day, right? So nowadays the same program is available on Nano Hub and this is what it looks like. Same thing, the only thing that we did was we put a graphical user interface on top of it. So it runs the same engine, the same code. But instead of looking like that, it's like this. And instead of a $10 bill, you just log on to Nano Hub and push the button and it comes up and starts running. And it's pretty easy to use. You just fill in the number fields and then click simulate and boom, you've got a resonant tunneling diode at your fingertips. So it turns out back in the day, nobody ever did this. I graduated thinking that I was going to make a million dollars. I'd be the next Bill Gates because everybody wants my resonant tunneling diode program and all I'd have to do is sell 100,000 copies, right? I'd be rich. But nobody did this because nobody wanted to go through the bother of $10 and the magnetic tape. But on the other hand, this now on Nano Hub has thousands of users. People are using the code because it's free and it's easy and it's available. So that's the point for all of you. You guys can do the same thing. You can take your code or your advisor's code. You can put a graphical interface online, put it out on Nano Hub, and thousands of people will find it and use it. In fact, if you look at the stats, you can see that. Nano Hub does a really great job of tracking stats, statistics like how many people have accessed this, how many questions are out there, how many citations in academic literature. I hardly ever got citations when I was doing this, but now it's actually starting to get some citations. Because it's out there and people find it. So the bottom line, the story, the moral of this story, I guess, is the magnetic tape was $10 and the live simulation tool is priceless. Like the MasterCard commercial. So that's what we're trying to do here. For the next three days, I want to show you guys how to do this, how to take your advisor's stinky Matlab code and make it look fantastically beautiful and live on Nano Hub. Don't tell him I said it was stinky. All right, so here's what it is. The Rapture toolkit takes that code and moves it into a graphical interface, sits in between the two, and basically manages all of the inputs and the outputs to your program. Rapture stands for the Rapid Application Infrastructure. Came out a long time ago in 2005, and we've been sort of working on it a little at a time ever since. It's available as open source on rapture.org. You have to spell it with the two P's, it's kind of an internet thing. So the two P's makes it cool, and it's basically creates standard desktop apps. The best thing about it is that it works with your favorite programming language. So all kinds of languages. You may say, well, I don't like Fortran, I don't know Fortran. Well, that's fine. Maybe you know Java or Ruby or Python or Pearl or any of those, Matlab. So we've even added R and a few others recently. So whatever programming language you like to use, you can take that code and you can put a Rapture interface on it. It'll work pretty much the same way. And so far, we've used it to deploy hundreds of tools on Nanohub and on other hubs. So Nanohub has about 230, 40 tools right now. Almost all of them are written in Rapture. Just because, not because we require it, you don't have to use Rapture to put tools on Nanohub, some people use other things. But it turns out it's a whole lot easier to build the tools in Rapture than it is to roll your own interface with QT or Matlab. A lot less work, so people like it. And it's used for other hubs too. Pharma Hub has about a dozen tools, Neese has a couple of tools. You look at all the different hubs, there's at least a few on a lot of the hubs written in Rapture. So there are really three parts to the Rapture. And we're gonna start today, this morning, with the builder. But let me walk you through all the parts. By the time we get to Thursday, we'll get all the way here to the tester. So you start with the Rapture builder and you can kind of drag and drop controls and fill in information and push a button. And it generates, it saves the information into a file that we call tool.xml. It's an XML description. XML is the extensible markup language, it's like HTML. So it's just an information description of everything you told it when you were dragging and dropping your interface. So we save this description, everything we need to know about your tool is in the tool.xml. Then when you wanna run the tool, Rapture, when you say Rapture or Rapture dash run, it will read the tool.xml that was generated by the builder. And it will generate the interface based on the description. So if you told Rapture I've got a number and I've got a Boolean control and a curve comes out, then the Rapture runtime reads that tool description and renders the graphical interface. And when you push the button to run your tool, it'll write out a run file. The run file will have all the information about the inputs and everything you need to know about that run. And then finally, the last part is a tester. The tester takes the description of your tool and a bunch of test cases that you've written in the past. So you can get your tool working perfectly and you can generate a bunch of test cases and set them aside. And then let's say your advisor comes back and says, I want you to add this. I want you to change that. I want you to fix this bug. So then you go to publish again. You wanna make sure everything's correct. At that point you can run the tester and the regression tester will run through all of the previous test cases you've generated and make sure everything matches up. If there's a problem all of a sudden, if you fixed a bug but actually broke something else in the process, the tester will catch that. It'll tell you something's wrong and then you can go back and take another look and fix it. So those are the three parts to Rapture. The builder, to build your tool. The runner, this is where when the tool's running on Nano Hub, it's mostly running in this area. And then the tester, whenever you go to put out a new version to the tool, you can test it and then deploy it. And these tools aren't once and done. I mean, you may put up a first version of your tool and add some stuff and put up a second version, 1.1, 1.2, 1.5, 1.5.7.1, you can have a lot of fun with numbers. But anyway, you put up a lot of different versions of your tool as you keep adding features. And that's typically a healthy thing to do. But along the way, you wanna test and make sure it's working. All right, so let me show you what the Rapture builder looks like. When you bring this up, which you guys will be doing in just a minute, you get a graphical kind of interface like this. Over here, on the left here, there are a bunch of different control types. So things that you can choose from, curves and boolean values and strings. And what you do is grab one of those and drag them over. Drag them into the input section and it becomes an input. Drag it to the output section, it's an output. So you drag these little objects around and you build up the inputs and the outputs for your tool. Then for each one, you highlight a particular one like this boolean value that's highlighted in the bluish-purple color. And it'll show you all its properties, so you fill in the properties. You change its label, its description, give it a default value. You keep doing that for all the different controls to configure them. And then you can click on that preview tab. And the preview tab will show you what your interface is gonna look like. And you can check it if it doesn't look right and go back. And you can edit some more, look at it again, preview it again. And then finally, there's a save button up at the top. And you click on that and you can save out your tool.xml file. That's it, that's the builder. If you've done that much, you build something, hooray. So what I wanna do next is kind of walk you through that. Show you what it looks like in real life, not just PowerPoint. Because you guys will be doing it in just a minute, so watch and learn. This is what I'm gonna build. I want a simple tool, it's like a Hello World application. So it's got two inputs. One input is who I'm gonna say hello to. I can put in any name there, Fred or whatever. Another one is a Boolean control, which is whether or not I want enthusiasm, add an exclamation point to the output. So I have two inputs coming into my tool, and then it's gonna generate some output. And the output it's gonna generate is just a string, the Hello World message, right? So that's my very simple tool that I'll build. And I'm gonna build it with two different languages just to kind of show you how it works. I'll build it in Python and I'll build it in Fortran, all right. So let me flip, bring up my web browser. I'm gonna work on hub zero. And when you're doing this work and you log into a hub, one of the tools that you'll find either on the all tools list or somewhere, maybe it's on your recent tools. One of the things you'll see is something called a workspace. A workspace is like a Linux desktop that you can access through the hub anytime, anywhere, and it's where we'll be doing most of our work today inside of the workspace. So you find this workspace tool, and there's a little button right here that you can click on to launch it. If I click here on workspace, it'll just take me to the description of the workspace, which I can also click here to launch it. So either way, you can click on the big black button to launch the workspace, or you can click on this little launch button. And what it does is you may have to allow Java to do its thing. It launches a workspace section back on hub zero, and mine didn't go so well, it says something about inactive plug-in right here. So I'm gonna try it again. Restart my browser after enabling, great, hold on. Hooray, all right, so that's the way it's supposed to work. Let me bump up my font size so you guys can see what I'm doing. All right, so this is what it looks like when your workspace comes up. And if you have any problems with Java, you gotta maybe fuss with it, and make sure Java's enabled, because if Java's disabled, you'll have all the problems I just did. So now I'm in a workspace, and I have a command line here where I can type stuff. You can see I have a bunch of files here. These are all on the hub zero side. And I'm gonna go into my boot camp, 2012, into the lectures. And I'm gonna make a directory called hello for hello world. Okay, so now I'm in my directory. I can say rapture-builder, and it'll bring up the builder program. All right, so this is what you guys are gonna do. You're gonna rapture-builder, and you get this screen. You can browse through all the objects on the side and see what's there. And I'm gonna start by grabbing a string and dragging it over to the input and dropping it. So now I have a string there, right? And I also wanted a Boolean value, and I'm gonna drag that in. So now I have those two values, and I can kind of configure them. This name right here is the name we'll use inside our program. We'll see that in a minute. Rather than call it value one, that's what rapture calls it by default. I'm gonna give that a little better name. I'm gonna call that name. That's the name of the person. And I'll label it on the GUI, say hello to. So that's who I'm gonna say hello to. Of description, you can say this is who we say hello to. And there's some other stuff that we'll talk about later. And I can put in a default value, like world. So by default, I've got the string control now. It's labeled, say hello to, and the default value is world, right? Hello world. Now I'm gonna look at the Boolean value the same way. And this one I'm gonna call in my program. I'll call it exclaim. So that's the name it'll have. I don't wanna just call it Boolean, I'll call it enthusiasm. And the description is add an exclamation point. And down in the default value, I'll set it to false. So you have to ask for enthusiasm to turn it on. Now one other thing, I wanna produce some output. So I can grab a string control and drop it over here on the output side. And the output, I'll give it the name result. And hello output. And this is the output generated by hello world. All right, so now I've got an interface. I've got two inputs, the string and the Boolean value. And it's gonna produce a string called result as the output. So I pretty much describe my interface. And I wanna take a look at it, so I can click on preview. When I click on preview, it tells me uh-oh, there's a couple of things wrong. There are three warnings for the current tool definition. You wanna take a look at them? Yeah, all right, let's take a look and see what I've messed up. Say yes, and it'll show you up here each warning. It says first of all, I should have a title that describes the tool. Yeah, I forgot completely, I didn't even look at the tool part when I was explaining all this to you. So let's make up a title. This is, I'll call this simple hello world. And then I click next and it gives me a description. Okay, it says you should have a brief description of the tool. This usually pops up when you're first doing it. So the description is demo app for bootcamp 2012. Okay, and then next, and then it says, you gotta set the program type down here. So if you click, and you notice it's highlighted, you click on that, it'll show you, these are all the different languages that Rapture supports. And depending on how I wanna do the demo, I can pick any one of these. So for right now, I'm gonna start off with Python. Any of you guys know Python? Seen Python before? Yeah, all right, well it'll make sense to a few of you, I guess. So let's see what it looks like. And there's no more warnings, so I'm all done here now. So I can click on preview again. And now it shows me the preview. So I get a sense of this is what the program's gonna look like in a minute when I start to run it. And you can very quickly take a look and see, does everything look right? Did I forget to label something? Did I have a good description? You notice all the descriptions that I gave will show up as tool tips. So if I mouse over, say hello to world, and then the little pop up message is, this is who we say hello to, right? And similarly, the Boolean value, add an exclamation point. So if I flip back, you can see again, if I wanna change the message, then I can just change any of these input or the default value and so forth. All right, so all that looks good to me. I'm gonna go ahead now and save this, so I'll click save as and choose, and I can choose to save it to any file. You notice by default, it says tool.xml. That's kind of the Rapture conventions that we always save it into a file called tool.xml. You can change it if you want to, but I'll just keep that. And I can also have it generate a program for me, a skeleton program that I'm gonna fill in with the logic for my program, and that's a good thing. It's probably a good way to get started, especially if you're just getting started with Rapture. So I'll choose this main.py, or I can give it a different name too. If I click choose, I can change whatever name I want, main.py or whatever. That's fine, I'll leave it alone. And then I'll say save, and then I can quit the program. Okay, now if I look around, you'll notice that my builder generated two files. It generated main.py and tool.xml. Let's start quickly with the tool.xml, just curiously to see what's in it. And you can see it's an xml file. Xml has the little diamond braces and a bunch of markup that explains all the bits and pieces. And you could pretty much see what we did in the interface here. You can see, for example, this part right here says that we're defining a string whose ID is name and AME. It has a label say hello to, it has a description, this is who we say hello to, and a default value of world. So pretty much everything you saw in the builder, you're seeing here, except it's saved out now in this xml format. All right, so that's the xml file. Now, let's take a look at the main program. This is the main program that got generated by the Rapture Builder, and it has some gobbledygook that's all, in this case, all set up for Python. This is what you need to say in Python. In Python, you start out by importing the Rapture package, and you might wanna bring in other things too, like sys and map, those are common libraries. And then it starts off with some stuff to open Rapture, rapture.library, and then it says io.get and io.get and all that. So this stuff, these statements are actually reaching inside that xml and getting the value of the thing called name. And this reaches inside the xml and gets the value of the Boolean control called exclaim. So now I have these two variables name and exclaim that represent my two inputs. That's what I'm trying to get out of the interface. And if I scroll down a little bit, you notice it says right here, add code here for the main body of your program. So I generate the skeleton. It's got, I've got a skeleton of a program now. I need to fill in middle with the stuff that I want to do. And then at the very end, you can see that it's doing io.put and it's saving that result variable. It's saving out the string called result. So what I'm gonna do is I'm gonna fix up the middle part here. We'll just get rid of the progress stuff. And I'm gonna add in some code here, basically. So the Hello World application, the whole point of it is to build a result string. And the result string is basically Hello plus my name variable, Hello World or Hello Fred, right? So that's basically it. But I added a wrinkle to make it just a little more fun that if the exclaim is turned on, then I wanna add on an exclamation point, okay? So when exclaim is set, we'll add an exclamation point to the set, to the end. So that's the guts of my program. And you notice I'm using all those variables that I declared in the Rapture builder. My inputs are the variable's name and exclaim. And my output is the variable result, which was automatically set up here to be saved as an output. So those names we defined earlier are important. They become the variable names in your program. All right, so now I can save this and now my program's all set to go. If I wanna run it, I can just say Rapture. And Rapture by default, if you say nothing else, will look for the tool.xml file in the current directory, will read the tool.xml and will generate the whole interface. You notice it's got the title that we set for the application. It says simple Hello World app and it says demo app for Bootcamp 2012. So that's the description stuff that we sent on the tool page. You notice that it's got say hello to and the enthusiasm control here. And I really don't have to, with the way Rapture is normally set up, everything has good default values. I don't have to mess with it. I can just click the button. All your tools should be set. Like most users don't know what to do, believe it or not, when confronted with a page like this. So the best thing is if they can at least click the button and it works, then you're in good shape. So we click the button, it went off and it ran my Python program and it gave me back the result Hello World. Now let me try it again. I can try something else. I can give it a different name, like Fred and I can turn on the enthusiasm and I can run it again. And now it generates Hello Fred with an exclamation point. And the way Rapture is built, you can run lots of cases like this and you can actually flip back and forth between the results. So we can try lots of different things. So now we have three different results. The original Hello World, the Hello Fred with enthusiasm, and Hello Bootcamp. So I've got all those different results that I can browse in the Rapture interface. It's actually a lot cooler when you have graphs and stuff because then you can actually flip back and forth between the graphs instead of just messages. All right, and if I want to make changes, I can go back into the builder, Rapture-Builder, and I can load up, I can open that existing tool.xml file and everything's right back where I left it so I can make changes to name and exclaim and all of that. So maybe I want the default value to be true for the exclaim. I can do that and I can save it. Now when I go to save it again, I may just want to change the tool.xml file. If I regenerate the skeleton program at this point, it'll actually overwrite the changes that I made, right? So if I regenerate main.py, it'll basically wipe out the body that I had stuck in there and that's no good. So if you do regenerate the skeleton program, you want to probably regenerate it in a different file, otherwise you're going to wipe out the work you did. But in this case, I'm not going to do that. I'm not going to generate the skeleton, I'll just change the tool.xml and I'll save it. And then now if I run Rapture again, you notice now enthusiasm is on by default because that's what I did. I changed it, right? So you can kind of go back and forth with the builder, make changes, test it. And when you get to a point like I am now where everything is working properly, then your tool is ready to go on NanoHub. You can actually deploy it and put it out and other people can use it, okay? All right, so that was my demo, taking the two inputs and producing a string output. Oh, I showed it to you in Python. I got to show it to you in Fortran too, right? Huh? Yeah, how many people use Fortran? How many people's grandfathers have used Fortran? A few? Nobody? Come on. I know your grandfathers use Fortran. Let me go back into the Rapture Builder and I'll leave everything just as it was. Oh yeah, I got to open my file again. So everything is just as it was, except now I'm going to go into the tool section and I'm going to change the language to Fortran. Click on it. Okay, so now it's Fortran 77 and I'm going to save it and I'm going to save the tool.xml. I'm going to have it generate a main program for Fortran, main.f And I'm also going to generate something called a make file. When you have Fortran, Fortran's an old man's language. You have to compile it down to machine code so that you can run it, right? And when you want to compile it, there's a certain thing called a make file that makes it easy to compile. And in fact, Rapture makes it even easier because it generates the make file for you. So if you just click on that button, I'll get a make file where I can use to build Fortran. So I'm going to build all three. I'm going to get the tool definition, the skeleton program and the make file and click save. Now if I take a look, you can see there's a make file there. Whoops, right there. The make file shows, these are the rules that I would use to build Rapture and to build my program main.f. So it's showing all of that. And I also have the program main.f that I need to fix up too. And again, this is the skeleton that Rapture generates, gets you most of the way there. It does the Fortran way of managing Rapture. It defines some stuff that Rapture needs and it, so variables at the top and it does some stuff to kind of open up. You notice it's doing roughly the same thing. It's still trying to get the variable called name and it's producing something called name and it's still trying to get the Boolean value for exclaim and it's setting that variable to exclaim as well. Has to do a little bit more stuff. There's still a middle part in here where you need to add your code and then there's a part at the end where it's saving the string result. So pretty much the same as Python, just a little different language in terms of how it works. Again, the recipe is I'm gonna get rid of the stuff in the middle and I'm gonna put in my own stuff in here. So I'm gonna add if statement, if exclaim then, result is hello concatenated with the name, concatenated with the exclamation point. Otherwise, just take hello and concatenate it with the name. So that's it. I just added in that little bit of code to kind of produce the string that I want, result. And now I have to compile it. So I type mate and what make does, oops, just gives me a couple of warnings for unused variables. I'll clean them up. I don't like having warnings there. So back into my program, I've got the variable okay and RPE units convert double that weren't really being used. Okay, when you say make, it invokes the compiler rule with all the right libraries to build everything and link it all together. And at the end of that now, I have an executable program. The executable program that we call main F77. And if I look, sure enough, there's a program there, main F77. So that's the actual executable that Rapture is gonna run when you're doing your simulation. And I'll type Rapture and it looks like the same program. It's the same interface, world and exclaim and enthusiasm and all that. When I click simulate, it goes off and it runs the Fortran version now and it builds that result. Probably wouldn't believe me unless I proved it to you. But we can take main.f and change it to, instead of hello, I'll just make it F77. And then I'll remake, whenever you've changed your program in Fortran, you always have to rebuild, remake it. And then run Rapture. See, it says F77 world, which makes no sense. But at least you know it's the Fortran program that it's running now under the hood. So that's how it works. And again, the tool.xml is something that you figure out once and it doesn't matter what language you're using. In the builder, you can choose whatever language you want and then you build a skeleton program and then you go from there to kind of connect it up to the guts of whatever you're trying to do. We have some programs on Nano Hub that aren't even one thing. It'll be Rapture calls the Python program, the Python program execs the Fortran program and MATLAB and half a dozen other things, takes all the results, puts them together and produces the final result. So you can build really complicated systems if you want to with all of this, but it all works pretty much that way. All right, so now that was my demo. Build the simple interface and show you two different programs, Python and Fortran. So now I want you guys to try it. I want you to get into a workspace. Now you should be, everybody authorized for workspace? All right, so you should be good to go being able to get into Nano Hub or Hub Zero into a workspace. And what I want you to do is build a program, whatever your favorite program or language is, whether it's Python or C or Fortran, whatever you feel comfortable with, Pearl, Tickle, I don't care, but pick a language that you're comfortable with and I want you to build a program that has two integers coming in and you can sum them and produce an integer result. So for example, you could have two plus two and you get the answer four, right? There's two plus two is four. So your program, when you're running it, should look like this, should have two integers on the input side and when you click the button, you're gonna get a number result, an integer result on the output side. Don't be surprised when Rapture shows you an integer value, it'll show it to you like this on a graph, which is kind of weird. You might think it would just print out the value like four, but it's actually more useful to see it on a graph because again, you can simulate again and again and again, you can stack up a bunch of results and you can see them all on the same plot. So it's kind of more useful to have it on a plot, but this is what the final program will look like. It's two integers on this side and an integer on this side, which shows up as a plot when you're running it. So if you do everything correctly, that's what you'll see. Now, when you're getting into Workspaces, how many of you guys have used Linux before? You're like Linux gurus? Good. For those of you who've never seen Linux before or a command line prompt, don't worry, we'll help you out. Derek here has got some sheets that he's gonna pass around the Workspace reference. And let me also show you, we have all the materials for this on the website too. If you can't remember anything else and you're trying to figure out where do I go for documentation, if you can just remember Rapture with two P's, Rapture.org with two P's, it will take you to the Rapture website with all the documentation. And if you search on there for Bootcamp, you have to spell it right, you'll find, see Bootcamp 2012, right? That's us, Bootcamp 2012. And on this page on Rapture.org and on Bootcamp 2012, you'll see the outline and you'll see all the materials and you'll also see this Workspace reference that Derek has here, he's passing out. So the Workspace reference will kind of help you get started, logging into a workspace, how you launch it and all of that. And it gives you kind of a cheat sheet of various things that you wanna do. What I'm gonna suggest for each lab assignment, start with a fresh directory. So for this first lab assignment, use the makedir command, M-K-D-I-R, right? Makedir assignment one, whatever, lab one, whatever you wanna call it. Make yourself a fresh directory. And then you can use the CD command, change directory. So you makedir lab one and then CD into lab one and then launch the builder and go from there. Each lab assignment, you're gonna wanna have a separate directory, otherwise when you start the next lab assignment, it's gonna overwrite the tool.xml from the first lab assignment and everything's gonna get all balled up, right? So go ahead and log into a workspace the way it shows on the left-hand side here. And from there, use some of these commands like makedir and CD, make yourself a lab one directory, change into that directory, and then you can go ahead and launch the Rapture Builder. And if you're like, dang it, I wish I was listening when he was telling me all that stuff about the builder, if you're thinking that, don't panic because you can just go back onto bootcamp and you can find right there all the slides that we just looked at, right? So remember rapture.org, rapturewith2ps.org, go onto that, search for bootcamp 2012 and on the bootcamp 2012, by the way, there's earlier bootcamps, 2011, 20, 29, don't get confused because the older labs or the older bootcamps are not so good, they're not so up to date. So look for bootcamp 2012, the fresh stuff and there's all the slides for introducing Rapture right there. You can pull up the PDF and use that as your cheat sheet and also the sheet that Derek passed around. And if you have any questions, we're gonna spend like the next half an hour working our way through the lab assignment, I'll put it back up on the screen here and if you have any questions, I want you to work through it and call people over, right? We got George here, we got Ben, we got Derek and I'll be walking around too, we're all happy to help you guys with questions. So give it a try and see what you can come up with. All right, let me show you what my solution is for this particular lab assignment. So remember, we're trying to build this program that takes two integer values and produces an integer result. And it's real important that we use integers so that Rapture can kind of enforce the interface. So here I am over on my workspace on hub zero. I'll go into bootcamp 2012. I have all these directories that I use like file folders to keep everything separate. So you can see I got a lot of stuff here on hubzero.org. I'm working on a lot of different projects and the easiest way to keep things straight is to make directories. So I've got this directory and you notice I'm such a lazy typer. I can just type bo and hit tab and it'll type everything else for me. Hey, that's pretty handy. So it types as much as it can and then it waits for me to finish the rest. Is it 2009, 2011, 2012? So I can go into bootcamp 2012 and look around and I've got these three assignments, lectures and solutions folders. So I'll go into solutions and again I type SO tab and it fills in the rest for me and I can look around and then I can go into exercise one. If I wanted to, I could make a new directory. I've got three solutions here. One for C language, one for Fortran and one for Python. But let's say I'll just make a new solution directory new. So I say makedir new and now I can cd to new and now I have a nice fresh clean directory where I can keep all my stuff. Because remember when you run the builder it's gonna generate a tool.xml and a make file and a main program and all that stuff and you don't want to get lost with everything else you're doing. So make yourself a clean directory. Then I run rapture-builder to bring up the builder and out of all these different controls I try to pick the most specific one. You could grab for example a string over here and use a string as an input value but that means that anybody could type in whatever string they want. They don't have to use integers. They could type in x, y, z or hello world and when you get into MATLAB or C and you're trying to add hello to world as numbers it's not gonna work, right? You're gonna get trouble. So forget about the string because that'll mess you up. When you've got a control you don't want there's a little delete button here over to the side. I can click delete and that goes away. So instead I'm gonna grab an integer and I'll put that over here. You notice there's also a number in rapture. The number in rapture lets you have fractional values. So if you wanted to have a number like 2.17 or 3.14159 you can use a number for that. The number also has physical systems of units and we'll be learning more about it as we go along. So you have to ask yourself in this case, am I supposed to use, could I allow number values with fractional values and double values with units or is it an integer? The assignment here was integer so I'm gonna stick with integers but there's a subtle difference. If you're trying to have a number of grid points for example, you can't have 2.7 grid points, right? That has to be an integer like 100 grid points or 1,000 grid points. You can't have fractional values. So think about the controls as you're dragging them over. Make sure you got the right ones. Again, I could always produce string output but I don't want a string output. I want an integer output so I can plot it. So I've got two integers coming in and I'm gonna rename the first one N1 and I'll prompt the user by saying add this and give it a default value. You should always give a default value. In fact, if I don't, when I go to save this or do something, preview it, rapture's gonna yell at me and tell me there's errors and warnings I have to fix up. So I'm gonna give it a default value. Whatever you think makes sense, I'll say zero. And then the other one, I'm gonna rename it to N2. That'll give it a nice variable name in my program N2 and I'll label it to this and I'll give it also a default value of zero. And then finally on the output side I'm gonna rename that to sum and this is, I'll call it sum, sum of the two inputs. All right. So now I can try to preview and see what I'm gonna get. Uh-oh, five warnings for the current tool definition. Do I wanna take a look? Yeah, I might as well take a look. Again, it's telling me I should have a title. I'll call it lap, oops, number one. Number one, all right. And then next, and it'll tell me a description. Solution or lab number one. And next, and it'll tell me I need to choose my program. Okay. So a lot of you guys, I noticed we're using MATLAB. That's good because it's easy and you may know it already. I'm gonna choose, you could choose MATLAB. I'm gonna choose octave and I'll tell you why. It's the same as MATLAB, like 99% the same. It's the same language, the same everything. It doesn't quite have as fancy a GUI but it also doesn't take as long for the whole program to start up. When MATLAB starts up, man, it takes a long time for that GUI to come up and that's nice when you're sitting there working with it interactively but it's not so nice when you have a program that you're trying to run and debug as some of you found out. So you may not be able to tell the difference between octave and MATLAB as far as Rapture is concerned because it's just, it's running your script under the hood and it's just the same programming language basically. Plus if you like free software, go GNU free software. Then you might as well use octave and support them. So anyway, and because it's not licensed software, you'll actually find it on a lot more places. When we deal with MATLAB, we have to be careful. We have to make sure Purdue people are using MATLAB and Nano Hub and all this stuff which is why we ran into the permission problems with some of you guys which we sort of worked around for now but there's a better fix. So with MATLAB, there's all these headaches that deal with commercial software and all of that. All the other hubs, you'll find octave. It's a standard thing. It's in Linux, it's on all the other hubs. So when you run into a roadblock with MATLAB, just switch to octave because chances are you won't notice the difference. The syntax is all pretty much the same unless you're using the toolboxes and stuff. All right, let me keep working through my, get down off my soapbox and keep working through my notes. It's asking me for a description and another description and that's pretty much it. So I didn't bother with those two descriptions. If I try to preview now, it still says there are two warnings but I'll just say don't look at those problems, go on ahead. So if the warnings are benign or you don't want to fix them or whatever, Rapture will keep nagging you about it but don't worry, just move on. So now I've got an interface where there are two integers coming in, default value zero and it'll produce an output integer which is the sum. All right, so I can save all this. So I'm gonna go ahead and save it and still nagging me about all those warnings. I really should fix them. I'm gonna choose a tool definition file in this directory, tool.xml and I'll have it generate the skeleton program and there's no need for a make file with octave. So I'll just have it generate that, save it and quit now. So now you can see my two files there. My tool.xml has all the XML code in it with the integers and all that this is my main program generated by the Rapture Builder and you can see that it's basically pulling out the variable n1 here and the variable n2 and then at the very bottom of the program it's saving out the variable sum right here, converting it to a number and then a number to a string basically and then saving it back out. So my job is to fix up where it says add your code here, right? That's your marker, that's where your code goes. If your program runs for a long time you can put out all these progress messages. You can say my program's starting, don't give up on me, don't give up on me, 10% done, hang on, hang on, 20% done. So if your program takes a long time to run it's a good idea to put out these progress messages so the user isn't like why is it hung up? So you can say what's happening in your program. In this case the program runs so quickly it's not even worth putting out the progress messages so I'll get rid of them. And what I say instead is sum equals n1 plus n2. So that's what I wanted to do basically. Two plus two is four and then write out the sum. So that's the whole body of this particular program. You notice this all looks like MATLAB syntax, right? I mean if you know MATLAB this is basically the same stuff, all the stuff you can do in MATLAB you can do here in octave. It's a clone of MATLAB. All right so I save that out and now I can run Rapture and it'll prompt me now, oops, for the two values so I can plug in two plus two and simulate, oh, and it's given me a hard time. It's given me a hard time, sometimes it gives you a hard time because you haven't got the right use thing. So if I say, you have to make sure, what? Yeah, but I do. So you have to make sure that you're using the right program, right? A lot of you guys ran into this because you got right to where I did and it was like dang it, it doesn't work. And in the next section I'm gonna show you how it all works under the hood and how to debug all of that but one of the first things that you can run into is the fact that octave may not be working. So you gotta make sure you've got the use thing set up. If it is set up you should see a star there. So I've got octave set up and if there's any doubt you can say use again and make it persistent. Let me see, beyond that I must have some kind of syntax error in what I did. On octave? So you say just int, what are you saying? And to a double, right? Try Derek's solution, we'll see if Derek got it. Two plus two, four, gray. So int 32 used to work in older versions of octave in order to convert to an integer but so the skeleton must be generating something a little funny or something. Yeah, check on that. And we'll talk a little bit more about debugging in the next section. I didn't wanna get too far into the debugging stuff cause we're gonna do that to death in the next section. Let me show you quickly one more solution because some of you guys did C language. So again, I can do rapture-builder and I can open my tool.xml and again preview it. Same interface but this time under the tool section, I'm gonna choose something else. I'm gonna choose C language as my target language and when I go to save it, I've got a tool.xml and I can have it generate a skeleton program and a make file. Make sure you do the make file. I saw some people generating the skeleton program but just trying to compile it by hand. It's too hard to compile it by hand cause you gotta get all the right libraries and the include files and everything. So when you're dealing with something where there's an option to generate a make file, make sure you generate the make file. That's very handy. So again, I'm gonna save this now and I can get in and edit my program. So here's the program that it generated for me in C and again you can see it grabbing the value for N1 and the value for N2 and producing the sum. So again, I'm gonna say sum equals N1 plus N2. That's basically the body of my program in C language and I'll save that out. And now that's not enough. I have to actually make it. I generated this nice make file that explains how to build my program and now that I've got it I can just say make. It's giving me a warning about an unused variable. I can go in and clean that up. Line 18 I think it said error so it didn't like that, that wasn't used. So I can say make, now it builds cleanly and you notice there's all the libraries and everything. At the end of that, there's a program there. It's called, the program it builds is called main C and so we're ready to run. Now I can run Rapture and give it a value like three and five and simulate and it gives me the sum eight. You notice I've got to give it different values like three and seven and it'll give me 10 and if I give it three and 12 it'll give me 15 and I can go back through all of the different values and I can also click on the all button to kind of plot them all at once. So when you simulate a bunch of cases in Rapture you can actually get a bunch of plots. This feature is actually more handy not when you're dealing with something like two plus two equals four but imagine that you're simulating something as a function of temperature and you want to try a bunch of different temperatures and at each temperature you get a number and then by trying a bunch of temperatures you can plot them all. You can actually sort of build a curve of how it varies versus temperature or how it varies versus pressure. All the different things that you can change. So this is kind of a handy feature, this plotting thing and that's the reason it's set up that way. You notice also because I used an integer value here if I try to type in X, Y, Z, it gives me an error. So Rapture does all this built-in error checking. If you try to type something funny then it's gonna give you an error. Even if I try to type 2.214724, whatever, it gives me a problem with it. And the integer control also has little buttons built in so you can just click the buttons to change the value which is another little feature. So if you use the right control for the type that you're trying to deal with it'll give you a better version. It'll do all the error checking properly. It'll give you built-in things like little buttons. So you should always be the most specific you can with all the Rapture controls and what you're intending to do.