Commit e5f4769f authored by jclamber's avatar jclamber

update nemolight with NEMO repository at Feb/05/2014

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@183 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 30f95753
......@@ -13,10 +13,11 @@
* 6-apr-01 changed malloc -> calloc pjt
* jan-02 experimenting with exception handling pjt/nas
* 7-sep-05 TOOLBOX benchmark pjt/chapman
* 31-may-07 use size_t to better match malloc() pjt/Pierre Fortin <pierre.fortin@lam.fr>
* 31-may-07 use size_t to better match malloc() pjt/Pierre Fortin <pierre.fortin@oamp.fr>
* 12-jun-08 allocate_FL etc, see stdinc.h WD
* 12-jun-08 removed tests for size_t < 0 WD
* 03-oct-08 debugged error in debug_info reporting WD
* 4-jan-11 add local/static arrays to show where they go in the TESTBED version
*/
#include <stdinc.h>
......@@ -94,12 +95,16 @@ string defv[] = {
"big1=100\n Allocate the product of these two",
"big2=100\n Allocate the product of these two",
"doubling=f\n Doubling the big1*big2 allocation until failure",
"VERSION=2.0\n 4-jul-2010 PJT",
"VERSION=2.1\n 4-jan-2011 PJT",
NULL,
};
string usage = "(re)allocate benchmark";
#define MAXTEST 128
static int test1[MAXTEST];
void nemo_main(void) {
int size, size0 = getiparam("size")*1024;
int nalloc = getiparam("nalloc");
......@@ -112,9 +117,16 @@ void nemo_main(void) {
size_t big64 = (size_t)big1*(size_t)big2; /* this is crucial to cast */
size_t i64;
int i;
int test2[MAXTEST];
static int test3[MAXTEST];
bool Qdouble = getbparam("doubling");
char *data;
nemo_dprintf(0,"static test1 @ %p\n",test1);
nemo_dprintf(0," test2 @ %p\n",test2);
nemo_dprintf(0,"static test3 @ %p\n",test3);
nemo_dprintf(0," Alloc: %d * %d bytes\n",nalloc,size0);
nemo_dprintf(0,"ReAlloc: %d * %d bytes\n",nrealloc,incr);
......
......@@ -29,15 +29,38 @@
* 12-sep-01 file_size
* 30-sep-03 testing memcpy, and improved the testing
* 20-sep-05 little and big endian versions
* 14-may-12 optionally use the ffswapX routines from cfitsio
*/
//#define HAVE_CFITSIO
//#define HAVE_FFSWAP
#include <stdinc.h>
#if defined(HAVE_CFITSIO)
#include "fitsio2.h"
#endif
void bswap(void *vdat, int len, int cnt)
{
char tmp, *dat = (char *) vdat;
int k;
#if defined(HAVE_FFSWAP)
if (len==1)
return;
else if (len==2)
ffswap2((short int *)dat,cnt);
else if (len==4)
ffswap4((int *) dat,cnt);
else if (len==8)
ffswap8((double *)dat,cnt);
else { /* the general SLOOOOOOOOOWE case; should never happen */
for(k=0; k<len/2; k++) {
tmp = dat[k];
dat[k] = dat[len-1-k];
dat[len-1-k] = tmp;
}
}
#else
if (len==1)
return;
else if (len==2)
......@@ -66,6 +89,7 @@ void bswap(void *vdat, int len, int cnt)
dat[len-1-k] = tmp;
}
}
#endif
}
/*
......@@ -103,11 +127,17 @@ string defv[] = {
"endian=\n assume 'Little' (l) or 'Big' (b) endian input file",
"memcpy=f\n Testing swapping double another way with memcpy",
"repeat=0\n How many times to repeat the swapping (speed testing)",
"VERSION=1.6\n 20-sep-05 PJT",
"VERSION=2.0\n 14-may-2012 PJT",
NULL,
};
string usage="swap bytes in a file";
#if defined(HAVE_FFSWAP)
string usage="swap bytes in a file - fast";
#else
string usage="swap bytes in a file - generic";
#endif
string cvsid="$Id: bswap.c,v 1.7 2013/10/24 03:34:18 pteuben Exp $";
extern int nemo_file_size(string);
......@@ -141,6 +171,10 @@ void nemo_main(void)
bool Qmemcpy = getbparam("memcpy");
bswap_proc bptr;
#if defined(HAVE_FFSWAP)
dprintf(1,"FFSWAP enabled\n");
#endif
fname = getparam("in");
len = getiparam("len");
offset = getiparam("offset");
......
/* ================================================================
| Copyright Jean-Charles LAMBERT - 2005
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS UMR 7326
| CNRS U.M.R 6110
| =================================================================
|* Keep track of open/close files
+---------------------------------------------------------------- */
......
/* ================================================================
| Copyright Jean-Charles LAMBERT - 2005
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS U.M.R 7326
| CNRS U.M.R 6110
| =================================================================
|* Keep track of open/close files
+---------------------------------------------------------------- */
......
/* =================================================================
| Copyright Jean-Charles LAMBERT - 2005
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS UMR 7326
| CNRS U.M.R 6110
| ==================================================================
|* Dummy function, do nothing, used to create useless libio_nemo.a
+---------------------------------------------------------------- */
......
......@@ -40,7 +40,7 @@ string defv[] = {
string usage="display endianism (1=big, like G5,Sparc 0=little, like i386)";
string cvsid="$Id: endian.c,v 1.4 2010/10/25 10:48:48 jcl Exp $";
string cvsid="$Id: endian.c,v 1.4 2006/08/06 00:08:12 pteuben Exp $";
void nemo_main()
{
......
/*++
/* NAME
/* error 3
/* SUMMARY
/* diagnostics
/* PACKAGE
/* unproto
/* SYNOPSIS
/* #include "error.h"
/*
* ERROR: scream (on stderr) and die (quickly?).
* WARNING: scream (on stderr)
* RECOVER: set a recover() function when error() called
* STOP: exit to system with proper shell status (does not return)
*
* See: dprintf() for a similar teachnique that issues a
* warning message and then continues.
*
* xx-xxx-86 - origal program for Nemo JEB
* xx-xxx-88 - proper <varargs.h>
* 12-sep-90 - first merged NEMO and Starlab program PJT
* 16-nov-90 - no #ifdef MICRO anymore PJT
* 22-mar-91 - ERROR env.var. introduced - via stop() PJT
* 8-jul-91 V1.2 using vfprintf() pjt
* 12-oct-91 - added __BORLANDC__ to the vfprintf() users pjt
* 25-feb-92 made all of them void'd pjt
* 6-apr-93 V1.3 moved stop() in here, plus local data pjt
* 20-sep-93 V1.4 ansi requires > 0 named arguments pjt
* 26-feb-94 V1.5 keep old <varags> code around too pjt
* 21-mar-01 V1.6 removed old <varargs> code, only allow ANSI compilers PJT
* 28-nov-01 V1.7 allow to set an exit level pjt
* 8-dec-01 V1.8 added errno reporting pjt
* 16-jan-01 V1.8a calling abort() will be announced pjt
* 13-feb-03 V1.8b revoking errno reporting pjt
* 06-jun-08 V1.8c nemo_exit wd
* 12-jun-08 V1.8d report MPI proc wd
* 16-sep-08 V1.8e removed nemo_exit (see stdinc.h) wd
*/
#include <stdinc.h>
#include <getparam.h>
#include <stdarg.h>
#include <errno.h>
extern int debug_level; /* see also user interface getparam.c for this */
int error_level = 0; /* yuck, but this needs to be globally visible */
local proc cleanup=NULL; /* if not NULL this points to error cleanup proc */
local int error_count=0;
local int exit_level=0;
local int last_errno=0;
static void report_errno(void)
{
#if 0
/* something wrong here, this thing is lying half the time */
if (errno)
fprintf(stderr,"### Fatal errno %d errmsg=%s\n",
errno, strerror(errno));
#endif
}
/*
* commented out WD 10-09-2008, also in stdinc.h
void errorn(string fmt, ...)
{
error("errorn is sadly not implemented; use debug>0 to get errno messages");
}
*/
/* Start changes WD 12/06/2008 */
extern bool mpi_proc; /* dprintf.c */
extern int mpi_rank; /* dprintf.c */
/* End changes WD 12/06/2008 */
void error(string fmt, ...)
{
va_list ap;
report_errno();
fprintf(stderr,"### Fatal error [%s]: ",getargv0()); /* report name */
/* Start changes WD 12/06/2008 */
if(mpi_proc)
fprintf(stderr,"@%d: ",mpi_rank);
/* End changes WD 12/06/2008 */
va_start(ap, fmt); /* ap starts with string 'fmt' */
#if defined(NEED_DOPRNT)
_doprnt(fmt, ap, stderr); /* print out on stderr */
#else
vfprintf(stderr, fmt, ap); /* print out on stderr */
#endif
if (fmt[strlen(fmt)-1] != '\n') /* be nice if no newline supplied */
fprintf(stderr,"\n"); /* and print it anyhow */
fflush(stderr); /* flush it NOW */
va_end(ap); /* end varargs */
if (cleanup==NULL){ /* if no cleanup set */
if (debug_level>5) { /* produce coredump if requested */
fprintf(stderr,"Now aborting....\n");
fflush(stderr);
abort();
}
if (exit_level)
stop(exit_level);
else
stop(-1); /* close the shop and pass this to parent */
} else { /* else say so : */
fprintf(stderr,"### Recoverable error ....\n");
(*cleanup)(); /* clean up */
} /* and proceed as if nothing happened */
}
/* int errcount;
/*
/* void error(text)
/* char *text;
/*
/* void error_where(path, line, text)
/* char *path;
/* int line;
/* char *text;
/*
/* void fatal(text)
/* char *text;
/* DESCRIPTION
/* The routines in this file print a diagnostic (text). Some also
/* terminate the program. Upon each error*() call, the errcount variable
/* is incremented.
/*
/* error() provides a default context, i.e. the source-file
/* coordinate of the last read token.
/*
/* error_where() allows the caller to explicitly specify context: path
/* is a source-file name, and line is a line number.
/*
/* fatal() is like error() but terminates the program with a non-zero
/* exit status.
/*
/* context is ignored if the line number is zero or if the path
/* is an empty string.
/* AUTHOR(S)
/* Wietse Venema
/* Eindhoven University of Technology
/* Department of Mathematics and Computer Science
/* Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
/* LAST MODIFICATION
/* 92/01/15 21:53:10
/* VERSION/RELEASE
/* 1.2
/*--*/
void fatal(string fmt, ...)
{
va_list ap;
report_errno();
fprintf(stderr,"### Fatal error [%s]: ",getargv0()); /* report name */
va_start(ap, fmt); /* ap starts with string 'fmt' */
#if defined(NEED_DOPRNT)
_doprnt(fmt, ap, stderr); /* print out on stderr */
#else
vfprintf(stderr, fmt, ap); /* print out on stderr */
#endif
if (fmt[strlen(fmt)-1] != '\n') /* be nice if no newline supplied */
fprintf(stderr,"\n"); /* and print it anyhow */
fflush(stderr); /* flush it NOW */
va_end(ap); /* end varargs */
fprintf(stderr,"Now aborting....\n");
fflush(stderr);
abort(); /* nasty, but writes a core dump and dies */
}
static char error_sccsid[] = "@(#) error.c 1.2 92/01/15 21:53:10";
void warning(string fmt, ...)
{
va_list ap;
/* C library */
fprintf(stderr,"### Warning [%s]: ",getargv0()); /* report name */
#include <stdio.h>
/* Start changes WD 12/06/2008 */
if(mpi_proc)
fprintf(stderr,"@%d: ",mpi_rank);
/* End changes WD 12/06/2008 */
extern void exit();
va_start(ap, fmt); /* ap starts with string 'fmt' */
/* Application-specific stuff */
#if defined(NEED_DOPRNT)
_doprnt(fmt, ap, stderr); /* print out on stderr */
#else
vfprintf(stderr, fmt, ap); /* print out on stderr */
#endif
#include "token.h"
#include "error.h"
if (fmt[strlen(fmt)-1] != '\n') /* be nice if no newline supplied */
fprintf(stderr,"\n"); /* and print it anyhow */
fflush(stderr); /* flush it NOW */
va_end(ap); /* end varargs */
}
int errcount = 0; /* error counter */
/* error - report problem (implicit context) */
void recover(proc cl)
void error(text)
char *text;
{
if (cl)
dprintf(1,"Setting recoverable error\n");
else
dprintf(1,"Resetting recoverable error\n");
cleanup = cl;
error_where(in_path, in_line, text);
}
/* error_where - report problem (explicit context) */
void stop(int lev)
{
if (lev<0)
if (error_count++ < error_level) {
warning("[%d/%d] error ignored",error_count,error_level);
return;
}
finiparam();
exit(lev);
/*NOTREACHED*/
}
void set_exit_level(int lev)
void error_where(path, line, text)
char *path;
int line;
char *text;
{
exit_level = lev;
}
errcount++;
/* Suppress context info if there is none. */
#ifdef TESTBED
string defv[]={
"recover=f\n Try a recoverable error",
"count=1\n Loopcount calling error",
"VERSION=1.5\n 26-feb-94 PJT",
NULL,
};
if (line && path[0])
fprintf(stderr, "%s, line %d: ", path, line);
nemo_main()
{
int fun(), n;
if (getbparam("recover"))
recover( (proc) fun );
n = getiparam("count");
while(n-- > 0)
error("error: foo=%f bar=%d fum=\"%s\"", 3.1415, 32768, "waldo");
fprintf(stderr, "%s\n", text);
}
fun()
/* fatal - report problem and terminate unsuccessfully */
void fatal(text)
char *text;
{
printf("Fun Fun Fun - a recoverable error occurred\n");
error(text);
exit(1);
}
#endif
......@@ -6,7 +6,7 @@
* minor differences in the implementation that result in
* a difference in capabilities, e.g. ZENO can handle
* multiple same-named items within a set, whereas NEMO
* cannot
* cannot (yet)
*
* Input is done through: Output through:
* fread() fwrite()
......@@ -36,9 +36,10 @@
* 18-jun-03 pjt <docs>
* V 3.1 15-mar-05 pjt C++ compilable
* V 3.2 2-jun-05 pjt blocked (sequential) I/O
* V 3.3 25-may-07 pjt handle > 2GB objects in memory (Pierre Fortin <pierre.fortin@lam.fr>)
* V 3.3 25-may-07 pjt handle > 2GB objects in memory (Pierre Fortin <pierre.fortin@oamp.fr>)
* V 3.4 12-dec-09 pjt support the new halfp type for I/O (see also csf)
* 27-Sep-10 jcl MINGW32/WINDOWS support
* 3.5 8-jun-13 pjt eltcnt type fixed for 64bit so it handles > 2B
*
* Although the SWAP test is done on input for every item - for deferred
* input it may fail if in the mean time another file was read which was
......@@ -1324,13 +1325,15 @@ local void safeseek(
/*
* ELTCNT: compute number of basic elements in subspace of item.
* @todo: long vs. size_t
*/
local int eltcnt(
local long eltcnt(
itemptr ipt, /* pointer to item w/ possible vector dims */
int skp) /* num of dims to skip, starting with dimN */
{
register int prod, *ip;
register int *ip;
register long prod;
prod = 1; /* scalers have one */
if (ItemDim(ipt) != NULL) { /* a vectorized item? */
......@@ -1338,7 +1341,7 @@ local int eltcnt(
if (--skp < 0) /* past 1st skp dims? */
prod *= *ip; /* include this dim */
}
return (prod); /* return product of dims */
return prod; /* return product of dims */
}
/*
......
/* =================================================================
| Copyright Jean-Charles LAMBERT - 2005
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS U.M.R 7326
| CNRS U.M.R 6110
| ==================================================================
|* Flags data imported from [io_init.c]
+---------------------------------------------------------------- */
......
/* ================================================================
| Copyright Jean-Charles LAMBERT - 2008
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS UMR 7326
| CNRS U.M.R 6110
| =================================================================
|* Wrapper of basic NEMO procedure, it makes me life easiest :)
+---------------------------------------------------------------- */
......
/* ================================================================
| Copyright Jean-Charles LAMBERT - 2008
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS U.M.R 7326
| CNRS U.M.R 6110
| =================================================================
|* Wrapper of basic NEMO procedure, it makes me life easiest :)
+---------------------------------------------------------------- */
......
......@@ -134,6 +134,7 @@
* 27-Sep-10 JCL c MINGW32/WINDOWS support
* 20-Nov-10 WD d import environ on darwin (so allow dynamic lib)
* 29-sep-11 PJT e new system keyword np= for OpenMP (and later others?)
* 3-feb-14 PJT f fixed bug when using long filenames
TODO:
- what if there is no VERSION=
......@@ -177,7 +178,7 @@
opag http://www.zero-based.org/software/opag/
*/
#define GETPARAM_VERSION_ID "3.6e 29-sep-2011 PJT"
#define GETPARAM_VERSION_ID "3.6f 31-jan-2013 PJT"
/*************** BEGIN CONFIGURATION TABLE *********************/
......@@ -545,7 +546,7 @@ void initparam(string argv[], string defv[])
free(keys[j].val);
keys[j].val = scopy(parvalue(argv[i])); /* get value */
keys[j].count++;
} else if (j=set_indexed(name,&idx)) { /* enter indexed keywords */
} else if (j=set_indexed(name,&idx)) { /* enter indexed keywords */
// process this indexed keyword
#if 1
addindexed(j,argv[i],idx);
......@@ -928,6 +929,7 @@ local void scan_environment()
"scan_environment: debug=%d yapp=%d help=%d history=%d review=%d error=%d\n",
debug_level, yapp_dev, help_level, nemo_history, review_flag, error_level);
dprintf(5,"date_id = %s\n",date_id());
dprintf(5,"MAXBUF = %d\n",MAXBUF);
#if defined(INTERACT)
if ((ev=getenv("NEMODEF")) != NULL) {
strcpy (key_filename,ev);
......@@ -1467,7 +1469,6 @@ bool updparam(string name)
int getparamstat(string name) {
error("getparamstat is a ZENO feature, not implemented in NEMO yet");
return 0;
}
......@@ -1967,11 +1968,12 @@ local void beep()
/*
* PARNAME: extract name from name=value string.
* W A R N I N G : returns ptr to static storage, that may also be empty
* also: values that are > MAXBUF will fail
*/
local string parname(string arg)
{
permanent char namebuf[64];
permanent char namebuf[MAXBUF];
char *ap, *np;
ap = (char *) arg;
......@@ -2947,10 +2949,11 @@ string defv[] = {
"foobar=12345\n just some digits",
"donot=read\n check if complains about never read params",
"prompt=t\n Checking interactive prompting routines?",
"verbiage=foobar\n Random verbiage",
#ifdef INDEXED
"naxis#=\n testing an indexed keyword",
#endif
"VERSION=1.4\n 16-sep-01 PJT",
"VERSION=1.5\n 31-jan-2014 PJT",
NULL,
};
......@@ -2963,7 +2966,7 @@ void nemo_main(void)
bool flag2, prompt;
double tstop;
int i, n, my_argc;
string *my_argv;
string *my_argv, verbiage;
my_argv = getargv(&my_argc);
if (my_argc) {
......@@ -2980,6 +2983,7 @@ void nemo_main(void)
check("tstop");
check("foobar");
check("prompt");
check("verbiage");
dprintf(0,"debug level 0 printout\n");
dprintf(1,"debug level 1 printout\n");
......@@ -2997,6 +3001,7 @@ void nemo_main(void)
#endif
verbiage = getparam("verbiage");
flag2 = getbparam("flag2");
tstop = getdparam("tstop");
......
......@@ -51,10 +51,10 @@
# define MAXHIST 1024 /* max size of history array */
#endif
local int nhist = 0; /* count history data stored so far */
local int nhist = 0; /* count history data stored so far */
local string histbuf[MAXHIST+1]; /* history string array */
local string headline = NULL; /* last headline read in */
local bool freeup[MAXHIST+1]; /* if space should be free'd */
local bool freeup[MAXHIST+1]; /* if space should be free'd */
int nemo_history = 1; /* 1=history is auto-mode 0=no history done */
/* this item should eventually disappear */
......
/* =================================================================
| Copyright Jean-Charles LAMBERT - 2005
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS U.M.R 7326
| CNRS U.M.R 6110
| ==================================================================
|* Keep track of the history (declared in [io_nemo.c])
+----------------------------------------------------------------- */
......
/* =================================================================
| Copyright Jean-Charles LAMBERT - 2005
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS U.M.R 7326
| CNRS U.M.R 6110
| ==================================================================
|* Keep track of the history (declared in [io_nemo_f.c])
+----------------------------------------------------------------- */
......
......@@ -6,8 +6,7 @@
* jan-2002 added ZENO compatible ones
* nov-2003 removed Yanc tags (YANC is also called gyrfalcON now)
* feb-2004 added some new SPH stuff (GasDensity, NPartners, NSPHPartners)
* may-2014
// Centre de donneeS Astrophysiques de Marseille (CeSAM) added in a few tag from atos.c for handling its' SPH
* may-2010 added in a few tag from atos.c for handling its' SPH
*/
#ifndef _snapshot_h
......
/* =================================================================
| Copyright Jean-Charles LAMBERT - 2008
| e-mail: Jean-Charles.Lambert@lam.fr
| e-mail: Jean-Charles.Lambert@oamp.fr
| address: Dynamique des galaxies
| Laboratoire d'Astrophysique de Marseille
| 2, place Le Verrier
| 13248 Marseille Cedex 4, France
| CNRS UMR 7326
| CNRS U.M.R 6110
| ==================================================================
|* Get/Put selected Data from io_nemo
| ==================================================================
......@@ -44,7 +44,7 @@
#define TIMEFUZZ 0.0000001
extern int maxbodies[];