Roberto Beccherle wrote:
> In module there is an option called conflict to be used to catch
> conflicts between already loaded modulefiles. I have to set up
> modulefiles for two different versions of software so i have
> something like:
> Software/verA (default) and Software/verB
> now in hte modulefiles i put the command conflict Software and if
> i load a version once anotherone is already loaded modules dumps
> an Error stating this fact (plus some other info) and exits.
> My question is the following:
> How do i catch the error message and instead of exiting dump
> something nice to stderr or even better automatically unload the
> other version and load the correct one telling the user i have
> done so? Tcl provides catch but i was not able to use it... :(
Hello, Roberto.
I think that this will work:
if {![module-info mode remove] && [info exists env(SOFT_VER)]} {
puts stderr "Unloading version $env(SOFT_VER) first...\n"
module unload Software
}
setenv SOFT_VER verA
No hiccups using modules-2.2b that I could detect. Strangely
enough, using "[module-info mode load" in place of "![module-info
mode remove]" _didn't_ work, and I don't know why... same function
implemented in both cases as far as I can tell, but the "load"
version was causing a recursive loop. Thoughts, anyone?
> In general how do i manage the errors eventualy produced by module?
To the best of my knowledge, you don't. Maybe there's a really
awesome method of capturing errors in Tcl that modules can work
with, but I'm also no Tcl expert so I don't know if it can trap
errors. I instead avoid the errors with "tricks" as above and
call it good. Thanks go to Dave Barnett for giving me the help
the other day which allowed me to work this out.
Hope this helps!
Cheers,
- Leo
|