Miscellaneous functions for IO operations.
More...
#include "al_hidden.h"
#include <string.h>
Go to the source code of this file.
Miscellaneous functions for IO operations.
- Author
- A. Malagoli (University of Chicago)
-
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
-
G. Muscianisi (g.mus.nosp@m.cian.nosp@m.isi@c.nosp@m.inec.nosp@m.a.it)
- Date
- Aug 26, 2012
Definition in file al_io.c.
int AL_File_close |
( |
int |
sz_ptr | ) |
|
Close a file associate with and array
- Parameters
-
[in] | sz_ptr | integer pointer to array descriptor |
Definition at line 83 of file al_io.c.
97 errcode = MPI_File_close(&(s->
ifp));
104 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
105 MPI_Error_string(errcode, es, &len);
106 printf(
"Errcode from MPI_File_close: %d | %s\n", errcode, es);
108 printf(
"myid %d, AL_File_close: Closed file, errcode %d \n",myid, errcode);
SZ * sz_stack[AL_MAX_ARRAYS]
int AL_File_open |
( |
char * |
filename, |
|
|
int |
sz_ptr |
|
) |
| |
Open a file associated with a distributed array
- Parameters
-
[in] | filename | name of the file |
[in] | sz_ptr | integer pointer to the distributed array descriptor |
- Returns
- ifp pointer to integer file pointer
Definition at line 27 of file al_io.c.
47 printf(
"AL_Decompose: wrong SZ pointer\n");
59 errcode = MPI_File_open(comm, filename,
60 MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_UNIQUE_OPEN,
70 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
72 MPI_Error_string(errcode, es, &len);
73 printf(
"Errcode from MPI_File_open: %d | %s\n", errcode, es);
75 printf(
"myid %d, AL_File_open: Opened file %s\n",myid,filename);
SZ * sz_stack[AL_MAX_ARRAYS]
int stack_ptr[AL_MAX_ARRAYS]
long long AL_Get_offset |
( |
int |
sz_ptr | ) |
|
Definition at line 327 of file al_io.c.
336 printf(
"AL_Get_offset: wrong SZ pointer\n");
SZ * sz_stack[AL_MAX_ARRAYS]
int stack_ptr[AL_MAX_ARRAYS]
int AL_Read_array |
( |
void * |
va, |
|
|
int |
sz_ptr, |
|
|
int |
istag |
|
) |
| |
Read a distributed array to a file in parallel using synchronous and collective IO operations
- Parameters
-
[in] | buffer | pointer to the buffer to write |
[in] | sz_ptr | integer pointer to a distributed array descriptor |
[in] | istag | set it to -1 for centred variables, set to 0,1,2 for staggered field in the x,y,z direction |
Bugs fixed on Aug 26, 2012:
- nelem has been declared long long in order to manage dbl and flt output 'single_file' in which each PLUTO variable is >= 4GB
- the updating of nelem after the writing of a variable has been modified from ''nelem *= (long long)(s->arrdim[i] +(istag == i));'' to ''nelem *= (long long)(s->arrdim[i]);'' because when a staggered variable is written, in the sz_ptr descriptor there is the information about the really number of element of this variable. This appens because the function AL_Set_staggered_dim is called for a staggered array.
Definition at line 209 of file al_io.c.
250 MPI_Barrier(s->
comm);
252 MPI_File_set_view(ifp, offset, MPI_BYTE, gsub_arr,
253 "native", MPI_INFO_NULL);
254 MPI_File_read_all(ifp, a, 1, lsub_arr, &status);
256 MPI_Type_size( s->
type, &size);
259 for(i = 0; i < s->
ndim; i++) {
273 nelem *= (
long long)(s->
arrdim[i]);
MPI_Datatype lsubarr_stag[AL_MAX_DIM]
SZ * sz_stack[AL_MAX_ARRAYS]
MPI_Datatype gsubarr_stag[AL_MAX_DIM]
int AL_Set_offset |
( |
int |
sz_ptr, |
|
|
long long |
offset |
|
) |
| |
Definition at line 342 of file al_io.c.
351 printf(
"AL_Get_offset: wrong SZ pointer\n");
SZ * sz_stack[AL_MAX_ARRAYS]
int stack_ptr[AL_MAX_ARRAYS]
int AL_Write_array |
( |
void * |
va, |
|
|
int |
sz_ptr, |
|
|
int |
istag |
|
) |
| |
Write a distributed array to a file in parallel using synchronous and collective IO operations
- Parameters
-
[in] | buffer | pointer to the buffer to write |
[in] | sz_ptr | integer pointer to the distributed array descriptor |
[in] | istag | set it to -1 for centred variables, set to 0,1,2 for staggered field in the x,y,z direction |
Bugs fixed on Aug 26, 2012:
- nelem has been declared long long in order to manage dbl and flt output 'single_file' in which each PLUTO variable is >= 4GB
- the updating of nelem after the writing of a variable has been modified from ''nelem *= (long long)(s->arrdim[i] +(istag == i));'' to ''nelem *= (long long)(s->arrdim[i]);'' because when a staggered variable is written, in the sz_ptr descriptor there is the information about the really number of element of this variable. This appens because the function AL_Set_staggered_dim is called for a staggered array.
Definition at line 115 of file al_io.c.
157 MPI_Barrier(s->
comm);
159 errcode = MPI_File_set_view(ifp, offset, MPI_BYTE, gsub_arr,
160 "native", MPI_INFO_NULL);
165 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
167 MPI_Error_string(errcode, es, &len);
168 printf(
"Errcode from MPI_File_set_view: %d | %s\n", errcode, es);
170 printf(
"myid %d, offset file_set_view %lld\n", myid,offset);
173 errcode = MPI_File_write_all(ifp, a, 1, lsub_arr, &status);
177 MPI_Error_string(errcode, es, &len);
178 printf(
"Errcode from MPI_File_write_all: %d | %s\n", errcode, es);
182 MPI_Type_size( s->
type, &size);
185 for(i = 0; i < s->
ndim; i++) {
199 nelem *= (
long long)(s->
arrdim[i]);
MPI_Datatype lsubarr_stag[AL_MAX_DIM]
SZ * sz_stack[AL_MAX_ARRAYS]
MPI_Datatype gsubarr_stag[AL_MAX_DIM]
int AL_Write_header |
( |
void * |
vbuffer, |
|
|
int |
nelem, |
|
|
AL_Datatype |
type, |
|
|
int |
sz_ptr |
|
) |
| |
Definition at line 285 of file al_io.c.
303 MPI_Type_size(type, &size);
304 buffer = (
char *) vbuffer;
312 MPI_Barrier(s->
comm);
313 MPI_File_set_view(ifp, offset, MPI_BYTE, MPI_CHAR,
314 "native", MPI_INFO_NULL);
317 MPI_File_write(ifp, buffer, nelem, type, &status);
SZ * sz_stack[AL_MAX_ARRAYS]