2009年11月25日星期三

Common Commands (beta, Sun Grid Engine)

Please see the man pages for qsub, qalter, qstat, qdel, qhost.

qsub : submit a script for execution
qlogin : request a node for interactive use: see HPC:Using qlogin
qstat -j : show the status of a job
qdel : cancel a job
qstat -f : display all of your jobs queued or running
qhost -j : display which jobs are on which host
qstat -u : display jobs queued or running for a single user
qstat -f -u '*' : to see all jobs
qacct -b 200810010000 -e 200810020000 -o username : show your usage statistics between those dates
qsub -l mem_free=4G script.sh : request that there are at least 4GB RAM free on the node where your script will run

qsub script

#$ -cwd
#$ -N yourjobname
/usr/local/bin/R CMD BATCH
/.../gwa_hmm/codes/gwa_hmm_chop_Chr.R



with -cwd option, the output will be sent to current directory;
otherwise home directory

2009年11月12日星期四

Vector for Array

One way:
vector< vector<int> > array(3); //R(3)
for(int i=0;i<3;i++)
array[i].resize(3); //C(3)

for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
array[i][j]=(i*j);

for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
cout<<array[i][j]<<" ";
cout<<endl;
}

array.resize(5); //5*3
array[3].resize(3);
array[4].resize(3);


Another way:
int m = 5, n = 2, s = 2;
vector < vector<int> > vecInt(m, vector<int>(n));
vector<vector<vector<int> > > dgamma(m,vector<vector<int> >(n,vector<int>(s)));

2009年11月4日星期三

C++ way to convert from a double to an int

The C++ way to convert from a double to an int is with static_cast:

int m;
double x;

m = static_cast<int>(x);