1#! /usr/bin/env python 2# -*- coding:utf-8 -*- 3# /* This file is part of MED. 4# * 5# * COPYRIGHT (C) 1999 - 2019 EDF R&D, CEA/DEN 6# * MED is free software: you can redistribute it and/or modify 7# * it under the terms of the GNU Lesser General Public License as published by 8# * the Free Software Foundation, either version 3 of the License, or 9# * (at your option) any later version. 10# * 11# * MED is distributed in the hope that it will be useful, 12# * but WITHOUT ANY WARRANTY; without even the implied warranty of 13# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# * GNU Lesser General Public License for more details. 15# * 16# * You should have received a copy of the GNU Lesser General Public License 17# * along with MED. If not, see <http://www.gnu.org/licenses/>. 18# */ 19 20 21# /****************************************************************************** 22# * - Nom du fichier : test21.py 23# * 24# * - Description : ecriture de valeurs scalaires numeriques dans un fichier MED 25# * 26# *****************************************************************************/ 27 28from med.medfile import * 29from med.medparameter import * 30 31nom_scalaire1 = "VariableEntiere" 32description1 = "Une premiere description" 33nom_scalaire2 = "VariableFlottante" 34description2 = "Une seconde description" 35vali1 = 56 36vali2 = -789 37valr1 = 67.98 38 39MODE_ACCES = MED_ACC_CREAT 40 41fid = MEDfileOpen("test21.med",MODE_ACCES) 42 43# /* Creation d'un variable scalaire entiere */ 44MEDparameterCr(fid,nom_scalaire1,MED_INT,description1,"ms") 45print("Creation d'une variable scalaire entiere \n") 46 47# /* Ecriture d'un valeur sans pas de temps et sans numero d'ordre*/ 48MEDparameterValueWr(fid,nom_scalaire1,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MEDINT([vali1])) 49print("Ecriture d'une valeur entiere avec pas de temps \n") 50 51# /* Ecriture d'une valeur entiere avec 1 pas de temps et sans numero d'ordre */ 52MEDparameterValueWr(fid,nom_scalaire1,1,MED_NO_IT,5.5,MEDINT([vali2])) 53print("Ecriture d'une valeur entiere avec pas de temps \n") 54 55# /* Creation d'un variable scalaire flottante */ 56MEDparameterCr(fid,nom_scalaire2,MED_FLOAT64,description2,"ms") 57print("Creation d'une variable scalaire flottante \n") 58 59# /* Ecriture d'une valeur reelle avec 1 pas de temps et 1 numero d'ordre */ 60MEDparameterValueWr(fid, nom_scalaire2, 1, 2, 5.5, MEDFLOAT([valr1])) 61print("Ecriture d'une valeur reelle avec pas de temps et numero d'ordre \n") 62 63# /* Fermeture du fichier */ 64MEDfileClose(fid) 65