See also: www.perplex.ethz.ch/perplex_documentation.html#SCRIPTING 1) Nuts and bolts The basic idea is to use ** some poorly known capacities of the dos, which is indeed able to read the user inputs from a text file (Jamie told me that trick). For instance, if you have a text file called, say, vertex_command.txt, and containing this: ----------------------- vertex_command.txt---------------- foo -------------------------------------------------- (where foo is the name of a build file), then C:\> vertex.exe < vertex_command.txt is a perfectly legal command that will run vertex and answer to the first (and only) question with "foo". Even better: ------------ werami_commands.txt---------------------- montel-grw_pl 2 7 melt(HP) n n 10 10 y 7 Pl(h) n y 7 Kf(h) [etc...] ------------------------------------------------- C:\> werami < werami_commands.txt will generate automatically the c-files, in this case cmontel-grw_pl, containing the melt fraction ccmontel-grw_pl, with the amount of Pl ccmontel-grw_pl, for K-spar etc. ** some unix utilities, that allow more advanced shell commands and file processing. In particular, we had to rely on awk, a file processing language (whose syntax you do not even want to try and understand....), for which several Windows implementation exist. There are lot of possibilities around; I found the easiest to use is Cygwin (http://www.cygwin.com/ ). Cygwin comes with an installer (http://www.cygwin.com/setup.exe ), that has lot of options but for what we'll be doing, you need to install just the basics (which is the default choice, anyway --just make sure you're installing the basic utilities, ls, grep, etc; gawk; and a shell, bash in my case. Leave the rest unchecked; you do not really need the 100+ megs of installs of cygwin, unless you want to be able to run unix programs on your PC. MELTS, anybody ? :-) ). When installed and launched, cygwin gives you a "shell" windows (same as a unix/linux or a mac OSX shell), which is quite similar to the dos command prompt but uses different commands. If you'd rather keep your dos shell, you need to look for other unix tools; shop around, there is a fair number of ports of unix tools for windiws. You'll need at least a (g)awk, a shell and base utilities such as grep and ls. 2) Running a batch of build file over the week-end. Ok, now you have 10 pseudosections to compute, each of them will take 5-6 hours. The total is about 60 hours, that should be done over the week-end but you certainly do not want to spend your sunday coming each 5 hours to restart vertex... Let's say your build files are called foo, bar, and toto. You have two solutions: ** pure dos solution: - create a .txt file for each of your build file, e.g --------------- tmp_foo.txt ------------------ foo ---------------------------------------------------- ------------- tmp_bar.txt --------------------- bar ----------------------------------------------------- etc. Then, write a batch file which will read --------------- vertex.bat-------------------- vertex < tmp_foo.txt vertex < tmp_bar.txt [etc.] ---------------------------------------------------- Double-click on vertex.bat (or launch it from the command prompt), and voilà ! all your ps will be calculated in sequence. ** unix-like solution if you installed unix tools (which you'll need for the following steps anyway), you can as well take advantage of the shell programming possibilities, and write -------------------- multivertex.sh--------------------------- #! /bin/bash # this shell launches vertex.exe once for each of its arguments for arg in $* do echo $arg > tmp_file.txt vertex.exe < tmp_file.txt rm -f tmp_file.txt done ----------------------------------------------------------------- Invoke it with $ multivertex.sh foo bar toto and come back on monday morning (probably, to discover that there was a typo in a file name or a power failure over the week-end... :-) ) I do not know how many arguments a shell script can accept .. a lot, I think. 3) Processing the werami outputs Ok, you've been running werami in mode 2 (grid) on a dozen of properties, and now you have 12 cccc...foo_pl files in your directory. Obviously you'd like to put them all in a single file, say a text-delimited file with one col per property investigated. Of course, you can open all 12 files and copy them into excel, but this will become tedious especially if you do that on numerous ps. Enters awk.... This does require unix-like commands. Firstly, create the awk script file, as follows: ------------------- merge.awk----------------------- # awk script to compile the werami ccc[...]output files into a single, text-delimited file # with one col per original cc-file. #Rémi Moyen, November 2005 #This scriptis published under the GNU General Public License as published #by the Free Software Foundation - www.gnu.org #You're not really supposed to understand how it works BEGIN{ info_file = "/dev/stderr" ; # Where to output info messages. This will probably not work on windows ;-) if (ARGC != 3 && ARGC != 4) { print "Usage: awk -f script_file file_suffix prefix [field_separator]" >info_file; print "All files of the form cccc[...]file_suffix will be" >info_file; print "processed, field_separator is a space if not specified." >info_file; exit ; } if (ARGC == 4) field_separator = ARGV[3] ; else field_separator = " " ; file_kernel = ARGV[1] ; prefix = ARGV[2] ; # THESE ARE THE TWO LINES TO CUSTOMISE. output_file = file_kernel"_merged" ; header_lines = 4 ; # Should no more be confused here, as we already know the prefix. # Still, you can uncomment next line and comment following two. #number_of_files = 3 ; cmd = "ls *"file_kernel" | grep \"^\\("prefix"\\)\\+"file_kernel"$\" | wc -w" ; cmd | getline number_of_files ; # ARGV[1] is erased, there is no file named file_kernel for (f = 1 ; f < number_of_files+1 ; ++f) { file_name = file_kernel ; for (ff = 0 ; ff < f ; ++ff) { file_name = prefix""file_name ; } ARGV[f] = file_name ; } ARGC = 2 ; # this is a trick to execute next block only once # Some feedback... print "Starting processing "number_of_files" files from "ARGV[1]" to "ARGV[number_of_files]", writing output to "output_file"..." >info_file; ORS="" ; } { # Skip the first 'header_lines' of each file. if (NR <= header_lines) { for (f = 1 ; f < number_of_files+1 ; ++f) getline value < ARGV[f] ; next ; } # Value line, read each file and print. for (f = 1 ; f < number_of_files+1 ; ++f) { getline value < ARGV[f] ; print value field_separator >output_file; } print "\n" >output_file; } -------------------------------------------------- Then, invoke it with $ gawk -f merge.awk foo_pl c it will then look for all the cc[...]foo_pl files, remove the 4 first lines of them (the header, this can be changed in the code by changing the value of header_lines), and put all of them in a (excel-readable) delimited text file, by default foo_pl_merged. 4) More fun with automation ? ** Let's do all the werami processing with a single command: --------------- werami_all.sh------------------ #!/bin/bash #This script extract properties (defined in base_wer.txt) out of a pl file #Use the build file name as an argument echo $1_pl > tmp_wer.txt cat base_wer.txt >> tmp_wer.txt werami < tmp_wer.txt gawk -f merge.awk $1_pl c rm -f tmp_wer.txt rm -f c*$1_pl ------------------------------ For this to work, you need to have a "base_wer.txt" file, containing all the werami inputs (as in the example above) EXCEPT the name of the file, which is generated on the fly by adding _pl to the arg. Of course, the plot file has to be called something_pl. It works like that : $ werami_all.sh foo this will extract all the properties that are "defined" in base_wer.txt from the foo_pl file, i.e. create the c(..)foo_pl files and merge them into foo_pl_merged. It then cleans the c-files. ** since we're at it, let's have this done over the week-end as well, after calculating all ps... -------------------- ps_for_lazy_guys.sh----------------------------- #! /bin/bash # this script launches vertex.exe once for each of its arguments # then extract the ps properties, using werami and the commands # defined in wer_base. Finally, the c-files are concatenated and cleaned. shopt -s extglob for arg in $* do echo $arg > tmp_vert.txt vertex.exe < tmp_vert.txt echo $arg_pl > tmp_wer.txt cat base_wer.txt >> tmp_wer.txt werami < tmp_wer.txt gawk -f merge.awk $arg_pl c head -4 c$arg_pl > $arg_pl_grid_properties rm -f tmp_wer.txt rm -f +(c)${arg}_pl rm -f tmp_vert.txt done ------------------------------------- $ ps_for_lazy_guys.sh foo bar toto will then calculate a ps for each of the build files foo, bar and toto. Then (assuming the plot files are indeed named foo_pl etc. in the build file), it will extract ps properties out of them, and merge the c-files into foo_pl_merged, etc., before cleaning the utilities. When you'll come back on monday morning, for each of your build files, you should therefore have - a _pl file - a _pl_merged file - a _pl_grid_properties file, which contains just the 4 lines of the header (giving you in P, T, etc.), for reference (if you do not like it, remove the line starting with "head" from above...) but *no* c-files. -- Dr. J.-F. Moyen http://moyen.free.fr Dept of Geology -- University of Stellenbosch Private Bag X1 7602 Matieland, South Africa Fax: +27 (0)21 808 3129, phone +27 (0)21 808 3126