sandbox/Antoonvh/hopkins.c
This is not basilisk C, but it is part of the methods I use. It
relies on some external libraries that are not under basilisk/src.
A manual will follow some time.
Database host request; “Do not use too many parallel threads. Upto
10 orso.”.
The code is self explainatory known that data is read in XY-slices.
#include <mpi.h> // the sandbox does not complain....
#include <stdio.h>
#include <float.h>
#include <math.h>

turblib.h: No such file or directory
#include "turblib.h"
int main(int argc, char *argv[]) {
(0,0);
MPI_Initint world_size;
(MPI_COMM_WORLD, &world_size);
MPI_Comm_sizeint world_rank;
(MPI_COMM_WORLD, &world_rank);
MPI_Comm_rank;
MPI_Status status1;
MPI_Status status2;
MPI_Status status3printf("thread with Rank %d starts working\n",world_rank);
();
soapinit(1);
turblibSetExitOnError
char * authtoken = "Your_Token_Goes_Here";
char * dataset = "isotropic1024coarse";
float time = 0.364;
int Nx = 1024; // x-width of slice per call
int Ny = 1024; // y-width of slice per call
int dbNz = 1024;
int Zw=1; // slices per call
int Nz=10; //Total number of slices
//CLA
if (argc>1)
= atoi(argv[1]);
Nz if (argc>2)
= atoi(argv[2]);
Zw if (argc>3)
= atoi(argv[3]);
Ny if (argc>4)
= atoi(argv[4]);
Nx
int K=Nz/(Zw*world_size)+0.5; //number of server calls per thread
if (K*world_size*Zw > dbNz)
printf("You might obtain zero-padded data\n");
if (K*world_size*Zw == dbNz)
printf("Downloading full snapshot\n");
if (K*world_size*Zw < dbNz)
printf("Downloading fraction of the database, Nz = %d, K = %d\n",Nz,K);
;
MPI_File fpu(MPI_COMM_WORLD,"datau",MPI_MODE_CREATE|MPI_MODE_WRONLY,MPI_INFO_NULL,&fpu);
MPI_File_open;
MPI_File fpv(MPI_COMM_WORLD,"datav",MPI_MODE_CREATE|MPI_MODE_WRONLY,MPI_INFO_NULL,&fpv);
MPI_File_open;
MPI_File fpw(MPI_COMM_WORLD,"dataw",MPI_MODE_CREATE|MPI_MODE_WRONLY,MPI_INFO_NULL,&fpw);
MPI_File_open
int components = 3; // Velocity components per cell
int amount = Nx*Ny*Zw; //Cells per server query
float * rawdata = (float*) malloc(amount*sizeof(float)*components);
float * ud = (float*) malloc(amount*sizeof(float));
float * vd = (float*) malloc(amount*sizeof(float));
float * wd = (float*) malloc(amount*sizeof(float));
if(rawdata == NULL||ud==NULL|| vd==NULL||wd==NULL) {
printf("malloc failed on thread %d!\n",world_rank);
return 1;
}
for (int it = 0;it<K;it++){
int Z = world_rank+world_size*it;
(authtoken, dataset, time, 0, 0, Z, Nx, Ny, Zw, (char*)rawdata);
getRawVelocityfor (int l = 0; l < amount; l++) {
[l]=rawdata[3*l];
ud[l]=rawdata[3*l+1];
vd[l]=rawdata[3*l+2];
wd}
// Guide file pointers and write the data
int g = Z*amount*sizeof(float);
= g;
MPI_Offset offset (fpu,offset,MPI_SEEK_SET);
MPI_File_seek(fpv,offset,MPI_SEEK_SET);
MPI_File_seek(fpw,offset,MPI_SEEK_SET);
MPI_File_seek(fpu,&ud[0],amount,MPI_FLOAT,&status1);
MPI_File_write(fpv,&vd[0],amount,MPI_FLOAT,&status2);
MPI_File_write(fpw,&wd[0],amount,MPI_FLOAT,&status3);
MPI_File_writefprintf(stdout,"thread #: %d, Z= %d. So Progress is at %g %%\n",world_rank,Z,100.*(double)(it+1)/(double)K);
}
// Finish the session
free(rawdata);
free(ud);
free(vd);
free(wd);
();
soapdestroy(MPI_COMM_WORLD); // Is this really needed?
MPI_Barrier(&fpu);
MPI_File_close(&fpv);
MPI_File_close(&fpw);
MPI_File_close();
MPI_Finalizereturn 0;
}