Switch times to uint64_t

This commit is contained in:
Ian Jauslin 2023-04-16 00:21:42 -04:00
parent 028a11cfd8
commit 2be9a3f6a5
3 changed files with 27 additions and 25 deletions

View File

@ -7,6 +7,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
#include "navier-stokes.h"
#include "driving.h"
@ -27,9 +28,9 @@ typedef struct nstrophy_parameters {
double nu;
double delta;
double L;
unsigned int print_freq;
uint64_t print_freq;
int seed;
unsigned int starting_time;
uint64_t starting_time;
unsigned int driving;
unsigned int init;
FILE* initfile;
@ -519,7 +520,7 @@ int set_parameter(
}
}
else if (strcmp(lhs,"print_freq")==0){
ret=sscanf(rhs,"%u",&(parameters->print_freq));
ret=sscanf(rhs,"%lu",&(parameters->print_freq));
if(ret!=1){
fprintf(stderr, "error: parameter 'print_freq' should be an unsigned integer\n got '%s'\n",rhs);
return(-1);
@ -533,7 +534,7 @@ int set_parameter(
}
}
else if (strcmp(lhs,"starting_time")==0){
ret=sscanf(rhs,"%u",&(parameters->starting_time));
ret=sscanf(rhs,"%lu",&(parameters->starting_time));
if(ret!=1){
fprintf(stderr, "error: parameter 'starting_time' should be an unsigned integer\n got '%s'\n",rhs);
return(-1);

View File

@ -10,15 +10,15 @@ int uk(
int K2,
int N1,
int N2,
unsigned int nsteps,
uint64_t nsteps,
double nu,
double delta,
double L,
_Complex double* u0,
_Complex double* g,
bool irreversible,
unsigned int print_freq,
unsigned int starting_time,
uint64_t print_freq,
uint64_t starting_time,
unsigned int nthreads,
FILE* savefile
){
@ -26,7 +26,7 @@ int uk(
_Complex double* tmp1;
_Complex double* tmp2;
_Complex double* tmp3;
unsigned int t;
uint64_t t;
fft_vect fft1;
fft_vect fft2;
fft_vect ifft;
@ -41,9 +41,9 @@ int uk(
t=3;
for(kx=-K1;kx<=K1;kx++){
for (ky=-K2;ky<=K2;ky++){
printf(" %6d:(%4d,%4d)r ",t,kx,ky);
printf(" %6lu:(%4d,%4d)r ",t,kx,ky);
t++;
printf(" %6d:(%4d,%4d)i ",t,kx,ky);
printf(" %6lu:(%4d,%4d)i ",t,kx,ky);
t++;
}
}
@ -53,8 +53,8 @@ int uk(
ns_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3, irreversible);
if(t%print_freq==0){
fprintf(stderr,"%d % .8e ",t,t*delta);
printf("%8d % .15e ",t,t*delta);
fprintf(stderr,"%lu % .8e ",t,t*delta);
printf("%8lu % .15e ",t,t*delta);
for(kx=-K1;kx<=K1;kx++){
for (ky=-K2;ky<=K2;ky++){
@ -83,15 +83,15 @@ int eea(
int K2,
int N1,
int N2,
unsigned int nsteps,
uint64_t nsteps,
double nu,
double delta,
double L,
_Complex double* u0,
_Complex double* g,
bool irreversible,
unsigned int print_freq,
unsigned int starting_time,
uint64_t print_freq,
uint64_t starting_time,
unsigned int nthreads,
FILE* savefile,
// for interrupt recovery
@ -106,7 +106,7 @@ int eea(
double alpha, energy, enstrophy;
double avg_e,avg_a,avg_en;
// index
unsigned int t;
uint64_t t;
fft_vect fft1;
fft_vect fft2;
fft_vect ifft;
@ -122,7 +122,7 @@ int eea(
avg_en=0;
// special first case when starting_time is not a multiple of print_freq
unsigned int first_box = print_freq - (starting_time % print_freq);
uint64_t first_box = print_freq - (starting_time % print_freq);
// iterate
for(t=starting_time;t<starting_time+nsteps;t++){
@ -156,8 +156,8 @@ int eea(
}
if(t>starting_time && t%print_freq==0){
fprintf(stderr,"%d % .8e % .8e % .8e % .8e % .8e % .8e % .8e\n",t,t*delta, avg_a, avg_e, avg_en, alpha, energy, enstrophy);
printf("%8d % .15e % .15e % .15e % .15e % .15e % .15e % .15e\n",t,t*delta, avg_a, avg_e, avg_en, alpha, energy, enstrophy);
fprintf(stderr,"%lu % .8e % .8e % .8e % .8e % .8e % .8e % .8e\n",t,t*delta, avg_a, avg_e, avg_en, alpha, energy, enstrophy);
printf("%8lu % .15e % .15e % .15e % .15e % .15e % .15e % .15e\n",t,t*delta, avg_a, avg_e, avg_en, alpha, energy, enstrophy);
}
// catch abort signal
@ -180,7 +180,7 @@ int eea(
remove_entry(params, "starting_time");
remove_entry(params, "init");
remove_entry(params, "nsteps");
fprintf(savefile," -p \"%s;starting_time=%u;nsteps=%u;init=file:%s\"", params, t+1, nsteps-t-1, savefile_string);
fprintf(savefile," -p \"%s;starting_time=%lu;nsteps=%lu;init=file:%s\"", params, t+1, nsteps-t-1, savefile_string);
free(params);
fprintf(savefile," energy\n");
@ -206,7 +206,7 @@ int quiet(
int K2,
int N1,
int N2,
unsigned int nsteps,
uint64_t nsteps,
double nu,
double delta,
double L,
@ -220,7 +220,7 @@ int quiet(
_Complex double* tmp1;
_Complex double* tmp2;
_Complex double* tmp3;
unsigned int t;
uint64_t t;
fft_vect fft1;
fft_vect fft2;
fft_vect ifft;

View File

@ -3,6 +3,7 @@
#include <complex.h>
#include <stdbool.h>
#include <stdint.h>
#include <fftw3.h>
#define M_PI 3.14159265358979323846
@ -17,13 +18,13 @@ typedef struct fft_vects {
} fft_vect;
// compute u_k
int uk( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, bool irreversible, unsigned int print_freq, unsigned int starting_time, unsigned int nthreadsl, FILE* savefile);
int uk( int K1, int K2, int N1, int N2, uint64_t nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, bool irreversible, uint64_t print_freq, uint64_t starting_time, unsigned int nthreadsl, FILE* savefile);
// compute energy, enstrophy and alpha
int eea( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, bool irreversible, unsigned int print_freq, unsigned int starting_time, unsigned int nthreads, FILE* savefile, char* cmd_string, char* params_string, char* savefile_string);
int eea( int K1, int K2, int N1, int N2, uint64_t nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, bool irreversible, uint64_t print_freq, uint64_t starting_time, unsigned int nthreads, FILE* savefile, char* cmd_string, char* params_string, char* savefile_string);
// compute solution as a function of time, but do not print anything (useful for debugging)
int quiet( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, bool irreversible, unsigned int nthreads, FILE* savefile);
int quiet( int K1, int K2, int N1, int N2, uint64_t nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, bool irreversible, unsigned int nthreads, FILE* savefile);
// initialize vectors for computation