[ADMB Users] running admb from R using system()

Nathan Taylor n.taylor at fisheries.ubc.ca
Mon May 31 09:59:37 PDT 2010


It's much less elegant than Mark's code because directories and model names are hard wired but for multiple instances such as multiple mcmc chains, i've been successful using system() as shown below (64 bit windows, R version 2.11.0).

setwd("dirname1")
system("model -commandoptions",wait=F,show.output.on.console=F,invisible=F)

setwd("dirname2")
system("model -commandoptions",wait=F,show.output.on.console=F,invisible=F)


It's been a while since i set this up but remember having some issues with the show.output.on.console option using system().  The default for this option is show.output.on.console = TRUE.

good luck.

NG

-----Original Message-----
From: users-bounces at admb-project.org on behalf of Mark Maunder
Sent: Mon 31/05/2010 9:08 AM
To: Benedikt Gehr; users at admb-project.org
Subject: Re: [ADMB Users] running admb from R using system()
 
Try this

   if (.Platform$OS.type == "windows") {
        shell(paste(exedr, file_name, 
            ".exe", " ", cmdoptions, sep = ""), invisible = TRUE)
    }
    else {
        system(paste("cp ", exedr, 
            file_name, " .", sep = ""))
        system(paste("./", file_name, " ", cmdoptions, sep = ""))
        unlink(file_name)
    }


 
Mark Maunder 
Head of the Stock Assessment Program
Inter-American  Tropical Tuna Commission
8604 La Jolla Shores Drive
La Jolla, CA, 92037-1508, USA
  
Tel: (858) 546-7027
Fax: (858) 546-7133
mmaunder at iattc.org
http://www.fisheriesstockassessment.com/TikiWiki/tiki-index.php?page=Mar
k+Maunder
 
Visit the AD Model Builder project at
 http://admb-project.org/
 
See the following website for information on fisheries stock assessment
http://www.fisheriesstockassessment.com/
 
-----Original Message-----
From: users-bounces at admb-project.org
[mailto:users-bounces at admb-project.org] On Behalf Of Benedikt Gehr
Sent: Monday, May 31, 2010 1:44 AM
To: users at admb-project.org
Subject: [ADMB Users] running admb from R using system()

Hi

I'm trying to run an admb model from R by using the system () command.
The admb model runs fine when running it from the admb command line or
when using emacs. However when I try it with system() then R crashes
every time.
And I tried using the R command line and RGui and in both it crashes. I
also tried it from different computers.

What I do is I first set the directory where I keep the admb template
file with the corresponding admb data file and then invoke the system
command either step by step or directly. I can build the model but when
executing the model.exe file R crashes.

##########################
#setting the working directory
setwd("Documents and Settings\\Beni User\\Desktop\\Transfer\\Model
Fournier\\admb models\\simulated data\\stochastic\\pooled age classes")

#building the model -> this works fine
system('makeadm stocpool')

#running the model -> makes R crash
system('stoc.exe')
###########################
#or directly like this:
setwd("Documents and Settings\\Beni User\\Desktop\\Transfer\\Model
Fournier\\admb models\\simulated data\\stochastic\\pooled age classes")
system("./stocpool") -> makes R crash right away


Does anyone know why this happens and how I can make this work?

Thanks a lot for the help!!

cheers

Beni





_______________________________________________
Users mailing list
Users at admb-project.org
http://lists.admb-project.org/mailman/listinfo/users
_______________________________________________
Users mailing list
Users at admb-project.org
http://lists.admb-project.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20100531/7faffb4d/attachment.html>


More information about the Users mailing list