Checkpoint with dprintf.

This commit is contained in:
Ernie Pasveer
2024-05-20 15:50:54 -05:00
parent 7f01660e96
commit 07d677cf1e
6 changed files with 55 additions and 2 deletions
+31 -2
View File
@@ -1,13 +1,40 @@
#include <string>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdarg.h>
FILE* logfile = NULL;
extern "C" {
void fortranfunction_ (int* count);
int log_msgxxx (const char* format, ...) {
int n;
va_list args;
// init the variable length argument list
va_start(args, format);
n = vfprintf(logfile, format, args);
// cleanup the variable length argument list
va_end(args);
return n;
}
}
extern "C" {
void fortranfunction_ (int* count);
}
int main (int argc, char** argv) {
const char* filename = "logfile.txt";
logfile = fopen(filename, "w");
if (logfile == NULL) {
fprintf(stderr, "Failed to open logfile: %s\n", filename);
return 1;
}
int count = 10;
int nfact = 1;
int n;
@@ -19,7 +46,9 @@ int main (int argc, char** argv) {
std::cout << std::setw(12) << n << std::setw(14) << nfact << std::endl;
}
fortranfunction_(&count);
// fortranfunction_(&count);
fclose(logfile);
return 0;
}