# Unittest_MEDfile_1.f

Aller à la documentation de ce fichier.

    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 * Tests for file module
    00020 C *
    00021 C *****************************************************************************
    00022       program MEDfile
    00023 C
    00024       implicit none
    00025       include 'med.hf'
    00026 C
    00027 C
    00028       integer cret
    00029       integer fid
    00030       character*64  fname
    00031       parameter (fname = "Unittest_MEDfile_1.med")
    00032       character*200 cmt1
    00033       parameter (cmt1 = "My first comment")
    00034       character*200 cmt2
    00035       parameter (cmt2 = "My second comment")
    00036       character*200 cmtrd
    00037       integer hdfok, medok
    00038       character*32 version
    00039       integer major, minor, rel
    00040 C
    00041 C
    00042 C     file creation
    00043       call mfiope(fid,fname,MED_ACC_CREAT,cret)
    00044       print *,cret
    00045       print *,fid
    00046       if (cret .ne. 0 ) then
    00047          print *,'ERROR : file creation'
    00048          call efexit(-1)
    00049       endif
    00050 C
    00051 C
    00052 C     write a comment
    00053       call mficow(fid,cmt1,cret)
    00054       print *,cret
    00055       if (cret .ne. 0 ) then
    00056          print *,'ERROR : write a comment'
    00057          call efexit(-1)
    00058       endif
    00059 C
    00060 C
    00061 C     close file
    00062       call mficlo(fid,cret)
    00063       print *,cret
    00064       if (cret .ne. 0 ) then
    00065          print *,'ERROR :  close file'
    00066          call efexit(-1)
    00067       endif
    00068 C
    00069 C
    00070 C     open file in read only access mode
    00071       call mfiope(fid,fname,MED_ACC_RDONLY,cret)
    00072       print *,cret
    00073       print *,fid
    00074       if (cret .ne. 0 ) then
    00075          print *,'ERROR : open file in READ_ONLY access mode'
    00076          call efexit(-1)
    00077       endif
    00078 C
    00079 C
    00080 C     read med library version in the file
    00081       call mfinvr(fid,major,minor,rel,cret)
    00082       print *,cret
    00083       print *,major,minor,rel
    00084       if (cret .ne. 0 ) then
    00085          print *,'ERROR : read MED (num) version in the file'
    00086          call efexit(-1)
    00087       endif
    00088
    00089       call mfisvr(fid,version,cret)
    00090       print *,cret
    00091       print *,version
    00092       if (cret .ne. 0 ) then
    00093          print *,'ERROR : read MED (str) version in the file'
    00094          call efexit(-1)
    00095       endif
    00096 C
    00097 C
    00098 C     read a comment
    00099       call mficor(fid,cmtrd,cret)
    00100       print *,cret
    00101       print *,cmtrd
    00102       if (cret .ne. 0 ) then
    00103          print *,'ERROR : read a comment'
    00104          call efexit(-1)
    00105       endif
    00106       if (cmtrd .ne. cmt1) then
    00107          print *,'ERROR : file comment is not the good one'
    00108          call efexit(-1)
    00109       endif
    00110 C
    00111 C
    00112 C     close file
    00113       call mficlo(fid,cret)
    00114       print *,cret
    00115       if (cret .ne. 0 ) then
    00116          print *,'ERROR :  close file'
    00117          call efexit(-1)
    00118       endif
    00119 C
    00120 C
    00121 C     open file in read and write access mode
    00122       call mfiope(fid,fname,MED_ACC_RDWR,cret)
    00123       print *,cret
    00124       print *,fid
    00125       if (cret .ne. 0 ) then
    00126          print *,'ERROR : open file in READ and WRITE access mode'
    00127          call efexit(-1)
    00128       endif
    00129 C
    00130 C
    00131 C     write a comment
    00132       call mficow(fid,cmt2,cret)
    00133       print *,cret
    00134       if (cret .ne. 0 ) then
    00135          print *,'ERROR : write a comment'
    00136          call efexit(-1)
    00137       endif
    00138 C
    00139 C
    00140 C     close file
    00141       call mficlo(fid,cret)
    00142       print *,cret
    00143       if (cret .ne. 0 ) then
    00144          print *,'ERROR :  close file'
    00145          call efexit(-1)
    00146       endif
    00147 C
    00148 C
    00149 C     open file in read and extension access mode
    00150       call mfiope(fid,fname,MED_ACC_RDEXT,cret)
    00151       print *,cret
    00152       print *,fid
    00153       if (cret .ne. 0 ) then
    00154          print *,'ERROR : open file in READ and WRITE access mode'
    00155          call efexit(-1)
    00156       endif
    00157 C
    00158 C
    00159 C     write a comment has to be impossible because it exits
    00160       call mficow(fid,cmt1,cret)
    00161       print *,cret
    00162       if (cret .eq. 0 ) then
    00163          print *,'ERROR : write a comment has to be impossible'
    00164          call efexit(-1)
    00165       endif
    00166 C
    00167 C
    00168 C     close file
    00169       call mficlo(fid,cret)
    00170       print *,cret
    00171       if (cret .ne. 0 ) then
    00172          print *,'ERROR :  close file'
    00173          call efexit(-1)
    00174       endif
    00175 C
    00176 C
    00177 C     test file compatiblity with hdf-5 et med
    00178       print *,fname
    00179       call mficom(fname,hdfok,medok,cret)
    00180       print *,cret
    00181       print *,medok,hdfok
    00182       if (cret .ne. 0 ) then
    00183          print *,'ERROR : file compatibility'
    00184          call efexit(-1)
    00185       endif
    00186       if (hdfok .ne. 1) then
    00187          print *,'ERROR : the file must be in hdf5 format'
    00188          call efexit(-1)
    00189       endif
    00190       if (medok .ne. 1) then
    00191          print *,'ERROR : the file must be compatible'
    00192          call efexit(-1)
    00193       endif
    00194       end
    00195