mirror of https://github.com/BOINC/boinc.git
- add support for making wrappers for Rappture:
https://nanohub.org/infrastructure/rappture/ svn path=/trunk/boinc/; revision=22775
This commit is contained in:
parent
36c95249bf
commit
bedfeafbee
|
@ -8476,3 +8476,15 @@ Rom 29 Nov 2010
|
|||
vboxwrapper.cpp
|
||||
win_build/
|
||||
vboxwrapper.vcproj
|
||||
|
||||
David 29 Nov 2010
|
||||
- add support for making wrappers for Rappture:
|
||||
https://nanohub.org/infrastructure/rappture/
|
||||
|
||||
samples/
|
||||
wrappture/
|
||||
wrappture.cpp,h
|
||||
wrappture_example.cpp
|
||||
Makefile
|
||||
wrapper/
|
||||
wrapper.cpp
|
||||
|
|
|
@ -565,6 +565,9 @@ int main(int argc, char** argv) {
|
|||
for (i=0; i<tasks.size(); i++) {
|
||||
total_weight += tasks[i].weight;
|
||||
}
|
||||
|
||||
// loop over tasks
|
||||
//
|
||||
for (i=0; i<tasks.size(); i++) {
|
||||
TASK& task = tasks[i];
|
||||
if ((int)i<ntasks_completed) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# This should work on Linux. Modify as needed for other platforms.
|
||||
|
||||
# Change the following to match your installation
|
||||
BOINC_DIR = ../..
|
||||
BOINC_API_DIR = $(BOINC_DIR)/api
|
||||
BOINC_LIB_DIR = $(BOINC_DIR)/lib
|
||||
|
||||
CXXFLAGS = -g \
|
||||
-I$(BOINC_DIR) \
|
||||
-I$(BOINC_LIB_DIR) \
|
||||
-I$(BOINC_API_DIR) \
|
||||
-L$(BOINC_API_DIR) \
|
||||
-L$(BOINC_LIB_DIR) \
|
||||
-L.
|
||||
|
||||
PROGS = wrappture_example
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
libstdc++.a:
|
||||
ln -s `g++ -print-file-name=libstdc++.a`
|
||||
|
||||
clean:
|
||||
rm $(PROGS) *.o
|
||||
|
||||
distclean:
|
||||
/bin/rm -f $(PROGS) *.o libstdc++.a
|
||||
|
||||
wrappture.o: wrappture.cpp
|
||||
g++ $(CXXFLAGS) -c -o wrappture.o wrappture.cpp
|
||||
|
||||
wrappture_example: wrappture.o wrappture_example.o libstdc++.a $(BOINC_LIB_DIR)/libboinc.a $(BOINC_API_DIR)/libboinc_api.a
|
||||
g++ $(CXXFLAGS) -o wrappture_example wrappture_example.o wrappture.o libstdc++.a -pthread -lboinc_api -lboinc
|
|
@ -0,0 +1,473 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2010 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC 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 Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#ifdef _WIN32
|
||||
#include "boinc_win.h"
|
||||
#include "win_util.h"
|
||||
#else
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "procinfo.h"
|
||||
#endif
|
||||
|
||||
#include "boinc_api.h"
|
||||
#include "diagnostics.h"
|
||||
#include "filesys.h"
|
||||
#include "parse.h"
|
||||
#include "str_util.h"
|
||||
#include "str_replace.h"
|
||||
#include "util.h"
|
||||
#include "error_numbers.h"
|
||||
|
||||
#include "wrappture.h"
|
||||
|
||||
#define POLL_PERIOD 1.0
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
struct TASK {
|
||||
string application;
|
||||
string stdin_filename;
|
||||
string stdout_filename;
|
||||
string stderr_filename;
|
||||
string checkpoint_filename;
|
||||
// name of task's checkpoint file, if any
|
||||
string fraction_done_filename;
|
||||
// name of file where app will write its fraction done
|
||||
string command_line;
|
||||
double weight;
|
||||
// contribution of this task to overall fraction done
|
||||
double final_cpu_time;
|
||||
double starting_cpu;
|
||||
// how much CPU time was used by tasks before this in the job file
|
||||
bool suspended;
|
||||
double wall_cpu_time;
|
||||
// for estimating CPU time on Win98/ME and Mac
|
||||
#ifdef _WIN32
|
||||
HANDLE pid_handle;
|
||||
DWORD pid;
|
||||
HANDLE thread_handle;
|
||||
struct _stat last_stat; // mod time of checkpoint file
|
||||
#else
|
||||
int pid;
|
||||
struct stat last_stat;
|
||||
#endif
|
||||
bool stat_first;
|
||||
bool poll(int& status);
|
||||
int run(int argc, char** argv);
|
||||
void kill();
|
||||
void stop();
|
||||
void resume();
|
||||
double cpu_time();
|
||||
inline bool has_checkpointed() {
|
||||
bool changed = false;
|
||||
if (checkpoint_filename.size() == 0) return false;
|
||||
struct stat new_stat;
|
||||
int retval = stat(checkpoint_filename.c_str(), &new_stat);
|
||||
if (retval) return false;
|
||||
if (!stat_first && new_stat.st_mtime != last_stat.st_mtime) {
|
||||
changed = true;
|
||||
}
|
||||
stat_first = false;
|
||||
last_stat.st_mtime = new_stat.st_mtime;
|
||||
return changed;
|
||||
}
|
||||
inline double fraction_done() {
|
||||
if (fraction_done_filename.size() == 0) return 0;
|
||||
FILE* f = fopen(fraction_done_filename.c_str(), "r");
|
||||
if (!f) return 0;
|
||||
double frac;
|
||||
int n = fscanf(f, "%lf", &frac);
|
||||
fclose(f);
|
||||
if (n != 1) return 0;
|
||||
if (frac < 0) return 0;
|
||||
if (frac > 1) return 1;
|
||||
return frac;
|
||||
}
|
||||
};
|
||||
|
||||
APP_INIT_DATA aid;
|
||||
double fraction_done, checkpoint_cpu_time;
|
||||
|
||||
#ifdef _WIN32
|
||||
// CreateProcess() takes HANDLEs for the stdin/stdout.
|
||||
// We need to use CreateFile() to get them. Ugh.
|
||||
//
|
||||
HANDLE win_fopen(const char* path, const char* mode) {
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
if (!strcmp(mode, "r")) {
|
||||
return CreateFile(
|
||||
path,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
&sa,
|
||||
OPEN_EXISTING,
|
||||
0, 0
|
||||
);
|
||||
} else if (!strcmp(mode, "w")) {
|
||||
return CreateFile(
|
||||
path,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
&sa,
|
||||
OPEN_ALWAYS,
|
||||
0, 0
|
||||
);
|
||||
} else if (!strcmp(mode, "a")) {
|
||||
HANDLE hAppend = CreateFile(
|
||||
path,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
&sa,
|
||||
OPEN_ALWAYS,
|
||||
0, 0
|
||||
);
|
||||
SetFilePointer(hAppend, 0, NULL, FILE_END);
|
||||
return hAppend;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void slash_to_backslash(char* p) {
|
||||
while (1) {
|
||||
char* q = strchr(p, '/');
|
||||
if (!q) break;
|
||||
*q = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
int TASK::run(int argct, char** argvt) {
|
||||
string stdout_path, stdin_path, stderr_path;
|
||||
char app_path[1024], buf[256];
|
||||
|
||||
if (checkpoint_filename.size()) {
|
||||
boinc_delete_file(checkpoint_filename.c_str());
|
||||
}
|
||||
if (fraction_done_filename.size()) {
|
||||
boinc_delete_file(fraction_done_filename.c_str());
|
||||
}
|
||||
|
||||
strcpy(buf, application.c_str());
|
||||
char* p = strstr(buf, "$PROJECT_DIR");
|
||||
if (p) {
|
||||
p += strlen("$PROJECT_DIR");
|
||||
sprintf(app_path, "%s%s", aid.project_dir, p);
|
||||
} else {
|
||||
boinc_resolve_filename(buf, app_path, sizeof(app_path));
|
||||
}
|
||||
|
||||
// Append wrapper's command-line arguments to those in the job file.
|
||||
//
|
||||
for (int i=1; i<argct; i++){
|
||||
command_line += string(" ");
|
||||
command_line += argvt[i];
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s wrapper: running %s (%s)\n",
|
||||
boinc_msg_prefix(buf, sizeof(buf)), app_path, command_line.c_str()
|
||||
);
|
||||
|
||||
#ifdef _WIN32
|
||||
PROCESS_INFORMATION process_info;
|
||||
STARTUPINFO startup_info;
|
||||
string command;
|
||||
|
||||
slash_to_backslash(app_path);
|
||||
memset(&process_info, 0, sizeof(process_info));
|
||||
memset(&startup_info, 0, sizeof(startup_info));
|
||||
command = string("\"") + app_path + string("\" ") + command_line;
|
||||
|
||||
// pass std handles to app
|
||||
//
|
||||
startup_info.dwFlags = STARTF_USESTDHANDLES;
|
||||
if (stdout_filename != "") {
|
||||
boinc_resolve_filename_s(stdout_filename.c_str(), stdout_path);
|
||||
startup_info.hStdOutput = win_fopen(stdout_path.c_str(), "a");
|
||||
}
|
||||
if (stdin_filename != "") {
|
||||
boinc_resolve_filename_s(stdin_filename.c_str(), stdin_path);
|
||||
startup_info.hStdInput = win_fopen(stdin_path.c_str(), "r");
|
||||
}
|
||||
if (stderr_filename != "") {
|
||||
boinc_resolve_filename_s(stderr_filename.c_str(), stderr_path);
|
||||
startup_info.hStdError = win_fopen(stderr_path.c_str(), "a");
|
||||
} else {
|
||||
startup_info.hStdError = win_fopen(STDERR_FILE, "a");
|
||||
}
|
||||
|
||||
if (!CreateProcess(
|
||||
app_path,
|
||||
(LPSTR)command.c_str(),
|
||||
NULL,
|
||||
NULL,
|
||||
TRUE, // bInheritHandles
|
||||
CREATE_NO_WINDOW|IDLE_PRIORITY_CLASS,
|
||||
NULL,
|
||||
NULL,
|
||||
&startup_info,
|
||||
&process_info
|
||||
)) {
|
||||
char error_msg[1024];
|
||||
windows_error_string(error_msg, sizeof(error_msg));
|
||||
fprintf(stderr, "can't run app: %s\n", error_msg);
|
||||
return ERR_EXEC;
|
||||
}
|
||||
pid_handle = process_info.hProcess;
|
||||
pid = process_info.dwProcessId;
|
||||
thread_handle = process_info.hThread;
|
||||
SetThreadPriority(thread_handle, THREAD_PRIORITY_IDLE);
|
||||
#else
|
||||
int retval, argc;
|
||||
char progname[256];
|
||||
char* argv[256];
|
||||
char arglist[4096];
|
||||
FILE* stdout_file;
|
||||
FILE* stdin_file;
|
||||
FILE* stderr_file;
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
perror("fork(): ");
|
||||
return ERR_FORK;
|
||||
}
|
||||
if (pid == 0) {
|
||||
// we're in the child process here
|
||||
//
|
||||
// open stdout, stdin if file names are given
|
||||
// NOTE: if the application is restartable,
|
||||
// we should deal with atomicity somehow
|
||||
//
|
||||
if (stdout_filename != "") {
|
||||
boinc_resolve_filename_s(stdout_filename.c_str(), stdout_path);
|
||||
stdout_file = freopen(stdout_path.c_str(), "a", stdout);
|
||||
if (!stdout_file) return ERR_FOPEN;
|
||||
}
|
||||
if (stdin_filename != "") {
|
||||
boinc_resolve_filename_s(stdin_filename.c_str(), stdin_path);
|
||||
stdin_file = freopen(stdin_path.c_str(), "r", stdin);
|
||||
if (!stdin_file) return ERR_FOPEN;
|
||||
}
|
||||
if (stderr_filename != "") {
|
||||
boinc_resolve_filename_s(stderr_filename.c_str(), stderr_path);
|
||||
stderr_file = freopen(stderr_path.c_str(), "a", stderr);
|
||||
if (!stderr_file) return ERR_FOPEN;
|
||||
}
|
||||
|
||||
// construct argv
|
||||
// TODO: use malloc instead of stack var
|
||||
//
|
||||
argv[0] = app_path;
|
||||
strlcpy(arglist, command_line.c_str(), sizeof(arglist));
|
||||
argc = parse_command_line(arglist, argv+1);
|
||||
setpriority(PRIO_PROCESS, 0, PROCESS_IDLE_PRIORITY);
|
||||
retval = execv(app_path, argv);
|
||||
perror("execv() failed: ");
|
||||
exit(ERR_EXEC);
|
||||
}
|
||||
#endif
|
||||
wall_cpu_time = 0;
|
||||
suspended = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool TASK::poll(int& status) {
|
||||
if (!suspended) wall_cpu_time += POLL_PERIOD;
|
||||
#ifdef _WIN32
|
||||
unsigned long exit_code;
|
||||
if (GetExitCodeProcess(pid_handle, &exit_code)) {
|
||||
if (exit_code != STILL_ACTIVE) {
|
||||
status = exit_code;
|
||||
final_cpu_time = cpu_time();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int wpid, stat;
|
||||
struct rusage ru;
|
||||
|
||||
wpid = wait4(pid, &status, WNOHANG, &ru);
|
||||
if (wpid) {
|
||||
final_cpu_time = (float)ru.ru_utime.tv_sec + ((float)ru.ru_utime.tv_usec)/1e+6;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void TASK::kill() {
|
||||
#ifdef _WIN32
|
||||
TerminateProcess(pid_handle, -1);
|
||||
#else
|
||||
::kill(pid, SIGKILL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TASK::stop() {
|
||||
#ifdef _WIN32
|
||||
suspend_or_resume_threads(pid, 0, false);
|
||||
#else
|
||||
::kill(pid, SIGSTOP);
|
||||
#endif
|
||||
suspended = true;
|
||||
}
|
||||
|
||||
void TASK::resume() {
|
||||
#ifdef _WIN32
|
||||
suspend_or_resume_threads(pid, 0, true);
|
||||
#else
|
||||
::kill(pid, SIGCONT);
|
||||
#endif
|
||||
suspended = false;
|
||||
}
|
||||
|
||||
void poll_boinc_messages(TASK& task) {
|
||||
BOINC_STATUS status;
|
||||
boinc_get_status(&status);
|
||||
if (status.no_heartbeat) {
|
||||
task.kill();
|
||||
exit(0);
|
||||
}
|
||||
if (status.quit_request) {
|
||||
task.kill();
|
||||
exit(0);
|
||||
}
|
||||
if (status.abort_request) {
|
||||
task.kill();
|
||||
exit(0);
|
||||
}
|
||||
if (status.suspended) {
|
||||
if (!task.suspended) {
|
||||
task.stop();
|
||||
}
|
||||
} else {
|
||||
if (task.suspended) {
|
||||
task.resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double TASK::cpu_time() {
|
||||
#ifdef _WIN32
|
||||
double x;
|
||||
int retval = boinc_process_cpu_time(pid_handle, x);
|
||||
if (retval) return wall_cpu_time;
|
||||
return x;
|
||||
#elif defined(__APPLE__)
|
||||
// There's no easy way to get another process's CPU time in Mac OS X
|
||||
//
|
||||
return wall_cpu_time;
|
||||
#else
|
||||
return linux_cpu_time(pid);
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_status_message(
|
||||
TASK& task, double frac_done, double checkpoint_cpu_time
|
||||
) {
|
||||
double current_cpu_time = task.starting_cpu + task.cpu_time();
|
||||
boinc_report_app_status(
|
||||
current_cpu_time,
|
||||
checkpoint_cpu_time,
|
||||
frac_done
|
||||
);
|
||||
}
|
||||
|
||||
#define PROGRESS_MARKER "=RAPPTURE-PROGRESS=>"
|
||||
|
||||
// the following runs in a thread and parses the app's stdout file,
|
||||
// looking for progress tags
|
||||
//
|
||||
void* parse_app_stdout(void*) {
|
||||
char buf[8192];
|
||||
FILE* f = boinc_fopen("rappture_stdout.txt", "r");
|
||||
|
||||
while (1) {
|
||||
if (fgets(buf, sizeof(buf), f)) {
|
||||
if (strstr(buf, PROGRESS_MARKER)) {
|
||||
fraction_done = atof(buf+strlen(PROGRESS_MARKER))/100;
|
||||
}
|
||||
} else {
|
||||
boinc_sleep(1.);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int create_parser_thread() {
|
||||
#ifdef _WIN32
|
||||
DWORD parser_thread_id;
|
||||
if (!CreateThread(NULL, 0, parse_app_stdout, 0, 0, &parser_thread_id)) {
|
||||
return ERR_THREAD;
|
||||
}
|
||||
#else
|
||||
pthread_t parser_thread_handle;
|
||||
pthread_attr_t thread_attrs;
|
||||
pthread_attr_init(&thread_attrs);
|
||||
pthread_attr_setstacksize(&thread_attrs, 16384);
|
||||
int retval = pthread_create(
|
||||
&parser_thread_handle, &thread_attrs, parse_app_stdout, NULL
|
||||
);
|
||||
if (retval) {
|
||||
return ERR_THREAD;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int boinc_run_rappture_app(const char* program, const char* cmdline) {
|
||||
TASK task;
|
||||
int retval;
|
||||
BOINC_OPTIONS options;
|
||||
|
||||
memset(&options, 0, sizeof(options));
|
||||
options.main_program = true;
|
||||
options.check_heartbeat = true;
|
||||
options.handle_process_control = true;
|
||||
boinc_init_options(&options);
|
||||
|
||||
memset(&task, 0, sizeof(task));
|
||||
task.application = program;
|
||||
task.command_line = cmdline;
|
||||
task.stdout_filename = "rappture_stdout.txt";
|
||||
|
||||
retval = task.run(0, 0);
|
||||
create_parser_thread();
|
||||
while (1) {
|
||||
int status;
|
||||
if (task.poll(status)) {
|
||||
if (status) {
|
||||
boinc_finish(EXIT_CHILD_FAILED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
poll_boinc_messages(task);
|
||||
send_status_message(task, fraction_done, checkpoint_cpu_time);
|
||||
boinc_sleep(POLL_PERIOD);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2010 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// BOINC 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 Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern int boinc_run_rappture_app(const char* program, const char* cmdline);
|
|
@ -0,0 +1,107 @@
|
|||
// ----------------------------------------------------------------------
|
||||
// EXAMPLE: Fermi-Dirac function in C.
|
||||
//
|
||||
// This simple example shows how to use Rappture within a simulator
|
||||
// written in C.
|
||||
// ======================================================================
|
||||
// AUTHOR: Derrick Kearney, Purdue University
|
||||
// Copyright (c) 2004-2008 Purdue Research Foundation
|
||||
//
|
||||
// See the file "license.terms" for information on usage and
|
||||
// redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
// ======================================================================
|
||||
|
||||
//#include "rappture.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "error_numbers.h"
|
||||
#include "boinc_api.h"
|
||||
#include "wrappture.h"
|
||||
|
||||
#define RPLIB_OVERWRITE 0
|
||||
struct RpLibrary{};
|
||||
RpLibrary* rpLibrary(char*){return NULL;}
|
||||
void rpGetString(RpLibrary*, const char*, const char**){}
|
||||
double rpConvertDbl(const char*, const char*, int*){return 0;}
|
||||
void rpPutString (RpLibrary*, const char*, const char*, int){}
|
||||
void rpResult(RpLibrary*);
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
|
||||
RpLibrary* lib = NULL;
|
||||
|
||||
const char* data = NULL;
|
||||
char line[100];
|
||||
|
||||
double T = 0.0;
|
||||
double Ef = 0.0;
|
||||
double E = 0.0;
|
||||
double dE = 0.0;
|
||||
double kT = 0.0;
|
||||
double Emin = 0.0;
|
||||
double Emax = 0.0;
|
||||
double f = 0.0;
|
||||
|
||||
int err = 0;
|
||||
|
||||
// create a rappture library from the file filePath
|
||||
lib = rpLibrary(argv[1]);
|
||||
|
||||
if (lib == NULL) {
|
||||
// cannot open file or out of memory
|
||||
printf("FAILED creating Rappture Library\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
rpGetString(lib,"input.number(temperature).current",&data);
|
||||
T = rpConvertDbl(data, "K", &err);
|
||||
if (err) {
|
||||
printf ("Error while retrieving input.number(temperature).current\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
rpGetString(lib,"input.number(Ef).current",&data);
|
||||
Ef = rpConvertDbl(data, "eV", &err);
|
||||
if (err) {
|
||||
printf ("Error while retrieving input.number(Ef).current\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
kT = 8.61734e-5 * T;
|
||||
Emin = Ef - 10*kT;
|
||||
Emax = Ef + 10*kT;
|
||||
|
||||
E = Emin;
|
||||
dE = 0.005*(Emax-Emin);
|
||||
|
||||
rpPutString ( lib,
|
||||
"output.curve(f12).about.label",
|
||||
"Fermi-Dirac Factor",
|
||||
RPLIB_OVERWRITE );
|
||||
rpPutString ( lib,
|
||||
"output.curve(f12).xaxis.label",
|
||||
"Fermi-Dirac Factor",
|
||||
RPLIB_OVERWRITE );
|
||||
rpPutString ( lib,
|
||||
"output.curve(f12).yaxis.label",
|
||||
"Energy",
|
||||
RPLIB_OVERWRITE );
|
||||
rpPutString ( lib,
|
||||
"output.curve(f12).yaxis.units",
|
||||
"eV",
|
||||
RPLIB_OVERWRITE );
|
||||
|
||||
int retval = boinc_run_rappture_app("foobar.exe", "-kT 4.3");
|
||||
if (retval == 0) {
|
||||
boinc_finish(0);
|
||||
rpResult(lib);
|
||||
} else {
|
||||
boinc_finish(EXIT_CHILD_FAILED);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue