1 // Copyright (C) 2010-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 * TestMedParallelRead.cxx
23 * Created on: 20 avr. 2011
27 #define MAX(a,b) ((a) > (b) ? (a) : (b))
33 #include "med_utils.h"
39 #if TIME_WITH_SYS_TIME
40 # include <sys/time.h>
44 # include <sys/time.h>
50 int main (int argc, char **argv)
55 int mpi_size, mpi_rank;
56 MPI_Comm comm = MPI_COMM_WORLD;
57 MPI_Info info = MPI_INFO_NULL;
59 med_int _nbofentitiesfiltered=0;
60 med_int *_filterarray=NULL;
62 MPI_Init(&argc, &argv);
63 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
64 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
66 med_size _nbblocksperproc = 0;
67 int _nbofentities = 0;
68 int _nbofvaluesperentity = 0;
69 int _nbofconstituentpervalue = 0;
71 printf("mpi_size = %03d\n", mpi_size);
77 _tm = localtime(&_tt);
79 srandom((*_tm).tm_sec * (*_tm).tm_min );
80 _nbblocksperproc = 1 + (int) (mpi_size * (random() / (RAND_MAX + 1.0)));
81 _nbofentities = 1 + (int) (1000.0 * (random() / (RAND_MAX + 1.0)));
82 _nbofvaluesperentity = 1 + (int) (11.0 * (random() / (RAND_MAX + 1.0)));
83 _nbofconstituentpervalue = 1 + (int) (7.0 * (random() / (RAND_MAX + 1.0)));
86 MPI_Bcast(&_nbblocksperproc , 1, MPI_LONG, 0, MPI_COMM_WORLD);
87 MPI_Bcast(&_nbofentities , 1, MPI_LONG, 0, MPI_COMM_WORLD);
88 MPI_Bcast(&_nbofvaluesperentity , 1, MPI_LONG, 0, MPI_COMM_WORLD);
89 MPI_Bcast(&_nbofconstituentpervalue , 1, MPI_LONG, 0, MPI_COMM_WORLD);
91 printf( "NENT-%03d_NVAL-%03d_NCST-%03d_NBL-%03llu\n",_nbofentities,_nbofvaluesperentity,
92 _nbofconstituentpervalue,_nbblocksperproc);
94 char _filename [255]="";
95 sprintf(_filename,"/home/alejandro/work/Data-test-Med/tmp/depl.resu.med");
96 /* SSCRUTE(_filename); */
98 /* Ouverture du fichier en mode parallel */
99 if ((_fid = MEDparFileOpen(_filename, MED_ACC_RDONLY ,comm, info)) < 0){
100 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
103 if ( MEDfileClose( _fid ) < 0) {
104 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
107 /* MPI_Finalize must be called AFTER MEDclose which may use MPI calls */