1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "abevo.h"
#include "smalloc.h"
int main ()
{
printf ("Checking if processor is available...\n");
char* path;
char* pathExecpdb2gmx;
char* pathExeceditconf;
char* pathExecgenbox;
char* pathExecgrompp;
char* pathExecmdrun;
int ret;
char *Param_pdb2gmx[] = { "pdb2gmx", "-f", "cpeptide.pdb", "-o", "cpeptide.gro", "-p", "cpeptide.top",(char *)0 };
char *Param_editconf[] = { "editconf", "-f", "cpeptide.gro", "-o", "cpeptide.gro", "-d", "0.5",(char *)0 };
char *Param_genbox[] = { "genbox", "-cp", "cpeptide.gro", "-cs", "-o", "cpeptide_b4em.gro", "-p", "cpeptide.top",(char *)0 };
char *Param_grompp[] = { "grompp", "-f", "em.mdp", "-c", "cpeptide.gro", "-p", "cpeptide.top", "-o", "cpeptide_b4em.tpr", (char *)0 }; //cpeptide_b4em.gro
char *Param_mdrun[] = { "mdrun", "-nice", "4", "-s", "cpeptide_em", "-o", "cpeptide_em", "-c", "cpeptide_b4pr","-v", (char *)0 };
//leParametro("parameters.txt");
//CRIA AS VARIĆVEIS
snew(path,60);
snew(pathExecpdb2gmx,100);
snew(pathExeceditconf,100);
snew(pathExecgenbox,100);
snew(pathExecgrompp,100);
snew(pathExecmdrun,100);
path = "/home/faccioli/Projects/AbevoGROMACS_TESTE/";//retornaParametro("pathExec");
int processos;
int child = 0;
processos = 0;
while (processos <= 5) //COLOCAR A QTDE DE PROCESSOS QUE DEVEM SER EXECUTADOS
{
if (processos == 0)
{
//pdb2gmx
child = fork();//cria novo processo
if (child == 0)
{
strcat(pathExecpdb2gmx,path);
strcat(pathExecpdb2gmx,"pdb2gmx");
ret = execv (pathExecpdb2gmx, Param_pdb2gmx);
} else
{
wait(child);
processos++;
}
}
if (processos == 1)
{
//editconf
child = fork();
if (child == 0)
{
strcat(pathExeceditconf,path);
strcat(pathExeceditconf,"editconf");
ret = execv (pathExeceditconf, Param_editconf);
}else
{
wait(child);
processos++;
}
}
if (processos == 2)
{
//genbox
child = fork();
if (child == 0)
{
strcat(pathExecgenbox,path);
strcat(pathExecgenbox,"genbox");
ret = execv (pathExecgenbox, Param_genbox);
}else
{
wait(child);
processos++;
}
}
if (processos == 3)
{
//grompp
child = fork();
if (child == 0)
{
strcat(pathExecgrompp,path);
strcat(pathExecgrompp,"grompp");
ret = execv (pathExecgrompp, Param_grompp);
}else
{
wait(child);
processos++;
}
}
if (processos == 4)
{
//mdrun
child = fork();
if (child == 0)
{
printf ("COMECANDO O mdrun \n");
strcat(pathExecmdrun,path);
strcat(pathExecmdrun,"mdrun");
ret = execv (pathExecmdrun, Param_mdrun);
}else
{
wait(child);
processos++;
}
}
}
//FIM
printf ("Fim da execucao !!! \n");
return 0;
}
| |