Subject: Re: Tecplot, etc.
From: Polyhedron Software
Date: Thu, 19 Sep 1996 17:21:58 +0100
In article <323EFF92.41C6@flow.mit.edu>, Joe Curran
writes
>Does anyone out there know of a good site for information about
>linking Tecplot to Fortran 77 programs, or how to create binary
>data files directly by F77 to be read real-time into Tecplot during
>a run?
>If anyone has any personal information/experience, that would be
>appreciated as well.
>Thank you.
>
Appendix D of the Tecplot manual contains information on using Tecplot
with fortran using the tecutil.a Unix library.
For users with PCs, Amtec has a file called User.doc on their ftp site,
which contains the (C) source for the above, plus some extra functions
undocumented in the manual, along with a fortran example/test program. I
append this below.
Mark Williams
--
Sales Dept. Sales@polyhdrn.demon.co.uk
Polyhedron Software Ltd.
Programs for Programmers - QA, Compilers, Graphics
************ Visit our Web site on http://www.polyhedron.co.uk/ ************
USER.DOC
This document has 6 parts
1. Introduction.
2. Instructions.
3. Makefile for compiling a test program.
4. c source code for utility functions to create binary tecplot
datafiles.
5. FORTRAN test program.
6. Detailed notes on new utility functions.
------------------------------------------------ PART 1. Introduction
These new TECXXX routines replace the TECXXX routines contained in
the tecutil.a library you received with tecplot. The documentation
in the users manual is still valid and correct - new functionality
has been added without compromising the syntax and calling sequence
described in the users manual.
The following Utilities have been added:
TECFIL....... This function allows you to write to multiple files
at the same time.
TECTXT....... Write a text record to the file.
TECGEO....... Write a geometry record to the file.
TECLAB....... Write a custom axis label record.
Detailed notes on these functions are at the bottom of this
document.
------------------------------------------------ PART 2. Instructions
1. Separate out parts 3,4, and 5 from this document. Name
them accordingly.
2. Edit the file "Makefile" and follow instructions there.
3. run make by typing:
make
This will create a test program.
4. To run the test program type:
./test
This will create a file called "t.plt" and a file called td.plt.
These files are binary datafiles in ieee format for use on
most unix workstations.
5. To incorporate the new set of TECXXX routines in your
application use preutil.o (created by running make in step
3) instead of tecutil.a when linking your application.
------------------------------------------------ PART 3. Makefile.
##
## Comment or uncomment the appropriate set of variable defines below.
##
## Cray ##
#FCOMPILER=cf77
#CFLAGS=-DCRAYB
##########
## Sun ##
FCOMPILER=f77
CFLAGS=-DSUN
##########
## HP ##
#FCOMPILER=f77
#CFLAGS=-DHP
##########
## DEC ##
#FCOMPILER=f77
#CFLAGS=-DDEC
##########
## DEC ALPHA ##
#FCOMPILER=f77
#CFLAGS=-DDECALPHA
##########
## SGI ##
#FCOMPILER=f77
#CFLAGS=-DIRIS
##########
## IBM-RS6000 ##
#FCOMPILER=f77
#CFLAGS=-DIBM6K
##########
test : preutil.o test.o
$(FCOMPILER) test.o preutil.o -o test
test.o : test.f
$(FCOMPILER) -c test.f
preutil.o : preutil.c
cc -c $(CFLAGS) preutil.c
------------------------------------------------ PART 4. preutil.c
/*
* Revision History
*
* 10/06/94 - Added TECFIL routine.
* 03/21/94 - Added TECTXT, TECGEO, and TECLAB routines
* 03/23/94 - Fixed for SUN compiler.
*
*/
#include
#include
#include
/* GLOBAL */
#if defined (DOS)
#include
#endif
#if defined IRIS3000
#define IRIS
#endif
#if defined DECALPHA
#define DEC
#endif
#if !defined CRAYB
#if defined IRIS ||\
defined SUN ||\
defined STARDENT ||\
defined DEC
#define TECINI tecini_
#define TECZNE teczne_
#define TECDAT tecdat_
#define TECNOD tecnod_
#define TECGEO tecgeo_
#define TECTXT tectxt_
#define TECLAB teclab_
#define TECFIL tecfil_
#define TECEND tecend_
#else
#define TECINI tecini
#define TECZNE teczne
#define TECDAT tecdat
#define TECNOD tecnod
#define TECGEO tecgeo
#define TECTXT tectxt
#define TECLAB teclab
#define TECFIL tecfil
#define TECEND tecend
#endif
#endif
#define round2(X) ((X) >= 0 ? ((LgIndex)(X+0.49)) : ((LgIndex)(X-0.49)))
#define Version 6.3
typedef enum { GridMode,
WindowMode,
LogMode,
ScreenMode } CoordModeType;
typedef enum { SolidLine,
DashedLine,
DashDotLine,
DottedLine,
LongDashLine,
DashDotDotLine } LineType;
typedef enum { G_LineSegs,
G_Rectangle,
G_Circle,
G_Ellipse,
G_3DLineSegs} GeometryType;
typedef enum { NoTextBox,
HollowTextBox,
FilledTextBox } TextBoxType;
typedef enum { F_Helv,
F_HelvBold,
F_Greek,
F_Math,
F_UserDef,
F_Times,
F_TimesItalic,
F_TimesBold,
F_TimesItalicBold,
F_Courier,
F_CourierBold } FontType;
typedef enum { S_Global,
S_Local } ScopeType;
typedef enum FormatType {BLOCK,POINT,FEBLOCK,FEPOINT} FormatType;
#if defined DECALPHA
typedef int LgIndex;
#else
typedef long int LgIndex;
#endif
typedef char *FNameType;
typedef FILE *FilePtr;
#define ZoneMarker 299.0
#define GeomMarker 399.0
#define TextMarker 499.0
#define CustomLabelMarker 599.0
#define EndHeaderMarker 357.0
#define MaxNumFiles 10
#define MaxChrsVarName 32
#define MaxChrsZneName 32
static LgIndex DoDebug[MaxNumFiles] = {0,0,0,0,0,0,0,0,0,0};
static int IsOpen[MaxNumFiles] = {0,0,0,0,0,0,0,0,0,0};
static LgIndex NumVars[MaxNumFiles];
static FNameType DestFName[MaxNumFiles];
static FNameType BlckFName[MaxNumFiles];
static FilePtr BlckFile[MaxNumFiles];
static FilePtr HeadFile[MaxNumFiles];
static FormatType ZoneFormat[MaxNumFiles];
static LgIndex IMax[MaxNumFiles];
static LgIndex JMax[MaxNumFiles];
static LgIndex KMax[MaxNumFiles];
static int NumIndicies[MaxNumFiles];
static LgIndex DataCount[MaxNumFiles];
static int CurZone[MaxNumFiles];
static int CurFile = -1;
#ifndef CRAYB
static void WriteI(F,I)
FILE *F;
LgIndex *I;
{
fwrite(I,4,1,F);
}
#endif
#if defined CRAYB
void WriteI(F,I)
FILE *F;
float *I;
{
char Int4Buffer[8];
int i = 1;
int type = 1;
int bitoff = 0;
CRAY2IEG(&type;,&i;,Int4Buffer,&bitoff;,I);
fwrite(Int4Buffer,4,1,F);
}
#endif
#ifndef CRAYB
static void WriteR(F,R)
FILE *F;
float *R;
{
int i;
char bufr[4];
#ifndef CONVEX
char *buf = (char *)R;
#endif
#if defined CONVEX
float RR;
char *buf = (char *)&RR;
RR = (float)dcvtid((double)*R); /* Must use the Double precision
version due to bug in single.
*/
#endif
fwrite(buf,4,1,F);
}
#endif
#if defined CRAYB
static void WriteR(F,R)
FILE *F;
float *R;
{
float RR = *R;
char Real4Buffer[8];
char bufr[4];
int i = 1;
int type = 2;
int bitoff = 0;
if ((RR > -1.0E-36) && (RR < 1.0E-36))
RR = 0.0;
else if (RR > 1.0E36)
RR = 1.0E36;
else if (RR < -1.0E36)
RR = -1.0E36;
CRAY2IEG(&type;,&i;,Real4Buffer,&bitoff;,&RR;);
fwrite(Real4Buffer,4,1,F);
}
#endif
static void WriteN(F,R)
FILE *F;
float R;
{
float RR;
RR = R;
WriteR(F,&RR;);
}
static void WriteS(F,S)
FILE *F;
char *S;
{
char *CPtr = S;
while (*CPtr)
{
WriteN(F,(float)*CPtr);
CPtr++;
}
WriteN(F,(float)0);
}
int TECINI(Title,Variables,FName,ScratchDir,Debug)
char *Title;
char *Variables;
char *FName;
char *ScratchDir;
int *Debug;
{
int I,L;
char RName[10];
char *CPtr;
int IsOk = 1;
int NewFile = -1;
for (I = 0; (I < MaxNumFiles) && (NewFile == -1); I++)
{
if (!IsOpen[I])
NewFile = I;
}
if (NewFile == -1)
{
printf("Err: Too many files (%d) opened for printing\n",NewFile);
return (-1);
}
if (CurFile == -1)
CurFile = 0;
DoDebug[NewFile] = *Debug;
CurZone[NewFile] = 0;
L = 0;
if (FName != NULL)
L = strlen(FName);
if (L == 0)
{
printf("Err: Bad Filename for tecplot plot file, ref=%d\n",NewFile);
return (-1);
}
DestFName[NewFile] = (char *)malloc(L+1);
strcpy(DestFName[NewFile],FName);
#if defined (DOS)
strcpy(RName,"BLCKFLE");
#else
sprintf(RName,"tp%1dXXXXXX",NewFile+1);
mktemp(RName);
#endif
L = 0;
if (ScratchDir != NULL)
L = strlen(ScratchDir);
BlckFName[NewFile] = (char *)malloc(L+1+8);
if (ScratchDir != NULL)
{
strcpy(BlckFName[NewFile],ScratchDir);
#if defined DOS
strcat(BlckFName[NewFile],"\\");
#else
strcat(BlckFName[NewFile],"/");
#endif
}
else
BlckFName[NewFile][0] = '\0';
strcat(BlckFName[NewFile],RName);
if (DoDebug[NewFile])
{
printf("Scratch File #%d: %s\n",NewFile+1,BlckFName[NewFile]);
printf("Dest File #%d: %s\n",NewFile+1,DestFName[NewFile]);
}
#if defined DOS
HeadFile[NewFile] = fopen(DestFName[NewFile],"wb");
BlckFile[NewFile] = fopen(BlckFName[NewFile],"wb");
#else
HeadFile[NewFile] = fopen(DestFName[NewFile],"w");
BlckFile[NewFile] = fopen(BlckFName[NewFile],"w");
#endif
if (BlckFile[NewFile] == NULL)
{
printf("Err: Cannot open scratch file for tecplot output....\n");
printf(" Check permissions in scratch directory.\n");
return (-1);
}
if (HeadFile[NewFile] == NULL)
{
printf("Err: Cannot open tecplot plot file... Check permissions.\n");
return (-1);
}
WriteN(HeadFile[NewFile],Version);
WriteS(HeadFile[NewFile],Title);
NumVars[NewFile] = 0;
CPtr = Variables;
while (*CPtr)
{
while (*CPtr && ((*CPtr == ' ') || (*CPtr == ','))) CPtr++;
if (*CPtr)
{
NumVars[NewFile]++;
while (*CPtr && (*CPtr != ' ') && (*CPtr != ',')) CPtr++;
}
}
if (NumVars[NewFile] == 0)
{
printf("Err: No variable names were defined\n");
return (-1);
}
if (DoDebug[NewFile])
printf("NumVars=%d\n",NumVars[NewFile]);
WriteN(HeadFile[NewFile],(float)NumVars[NewFile]);
CPtr = Variables;
while (*CPtr)
{
while (*CPtr && ((*CPtr == ' ') || (*CPtr == ','))) CPtr++;
if (*CPtr)
{
while (*CPtr && (*CPtr != ' ') && (*CPtr != ','))
{
L = 0;
if (L < MaxChrsVarName)
WriteN(HeadFile[NewFile],(float)*CPtr);
L++;
CPtr++;
}
WriteN(HeadFile[NewFile],(float)0.0);
}
}
IsOpen[NewFile] = 1;
return (0);
}
static int CheckData()
{
LgIndex NumDataPoints;
if ((ZoneFormat[CurFile] == FEPOINT) ||
(ZoneFormat[CurFile] == FEBLOCK))
NumDataPoints = NumVars[CurFile]*IMax[CurFile];
else
NumDataPoints = NumVars[CurFile]*IMax[CurFile]*JMax[CurFile]*KMax[CurFile];
if (NumDataPoints != DataCount[CurFile])
{
printf("Err in file %d: \n",CurFile+1);
printf(" %d data values for Zone %d were processed \n",DataCount[CurFi
le],CurZone[CurFile]);
printf(" %d data values were expected.\n",NumDataPoints);
return (-1);
}
return (0);
}
int TECZNE(ZoneTitle,IMx,JMx,KMx,ZFormat)
char *ZoneTitle;
int *IMx;
int *JMx;
int *KMx;
char *ZFormat;
{
int I;
int L = 0;
int IsOk = 1;
char *CPtr;
if ((CurFile == -1) || (!IsOpen[CurFile]))
{
printf("Err: TECZNE called for invalid file (%d)\n",CurFile+1);
return (-1);
}
if (CurZone[CurFile] > 0)
{
if (CheckData() < 0)
return (-1);
}
DataCount[CurFile] = 0;
CurZone[CurFile]++;
IMax[CurFile] = *IMx;
JMax[CurFile] = *JMx;
KMax[CurFile] = *KMx;
WriteN(HeadFile[CurFile],(float)ZoneMarker);
if (ZoneTitle != NULL)
{
WriteS(HeadFile[CurFile],ZoneTitle);
}
if (ZFormat == NULL)
IsOk = 0;
else if (!strcmp(ZFormat,"BLOCK"))
ZoneFormat[CurFile] = BLOCK;
else if (!strcmp(ZFormat,"FEBLOCK"))
ZoneFormat[CurFile] = FEBLOCK;
else if (!strcmp(ZFormat,"POINT"))
ZoneFormat[CurFile] = POINT;
else if (!strcmp(ZFormat,"FEPOINT"))
ZoneFormat[CurFile] = FEPOINT;
else
IsOk = 0;
if (IsOk == 0)
{
printf("Err: Bad Zone Format for Tecplot plot file %d\n",CurFile+1);
return (-1);
}
if ((ZoneFormat[CurFile] == FEPOINT) ||
(ZoneFormat[CurFile] == FEBLOCK))
{
if (KMax[CurFile] == 0)
NumIndicies[CurFile] = 3;
else if (KMax[CurFile] == 1)
NumIndicies[CurFile] = 4;
else if (KMax[CurFile] == 2)
NumIndicies[CurFile] = 4;
else if (KMax[CurFile] == 3)
NumIndicies[CurFile] = 8;
}
WriteN(HeadFile[CurFile],(float)ZoneFormat[CurFile]);
WriteN(HeadFile[CurFile],(float)-1.0); /* No Zone Color Assignment */
WriteN(HeadFile[CurFile],(float)IMax[CurFile]);
WriteN(HeadFile[CurFile],(float)JMax[CurFile]);
WriteN(HeadFile[CurFile],(float)KMax[CurFile]);
WriteN(BlckFile[CurFile],(float)ZoneMarker);
WriteN(BlckFile[CurFile],(float)0.0);
if (DoDebug[CurFile])
{
printf("Writing Zone %d:\n",CurZone[CurFile]);
printf(" Title = %s\n",ZoneTitle);
printf(" Format= %s\n",ZFormat);
printf(" IMax = %d\n",IMax[CurFile]);
printf(" JMax = %d\n",JMax[CurFile]);
printf(" KMax = %d\n",KMax[CurFile]);
}
return (0);
}
static int CheckFile()
{
if ((CurFile == -1) || (!IsOpen[CurFile]))
{
printf("Err: Attempt to write tecplot data when no files are defined\n");
return (-1);
}
return (1);
}
int TECDAT(N,Data,IsDouble)
LgIndex *N;
float *Data;
long *IsDouble;
{
LgIndex I;
if (CheckFile() == -1)
return (-1);
if (*IsDouble == 1)
{
double *d;
float f;
d = (double *)Data;
for (I = 0; I < *N; I++)
{
if (*d < -1.0E36)
f = -1.0E36;
else if ((*d > -1.0E-36) && (*d < 1.0E-36))
f = 0.0;
else
f = *d;
WriteR(BlckFile[CurFile],&f;);
d++;
}
}
else
{
for (I = 0; I < *N; I++)
WriteR(BlckFile[CurFile],&Data;[I]);
}
DataCount[CurFile] += *N;
return (0);
}
int TECNOD(NData)
LgIndex *NData;
{
LgIndex L = NumIndicies[CurFile]*JMax[CurFile];
LgIndex I;
if ((CurFile == -1) || !IsOpen[CurFile])
{
printf("Err: Attempt to write tecplot data on invalid file
(%d)\n",CurFile+1);
return (-1);
}
WriteN(BlckFile[CurFile],(float)0.0); /* No Repeat Variables */
if ((ZoneFormat[CurFile] == BLOCK) || (ZoneFormat[CurFile] == POINT))
{
printf("Err: Tecplot output: Cannot call TECNOD if format is POINT or
BLOCK\n");
return (-1);
}
if (CheckData() < 0)
return (-1);
for (I = 0; I < L; I++)
WriteI(BlckFile[CurFile],&NData;[I]);
return (0);
}
int TECEND()
{
char buf[4];
if ((CurFile == -1) || (!IsOpen[CurFile]))
{
printf("Err: Attempt to close invalid tecplot file %d\n",CurFile+1);
return (-1);
}
if (CheckData() < 0)
return (-1);
WriteN(HeadFile[CurFile],(float)EndHeaderMarker);
fclose(BlckFile[CurFile]);
#if defined DOS
BlckFile[CurFile] = fopen(BlckFName[CurFile],"rb");
#else
BlckFile[CurFile] = fopen(BlckFName[CurFile],"r");
#endif
/*
rewind(BlckFile[CurFile]);
*/
while (fread(buf,4,1,BlckFile[CurFile]))
fwrite(buf,4,1,HeadFile[CurFile]);
fclose(BlckFile[CurFile]);
unlink(BlckFName[CurFile]);
fclose(HeadFile[CurFile]);
if (DoDebug[CurFile])
printf("File %d closed.\n",CurFile+1);
IsOpen[CurFile] = 0;
CurFile = 0;
while ((CurFile < MaxNumFiles) && !IsOpen[CurFile])
CurFile++;
if (CurFile == MaxNumFiles)
CurFile = -1;
return (0);
}
static void GetNextLabel(CPtr,NextLabel)
char **CPtr;
char *NextLabel;
{
int N = 0;
char *NPtr = NextLabel;
*NPtr = '\0';
/* Find label start */
while ((**CPtr) && (**CPtr != '"'))
(*CPtr)++;
if (**CPtr)
(*CPtr)++;
while ((N < 60) && (**CPtr) && (**CPtr != '"'))
{
if (**CPtr == '\\')
{
(*CPtr)++;
}
*NPtr++ = **CPtr;
N++;
(*CPtr)++;
}
if (**CPtr)
(*CPtr)++;
*NPtr = '\0';
}
int TECLAB(S)
char *S;
{
char *CPtr = S;
LgIndex N = 0;
char Label[60];
if (CheckFile() == -1)
return (-1);
if (DoDebug[CurFile])
printf("\nInserting Custom Labels:\n");
do
{
GetNextLabel(&CPtr;,Label);
if (*Label)
N++;
}
while (*Label);
if (N == 0)
{
printf("Err: Invalid custom label string: %s\n",
(S? S : " "));
return (-1);
}
WriteN(HeadFile[CurFile],CustomLabelMarker);
WriteN(HeadFile[CurFile],(float)N);
CPtr = S;
do
{
GetNextLabel(&CPtr;,Label);
if (*Label)
{
WriteS(HeadFile[CurFile],Label);
if (DoDebug[CurFile])
printf(" %s\n",Label);
}
}
while (*Label);
return (0);
}
static void WriteGeomDataBlock(Data,NumPts)
float *Data;
LgIndex NumPts;
{
LgIndex I;
for (I = 0; I < NumPts; I++)
WriteR(HeadFile[CurFile],&Data;[I]);
}
static void ShowDebugColor(Color)
LgIndex Color;
{
switch (Color)
{
case 0 : printf("BLACK\n"); break;
case 1 : printf("RED\n"); break;
case 2 : printf("GREEN\n"); break;
case 3 : printf("BLUE\n"); break;
case 4 : printf("CYAN\n"); break;
case 5 : printf("YELLOW\n"); break;
case 6 : printf("PURPLE\n"); break;
case 7 : printf("WHITE\n"); break;
case 15 :
case 16 :
case 17 :
case 18 :
case 19 :
case 20 :
case 21 :
case 22 : printf("CUSTOM%1d\n",Color-14); break;
default : printf("INVALID\n");
}
}
int TECGEO(CoordMode,
XPos,
YPos,
ZPos,
Scope,
Zone,
Color,
FillColor,
IsFilled,
LineStyle,
GeomType,
NumSegments,
NumSegPts,
XGeomData,
YGeomData,
ZGeomData)
LgIndex *CoordMode;
float *XPos;
float *YPos;
float *ZPos;
LgIndex *Scope;
LgIndex *Zone;
LgIndex *Color;
LgIndex *FillColor;
LgIndex *IsFilled;
LgIndex *LineStyle;
LgIndex *GeomType;
LgIndex *NumSegments;
LgIndex *NumSegPts;
float *XGeomData;
float *YGeomData;
float *ZGeomData;
{
int I,S;
if (CheckFile() == -1)
return (-1);
WriteN(HeadFile[CurFile],GeomMarker);
WriteN(HeadFile[CurFile],(float)*CoordMode);
WriteN(HeadFile[CurFile],(float)*Scope);
WriteR(HeadFile[CurFile],XPos);
WriteR(HeadFile[CurFile],YPos);
WriteR(HeadFile[CurFile],ZPos);
WriteN(HeadFile[CurFile],(float)*Zone);
WriteN(HeadFile[CurFile],(float)*Color);
WriteN(HeadFile[CurFile],(float)*FillColor);
WriteN(HeadFile[CurFile],(float)*IsFilled);
WriteN(HeadFile[CurFile],(float)*GeomType);
WriteN(HeadFile[CurFile],(float)*LineStyle);
if (DoDebug[CurFile])
{
printf("\nInserting Geometry\n");
printf(" CoordMode = ");
switch ((CoordModeType)*CoordMode)
{
case GridMode : printf("GRID\n"); break;
case WindowMode : printf("WINDOW\n"); break;
default : printf("INVALID\n");
}
printf(" Scope = ");
switch ((ScopeType)*Scope)
{
case S_Local : printf("LOCAL\n"); break;
case S_Global : printf("GLOBAL\n"); break;
default : printf("INVALID\n");
}
printf(" X,Y,Z Origin = %G,%G,%G\n",*XPos,*YPos,*ZPos);
printf(" Zone = %d\n",*Zone);
printf(" Color = "); ShowDebugColor(*Color);
printf(" FillColor = "); ShowDebugColor(*FillColor);
printf(" IsFilled = %d\n",*IsFilled);
printf(" GeomType = ");
switch ((GeometryType)*GeomType)
{
case G_LineSegs : printf("LINESEGS\n"); break;
case G_Rectangle : printf("RECTANGLE\n"); break;
case G_Circle : printf("CIRCLE\n"); break;
case G_Ellipse : printf("ELLIPSE\n"); break;
case G_3DLineSegs : printf("3D-LINESEGS\n"); break;
default : printf("INVALID\n");
}
printf(" LineStyle = ");
switch ((LineType)*LineStyle)
{
case SolidLine : printf("SOLID\n"); break;
case DashedLine : printf("DASHED\n"); break;
case DashDotLine : printf("DASHDOT\n"); break;
case DottedLine : printf("DOTTED\n"); break;
case LongDashLine : printf("LONGDASH\n"); break;
case DashDotDotLine : printf("DASHDOTDOT\n"); break;
default : printf("INVALID\n");
}
}
if ((*GeomType == (int)G_LineSegs) ||
(*GeomType == (int)G_3DLineSegs))
{
WriteN(HeadFile[CurFile],(float)*NumSegments);
I = 0;
for (S = 0; S < *NumSegments; S++)
{
WriteN(HeadFile[CurFile],(float)NumSegPts[S]);
WriteGeomDataBlock(&XGeomData;[I],NumSegPts[S]);
WriteGeomDataBlock(&YGeomData;[I],NumSegPts[S]);
if (*GeomType == (int)G_3DLineSegs)
WriteGeomDataBlock(&ZGeomData;[I],NumSegPts[S]);
I += NumSegPts[S];
}
}
else if (*GeomType == (int)G_Circle)
{
WriteN(HeadFile[CurFile],XGeomData[0]);
}
else /* ellipse or rectangle */
{
WriteN(HeadFile[CurFile],XGeomData[0]);
WriteN(HeadFile[CurFile],YGeomData[0]);
}
return (0);
}
int TECTXT(CoordMode,
XPos,
YPos,
Scope,
Font,
FontHeight,
BoxType,
BoxMargin,
BoxColor,
BoxFillColor,
Angle,
Zone,
TextColor,
Text)
LgIndex *CoordMode;
float *XPos;
float *YPos;
LgIndex *Scope;
LgIndex *Font;
float *FontHeight;
LgIndex *BoxType;
float *BoxMargin;
LgIndex *BoxColor;
LgIndex *BoxFillColor;
LgIndex *Angle;
LgIndex *Zone;
LgIndex *TextColor;
char *Text;
{
char *CPtr = Text;
LgIndex L = strlen(Text);
if (CheckFile() == -1)
return (-1);
WriteN(HeadFile[CurFile],TextMarker);
WriteN(HeadFile[CurFile],(float)*CoordMode);
WriteN(HeadFile[CurFile],(float)*Scope);
WriteR(HeadFile[CurFile],XPos);
WriteR(HeadFile[CurFile],YPos);
WriteN(HeadFile[CurFile],(float)*Font);
WriteR(HeadFile[CurFile],FontHeight);
WriteN(HeadFile[CurFile],(float)*BoxType);
WriteR(HeadFile[CurFile],BoxMargin);
WriteN(HeadFile[CurFile],(float)*BoxColor);
WriteN(HeadFile[CurFile],(float)*BoxFillColor);
WriteN(HeadFile[CurFile],(float)*Angle);
WriteN(HeadFile[CurFile],(float)*Zone);
WriteN(HeadFile[CurFile],(float)*TextColor);
WriteN(HeadFile[CurFile],(float)L);
while (*CPtr)
{
WriteN(HeadFile[CurFile],(float)(*CPtr));
CPtr++;
}
if (DoDebug[CurFile])
{
printf("\nInserting Text\n");
printf(" CoordMode = ");
switch ((CoordModeType)*CoordMode)
{
case GridMode : printf("GRID\n"); break;
case WindowMode : printf("WINDOW\n"); break;
default : printf("INVALID\n");
}
printf(" Scope = ");
switch ((ScopeType)*Scope)
{
case S_Local : printf("LOCAL\n"); break;
case S_Global : printf("GLOBAL\n"); break;
default : printf("INVALID\n");
}
printf(" X,Y Origin = %G,%G\n",*XPos,*YPos);
printf(" Font = ");
switch ((FontType)*Font)
{
case F_Helv : printf("HELVETICA\n"); break;
case F_HelvBold : printf("HELVETICA-BOLD\n"); break;
case F_Greek : printf("GREEK\n"); break;
case F_Math : printf("MATH\n"); break;
case F_UserDef : printf("USERDEF\n"); break;
case F_Times : printf("TIMES\n"); break;
case F_TimesItalic : printf("TIMES-ITALIC\n"); break;
case F_TimesBold : printf("TIMES-BOLD\n"); break;
case F_TimesItalicBold : printf("TIMES-ITALIC-BOLD\n"); break;
case F_Courier : printf("COURIER\n"); break;
case F_CourierBold : printf("COURIER-BOLD\n"); break;
default : printf("INVALID\n");
}
printf(" Font Height = %G\n",*FontHeight);
printf(" Box Type = ");
switch ((TextBoxType)*BoxType)
{
case NoTextBox : printf("NONE\n"); break;
case HollowTextBox : printf("PLAIN\n"); break;
case FilledTextBox : printf("FILLED\n"); break;
default : printf("INVALID\n");
}
printf(" Box Margin = %G\n",*BoxMargin);
printf(" BoxColor = "); ShowDebugColor(*BoxColor);
printf(" BoxFillColor = "); ShowDebugColor(*BoxFillColor);
printf(" Angle = %d\n",*Angle);
printf(" Zone = %d\n",*Zone);
printf(" TextColor = "); ShowDebugColor(*TextColor);
printf(" Text = %s\n",Text);
}
return (0);
}
int TECFIL(F)
LgIndex *F;
{
if ((*F < 1) || (*F > MaxNumFiles))
{
printf("Err: Invalid file number requested (%d)\n",*F);
return (-1);
}
if (!IsOpen[*F-1])
{
int I;
printf("Err: File set %d is not open! File set not changed\n",
*F);
printf("\n\nFile states are:\n");
for (I = 0; I < MaxNumFiles; I++)
printf("File %d, IsOpen=%d\n",I+1,IsOpen[I]);
printf("Current File is: %d\n",CurFile+1);
return (-1);
}
CurFile = *F-1;
if (DoDebug[CurFile])
{
printf("Switching to tecplot file #%d\n\n",CurFile+1);
printf("Current State is:\n");
printf(" Debug = %d\n",DoDebug[CurFile]);
printf(" NumVars = %d\n",NumVars[CurFile]);
printf(" DestFName = %s\n",DestFName[CurFile]);
printf(" BlckFName = %s\n",BlckFName[CurFile]);
printf(" ZoneFormt = ");
switch (ZoneFormat[CurFile])
{
case BLOCK :
{
printf("BLOCK\n");
} break;
case POINT :
{
printf("POINT\n");
} break;
case FEBLOCK :
{
printf("FEBLOCK\n");
} break;
case FEPOINT :
{
printf("FEPOINT\n");
} break;
default :
{
printf("UNKNOWN\n");
} break;
}
if ((ZoneFormat[CurFile] == BLOCK) ||
(ZoneFormat[CurFile] == POINT))
{
printf(" IMax = %d\n",IMax[CurFile]);
printf(" JMax = %d\n",JMax[CurFile]);
printf(" KMax = %d\n",KMax[CurFile]);
}
else if ((ZoneFormat[CurFile] == FEBLOCK) ||
(ZoneFormat[CurFile] == FEPOINT))
{
printf(" NumPoints = %d\n",IMax[CurFile]);
printf(" NumElmnts = %d\n",JMax[CurFile]);
printf(" EType = ");
if (KMax[CurFile] == 0)
printf("Triangle\n");
else if (KMax[CurFile] == 1)
printf("Quadrilateral\n");
else if (KMax[CurFile] == 2)
printf("Tetrahedron\n");
else if (KMax[CurFile] == 3)
printf("Brick\n");
else
printf("Unknown\n");
}
printf(" DataCount = %d\n",DataCount[CurFile]);
printf(" CurZone = %d\n",CurZone[CurFile]);
}
return (0);
}
------------------------------------------------ PART 5. test program.
program test
character*1 NULLCHR
Integer*4 Debug,III,NPts,NElm
Dimension X(4,5), Y(4,5), P(4,5)
Real*8 XX(4,5), YY(4,5), PP(4,5)
Real*4 XP,YP,FH
Real*4 XG(5),YG(5)
Integer*4 NM(4,12)
NULLCHR = CHAR(0)
Debug = 1
IMax = 4
JMax = 5
KMax = 1
I = TecIni('HI MOM'//NULLCHR,
& 'X Y P'//NULLCHR,
& 't.plt'//NULLCHR,
& '.'//NULLCHR,
& Debug)
I = TecIni('BYE MOM'//NULLCHR,
& 'X Y P'//NULLCHR,
& 'td.plt'//NULLCHR,
& '.'//NULLCHR,
& Debug)
Do 10 I = 1,4
Do 10 J = 1,5
X(I,J) = I
Y(I,J) = J
P(I,J) = I*J
XX(I,J) = I
YY(I,J) = J
PP(I,J) = I*J
10 Continue
I = TecFil(1)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC TITLE- FILE 1
XP = 0.5
YP = 0.5
FH = 0.05
C
C
C Paramters for call to TECTXT are:
C
C Window Mode
C X-Position
C Y-Position
C Local Scope
C Helvetica Bold font
C Font Height
C No Box
C Dummy - Box Margin
C Box Color
C Box Fill Color
C Angle
C Zone (All Zones)
C Text Color (Red)
C TEXT
C
I = TECTXT(1,
& XP,
& YP,
& 1,
& 1,
& FH,
& 0,
& FH,
& 0,
& 0,
& 30,
& 0,
& 1,
& 'HI MOM'//NULLCHR)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC GEOMETRY CIRCLE - FILE 1
C
C Geometry parameters....
C
C
C CoordMode,
C XPos,
C YPos,
C ZPos,
C Scope,
C Zone,
C Color,
C FillColor,
C IsFilled,
C LineStyle,
C GeomType,
C NumSegments,
C NumSegPts,
C XGeomData,
C YGeomData,
C ZGeomData)
I = TecGeo(1,
& 0.75,
& 0.75,
& 0.0,
& 1,
& 0,
& 3,
& 5,
& 1,
& 0,
& 2,
& 0,
& XP,
& 0.2,
& 0.0,
& 0.0)
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC GEOMETRY ELLIPSE - FILE 1
I = TecGeo(1,
& 0.25,
& 0.45,
& 0.0,
& 1,
& 0,
& 2,
& 18,
& 1,
& 0,
& 3,
& 0,
& XP,
& 0.2,
& 0.4,
& 0.0)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC GEOMETRY RECTANGLE/GRID MODE
I = TecGeo(0,
& 4.0,
& 1.0,
& 0.0,
& 1,
& 0,
& 20,
& 1,
& 1,
& 0,
& 1,
& 0,
& XP,
& 0.8,
& 0.5,
& 0.0)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC GEOMETRY POLYLINE - FILE 1
XG(1) = 0.0
XG(2) = 0.2
XG(3) = 0.3
XG(4) = 0.3
XG(5) = 0.2
YG(1) = 0.3
YG(2) = 0.2
YG(3) = 0.1
YG(4) = 0.4
YG(5) = 0.2
I = TecGeo(1,
& 0.0,
& 0.0,
& 0.0,
& 1,
& 0,
& 2,
& 0,
& 0,
& 0,
& 0,
& 1,
& 5,
& XG,
& YG,
& 0.0)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC IJK ZONE - FILE 1
I = TecZne('Hi Dad'//NULLCHR,
& IMax,
& JMax,
& KMax,
& 'BLOCK'//NULLCHR)
C
C
III = IMax*JMax
I = TecDat(III,X,0)
I = TecDat(III,Y,0)
I = TecDat(III,P,0)
C
C
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC FE ZONE - FILE 1
NPts = IMax*JMax
NElm = (IMax-1)*(JMax-1)
I = TecZne('Hi Dad'//NULLCHR,
& NPts,
& NElm,
& 1,
& 'FEBLOCK'//NULLCHR)
C
C
III = IMax*JMax
I = TecDat(III,X,0)
I = TecDat(III,Y,0)
I = TecDat(III,P,0)
Do 15 I = 1,IMax-1
Do 15 J = 1,JMax-1
K = I+(J-1)*(IMax-1)
L = I+(J-1)*IMax
NM(1,K) = L
NM(2,K) = L+1
NM(3,K) = L+IMax+1
NM(4,K) = L+IMax
15 Continue
I = TecNod(NM)
C
I = TecFil(2)
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CUSTOM LABELS - FILE 2
I = TecLab('"label1","label2","label3"'//NULLCHR)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC IJK ZONE - FILE 2
I = TecZne('Bye Mom'//NULLCHR,
& IMax,
& JMax,
& KMax,
& 'BLOCK'//NULLCHR)
III = IMax*JMax
I = TecDat(III,XX,1)
I = TecDat(III,YY,1)
I = TecDat(III,PP,1)
I = TecFil(1)
I = TecEnd()
I = TecFil(2)
I = TecEnd()
Stop
End
------------------------------------------------ PART 6. FUNCTION NOTES
I. NOTES ON USING TECFIL
You can open up to MaxNumFiles (currently 10) files at once. A
complete set of "file state" variables are maintained for each file
that is opened.
To open multiple files call TECINI more than once. Each time TECINI
is called it opens a new file (in addition to any already opened)
and initializes a completly separate set of state variables for the
new file.
The function TECFIL is new and is used to switch between file states.
For example, calling TECFIL using:
IErr = tecfil(3)
will cause all subsequent calls to TECXXX (except TECINI) routines
to reference the third file state set up by TECINI.
Please note the following special rules:
1. Calling TECINI does NOT change the current file state.
It only creates a new file state.
2. You must call TECEND for each file state. For
example suppose you have 3 file states. At the
end of your program you must do somthing like:
ierr = tecfil(1)
ierr = tecend()
ierr = tecfil(2)
ierr = tecend()
ierr = tecfil(3)
ierr = tecend()
3. If you close out a file (i.e. set tecfil and call tecend)
then that file state can be reused by calling tecini.
When TECINI is called it registers a new file state using
the lowest numbered file state that is not active.
II. NOTES ON USING TECLAB
To use TECLAB simply call:
IErr = TecLab(labelstring)
where
labelstring is a character string using the following syntax:
"label1","label1",....."labeln"
where you MUST include the double quotes.
EXAMPLE.
From FORTRAN use:
IErr = TecLab('"sunday","monday","tuesday"'//NULLCHR)
From c use:
IErr = teclab("\"sunday\",\"monday\",\"tuesday\"");
III. NOTES ON USING TECTXT
The syntax for TECTXT IS:
Integer Function TECTXT(CoordMode,
& XPos,
& YPos,
& Scope,
& Font,
& FontHeight,
& BoxType,
& BoxMargin,
& BoxColor,
& BoxFillColor,
& Angle,
& Zone,
& TextColor,
& Text)
INTEGER*4 CoordMode
REAL*4 XPos
REAL*4 YPos
INTEGER*4 Scope
INTEGER*4 Font
REAL*4 FontHeight
INTEGER*4 BoxType
REAL*4 BoxMargin
INTEGER*4 BoxColor
INTEGER*4 BoxFillColor
INTEGER*4 Angle
INTEGER*4 Zone
INTEGER*4 TextColor
CHARACTER*(*) Text
Where:
Scope,
= 0, Global
= 1, Local
Font
= 0, Helvetica
= 1, Helvetica-Bold
= 2, Greek
= 3, Math
= 4, UserDef
= 5, Times
= 6, Times-Italic
= 7, Times-Bold
= 8, Times-Italic-Bold
= 9, Courier
= 10, Courier-Bold
BoxType
= 0, No Box
= 1, Plain Box
= 2, Filled Box
BoxColor |
BoxFillColor | See BasicColor at end of this section
TextColor |
IV. NOTES ON USING TECGEO
Integer Function TECGEO(CoordMode,
& XPos,
& YPos,
& ZPos,
& Scope,
& Zone,
& Color,
& FillColor,
& IsFilled,
& LineStyle,
& GeomType,
& NumSegments,
& NumSegPts,
& XGeomData,
& YGeomData,
& ZGeomData)
INTEGER*4 CoordMode
REAL*4 XPos
REAL*4 YPos
REAL*4 ZPos
INTEGER*4 Scope
INTEGER*4 Zone
INTEGER*4 Color
INTEGER*4 FillColor
INTEGER*4 IsFilled
INTEGER*4 LineStyle
INTEGER*4 GeomType
INTEGER*4 NumSegments
INTEGER*4 NumSegPts(1)
REAL*4 XGeomData(1)
REAL*4 YGeomData(1)
REAL*4 ZGeomData(1)
Where:
CoordMode,
= 0, Grid
= 1, Window
Scope,
= 0, Global
= 1, Local
Color |
FillColor | See BasicColor at end of this section
LineStyle
= 0, Solid
= 1, Dashed
= 2, DashDot
= 3, Dotted
= 4, LongDash
= 5, DashDotDot
GeomType
= 0, Line Segments
= 1, Rectangle
= 2, Circle
= 3, Ellipse
= 4, 3D Line Segments
NumSegPts
This is an array of the number of points in each segment
for GeomType of 0 or 4..
Data:
For Rectangles and Ellipses:
Put the Width as the first entry in the XGeomData Array.
Put the Height as the first entry in the YGeomData Array.
For Circles:
Put the radius as the first entry in the XGeomData Array.
Line Segments and 3D LineSegments:
Put all X,Y (and Z if 3D) data in the XGeomData, YGeomData
(and ZGeomData) arrays.
Data Example 1 (FORTRAN syntax).
Simple Line segment with 3 points.
GeomType = 0
NumSegments = 1
NumSegPts(1) = 3
XGeomData(1) = x1
XGeomData(2) = x2
XGeomData(3) = x3
YGeomData(1) = y1
YGeomData(2) = y2
YGeomData(3) = y3
Data Example 2 (FORTRAN syntax).
2 line segmented 3d geometry.
- segment 1 has 3 points
- segment 2 has 2 points
GeomType = 4
NumSegments = 2
NumSegPts(1) = 3
XGeomData(1) = x1,1
XGeomData(2) = x2,1
XGeomData(3) = x3,1
YGeomData(1) = y1,1
YGeomData(2) = y2,1
YGeomData(3) = y3,1
ZGeomData(1) = z1,1
ZGeomData(2) = z2,1
ZGeomData(3) = z3,1
NumSegPts(2) = 2
XGeomData(4) = x1,2
XGeomData(5) = x2,2
YGeomData(4) = y1,2
YGeomData(5) = y2,2
ZGeomData(4) = z1,2
ZGeomData(5) = z2,2
Note that the GeomData arrays pack in all of the
position data for each segment, one after another.
Data Example 3 (FORTRAN syntax).
Ellipse with Width = 0.5 and height = 0.75
GeomType = 3
XGeomData(1) = 0.5
YGeomData(1) = 0.75
V. Basic Colors
= 0, Black
= 1, Red
= 2, Green
= 3, Blue
= 4, Cyan
= 5, Yellow
= 6, Purple
= 7, White
= 15, Custom1
= 16, Custom2
= 17, Custom3
= 18, Custom4
= 19, Custom5
= 20, Custom6
= 21, Custom7
= 22, Custom8