2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-06-15 09:11:08 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// 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.
|
2004-06-15 09:11:08 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2004-06-15 09:11:08 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2004-06-15 09:11:08 +00:00
|
|
|
|
|
|
|
// This file defines a Fortran wrapper to the BOINC API.
|
|
|
|
|
2005-04-15 22:38:22 +00:00
|
|
|
// Define this symbol (here or in Makefile) if you want graphics functions
|
|
|
|
//#define GRAPHICS
|
|
|
|
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2005-04-15 22:38:22 +00:00
|
|
|
#include "util.h"
|
2004-06-15 09:11:08 +00:00
|
|
|
#include "boinc_api.h"
|
2005-04-15 22:38:22 +00:00
|
|
|
#ifdef GRAPHICS
|
2004-08-09 09:58:14 +00:00
|
|
|
#include "graphics_api.h"
|
2005-04-15 22:38:22 +00:00
|
|
|
#endif
|
2006-01-25 05:10:29 +00:00
|
|
|
#include "boinc_zip.h"
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2005-04-15 22:38:22 +00:00
|
|
|
// helper class that makes a C-string from a character array and length,
|
|
|
|
// automatically deleted on destruction.
|
2004-06-15 09:11:08 +00:00
|
|
|
// Fortran strings are passed as character array plus length
|
2005-04-15 22:38:22 +00:00
|
|
|
//
|
|
|
|
class STRING_FROM_FORTRAN {
|
2004-06-15 09:11:08 +00:00
|
|
|
char* p;
|
|
|
|
public:
|
2005-04-15 22:38:22 +00:00
|
|
|
STRING_FROM_FORTRAN(const char* s, int s_len) {
|
2004-06-15 09:11:08 +00:00
|
|
|
p = new char[s_len + 1];
|
|
|
|
memcpy(p, s, s_len);
|
|
|
|
p[s_len] = 0;
|
|
|
|
}
|
2005-04-15 22:38:22 +00:00
|
|
|
~STRING_FROM_FORTRAN() { delete [] p; }
|
|
|
|
void strip_whitespace() {
|
|
|
|
::strip_whitespace(p);
|
|
|
|
}
|
|
|
|
const char* c_str() { return p; }
|
2004-06-15 09:11:08 +00:00
|
|
|
};
|
|
|
|
|
2005-04-15 22:38:22 +00:00
|
|
|
// remove terminating null and pad with blanks a la FORTRAN
|
|
|
|
//
|
|
|
|
static void string_to_fortran(char* p, int len) {
|
|
|
|
for (int i=strlen(p); i<len; i++) {
|
|
|
|
p[i] = ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-15 09:11:08 +00:00
|
|
|
extern "C" {
|
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_init_() {
|
|
|
|
boinc_init();
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_finish_(int* status) {
|
|
|
|
boinc_finish(*status);
|
|
|
|
}
|
2004-08-09 09:58:14 +00:00
|
|
|
|
2005-04-15 22:38:22 +00:00
|
|
|
#ifdef GRAPHICS
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_init_graphics_(){
|
|
|
|
boinc_init_graphics();
|
|
|
|
}
|
2005-04-15 22:38:22 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_finish_graphics_(){
|
|
|
|
boinc_finish_graphics();
|
|
|
|
}
|
2005-04-15 22:38:22 +00:00
|
|
|
#endif
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_is_standalone_(int* result) {
|
|
|
|
*result = boinc_is_standalone();
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boincrf_(const char* s, char* t, int s_len, int t_len) {
|
|
|
|
STRING_FROM_FORTRAN sff(s, s_len);
|
|
|
|
sff.strip_whitespace();
|
|
|
|
boinc_resolve_filename(sff.c_str(), t, t_len);
|
|
|
|
string_to_fortran(t, t_len);
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_parse_init_data_file_() {
|
|
|
|
boinc_parse_init_data_file();
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_write_init_data_file_() {
|
|
|
|
boinc_write_init_data_file();
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_time_to_checkpoint_(int* result) {
|
|
|
|
*result = boinc_time_to_checkpoint();
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_checkpoint_completed_() {
|
|
|
|
boinc_checkpoint_completed();
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_fraction_done_(double* d) {
|
|
|
|
boinc_fraction_done(*d);
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_wu_cpu_time_(double* d_out) {
|
|
|
|
boinc_wu_cpu_time(*d_out);
|
|
|
|
}
|
2004-06-15 09:11:08 +00:00
|
|
|
|
2006-01-25 05:10:29 +00:00
|
|
|
void boinc_calling_thread_cpu_time_(double* d) {
|
|
|
|
boinc_calling_thread_cpu_time(*d);
|
2004-06-15 09:11:08 +00:00
|
|
|
}
|
|
|
|
|
2006-01-28 00:17:26 +00:00
|
|
|
void boinc_zip_(int* zipmode, const char* zipfile,
|
|
|
|
const char* path, int zipfile_len, int path_len
|
2006-01-25 05:10:29 +00:00
|
|
|
) {
|
2006-01-28 00:17:26 +00:00
|
|
|
//zipmode = 0 to unzip or 1 to zip. FORTRAN variable of type INTEGER.
|
|
|
|
//zipfile, path = FORTRAN variables of type CHARACTER.
|
|
|
|
STRING_FROM_FORTRAN zipfileff(zipfile, zipfile_len);
|
|
|
|
STRING_FROM_FORTRAN pathff(path, path_len);
|
|
|
|
zipfileff.strip_whitespace();
|
|
|
|
pathff.strip_whitespace();
|
|
|
|
boinc_zip(*zipmode,zipfileff.c_str(),pathff.c_str());
|
2006-01-25 05:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // extern "C"
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_4f5153609c = "$Id$";
|