# usecases/f/UsesCase_MEDfield_1.f

    00001 C*  This file is part of MED.
    00002 C*
    00003 C*  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004 C*  MED is free software: you can redistribute it and/or modify
    00005 C*  it under the terms of the GNU Lesser General Public License as published by
    00006 C*  the Free Software Foundation, either version 3 of the License, or
    00007 C*  (at your option) any later version.
    00008 C*
    00009 C*  MED is distributed in the hope that it will be useful,
    00010 C*  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011 C*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012 C*  GNU Lesser General Public License for more details.
    00013 C*
    00014 C*  You should have received a copy of the GNU Lesser General Public License
    00015 C*  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016 C*
    00017
    00018 C******************************************************************************
    00019 C *
    00020 C * Field use case 1 : write a field on mesh vertices and elements
    00021 C *
    00022 C *****************************************************************************
    00023       program UsesCase_MEDfield_1
    00024 C
    00025       implicit none
    00026       include 'med.hf77'
    00027 C
    00028 C
    00029 C
    00030       integer cret
    00031       integer fid
    00032 C     component number, node number
    00033       integer ncompo, nnodes
    00034 C     triangular elements number, quadrangular elements number
    00035       integer ntria3, nquad4
    00036 C     med file name, field name, link file name
    00037       character*64  fname, finame, lfname
    00038 C     component name, commponent unit
    00039       character*16 cpname, cpunit
    00040 C     mesh name
    00041       character*64 mname
    00042       character*16 dtunit
    00043       real*8 dt
    00044 C     vertices values
    00045       real*8 verval(15)
    00046       real*8 tria3v(8)
    00047       real*8 quad4v(4)
    00048 C
    00049       parameter (fname = "./UsesCase_MEDfield_1.med")
    00050       parameter (lfname= "./UsesCase_MEDmesh_1.med")
    00051       parameter (mname = "2D unstructured mesh")
    00052       parameter (finame = "TEMPERATURE_FIELD")
    00053       parameter (cpname = "TEMPERATURE")
    00054       parameter (cpunit = "C")
    00055       parameter (dtunit = " ")
    00056       parameter (nnodes = 15, ncompo = 1 )
    00057       parameter (ntria3 =  8, nquad4 = 4)
    00058       parameter (dt = 0.0d0)
    00059 C
    00060       data verval /   0.,  100., 200.,  300.,  400.,
    00061      &              500.,  600., 700.,  800.,  900,
    00062      &             1000., 1100, 1200., 1300., 1500. /
    00063       data tria3v / 1000., 2000., 3000., 4000.,
    00064      &              5000., 6000., 7000., 8000. /
    00065       data quad4v / 10000., 20000., 30000., 4000. /
    00066 C
    00067 C
    00068 C     file creation
    00069       call mfiope(fid,fname,MED_ACC_CREAT,cret)
    00070       if (cret .ne. 0 ) then
    00071          print *,'ERROR : file creation'
    00072          call efexit(-1)
    00073       endif
    00074 C
    00075 C
    00076 C     create mesh link
    00077       call mlnliw(fid,mname,lfname,cret)
    00078       if (cret .ne. 0 ) then
    00079          print *,'ERROR : create mesh link ...'
    00080          call efexit(-1)
    00081       endif
    00082 C
    00083 C
    00084 C     field creation : temperature field  : 1 component in celsius degree
    00085 C                      the mesh is the 2D unstructured mesh of
    00086 C                      UsecaseMEDmesh_1.f
    00087       call mfdcre(fid,finame,MED_FLOAT64,ncompo,cpname,cpunit,dtunit,
    00088      &            mname,cret)
    00089       if (cret .ne. 0 ) then
    00090          print *,'ERROR : create field ...'
    00091          call efexit(-1)
    00092       endif
    00093 C
    00094 C
    00095 C     write field values at vertices
    00096       call mfdrvw(fid,finame,MED_NO_DT,MED_NO_IT,dt,MED_NODE,
    00097      &            MED_NONE,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,
    00098      &            nnodes,verval,cret)
    00099       if (cret .ne. 0 ) then
    00100          print *,'ERROR : write field values on vertices'
    00101          call efexit(-1)
    00102       endif
    00103 C
    00104 C
    00105 C     write values at cell centers : 8 MED_TRIA3 and 4 MED_QUAD4
    00106 C     MED_TRIA3
    00107       call mfdrvw(fid,finame,MED_NO_DT,MED_NO_IT,dt,MED_CELL,
    00108      &            MED_TRIA3,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,
    00109      &            ntria3,tria3v,cret)
    00110       if (cret .ne. 0 ) then
    00111          print *,'ERROR : write field values on MED_TRIA3'
    00112          call efexit(-1)
    00113       endif
    00114 C
    00115 C
    00116 C     MED_QUAD4
    00117       call mfdrvw(fid,finame,MED_NO_DT,MED_NO_IT,dt,MED_CELL,
    00118      &            MED_QUAD4,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,
    00119      &            nquad4,quad4v,cret)
    00120       if (cret .ne. 0 ) then
    00121          print *,'ERROR : write field values on MED_QUAD4'
    00122          call efexit(-1)
    00123       endif
    00124 C
    00125 C
    00126 C     close file
    00127       call mficlo(fid,cret)
    00128       if (cret .ne. 0 ) then
    00129          print *,'ERROR :  close file'
    00130          call efexit(-1)
    00131       endif
    00132 C
    00133       end
    00134 C