16 #if defined (__WAT32__)
28 #include <sys/types.h>
32 #if defined(__TURBOC__)
40 #include <iostream.hpp>
41 #define S_IREAD 0000400
42 #define S_IWRITE 0000200
51 int LSEEK(
int,
int,
int);
52 int open(
const char*,
int);
53 int creat(
const char*,
int);
55 int write(
int,
char*,
int);
68 #if defined(__MINGW64__) || (defined(_MSC_VER) && defined(_M_X64))
75 typedef __int64 ssize_t;
80 #define SSIZE_MAX INT_MAX
119 cerr <<
"Memory allocation error in grad_stack constructor\n"
120 <<
" trying to allocate grad_stack_entry[" <<
length <<
"] array.\n";
138 char* path = getenv(
"ADTMP");
140 #if defined(USE_ADPVM)
142 if (path) string_path=path;
156 path=(
char*) string_path;
160 cerr <<
"Wrong number of options to -slave -- must be 1"
161 " you have " << nopt <<
endl;
168 if (path != NULL && strlen(path) <= 45)
170 #if !defined (_WIN32)
200 path = getenv(
"ADTMP1");
201 #if defined(USE_ADPVM)
203 if (path) string_path2=path;
205 path=(
char*) string_path2;
207 if (path != NULL && strlen(path) <= 45)
209 #if !defined (_WIN32)
210 if (strlen(path) > 0)
292 <<
" = " << pos <<
endl;
296 <<
" = " << pos <<
endl;
300 <<
" = " << pos <<
endl;
305 <<
"in grad_stack::~grad_stack().\n";
311 <<
"in grad_stack::~grad_stack().\n";
317 <<
"in grad_stack::~grad_stack().\n";
320 #if !defined (_MSC_VER)
342 cout <<
"Grad_stack size exceeded\n ";
343 cout <<
"Writing to temporary file -- \n";
351 cout <<
"Offset in file before write is " << lpos
352 <<
" bytes from the beginning\n";
364 #if defined(__MINGW64__) || (defined(_WIN64) && defined(_MSC_VER))
365 assert(nbw <= UINT_MAX);
373 assert(nbw <= SSIZE_MAX);
377 if (ierr != (ssize_t)nbw)
379 cout <<
"Wrote " << ierr <<
" not " << nbw <<
endl;
383 assert(offset != -1);
391 #if defined(__MINGW64__) || (defined(_WIN64) && defined(_MSC_VER))
392 assert(nbw <= UINT_MAX);
398 if (ierr != (ssize_t)nbw)
400 perror(
"Error writing to temporary gradient stack file");
402 #if defined(_MSC_VER)
403 cerr <<
" File length: "
407 cerr <<
" Attempting to write " << nbw <<
" bytes; wrote "
415 cout <<
"Wrote " << ierr <<
"bytes into temp. grad. file\n";
418 OFF_T lpos =
LSEEK(gradient_structure::_GRADFILE_PTR,0L,SEEK_CUR);
419 cout <<
"Offset in file after write is " << lpos
420 <<
" bytes from the beginning\n";
434 #if defined (__TURBOC__)
436 O_TRUNC |
O_BINARY, S_IRUSR | S_IWUSR);
438 O_TRUNC |
O_BINARY, S_IRUSR | S_IWUSR);
439 #elif defined (__ZTC__)
441 O_TRUNC , S_IRUSR | S_IWUSR);
443 | O_TRUNC, S_IRUSR | S_IWUSR);
444 #elif defined (__NDPX__)
447 #elif defined (__WAT32__)
449 O_TRUNC |
O_BINARY, S_IRUSR | S_IWUSR);
451 O_TRUNC |
O_BINARY, S_IRUSR | S_IWUSR);
456 O_CREAT | O_TRUNC |
O_BINARY, 0777);
461 ad_printf(
"Error opening temporary gradient file"
468 perror(
"Error opening temporary gradient file");
473 #if defined (__TURBOC__)
476 #elif defined (__ZTC__)
479 #elif defined (__NDPX__)
481 #elif defined (_MSC_VER)
484 #elif defined (__WAT32__)
494 perror(
"Error opening temporary gradient file");
507 cerr <<
"Attempted to open a third gradient file -- There is\n"
508 "probably no more room on the TMP1 (if defined) device\n"
509 "if possible set TMP1 environment string to a device with more room\n";
537 return _GRADFILE_PTR;
556 unsigned int end_buf_size=5000L;
static adpvm_manager * pvm_manager
void set_gbuffer_pointers(void)
Description not yet available.
grad_stack_entry * true_ptr_first
static ofstream * global_logfile
static int no_derivatives
Holds derivative information for arithmetic operators and math library functions. ...
int decrement_current_gradfile_ptr(void)
If there is a previous file set the handle to point to it otherwise return a -1.
void write_grad_stack_buffer()
char * get_gradfile_name()
Description not yet available.
char lastchar(char *)
Description not yet available.
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void create_gradfile()
Description not yet available.
void ad_getcd(const adstring &s)
Description not yet available.
grad_stack_entry * ptr_first
int option_match(int argc, char *argv[], const char *string)
Checks if the program has been invoked with a particular command line argument ("string").
void write(const test_smartlist &, void *, int nsize)
char var_store_file_name[61]
size_t pos(const adstring &substr, const adstring &s)
void fill_ad_random_part(void)
void set_gradient_stack0(void(*func)(void), double *dep_addr)
Description not yet available.
int make_sub_directory(const char *s)
Create a sub directory s.
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
grad_stack_entry * ptr_last
void(* func)(void)
< Pointer to function (if any) to be used for derivative calculation
double * dep_addr
Pointer to dependent variable.
void increment_current_gradfile_ptr(void)
If there is another file set the handle to point to it otherwise we are out of room.
int ad_printf(FILE *stream, const char *format, Args...args)