Commit e9ca49bd authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

libraries compile now - head for test code

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 227
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 616e1047
/* this is <ctime_read.c>
* ----------------------------------------------------------------------------
*
* $Id: ctime_read.c,v 2.0 2000-08-06 12:49:10 thof Exp $
* $Id: ctime_read.c,v 2.1 2000-08-06 14:08:47 thof Exp $
*
* 06/08/2000 by Thomas Forbriger (IfG Stuttgart)
*
......@@ -15,6 +15,7 @@
#include <libtime.h>
#include <string.h>
#include <stdio.h>
int time_read(time_Ts *Date, char *String)
{
......
/* this is <ctime_util_fatal.c>
* ----------------------------------------------------------------------------
*
* $Id: ctime_util_fatal.c,v 2.0 2000-08-06 12:49:10 thof Exp $
* $Id: ctime_util_fatal.c,v 2.1 2000-08-06 14:08:47 thof Exp $
*
* 06/08/2000 by Thomas Forbriger (IfG Stuttgart)
*
......@@ -24,9 +24,9 @@ int time_util_fatal__(char *caller, char *text,
{
int i;
fputs("ERROR (", stderr);
for (i=0; i<caller_len; i++) { fputc(caller++, stderr); }
for (i=0; i<caller_len; i++) { fputc((int)*(caller++), stderr); }
fputs("): ",stderr);
for (i=0; i<text_len; i++) { fputc(text++, stderr); }
for (i=0; i<text_len; i++) { fputc((int)*(text++), stderr); }
fputc('\n', stderr);
abort();
} /* time_util_fatal__ */
......
/* this is <ctime_util_warning.c>
* ----------------------------------------------------------------------------
*
* $Id: ctime_util_warning.c,v 2.0 2000-08-06 12:49:10 thof Exp $
* $Id: ctime_util_warning.c,v 2.1 2000-08-06 14:08:47 thof Exp $
*
* 06/08/2000 by Thomas Forbriger (IfG Stuttgart)
*
......@@ -24,9 +24,9 @@ int time_util_warning__(char *caller, char *text,
{
int i;
fputs("ERROR (", stderr);
for (i=0; i<caller_len; i++) { fputc(caller++, stderr); }
for (i=0; i<caller_len; i++) { fputc((int)*(caller++), stderr); }
fputs("): ",stderr);
for (i=0; i<text_len; i++) { fputc(text++, stderr); }
for (i=0; i<text_len; i++) { fputc((int)*(text++), stderr); }
fputc('\n', stderr);
return 0;
} /* time_util_warning__ */
......@@ -36,9 +36,9 @@ int time_util_warning_n__(char *caller, char *text, integer *n,
{
long int i;
fputs("ERROR (", stderr);
for (i=0; i<caller_len; i++) { fputc(caller++, stderr); }
for (i=0; i<caller_len; i++) { fputc((int)*(caller++), stderr); }
fputs("): ",stderr);
for (i=0; i<text_len; i++) { fputc(text++, stderr); }
for (i=0; i<text_len; i++) { fputc((int)*(text++), stderr); }
i=(int)*n;
fprintf(stderr," %d\n",i);
return 0;
......
#
# this is <Makefile>
# ----------------------------------------------------------------------------
# Makefile for work/src/libs/libtime
#
# $Id: Makefile,v 2.1 2000-08-06 12:00:39 thof Exp $
#
# ($Id: Makefile,v 2.2 2000-08-06 14:08:47 thof Exp $)
#
# 06/08/2000 by Thomas Forbriger (IfG Stuttgart)
#
# how to build all flavours of libtime
#
# REVISIONS and CHANGES
# 06/08/2000 V1.0 Thomas Forbriger
#
# ============================================================================
F2CLIB=-lm -lf2c -L${SERVERLIBDIR}
F2CFLAGS=-f -u
#CC=gcc
CFLAGS=-O2 -I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR}
LIBTIMEOBS=libtime.o clibtime.o timeutil.o
docs: $(DOCS)
CC=gcc
FC=g77
CFLAGS=-O2
CPPFLAGS=-I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR}
%.o: %.f
f2c $(F2CFLAGS) $<
$(CC) $(CFLAGS) $(<:.f=.c) -c
@rm $(<:.f=.c)
clean:
-/bin/rm *.o *.bak
#======================================================================
#
# source code package definitions
# -------------------------------
# the libtime kernel written in FORTRAN
KERNEL=kernel/time_add.f kernel/time_clear.f kernel/time_compare.f \
......@@ -30,8 +33,10 @@ KERNEL=kernel/time_add.f kernel/time_clear.f kernel/time_compare.f \
# language specific code
# FORTRAN
FCODE= kernel/time_sprint.f kernel/time_read.f kernel/time_util_fatal.f \
kernel/time_util_warning.f
FCODE= kernel/time_sprint.f kernel/time_read.f
FHANDLER= kernel/time_util_fatal.f kernel/time_util_warning.f
#----------------------------------------------------------------------
# C
CWRAPPER=Cwrapper/ctime_add.c Cwrapper/ctime_clear.c \
......@@ -41,23 +46,85 @@ CWRAPPER=Cwrapper/ctime_add.c Cwrapper/ctime_clear.c \
Cwrapper/ctime_libversion.c Cwrapper/ctime_mul.c \
Cwrapper/ctime_nfit.c Cwrapper/ctime_norm.c Cwrapper/ctime_setdoy.c \
Cwrapper/ctime_sub.c
CCODE=Cwrapper/ctime_sprint.c Cwrapper/ctime_read.c \
Cwrapper/ctime_util_fatal.c Cwrapper/ctime_util_warning.c
flist: $(KERNEL) $(FCODE) $(CWRAPPER) $(CCODE) $(wildcard Makefile README*)
# language specific code
CCODE= Cwrapper/ctime_sprint.c Cwrapper/ctime_read.c
CHANDLER=Cwrapper/ctime_util_fatal.c Cwrapper/ctime_util_warning.c
#======================================================================
#
# dependencies
# ------------
%.d: %.c
$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
| sed '\''s,\($*\)\.o[ :]*,\1.o $@ : ,g'\'' > $@; \
[ -s $@ ] || rm -f $@'
-include $(patsubst %.c,%.d,$(CWRAPPER) $(CCODE) $(CHANDLER))
#======================================================================
#
# rules
# -----
# how to create object files thorugh f2c
%.o: %.f
f2c $(F2CFLAGS) -d $(@D) $<
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(<:.f=.c) -c
@rm $(<:.f=.c)
# how to create pure f77 object files
%.o77: %.f; $(FC) -c -o $@ $^
# how to build a library
%.a: ; ar rcv $@ $^ ; ranlib $@ ; newlib $@
#======================================================================
#
# misc targets
# ------------
.PHONY: clean edit
clean:
find . \( -name \*.bak -o -name \*.o -o -name \*.o77 -o -name \*.d \) | \
xargs --no-run-if-empty /bin/rm -v
-/bin/rm -v flist libtime.doc
flist: $(KERNEL) $(FCODE) $(CWRAPPER) $(CCODE) $(wildcard Makefile README*) \
timeutil.c timeutil.h libtime.h $(FHANDLER) $(CHANDLER)
echo $^ | tr ' ' '\n' | sort > $@
edit: flist; vim $<
#======================================================================
#
# library dependency definitions
# ------------------------------
# traditional libtime
libtime_trad.a: $(patsubst %.f,%.o,$(KERNEL) $(FCODE) $(FHANDLER)) \
$(patsubst %.c,%.o,$(CWRAPPER) $(CCODE)) timeutil.o
# pure FORTRAN libtime (f2c version)
libtime.a: $(patsubst %.f,%.o,$(KERNEL) $(FCODE) $(FHANDLER))
# pure FORTRAN libtime (f77 version)
libtime77.a: $(patsubst %.f,%.o77,$(KERNEL) $(FCODE) $(FHANDLER))
# pure C libtime
libctime.a: $(patsubst %.f,%.o,$(KERNEL)) \
$(patsubst %.c,%.o,$(CWRAPPER) $(CCODE) $(CHANDLER))
#======================================================================
datatime.o: datatime.c datatime.h
timeutil.o: timeutil.c timeutil.h
clibtime.o: clibtime.c libtime.h
libtime.a: $(LIBTIMEOBS)
ar rcv libtime.a $(LIBTIMEOBS)
ranlib libtime.a
newlib libtime.a
#======================================================================
libtime.doc: libtime.f
extractdoc.tcl libtime.f > libtime.doc
# ----- END OF Makefile -----
c this is <time_compare.f> (extracted from ../libtime.f)
c automatically generated by "SPLITF.PL V1.0 SPLIT Fortran source code"
c----------------------------------------------------------------------
c $Id: time_compare.f,v 2.0 2000-08-05 21:58:30 thof Exp $
c $Id: time_compare.f,v 2.1 2000-08-06 14:08:47 thof Exp $
c
c 05/08/2000 by Thomas Forbriger (IfG Stuttgart)
c
......@@ -46,9 +46,9 @@ c
endif
else
call time_util_warning('time_compare',
& 'do not mix absolute and relative times'
& 'do not mix absolute and relative times')
call time_util_warning('time_compare',
& 'routine skipped... (result=-2)'
& 'routine skipped... (result=-2)')
result=-2
endif
time_compare=result
......
c this is <time_fullyear.f> (extracted from ../libtime.f)
c automatically generated by "SPLITF.PL V1.0 SPLIT Fortran source code"
c----------------------------------------------------------------------
c $Id: time_fullyear.f,v 2.0 2000-08-05 21:58:30 thof Exp $
c $Id: time_fullyear.f,v 2.1 2000-08-06 14:08:47 thof Exp $
c
c 05/08/100 by Thomas Forbriger (IfG Stuttgart)
c
......@@ -28,8 +28,8 @@ c
cE
if (year.lt.70) year=year+2000
if (year.lt.100) year=year+1900
if (year.lt.1970) then
call time_util_warning_n('time_fullyear',
if (year.lt.1970)
& call time_util_warning_n('time_fullyear',
& 'spurious year value: ',year)
return
end
......
c this is <time_setdoy.f> (extracted from ../libtime.f)
c automatically generated by "SPLITF.PL V1.0 SPLIT Fortran source code"
c----------------------------------------------------------------------
c $Id: time_setdoy.f,v 2.0 2000-08-05 21:58:30 thof Exp $
c $Id: time_setdoy.f,v 2.1 2000-08-06 14:08:47 thof Exp $
c
c 05/08/2000 by Thomas Forbriger (IfG Stuttgart)
c
......@@ -56,7 +56,7 @@ c
result=result+days(mon,sel)
mon=mon+1
if (mon.gt.13) call time_util_fatal('time_setdoy',
& 'month value out of range')
& 'month value out of range')
goto 1
2 continue
result=result+day
......
c this is <time_util_warning.f>
c------------------------------------------------------------------------------
c $Id: time_util_warning.f,v 2.0 2000-08-05 21:58:30 thof Exp $
c $Id: time_util_warning.f,v 2.1 2000-08-06 14:08:47 thof Exp $
c
c 05/08/2000 by Thomas Forbriger (IfG Stuttgart)
c
......@@ -47,7 +47,7 @@ c go
print 50,caller(1:index(caller,' ')-1),text,n
c
return
50 format('WARNING (',a,'): ',a,i)
50 format('WARNING (',a,'): ',a,I6)
end
c
c ----- END OF time_util_warning.f -----
/* this is <libtime.h>
* ----------------------------------------------------------------------------
*
* $Id: libtime.h,v 2.0 2000-08-05 20:00:06 thof Exp $
* $Id: libtime.h,v 2.1 2000-08-06 14:08:47 thof Exp $
*
* 12/08/97 by Thomas Forbriger (IfG Stuttgart)
*
......@@ -9,6 +9,7 @@
*
* REVISIONS and CHANGES
* 12/08/97 V1.0 Thomas Forbriger
* 06/08/00 V2.0 do not include f2c - rather copy relevant definitions
*
* ============================================================================
*/
......@@ -16,22 +17,63 @@
#ifndef _TF_LIBTIME_H
#define _TF_LIBTIME_H
#include <f2c.h>
#include <stdio.h>
/* #include <f2c.h> */
/* #include <stdio.h> */
/*
* all f2c stuff that is needed here
* =================================
*/
#ifndef F2C_INCLUDE
/* FORTRAN (f2c) types needed by the wrapper functions */
typedef long int integer;
typedef double doublereal;
typedef long int logical;
typedef long int ftnlen;
#endif
/*
* a few tf-macros needed by the C specific functions
* ==================================================
*/
/* return value of time_read on success */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
/* return value of time_read on failure */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
/* error handling macro used within time_read */
#ifndef RETURNERROR
#define RETURNERROR( EXPR , SUB, STR, CODE )\
if ( EXPR ) { fprintf(stderr, "ERROR (%s):\n %s\n", SUB, STR );\
return(CODE); }
#endif
/*
* some macro constants
* ====================
*/
/* value returned by time_isleapyear in case year IS a leap-year */
#define TIME_ISLEAP (1)
/* value returned by time_isleapyear in case year IS NOT a leap-year */
#define TIME_ISNOTLEAP (0)
/* length of static string buffer in time_sprint */
#define TIME_SLEN (35)
/*
* time data structure
* ===================
*/
/* standard structure to hold date record */
typedef struct {
long int year; /* year (=0 for relative times) */
long int doy; /* day within yaer (may be 0 for relative times */
......@@ -42,14 +84,17 @@ typedef struct {
long int micsec; /* microsecond within millisecond */
} time_Ts;
/* this unios is used to convert date records between different
* representations and language specific functions */
typedef union {
long int array[7];
integer farray[7];
time_Ts s;
long int array[7]; /* linear access in C */
integer farray[7]; /* linear access in FORTRAN */
time_Ts s; /* the structure that is fed in */
} time_Tu;
/*
* prototypes
* wrapper function prototypes
* ===========================
*/
double time_libversion();
......@@ -57,7 +102,6 @@ long int time_isleapyear(long int);
void time_fullyear(long int *);
void time_setdoy(long int, long int, time_Ts *);
void time_getdate(long int*, long int*, time_Ts);
char *time_sprint(time_Ts);
void time_clear(time_Ts *);
void time_norm(time_Ts *);
void time_add(time_Ts, time_Ts, time_Ts *);
......@@ -68,6 +112,13 @@ long int time_compare(time_Ts, time_Ts);
void time_mul(time_Ts, time_Ts *, long int);
void time_div(time_Ts, time_Ts *, long int, long int *);
void time_nfit(time_Ts, time_Ts, long int *, time_Ts *);
/*
* prototypes of pure C functions
* ==============================
*/
char *time_sprint(time_Ts);
int time_read(time_Ts *, char *);
#endif /* _TF_LIBTIME_H */
......
CC=gcc
CFLAGS=-I$(SERVERINCLUDEDIR)
LIBF2C=-lf2c -lm -L$(SERVERLIBDIR)
LIBTF=-ltf -L$(LOCLIBDIR)
F2CFLAGS=-u -f
LIBFLAGS=-L$(LOCLIBDIR) -L$(SERVERLIBDIR) -lf2c -lm
PGPLOTLIB=-lf2cpgplot52 -lX11 -L/usr/X11/lib
.f.o:
f2c $(F2CFLAGS) $<
$(CC) $(CFLAGS) $(<:.f=.c) -c
@rm $(<:.f=.c)
ttime_read: ttime_read.o
gcc $< -o $@ -ltime -ltf $(LIBFLAGS) $(CFLAGS)
testlibtime: testlibtime.o
gcc testlibtime.o -o testlibtime -ltime -ltf $(LIBFLAGS) $(CFLAGS)
guage: guage.o
gcc guage.o -o guage $(LIBFLAGS)
pgpolytest: pgpolytest.o
gcc $< -o $@ -ltf $(PGPLOTLIB) $(LIBFLAGS)
rgbtest: rgbtest.o
gcc $< -o $@ -ltf $(PGPLOTLIB) $(LIBFLAGS)
pgplottest: pgplottest.o
gcc pgplottest.o -o pgplottest -ltf $(PGPLOTLIB) $(LIBFLAGS)
nobuggy: buggytest.o
gcc buggytest.o -o nobuggy $(LIBFLAGS)
fcoltest: fcoltest.o
gcc fcoltest.o -o fcoltest -ltf $(LIBFLAGS)
buggytest: buggytest.o
gcc buggytest.o -o buggytest -lbuggy $(LIBFLAGS)
mkgrdtest: mkgrdtest.o
gcc -o $@ $< $(LIBTF) $(LIBF2C)
/* this is <timeutil.c>
*
* $id:$
* $Id: timeutil.c,v 2.1 2000-08-06 14:08:47 thof Exp $
*
* for manipulating absolute data times
*
......
/* this is <timeutil.h>
*
* $Id: timeutil.h,v 2.0 2000-08-05 20:00:06 thof Exp $
* $Id: timeutil.h,v 2.1 2000-08-06 14:08:47 thof Exp $
*
* this file contains definitions for timeutil.c routines
*
* 25/04/97 Thomas Forbriger (IfG Stuttgart)
*
* This is a pure C pre-version of libtime.f
* By now (5/8/2000) it is still included in libtime.a but provides no extra
* functionality. It may be removed in the future.
*
*/
#ifndef _TF_TIMEUTIL_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment