I have written an awk script (first ever awk script for me!) to extract foo.lib.clu from foo.clu automatically, and I put it in our group directory. Just type:
awk -f clulib.awk foo.clu > foo.lib.clu
to extract the specifications from foo.clu into foo.lib.clu. If you have any problems with the script, let me know.
Notes on the Script
- When you declare proc's, iter's and cluster's, make sure you put spaces around the equals sign. e.g., do: "foo = cluster is ..." rather than "foo=cluster is ...". Otherwise, the script won't work right.
- You may be surprised that, when you run the script on a cluster foo, it replaces whatever representation you have with "rep = int". This is okay--it is a feature, not a bug, really! The reason I do this is so that the foo.lib.clu file does not depend upon the representation you use--you can change the representation and still not have to recompile any files which depend upon your module. When PCLU creates a lib file, it needs to have some representation, so I give it a dummy representation of int.
- You should note that, when creating foo.lib.clu for a cluster, the script only includes those subroutines which are visible externally -- i.e. those which are named in the "cluster is ..." statement. Again, this is a feature--other files don't need to know what other subroutines you use internally to implement your data structure.
It Works
There was some doubt in my mind that all this would work--I wasn't sure if the CLU compiler would let us use this hack to prevent unnecessary recompilations. However, it does. I tried using this hack on the p_table library for my problem set number 4, and everything worked just fine when I compiled it! So, rest easy.