Commit abad5f27 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add version of C table write for stdio streams.

parent 1cb3f25e
......@@ -7,6 +7,7 @@
#ifndef CDI_H_
#define CDI_H_
#include <stdio.h>
#include <sys/types.h>
/*
#if defined(__cplusplus)
......@@ -994,6 +995,7 @@ char *modelInqNamePtr(int modelID);
/* Table routines */
void tableWriteC(const char *filename, int tableID);
void tableFWriteC(FILE *ptfp, int tableID);
void tableWrite(const char *filename, int tableID);
int tableRead(const char *tablefile);
int tableDef(int modelID, int tablenum, const char *tablename);
......
......@@ -669,14 +669,23 @@ void tableWrite(const char *ptfile, int tableID)
void tableWriteC(const char *filename, int tableID)
{
FILE *ptfp = fopen(filename, "w");
if (!ptfp)
Error("failed to open file \"%s\"!", filename);
if ( CDI_Debug )
Message("write parameter table %d to %s", tableID, filename);
tableFWriteC(ptfp, tableID);
fclose(ptfp);
}
void tableFWriteC(FILE *ptfp, int tableID)
{
char chelp[] = "";
int item, npars;
size_t maxname = 0, maxlname = 0, maxunits = 0;
char tablename[256];
if ( CDI_Debug )
Message("write parameter table %d to %s", tableID, filename);
if ( tableID == UNDEFID )
{
......@@ -686,8 +695,6 @@ void tableWriteC(const char *filename, int tableID)
partabCheckID(tableID);
FILE *ptfp = fopen(filename, "w");
npars = parTable[tableID].npars;
for ( item = 0; item < npars; item++)
......@@ -751,8 +758,6 @@ void tableWriteC(const char *filename, int tableID)
}
fprintf(ptfp, "};\n\n");
fclose(ptfp);
}
......
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