/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include using namespace std; const mstring LABAT=htchome()+sref("/bin/labat"); const int SLOTS=8; const int RUNLIMIT=600; static int SLOT; extern "C" { static void FreeSlot(int dummy) { static int ok=0; static char buf[256]; if(!ok) { ok=1; sprintf(buf,"rm -rf /tmp/labat%d/",SLOT); system(buf); } } } static int AllocSlot() { struct stat FS; char buf[256]; for(SLOT=0;SLOT0||nr>0) { ctl.left[ctl.basisn].n=i+1; ctl.left[ctl.basisn].l=k; ctl.left[ctl.basisn].occ=nl; ctl.left[ctl.basisn].SetEnergy(ctl.atomz); ctl.right[ctl.basisn].n=i+1; ctl.right[ctl.basisn].l=k; ctl.right[ctl.basisn].occ=nr; ctl.right[ctl.basisn].SetEnergy(ctl.atomz); ctl.basisn++; } elecs+=nl+nr; } } ctl.atomz+=elecs; char buf[1024]; sprintf(buf,"/tmp/labat%d/atomctrl.dat",SLOT); ofstream os(buf); os<\n"; cout<<"NOTE: if the program does >="<\n"; cout<<"Also note that there is currently a maximum time limit of "<< RUNLIMIT<<" seconds.
\n"; } static void RunLabat() { char buf[1024]; sprintf(buf,"cd /tmp/labat%d/\nulimit -t %d\n%s",SLOT,RUNLIMIT,LABAT.c_str()); system(buf); } static void SaveLabat(const mstring& resfile) { const char* docroot=getenv("DOCROOT"); if(docroot&&resfile.size()) { char buf[1024]; sprintf(buf,"cp -rfp /tmp/labat%d/atomdens.dat %s/%s", SLOT,docroot,resfile.c_str()); system(buf); cout<<"

\n" <<"Here you may download the density profile.\n" <<"Example: Save the file as 'dens.dat', and load it from\n" <<"matlab with 'load dens.dat'.\n" <<"Then you can look at it with 'plot(dens(:,1),dens(:,2))'.\n" <<"

\n"<<"Get atomic density\n"; } } main(int argc,char* argv[]) { if(argc<12) { cerr<<"Usage: "< x6\n"; exit(-1); } mstring resfile; char buf[1024]; if(AllocSlot()) { cout<<"

Running

\n" <<"
\n";
    cout.flush();
    SetupLabat(resfile,argc,argv);
    RunLabat();
    cout<<"
\n" <<"

Done

\n"; SaveLabat(resfile); FreeSlot(0); } else { cout<<"No vacant slots at the moment. Try again later.\n"; } }