Back to index

salome-med  6.5.0
TestOpenMED.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDMEMTest_Utils.hxx"
00021 
00022 #include <string>
00023 #include <iostream>
00024 
00025 using namespace std;
00026 
00027 namespace med_2_3 {
00028   extern "C" { 
00029     #include <med.h>
00030     #include <med_proto.h>
00031     extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
00032     extern med_err _MEDdatagroupFermer(med_idt id);
00033   }
00034 }
00035 
00036 int main(int argc, char** argv)
00037 {
00038   cout<<"test start"<<endl;
00039 
00040   std::string filename = getResourceFile("pointe.med");
00041 
00042   med_2_3::med_idt medIdt = med_2_3::MEDouvrir( (const_cast <char *> (filename.c_str())),
00043                                                  med_2_3::MED_LECTURE_ECRITURE);
00044 
00045   cout<<"The idt of file "<<filename<<" is : "<<medIdt<<endl;
00046 
00047   if(medIdt > 0) {
00048     cout<<"File is opened in mode MED_LECTURE_ECRITURE"<<endl;
00049     int err = med_2_3::MEDfermer(medIdt);
00050     if (err != 0)
00051       cout<<"Error when closing file !"<<endl;
00052   }
00053   else {
00054     cout<<"Could not open file in mode MED_LECTURE_ECRITURE"<<endl;
00055   }
00056 
00057   medIdt = med_2_3::MEDouvrir( (const_cast <char *> (filename.c_str())),
00058                                med_2_3::MED_LECTURE);
00059 
00060   cout<<"The idt of file "<<filename<<" is : "<<medIdt<<endl;
00061 
00062   if(medIdt > 0) {
00063     cout<<"File is opened in mode MED_LECTURE"<<endl;
00064     int err = med_2_3::MEDfermer(medIdt);
00065     if (err != 0)
00066       cout<<"Error when closing file !"<<endl;
00067   }
00068   else {
00069     cout<<"Could not open file in mode MED_LECTURE"<<endl;
00070   }
00071 
00072   cout<<"test end"<<endl;
00073 
00074   return 1;
00075 }