[med-fichier] 02/03: Add 2 more autotests.

Anton Gladky gladk at moszumanska.debian.org
Sat May 3 14:42:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

gladk pushed a commit to branch master
in repository med-fichier.

commit 9b7e17a07961659c160eea59c85a7a11e2c9bb63
Author: Anton Gladky <gladk at debian.org>
Date:   Sat May 3 16:16:42 2014 +0200

    Add 2 more autotests.
---
 debian/tests/build             | 202 -------------------
 debian/tests/{build => build1} |   0
 debian/tests/build2            | 438 +++++++++++++++++++++++++++++++++++++++++
 debian/tests/build3            | 341 ++++++++++++++++++++++++++++++++
 debian/tests/control           |   2 +-
 5 files changed, 780 insertions(+), 203 deletions(-)

diff --git a/debian/tests/build b/debian/tests/build
old mode 100755
new mode 100644
index c3a51d9..6b14ca8
--- a/debian/tests/build
+++ b/debian/tests/build
@@ -11,209 +11,7 @@ WORKDIR=$(mktemp -d)
 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
 cd $WORKDIR
 cat <<EOF > usescase.c
-/*  This file is part of MED.
- *
- *  COPYRIGHT (C) 1999 - 2012  EDF R&D, CEA/DEN
- *  MED is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU Lesser General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  MED is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public License
- *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
- */
 
-/* 
- * Field use case 10 : write a field in a MED file with computing steps,
- *                     profiles, integration points and interpolation families
- */
-
-#include <med.h>
-#define MESGERR 1
-#include <med_utils.h>
-
-#include <string.h>
-
-
-int main (int argc, char **argv) {
-  med_idt fid;
-  const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh";
-  const char fieldname[MED_NAME_SIZE+1] = "TEMPERATURE_FIELD";
-  const med_int ncomponent = 1;
-  const char componentname[MED_SNAME_SIZE+1] = "TEMPERATURE";
-  const char componentunit[MED_SNAME_SIZE+1] = "C";
-  const med_float tria3values_step1_profile1[9] = {1000.,1010.,1020.,    
-						   4000.,4010.,4020.,    
-						   8000.,8010.,8020. };
-  const med_float tria3values_step2_profile1[24] = {1500.,1510.,1520.,    
-						    0.,   0.,   0.,
-						    0.,   0.,   0.,
-						    4500.,4510,4520.,
-						    0.,   0.,   0.,
-						    0.,   0.,   0.,
-						    0.,   0.,   0.,
-						    8500., 8510, 8520 };
-  const med_float tria3values_step2_profile2[32] = {   0.,   0.,   0.,  0.,
-						       2500.,2510.,2520,2530., 
-						       3500.,3510.,3520.,3530.,    
-						       0.,   0.,   0.,  0.,
-						       5500.,5510.,5520.,5530., 
-						       6500.,6510.,6520.,6530., 
-						       7500.,7510.,7520.,7530.,   
-						       0.,   0.,   0.,   0. };
-  const med_int ntria3 = 8;
-  const med_int nquad4 = 4;
-  const med_float quad4values_step1[4] = {10000., 20000., 30000., 40000.};
-  const med_float quad4values_step2[4] = {15000., 25000., 35000., 45000.};
-  const char profile1name[MED_NAME_SIZE+1] = "MED_TRIA3_PROFILE1";
-  const med_int profile1[3] = {1, 4, 8}; 
-  const med_int profile1size = 3;
-  const char profile2name[MED_NAME_SIZE+1] = "MED_TRIA3_PROFILE2";
-  const med_int profile2[5] = {2, 3, 5, 6, 7}; 
-  const med_int profile2size = 5;
-  const char localization1name[MED_NAME_SIZE+1] = "TRIA3_INTEGRATION_POINTS_3";
-  const med_float weight1[3] = {1.0/6, 1.0/6, 1.0/6};
-  const med_float elementcoordinate[6] = {0.0, 0.0,  1.0, 0.0,  0.0,1.0};
-  const med_float ipoint1coordinate[6] = {1.0/6, 1.0/6,  2.0/3, 1.0/6,  1.0/6, 2.0/6};
-  const char localization2name[MED_NAME_SIZE+1] = "TRIA3_INTEGRATION_POINTS_4";
-  const med_float weight2[6] = {25.0/(24*4), 25.0/(24*4), 25.0/(24*4), -27.0/(24*4)};
-  const med_float ipoint2coordinate[8] = {1.0/5, 1.0/5,  3.0/5, 1.0/5,  1.0/5, 3.0/5,  1.0/3, 1.0/3};
-  med_int nipoint, spacedim;
-  const char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
-  int ret=-1;
-
-  /* file creation */
-  fid = MEDfileOpen("UsesCase_MEDfield_10.med",MED_ACC_CREAT);
-  if (fid < 0) {
-    MESSAGE("ERROR : file creation ...");
-    goto ERROR;
-  }
-
-  /* create mesh link */
-  if (MEDlinkWr(fid,meshname,"./UsesCase_MEDmesh_1.med") < 0) {
-    MESSAGE("ERROR : create mesh link ...");
-    goto ERROR;
-  }
-  
-  /* create the profiles in the file */
-  if (MEDprofileWr(fid, profile1name, profile1size, profile1 ) < 0) {
-    MESSAGE("ERROR : create profile ...");
-    goto ERROR; 
-  }
-
-  if (MEDprofileWr(fid, profile2name, profile2size, profile2 ) < 0) {
-    MESSAGE("ERROR : create profile ...");
-    goto ERROR; 
-  }
-
-  /* create the localization elements for integration points */
-  spacedim = 2;
-  nipoint = 3;
-  if (MEDlocalizationWr(fid, localization1name, MED_TRIA3, spacedim, 
-			elementcoordinate, MED_FULL_INTERLACE, 
-			nipoint, ipoint1coordinate, weight1,
-			MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT) < 0) {
-    MESSAGE("ERROR : create famlily of integration points ...");
-    goto ERROR; 
-  }
-
-  spacedim = 2;
-  nipoint = 4;
-  if (MEDlocalizationWr(fid, localization2name, MED_TRIA3, spacedim, 
-			elementcoordinate, MED_FULL_INTERLACE, 
-			nipoint, ipoint2coordinate, weight2, 
-			MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT) < 0) {
-    MESSAGE("ERROR : create famlily of integration points ...");
-    goto ERROR; 
-  }
-
-  /* 
-   * Temperature field  creation : 
-   * - 1 component 
-   * - component unit : celsius degree
-   * - mesh is the 2D unstructured mesh of UsecaseMEDmesh_1.c use case.
-   * - computation step unit in 'ms'
-   */ 
-  if (MEDfieldCr(fid, fieldname, MED_FLOAT64, 
-		 ncomponent, componentname, componentunit,
-		 "ms", meshname) < 0) {
-    MESSAGE("ERROR : create field");
-    goto ERROR;
-  }
-
-  /* write interpolation family name for MED_TRIA3 cell type */
-  /* The interpolation family "interpname" is created in the UsesCase_MEDinterp_1 
-     use case */
-  if (MEDfieldInterpWr(fid,fieldname,interpname) <0) {
-    MESSAGE("ERROR : write field interpolation family name ...");
-    goto ERROR;
-  }  
-  
-  /* two computation steps */
-  /* write values at cell centers : 8 MED_TRIA3 and 4 MED_QUAD4 */
-
-  /* STEP 1 : dt1 = 5.5, it = 1*/
-  /* MED_TRIA3 : with a profile of 3 values in compact memory storage mode 
-     and a family of 3 integration points */
-  if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_CELL,MED_TRIA3, 
-				 MED_COMPACT_PFLMODE, profile1name, localization1name,    
-				 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, 
-				 ntria3, (unsigned char*) tria3values_step1_profile1) < 0) {
-    MESSAGE("ERROR : write field values on MED_TRIA3");
-    goto ERROR;
-  }
-   /* MED_QUAD4  : with no profile */ 
-  if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_CELL, MED_QUAD4, 
-				 MED_COMPACT_PFLMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
-				 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, 
-				 nquad4, (unsigned char*) quad4values_step1) < 0) {
-    MESSAGE("ERROR : write field values on MED_QUAD4 ");
-    goto ERROR;
-  }
-
-  /* STEP 2 : dt2 = 8.9, it = 1*/
-  /* MED_TRIA3 : with a profile of 3 values then a profile of 5 values in global memory storage mode 
-   * For each profile, a family of 3 and then 4 integration points */
-  if (MEDfieldValueWithProfileWr(fid, fieldname, 2 , 1 , 8.9 , MED_CELL, MED_TRIA3, 
-				 MED_GLOBAL_PFLMODE, profile1name, localization1name,    
-				 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,  
-				 ntria3, (unsigned char*) tria3values_step2_profile1) < 0) {
-    MESSAGE("ERROR : write field values on MED_TRIA3 ...");
-    goto ERROR;
-  }
-  if (MEDfieldValueWithProfileWr(fid, fieldname, 2 , 1 , 8.9 , MED_CELL, MED_TRIA3, 
-				 MED_GLOBAL_PFLMODE, profile2name, localization2name,    
-				 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,  
-				 ntria3, (unsigned char*) tria3values_step2_profile2) < 0) {
-    MESSAGE("ERROR : write field values on MED_TRIA3 ...");
-    goto ERROR;
-  }
-
-  /* MED_QUAD4 : with no profile */
-  if (MEDfieldValueWithProfileWr(fid, fieldname, 2, 1, 8.9, MED_CELL, MED_QUAD4, 
-				 MED_COMPACT_PFLMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
-				 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,  
-				 nquad4, (unsigned char*) quad4values_step2) < 0) {
-    MESSAGE("ERROR : write field values on MED_QUAD4 ... ");
-    goto ERROR;
-  }
-
-  ret=0;
- ERROR:
-  
-  /* close file */
-  if (MEDfileClose(fid) < 0) {
-    MESSAGE("ERROR : close file ...");             
-    ret=-1; 
-  } 
-  
-  return ret;
-}
 
 EOF
 
diff --git a/debian/tests/build b/debian/tests/build1
similarity index 100%
copy from debian/tests/build
copy to debian/tests/build1
diff --git a/debian/tests/build2 b/debian/tests/build2
new file mode 100755
index 0000000..711cc39
--- /dev/null
+++ b/debian/tests/build2
@@ -0,0 +1,438 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+#         Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > usescase.c
+/*  This file is part of MED.
+ *
+ *  COPYRIGHT (C) 1999 - 2012  EDF R&D, CEA/DEN
+ *  MED is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  MED is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Unitary tests to create parameters in MED files
+ */
+
+#include <med.h>
+#define MESGERR 1
+#include <med_utils.h>
+
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+  med_idt fid;
+  const char filename[] = "Unittest_MEDparameter_1.med";
+  const char comment[] = "Parameters unit tests";
+  const char p1name[] = "FLOAT_PARAMETER";
+  const char p2name[] = "INT_PARAMETER_1";
+  const char p3name[] = "INT_PARAMETER_2";
+  const med_parameter_type p1type = MED_FLOAT64;
+  const med_parameter_type p2type = MED_INT;
+  const med_parameter_type p3type = MED_INT;
+  const char p1description[] = "PARAMETER 1 DESCRIPTION";
+  const char p2description[] = "PARAMETER 2 DESCRIPTION";
+  const char p3description[] = "PARAMETER 3 DESCRIPTION";
+  const char dtunit1[] = "DT UNIT P1";
+  const char dtunit2[] = "DT UNIT P2";
+  const char dtunit3[] = "DT UNIT P3";
+  med_int np;
+  char nameToRead[MED_NAME_SIZE+1];
+  char descriptionToRead[MED_COMMENT_SIZE+1];
+  med_parameter_type typeToRead;
+  char dtunitToRead[MED_SNAME_SIZE+1];
+  med_int nstepToRead;
+  int i,j;
+  med_float p1v1 = 6.98;
+  med_float p1v2 = 19.07;
+  med_float p1v3 = 78.0;
+  med_int p1numdt1 = MED_NO_DT;
+  med_int p1numdt2 = 1;
+  med_int p1numdt3 = 1;
+  med_int p1numit1 = MED_NO_IT;
+  med_int p1numit2 = 3;
+  med_int p1numit3 = 2;
+  med_float p1dt1 = 0.0;
+  med_float p1dt2 = 0.1;
+  med_float p1dt3 = 5.5;
+  const med_int p1ncpst = 3;
+  med_int p2v1 = 5;
+  med_int p2v2 = 6;
+  med_int p2numit1 = MED_NO_IT;
+  med_int p2numdt1 = MED_NO_DT;
+  med_float p2dt1 = 0.0;
+  const med_int p2ncpst = 1;
+  med_int p3v1 = 77;
+  med_int p3v2 = 89;
+  med_int p3numdt1 = 1;
+  med_int p3numit1 = 1;
+  med_float p3dt1 = 18.9;
+  med_int p3numdt2 = MED_NO_DT;
+  med_int p3numit2 = MED_NO_IT;
+  med_float p3dt2 = 0.0;
+  const med_int p3ncpst = 2;
+  med_int numdtToRead;
+  med_int numitToRead;
+  med_float dtToRead; 
+  med_float fvalueToRead;
+  med_int ivalueToRead;
+
+  /* file creation */
+  fid = MEDfileOpen(filename,MED_ACC_CREAT);
+  if (fid < 0) {
+    MESSAGE("ERROR : file creation ...");
+    SSCRUTE(filename);
+    return -1;
+  }
+
+  if (MEDfileCommentWr(fid,comment) < 0) {
+    MESSAGE("ERROR : write comment ...");
+    SSCRUTE(comment);
+    return -1;
+  }
+
+  /* create a MED_FLOAT64 parameter */
+  if (MEDparameterCr(fid, p1name, p1type, p1description, dtunit1) < 0) {
+        MESSAGE("ERROR : parameter p1 creation ...");
+	SSCRUTE(p1name);
+	return -1;
+  }
+
+  if (MEDparameterValueWr(fid, p1name, p1numdt1, p1numit1, p1dt1, (unsigned char*) &p1v1) < 0) {
+        MESSAGE("ERROR : write p1v1   ...");
+	SSCRUTE(p1name);
+	return -1;
+  }
+  if (MEDparameterValueWr(fid, p1name, p1numdt2, p1numit2, p1dt2, (unsigned char*) &p1v2) < 0) {
+        MESSAGE("ERROR : write p1v2   ...");
+	SSCRUTE(p1name);
+	return -1;
+  }
+  if (MEDparameterValueWr(fid, p1name, p1numdt3, p1numit3, p1dt3, (unsigned char*) &p1v3) < 0) {
+        MESSAGE("ERROR : write p1v3   ...");
+	SSCRUTE(p1name);
+	return -1;
+  }
+
+  /* create a MED_INT parameter with different values */
+  if (MEDparameterCr(fid, p2name, p2type, p2description, dtunit2) < 0) {
+        MESSAGE("ERROR : paramter p2 creation ...");
+	SSCRUTE(p2name);
+	return -1;
+  }
+  if (MEDparameterValueWr(fid, p2name, p2numdt1, p2numit1, p2dt1, (unsigned char*) &p2v1) < 0) {
+        MESSAGE("ERROR : write p2v1   ...");
+	SSCRUTE(p2name);
+	return -1;
+  }
+  if (MEDparameterValueWr(fid, p2name, p2numdt1, p2numit1, p2dt1, (unsigned char*) &p2v2) < 0) {
+        MESSAGE("ERROR : write p2v2 on same computation step  ...");
+	SSCRUTE(p2name);
+	return -1;
+  }
+
+  /* create another MED_INT parameter */
+  if (MEDparameterCr(fid, p3name, p3type, p3description, dtunit3) < 0) {
+        MESSAGE("ERROR : paramter p3 creation ...");
+	SSCRUTE(p3name);
+	return -1;
+  }
+  if (MEDparameterValueWr(fid, p3name, p3numdt1, p3numit1, p3dt1, (unsigned char*) &p3v1) < 0) {
+        MESSAGE("ERROR : write p3v1   ...");
+	SSCRUTE(p3name);
+	return -1;
+  }
+  if (MEDparameterValueWr(fid, p3name, p3numdt2, p3numit2, p3dt2, (unsigned char*) &p3v2) < 0) {
+        MESSAGE("ERROR : write p3v2   ...");
+	SSCRUTE(p3name);
+	return -1;
+  }
+
+  /* close file */
+  if (MEDfileClose(fid) < 0) {
+    MESSAGE("ERROR : file closing ...");             
+    return -1; 
+  } 
+
+  /* open file in READ ONLY access mode */
+  fid = MEDfileOpen(filename,MED_ACC_RDONLY);
+  if (fid < 0) {
+    MESSAGE("ERROR : open in READ ONLY ACCESS mode ...");
+    SSCRUTE(filename);
+    return -1;
+  }
+
+  /* direct access to parameters */
+  if (MEDparameterInfoByName(fid, p1name, &typeToRead, descriptionToRead,
+			     dtunitToRead, &nstepToRead) < 0) {
+    MESSAGE("ERROR : read information for parameter p1 ...");
+    SSCRUTE(p1name);
+    ISCRUTE(typeToRead);
+    SSCRUTE(descriptionToRead);
+    SSCRUTE(dtunitToRead);
+    ISCRUTE(nstepToRead);
+    return -1;
+  }
+  if ((typeToRead != p1type) || strcmp(descriptionToRead, p1description) ||
+      strcmp(dtunitToRead,dtunit1) || (nstepToRead != p1ncpst)) {
+    MESSAGE("ERROR : read information for parameter p1 : attributes ...");
+    SSCRUTE(p1name);
+    ISCRUTE(typeToRead);
+    SSCRUTE(descriptionToRead);
+    SSCRUTE(dtunitToRead);
+    ISCRUTE(nstepToRead);
+    return -1;
+  }
+
+  if (MEDparameterInfoByName(fid, p2name, &typeToRead, descriptionToRead,
+			     dtunitToRead, &nstepToRead) < 0) {
+    MESSAGE("ERROR : read information for parameter p2 ...");
+    SSCRUTE(p2name);
+    ISCRUTE(typeToRead);
+    SSCRUTE(descriptionToRead);
+    SSCRUTE(dtunitToRead);
+    ISCRUTE(nstepToRead);
+    return -1;
+  }
+  if ((typeToRead != p2type) || strcmp(descriptionToRead, p2description) ||
+      strcmp(dtunitToRead,dtunit2) || (nstepToRead != p2ncpst)) {
+    MESSAGE("ERROR : read information for parameter p2 : attributes ...");
+    SSCRUTE(p2name); 
+    ISCRUTE(typeToRead); ISCRUTE(p2type);
+    SSCRUTE(descriptionToRead); SSCRUTE(p2description);
+    SSCRUTE(dtunitToRead); SSCRUTE(dtunit2);
+    ISCRUTE(nstepToRead); ISCRUTE(p2ncpst);
+    return -1;
+  }
+
+  if (MEDparameterInfoByName(fid, p3name, &typeToRead, descriptionToRead,
+			     dtunitToRead, &nstepToRead) < 0) {
+    MESSAGE("ERROR : read information for parameter p3 ...");
+    SSCRUTE(p3name);
+    ISCRUTE(typeToRead);
+    SSCRUTE(descriptionToRead);
+    SSCRUTE(dtunitToRead);
+    ISCRUTE(nstepToRead);
+    return -1;
+  }
+  if ((typeToRead != p3type) || strcmp(descriptionToRead, p3description) ||
+      strcmp(dtunitToRead,dtunit3) || (nstepToRead != p3ncpst)) {
+    MESSAGE("ERROR : read information for parameter p2 : attributes ...");
+    SSCRUTE(p3name);
+    ISCRUTE(typeToRead);
+    SSCRUTE(descriptionToRead);
+    SSCRUTE(dtunitToRead);
+    ISCRUTE(nstepToRead);
+    return -1;
+  }
+  
+  /* how many parameter(s) in the file ? */
+  if ((np = MEDnParameter(fid)) < 0) {
+    MESSAGE("ERROR : read number of paremeter ...");
+    ISCRUTE(np);
+    return -1;
+  }
+  if (np != 3) {
+    MESSAGE("The number of parameter is 3 !");
+    ISCRUTE(np);
+    return -1;
+  }
+  /* TODO : A SUPPRIMER */
+  np=0;
+
+  /* read informations for each parameter */ 
+  for (i=0;i<np;i++) {
+
+    if (MEDparameterInfo(fid, i+1, nameToRead, &typeToRead, descriptionToRead,
+			 dtunitToRead, &nstepToRead) < 0) {
+      MESSAGE("ERROR : read information for parameter p3 ...");
+      SSCRUTE(nameToRead);
+      ISCRUTE(typeToRead);
+      SSCRUTE(descriptionToRead);
+      SSCRUTE(dtunitToRead);
+      ISCRUTE(nstepToRead);
+      return -1;
+    }
+
+    if (i == 0)
+      if (strcmp(nameToRead, p1name) || (typeToRead != p1type) || 
+	  strcmp(descriptionToRead, p1description) || strcmp(dtunitToRead,dtunit1) 
+	  || (nstepToRead != p1ncpst)) {
+	MESSAGE("ERROR : read information for parameter p1 : attributes ...");
+	SSCRUTE(nameToRead);
+	ISCRUTE(typeToRead);
+	SSCRUTE(descriptionToRead);
+	SSCRUTE(dtunitToRead);
+	ISCRUTE(nstepToRead);
+	return -1;
+      }
+
+    if (i == 1)
+      if ( strcmp(nameToRead, p2name) || (typeToRead != p2type) || 
+	   strcmp(descriptionToRead, p2description) || strcmp(dtunitToRead,dtunit2) 
+	   || (nstepToRead != p2ncpst)) {
+	MESSAGE("ERROR : read information for parameter p2 : attributes ...");
+	SSCRUTE(nameToRead);
+	ISCRUTE(typeToRead);
+	SSCRUTE(descriptionToRead);
+	SSCRUTE(dtunitToRead);
+	ISCRUTE(nstepToRead);
+	return -1;
+      }
+
+    if (i == 3)
+      if (strcmp(nameToRead,p3name) || (typeToRead != p3type) || 
+	  strcmp(descriptionToRead, p3description) || strcmp(dtunitToRead,dtunit3) || 
+	  (nstepToRead != p3ncpst)) {
+	MESSAGE("ERROR : read information for parameter p2 : attributes ...");
+	SSCRUTE(nameToRead);
+	ISCRUTE(typeToRead);
+	SSCRUTE(descriptionToRead);
+	SSCRUTE(dtunitToRead);
+	ISCRUTE(nstepToRead);
+	return -1;
+      }
+
+    /* read informations about each computation step
+       and then read value for each parameter */
+    for (j=0; j<nstepToRead; j++) {
+
+      if (MEDparameterComputationStepInfo(fid, nameToRead, j+1, 
+					  &numdtToRead, &numitToRead, &dtToRead) < 0) {
+	MESSAGE("ERROR : read information about computation step ...");
+	SSCRUTE(nameToRead);
+	ISCRUTE(j);
+	ISCRUTE(numdtToRead);
+	ISCRUTE(numitToRead);
+	return -1;
+      }
+
+      if (typeToRead == MED_FLOAT64)
+	if (MEDparameterValueRd(fid, nameToRead, numdtToRead, numitToRead,
+				(unsigned char *) &fvalueToRead) < 0) {
+	  MESSAGE("ERROR : read parameter value ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead);
+	  ISCRUTE(numitToRead);
+	  return -1;
+	}
+
+      if (typeToRead != MED_FLOAT64)
+	if (MEDparameterValueRd(fid, nameToRead, numdtToRead, numitToRead,
+				(unsigned char *) &ivalueToRead) < 0) {
+	  MESSAGE("ERROR : read parameter value ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead);
+	  ISCRUTE(numitToRead);
+	  ISCRUTE(ivalueToRead);
+	  return -1;
+	}
+
+      /* data verifications */
+      if ((i==0) && (j==0))
+	if ((numdtToRead != p1numdt1) || (numitToRead != p1numit1) || (dtToRead != p1dt1) ||
+	    (fvalueToRead != p1v1)) {
+	  MESSAGE("ERROR : false informations for computation step : attributes ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead); ISCRUTE(p1numdt1);
+	  ISCRUTE(numitToRead); ISCRUTE(p1numit1);
+	  return -1;
+	}
+
+      if ((i==0) && (j==1))
+	if ((numdtToRead != p1numdt3) || (numitToRead != p1numit3) || (dtToRead != p1dt3) ||
+	    (fvalueToRead != p1v3)) {
+	  MESSAGE("ERROR : false informations for computation step : attributes ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead); ISCRUTE(p1numdt3);
+	  ISCRUTE(numitToRead); ISCRUTE(p1numit3);
+	  return -1;
+	}
+
+      if ((i==0) && (j==2))
+	if ((numdtToRead != p1numdt2) || (numitToRead != p1numit2) || (dtToRead != p1dt2) ||
+	    (fvalueToRead != p1v2)) {
+	  MESSAGE("ERROR : false informations for computation step : attributes ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead); ISCRUTE(p1numdt2);
+	  ISCRUTE(numitToRead); ISCRUTE(p1numit2);
+	  return -1;
+	}
+
+      if (i==1)
+	if ((numdtToRead != p2numdt1) || (numitToRead != p2numit1) || (dtToRead != p2dt1) ||
+	    (ivalueToRead != p2v2)) {
+	  MESSAGE("ERROR : false informations for computation step : attributes ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead); ISCRUTE(p2numdt1);
+	  ISCRUTE(numitToRead); ISCRUTE(p2numit1);
+	  return -1;
+	}
+
+      if ((i == 2) && (j == 0))
+	if ((numdtToRead != p3numdt2) || (numitToRead != p3numit2) || (dtToRead != p3dt2) ||
+	    (ivalueToRead != p3v2)) {
+	  MESSAGE("ERROR : false informations for computation step : attributes ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead); ISCRUTE(p3numdt2);
+	  ISCRUTE(numitToRead); ISCRUTE(p3numit2);
+	  return -1;
+	}
+
+      if ((i == 2) && (j == 1))
+	if ((numdtToRead != p3numdt1) || (numitToRead != p3numit1) || (dtToRead != p3dt1) ||
+	    (ivalueToRead != p3v1)) {
+	  MESSAGE("ERROR : false informations for computation step : attributes ...");
+	  SSCRUTE(nameToRead);
+	  ISCRUTE(j);
+	  ISCRUTE(numdtToRead); ISCRUTE(p3numdt1);
+	  ISCRUTE(numitToRead); ISCRUTE(p3numit1);
+	  return -1;
+	}
+
+    }
+
+  }
+
+  /* close file */
+  if (MEDfileClose(fid) < 0) {
+    MESSAGE("ERROR : close file ...");
+    return -1;
+  }
+  
+  return 0;
+}
+
+EOF
+
+gcc -I/usr/include/mpi -I/usr/include -lmedC  -o usescase usescase.c
+echo "build: OK"
+[ -x usescase ]
+./usescase
+echo "run: OK"
diff --git a/debian/tests/build3 b/debian/tests/build3
new file mode 100755
index 0000000..e9045fb
--- /dev/null
+++ b/debian/tests/build3
@@ -0,0 +1,341 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+#         Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > usescase.c
+/*  This file is part of MED.
+ *
+ *  COPYRIGHT (C) 1999 - 2012  EDF R&D, CEA/DEN
+ *  MED is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  MED is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * StructElement use case 1 : write struct elements model in a file
+ * STEP 1 : suppport mesh creation
+ * STEP 2 : struct element model creation
+ * STEP 3 : computation mesh creation
+ */
+
+#include <med.h>
+#define MESGERR 1
+#include <med_utils.h>
+
+#include <string.h>
+
+int main (int argc, char **argv) {
+  med_idt fid;
+  char elementname[MED_NAME_SIZE+1]="";
+  const char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
+  const char beamsupportname[MED_NAME_SIZE+1]="BEAM_SUPPORT_MESH";
+  const char computmeshname[MED_NAME_SIZE+1]="COMPUT_MESH";
+  const char beamsectionname[MED_NAME_SIZE+1]="BEAM_SECTION_MESH";
+  const med_int elementdim = 3;
+  med_int nnode;
+  med_geometry_type geotype=MED_NONE;
+  med_int ncomp;
+  const med_float ballmeshnodescoo[3] = {0.0, 0.0, 0.0 };
+  const med_float beammeshnodescoo[3*7] = {0.0,0.0,0.0,
+					   0.0,0.0,2.0,
+					   0.0,0.0,4.0,
+					   0.0,0.0,5.0,
+					   0.0,0.0,7.0,
+					   0.0,0.0,10.0,
+					   0.0,0.0,11.0 };
+  const med_float beamsectioncoo[9*3] = {-0.2,-0.2,0.0,
+					 0.0,-0.2,0.0,
+					 0.2,-0.2,0.0,
+					 -0.2, 0.0,0.0,
+					 0.0, 0.0,0.0,
+					 0.2, 0.0,0.0,
+					 -0.2, 0.2,0.0,
+					 0.0, 0.2,0.0,
+					 0.2, 0.2,0.0 };
+  const med_int seg2connectivity[2*6] = {1,2, 2,3, 3,4, 4,5, 5,6, 6,7};
+  med_int spacedim, meshdim,nseg2;
+  /*                                         123456789012345612345678901234561234567890123456 */
+  const char axisname[3*MED_SNAME_SIZE+1] = "x               y               z               ";
+  const char unitname[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
+  const med_float attvalue[6] = {0.2,0.3,0.4,0.4,0.3,0.2};
+  /*                                            1234567890123456789012345678901234567890123456789012345678901234        */
+  const char attprovalue[2*MED_NAME_SIZE+1] = {"EXTREMITY_1_____________________________________________________" \
+                                               "EXTREMITY_2_____________________________________________________" };
+  const char profilename[MED_NAME_SIZE+1] = "EXTREMITY_PROFILE_NAME";
+  const med_int profilesize = 2;
+  const med_int profile[2] = {1,6};
+  const med_float meshcoo[3*12] = { 0.0, 0.0, 0.0,
+				    1.1, 1.1, 1.1,
+				    2.2, 2.2, 2.2,
+				    10., 10., 10.,
+				    12., 12., 12.,
+				    60., 20., 20.,
+				    70., 20., 20.,
+				    80., 20., 20.,
+				    90., 20., 20.,
+				    100., 20., 20.,
+				    110., 20., 20.,
+				    120., 20., 20.
+  };
+  const med_int beamconnectivity[12] = {  6,7,
+					  7,8,
+					  8,9,
+					  9,10,
+					  10,11,
+					  11,12 };
+  med_int nentity;
+  const med_int labels[3] = { 1, 2, 3 }; /* nodes numbers */
+  const med_int ballconnectivity[2] = { 4, 5 }; /* nodes numbers */
+  const med_float balldiameter[2] = { 2.0, 5.8 };
+  const med_int nquad4=4;
+  const med_int beamsectionconnectivity[4*4] = { 4,5,2,1,
+						 5,6,3,2,
+						 7,8,5,4,
+						 8,9,6,5};
+  int ret=-1;
+  
+  /* file creation */
+  fid = MEDfileOpen("UsesCase_MEDstructElement_1.med",MED_ACC_CREAT);
+  if (fid < 0) {
+    MESSAGE("ERROR : file creation");
+    goto ERROR;
+  }
+
+  /* STEP 1 : support meshes creation */
+  spacedim =  3;
+  meshdim = 3;
+
+  /* Mesh 1 : support mesh for ball model */
+  if (MEDsupportMeshCr(fid, ballsupportname, spacedim, meshdim, "Support mesh for a ball model",
+		       MED_CARTESIAN, axisname, unitname) < 0) {
+    MESSAGE("ERROR : creating a support mesh ...");
+    goto ERROR;
+  }
+  /* 1 node and no cell in the mesh */
+  nnode = 1;
+  if (MEDmeshNodeCoordinateWr(fid, ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
+			      MED_FULL_INTERLACE, nnode, ballmeshnodescoo) < 0) {
+    MESSAGE("ERROR : write nodes coordinates ...");
+    goto ERROR;
+  }
+
+  /* Mesh 2 :support mesh for beam model */
+  if (MEDsupportMeshCr(fid, beamsupportname, spacedim, meshdim, "Support mesh for a beam model",
+		       MED_CARTESIAN, axisname, unitname) < 0) {
+    MESSAGE("ERROR : creating a support mesh ...");
+    goto ERROR;
+  }
+  /* 7 nodes and 6 MED_SEG2 */
+  nnode = 7;
+  if (MEDmeshNodeCoordinateWr(fid, beamsupportname, MED_NO_DT, MED_NO_IT, 0.0,
+			      MED_FULL_INTERLACE, nnode,  beammeshnodescoo) < 0) {
+    MESSAGE("ERROR : write nodes coordinates ...");
+    goto ERROR;
+  }
+  nseg2 = 6;
+  if (MEDmeshElementConnectivityWr(fid, beamsupportname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_SEG2,
+				   MED_NODAL, MED_FULL_INTERLACE, nseg2, seg2connectivity) < 0) {
+    MESSAGE("ERROR : write cells connectivity ...");
+    goto ERROR;
+  }
+
+  /* Mesh 3 : support mesh to define a section for integration points of
+     a struct element */
+  if (MEDsupportMeshCr(fid, beamsectionname, spacedim, meshdim, "Support mesh for a section of the beam model",
+		       MED_CARTESIAN, axisname, unitname) < 0) {
+    MESSAGE("ERROR : creating a support mesh ...");
+    goto ERROR;
+  }
+
+  nnode = 9;
+  if (MEDmeshNodeCoordinateWr(fid, beamsectionname, MED_NO_DT, MED_NO_IT, 0.0,
+			      MED_FULL_INTERLACE, nnode, beamsectioncoo) < 0) {
+    MESSAGE("ERROR : write nodes coordinates ...");
+    goto ERROR;
+  }
+
+  if (MEDmeshElementConnectivityWr(fid, beamsectionname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_QUAD4,
+				   MED_NODAL, MED_FULL_INTERLACE, nquad4, beamsectionconnectivity) < 0) {
+    MESSAGE("ERROR : write cells connectivity ...");
+    goto ERROR;
+  }
+
+  /* STEP 2 */
+  /* particle model creation : no support mesh */
+  strcpy(elementname,MED_PARTICLE_NAME);
+  if ((geotype = MEDstructElementCr(fid, elementname, elementdim, MED_NO_MESHNAME,
+				    MED_NONE,MED_NONE)) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+  ncomp=1;
+  if (MEDstructElementVarAttCr(fid, elementname,
+			       MED_PARTICLE_LABEL, MED_ATT_INT, ncomp) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+
+  /* ball model creation */
+  strcpy(elementname,MED_BALL_NAME);
+  if ((geotype = MEDstructElementCr(fid, elementname, elementdim, ballsupportname,
+				    MED_NODE,MED_NONE)) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+  ncomp=1;
+  if (MEDstructElementVarAttCr(fid, elementname,
+			       MED_BALL_DIAMETER, MED_ATT_FLOAT64, ncomp) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+
+
+  /* A beam */
+  strcpy(elementname,MED_BEAM_NAME);
+  if ((geotype = MEDstructElementCr(fid, elementname, elementdim, beamsupportname,
+				    MED_CELL,MED_SEG2)) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+  ncomp=1;
+  /* a first constant attribute */
+  if (MEDstructElementConstAttWr(fid, elementname,
+				 MED_BEAM_THICKNESS, MED_ATT_FLOAT64, ncomp,
+				 MED_CELL,(void*) attvalue) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+  /* a second constant attribute defined with a profile for the first and the
+     last segment */
+  /* create the profile */
+    if (MEDprofileWr(fid, profilename, profilesize, profile ) < 0) {
+    MESSAGE("ERROR : create profile ...");
+    goto ERROR;
+  }
+  /* write the constant attribute */
+  if (MEDstructElementConstAttWithProfileWr(fid,
+					    elementname,
+					    "BEAM_EXTREMITIES_LABELS",
+					    MED_ATT_NAME,
+					    ncomp,
+					    MED_CELL,
+					    profilename,
+					    (void*) attprovalue) < 0) {
+    MESSAGE("ERROR : creating struct element");
+    goto ERROR;
+  }
+
+  /* STEP 3 : Computation mesh creation */
+
+  /* mesh creation */
+  if (MEDmeshCr(fid, computmeshname, spacedim, meshdim,  MED_UNSTRUCTURED_MESH,
+		"Computation mesh", "s", MED_SORT_DTIT,
+		MED_CARTESIAN, axisname, unitname) < 0) {
+    MESSAGE("ERROR : creating computation mesh ...");
+    goto ERROR;
+  }
+
+  /* mesh node creation */
+  nnode = 12;
+  if (MEDmeshNodeCoordinateWr(fid, computmeshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
+			      MED_FULL_INTERLACE, nnode, meshcoo) < 0) {
+    MESSAGE("ERROR : writing nodes coordinates ...");
+    goto ERROR;
+  }
+
+  /* 1 beam */
+  nentity = 1;
+  SSCRUTE(elementname);
+  geotype = MEDstructElementGeotype(fid,elementname);
+  ISCRUTE(geotype);
+
+  if (MEDmeshElementConnectivityWr(fid,computmeshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
+				   MED_STRUCT_ELEMENT, geotype, MED_NODAL,
+				   MED_FULL_INTERLACE, nentity, beamconnectivity) < 0 ) {
+    MESSAGE("ERROR : beam connectivity ...");
+    goto ERROR;
+  }
+
+  /* Get the dynamic geometry type of each struct element model.
+     Then for each type, write the connectivity and variable(s) attribute(s) */
+
+  /* 3 particles in the mesh */
+  strcpy(elementname,MED_PARTICLE_NAME);
+  geotype = MEDstructElementGeotype(fid,elementname);
+  nentity = 3;
+  ISCRUTE(geotype);
+  if (MEDmeshElementConnectivityWr(fid, computmeshname, MED_NO_DT, MED_NO_IT, 0.0, 
+				   MED_STRUCT_ELEMENT, geotype , MED_NODAL, MED_FULL_INTERLACE,
+				   nentity, 0) < 0) {
+    MESSAGE("ERROR : writing particles connectivity ...");
+    goto ERROR;
+  }
+
+  /* no support mesh => no connectivity, the particles are localized with an association between
+     the mesh nodes and the label attribute defined in the struct model */
+  if (MEDmeshStructElementVarAttWr(fid, computmeshname, MED_NO_DT, MED_NO_IT,
+				   geotype, MED_PARTICLE_LABEL,
+				   nentity, labels) < 0 ) {
+    MESSAGE("ERROR : writing variable attributes  ...");
+    goto ERROR;
+  }
+
+
+  /* 2 balls */
+  strcpy(elementname,MED_BALL_NAME);
+  nentity = 2;
+  geotype = MEDstructElementGeotype(fid,elementname);
+  if (MEDmeshElementConnectivityWr(fid,computmeshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
+				   MED_STRUCT_ELEMENT, geotype, MED_NODAL,
+				   MED_FULL_INTERLACE, nentity, ballconnectivity) < 0 ) {
+    MESSAGE("ERROR : writing balls connectivity");
+    goto ERROR;
+  }
+
+  /* variable attribute : write ball diameter */
+  if (MEDmeshStructElementVarAttWr(fid, computmeshname, MED_NO_DT, MED_NO_IT,
+				   geotype, MED_BALL_DIAMETER,
+				   nentity, balldiameter) < 0 ) {
+    MESSAGE("ERROR : writing variable attributes ...");
+    goto ERROR;
+  }
+
+
+  ret=0;
+ ERROR:
+
+  /* close file */
+  if (MEDfileClose(fid) < 0) {
+    MESSAGE("ERROR : file closing");
+    ret=-1;
+  }
+
+  return ret;
+}
+
+
+
+EOF
+
+gcc -I/usr/include/mpi -I/usr/include -lmedC  -o usescase usescase.c
+echo "build: OK"
+[ -x usescase ]
+./usescase
+echo "run: OK"
diff --git a/debian/tests/control b/debian/tests/control
index 4c998ed..5b31579 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,2 +1,2 @@
-Tests: build
+Tests: build1 build2 build3
 Depends: libmed-dev, build-essential

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/med-fichier.git



More information about the debian-science-commits mailing list