Last active
August 29, 2015 14:00
-
-
Save tbates/11294078 to your computer and use it in GitHub Desktop.
Installer script for OpenMx http://openmx.psyc.virginia.edu/installing-openmx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://openmx.psyc.virginia.edu/getOpenMx.R | |
# run this as | |
# source_gist(11294078) | |
if (.Platform$OS.type == "windows") { | |
if (!is.null(.Platform$r_arch) && .Platform$r_arch == "x64") { | |
repos <- c('http://openmx.psyc.virginia.edu/packages/') | |
} else { | |
repos <- c('http://openmx.psyc.virginia.edu/32bit/') | |
} | |
install.packages(pkgs = c('OpenMx'), repos = repos) | |
} else { | |
darwinVers <- as.numeric(substr(Sys.info()['release'], 1, 2)) | |
if (Sys.info()["sysname"] == "Darwin" && darwinVers > 10) { | |
# = User is on OS X without default OpenMP support = | |
msg <- paste("We have detected that you are running on OS X 10.7 or greater.\n", | |
"The default gcc compiler does not support parallel execution.\n", | |
"If you have installed a gcc that supports OpenMP (say mac ports gcc)\n", | |
" choose the multi-threaded installation option.\n", | |
"Otherwise stay with default installation (single-threaded), i.e., '1'.\n\n" | |
) | |
cat(msg) | |
msg1 = "1. single-threaded [default]\n" | |
msg2 = "2. multi-threaded \n" | |
default = 1 | |
} else { | |
# = unix with OpenMP = | |
msg1 = "1. single-threaded\n" | |
msg2 = "2. multi-threaded [default]\n" | |
default = 2 | |
} | |
# =================== | |
# = get user choice = | |
# =================== | |
cat(msg1) | |
cat(msg2) | |
select <- readline("Which version of OpenMx should I install? ") | |
if (select == "") { select <- default } | |
while (!(select %in% c(1, 2))) { | |
message("Please enter '1' or '2'. You entered '", select, "'") | |
select <- readline("Which version of OpenMx should I install? ") | |
} | |
# ================== | |
# = Do the install = | |
# ================== | |
if (select == 1) { | |
repos <- c('http://openmx.psyc.virginia.edu/sequential/') | |
install.packages(pkgs = c('OpenMx'), repos = repos, configure.args = c('--disable-openmp')) | |
} else if (select == 2) { | |
repos <- c('http://openmx.psyc.virginia.edu/packages/') | |
install.packages(pkgs = c('OpenMx'), repos = repos) | |
} | |
} | |
message("If that worked, you can now load OpenMx and run some models! Try:\n", | |
'library("OpenMx")\n', | |
'help(mxRun) # scroll down for examples\n', | |
'If not, go here for help:\n', | |
'http://openmx.psyc.virginia.edu/forums/openmx-help/openmx-installation\n' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment