Back to index

salome-paravis  6.5.0
Defines | Functions
TestMedParallelRead.cxx File Reference
#include <vtkMed.h>
#include "med_utils.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>

Go to the source code of this file.

Defines

#define MAX(a, b)   ((a) > (b) ? (a) : (b))
#define MED_HAVE_MPI
#define MESGERR   1

Functions

int main (int argc, char **argv)

Define Documentation

#define MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 27 of file TestMedParallelRead.cxx.

#define MED_HAVE_MPI

Definition at line 29 of file TestMedParallelRead.cxx.

#define MESGERR   1

Definition at line 32 of file TestMedParallelRead.cxx.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file TestMedParallelRead.cxx.

{
  med_err _ret=0;
  med_idt _fid;

  int mpi_size, mpi_rank;
  MPI_Comm comm = MPI_COMM_WORLD;
  MPI_Info info = MPI_INFO_NULL;

  med_int    _nbofentitiesfiltered=0;
  med_int    *_filterarray=NULL;

  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
  MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);

  med_size            _nbblocksperproc    = 0;
  int           _nbofentities             = 0;
  int           _nbofvaluesperentity      = 0;
  int           _nbofconstituentpervalue  = 0;

  printf("mpi_size = %03d\n", mpi_size);

  if (mpi_rank == 0 ) {

    struct tm *_tm ;
    time_t _tt=time(0);
    _tm = localtime(&_tt);

    srandom((*_tm).tm_sec * (*_tm).tm_min );
    _nbblocksperproc         = 1 + (int) (mpi_size * (random() / (RAND_MAX + 1.0)));
    _nbofentities            = 1 + (int) (1000.0 * (random() / (RAND_MAX + 1.0)));
    _nbofvaluesperentity     = 1 + (int) (11.0 * (random() / (RAND_MAX + 1.0)));
    _nbofconstituentpervalue = 1 + (int) (7.0 * (random() / (RAND_MAX + 1.0)));
  }

  MPI_Bcast(&_nbblocksperproc         , 1, MPI_LONG, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_nbofentities            , 1, MPI_LONG, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_nbofvaluesperentity     , 1, MPI_LONG, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_nbofconstituentpervalue , 1, MPI_LONG, 0, MPI_COMM_WORLD);

  printf( "NENT-%03d_NVAL-%03d_NCST-%03d_NBL-%03llu\n",_nbofentities,_nbofvaluesperentity,
          _nbofconstituentpervalue,_nbblocksperproc);

  char         _filename   [255]="";
  sprintf(_filename,"/home/alejandro/work/Data-test-Med/tmp/depl.resu.med");
  /*     SSCRUTE(_filename); */

  /* Ouverture du fichier en mode parallel */
  if ((_fid = MEDparFileOpen(_filename, MED_ACC_RDONLY ,comm, info)) < 0){
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
  }

  if ( MEDfileClose( _fid ) < 0) {
      MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
    }

  /* MPI_Finalize must be called AFTER MEDclose which may use MPI calls */
  MPI_Finalize();

}