public void saveSimulation(String fname) {
		if (sim != null) {
			try {
				Path td = Files.createTempDirectory("PDTemp_");
				List<WorldDescriptor> worldsToSave = sim.getWDStack();
				for (int i = 0; i < worldsToSave.size(); i++) {
					WDLoader loader = new JAXBWDLoader(td + "/"
							+ Integer.toString(i) + ".xml");
					loader.save(worldsToSave.get(i));
				}

				/* Output Stream - that will hold the physical TAR file */
				OutputStream tar_output = new FileOutputStream(new File(fname));
				/*
				 * Create Archive Output Stream that attaches File Output Stream
				 * / and specifies TAR as type of compression
				 */
				ArchiveOutputStream my_tar_ball = new ArchiveStreamFactory()
						.createArchiveOutputStream(ArchiveStreamFactory.TAR,
								tar_output);
				/* Create Archieve entry - write header information */
				for (int i = 0; i < worldsToSave.size(); i++) {
					File tar_input_file = new File(td + "/"
							+ Integer.toString(i) + ".xml");
					TarArchiveEntry tar_file = new TarArchiveEntry(
							tar_input_file, Integer.toString(i) + ".xml");
					tar_file.setSize(tar_input_file.length());
					my_tar_ball.putArchiveEntry(tar_file);
					IOUtils.copy(new FileInputStream(tar_input_file),
							my_tar_ball);
					my_tar_ball.closeArchiveEntry();
				}
				my_tar_ball.finish();
				tar_output.close();
			} catch (IOException e) {
				logger.error("IO error while saving simulation.");
				ui.error("Exception occured while saving simulation.");
			} catch (ArchiveException e) {
				logger.error("Error while creating TAR archive");
				ui.error("Exception occured while saving simulation.");
			}
		}

	}