~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to prim/proc/md5.prg

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
! @(#)md5.prg   19.1 (ESO-DMD) 02/25/03 14:08:54
 
2
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
3
!
 
4
! MIDAS procedure md5.prg to implement COMPUTE/SIGNATURE
 
5
! K. Banse      010731
 
6
!
 
7
! use as COMPUTE/SIGNATURE file option [FITS name]
 
8
!       with option = Update (default)
 
9
!       or            Calculate_only
 
10
!            FITS name = optional name for conversion to FITS
 
11
!
 
12
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
13
!
 
14
define/param p1 ? c "Enter file name:"
 
15
define/param p2 update c "Enter option:"
 
16
define/param p3 + c "Enter FITS name:"
 
17
 
18
if p3(1:1) .ne. "+" then
 
19
   write/keyw action update
 
20
   define/local fits_out/i/1/1 1
 
21
else
 
22
   write/keyw action/c/1/8 p2
 
23
   define/local fits_out/i/1/1 0
 
24
endif
 
25
define/local orig_in/c/1/128 {p1}
 
26
if p2(1:1) .ne. "U" then
 
27
   define/local temp_fits/c/1/128 y__y.fits
 
28
   define/local upda/i/1/1 0
 
29
else
 
30
   define/local temp_fits/c/1/128 {orig_in}
 
31
   define/local upda/i/1/1 1                    !Yes. update the descr.
 
32
endif
 
33
define/local md5/c/1/32 "." all
 
34
define/local file_md5/c/1/128 {orig_in}
 
35
 
36
if aux_mode .lt. 2 then                 !VMS
 
37
   define/local version/c/1/2 ".*"
 
38
else                                    !Unix/Linux
 
39
   define/local version/c/1/1 " "
 
40
endif
 
41
mid$info(1) = m$filtyp(orig_in,"?fits")         !check, if FITS file
 
42
 
43
if mid$info(1) .eq. 1 then
 
44
   in_a = orig_in // "[0]"                      !always use primary FITS header
 
45
   inputi = m$existd(in_a,"datamd5")
 
46
else
 
47
   inputi = m$existd(orig_in,"datamd5")
 
48
   if fits_out .ne. 0 then
 
49
      inputi = m$filtyp(orig_in," ")
 
50
      if inputi .eq. 2 then                     !it's a Midas table
 
51
         create/image empty 0 ? no
 
52
         write/desc empty datamd5/c/1/32 "..." all
 
53
         write/dhelp empty datamd5 "MD5 signature of data in FITS format"
 
54
         fits_out = 2
 
55
      endif
 
56
   endif
 
57
endif
 
58
 
59
if inputi(1) .eq. 0 then                !DATAMD5 does not exist
 
60
   !
 
61
   if mid$info(1) .eq. 1 then                   !FITS file
 
62
      indisk/mfits {orig_in} x__x NOY no y__y.cat >Null
 
63
      write/keyw in_b x__x0000.bdf              !primary header => x__x0000.bdf
 
64
      write/desc {in_b} datamd5/c/1/32 "..." all
 
65
      write/dhelp {in_b} datamd5 "MD5 signature of data in FITS format"
 
66
      outdisk/sfits y__y.cat {temp_fits}                !(over)write FITS file
 
67
      run MID_EXE:fitsmd5.exe                           !and update
 
68
      delete/icat y__y.cat no >Null             !delete files from indisk/mfits
 
69
      -delete y__y.cat{version}
 
70
      if p2(1:1) .eq. "C" then
 
71
         -delete {temp_fits}{version}
 
72
      endif
 
73
   !
 
74
   else                                         !Midas file
 
75
      if fits_out .ne. 2 then
 
76
         write/desc {orig_in} datamd5/c/1/32 "..." all
 
77
         write/dhelp {orig_in} datamd5 "MD5 signature of data in FITS format"
 
78
      endif
 
79
      goto case_3
 
80
   endif
 
81
else                                    !DATAMD5 exists
 
82
   !
 
83
   if mid$info(1) .eq. 1 then                   !FITS file
 
84
      run MID_EXE:fitsmd5.exe                           !update
 
85
   !
 
86
   else                                         !Midas file
 
87
     case_3:
 
88
      if fits_out .ne. 0 then                   !create FITS file
 
89
         if fits_out .eq. 1 then
 
90
            outdisk/sfits {orig_in} {p3} >Null
 
91
         else
 
92
            outdisk/sfits empty.bdf,{orig_in} {p3} >Null
 
93
         endif
 
94
         file_md5 = p3
 
95
         run MID_EXE:fitsmd5.exe                        !signature -> OUTPUTC
 
96
      else
 
97
         outdisk/sfits {orig_in} x__x.fits >Null
 
98
         file_md5 = "x__x.fits"
 
99
         run MID_EXE:fitsmd5.exe                        !signature -> OUTPUTC
 
100
         !
 
101
         if upda .eq. 1 then
 
102
            write/desc {orig_in} datamd5/c/1/32 {outputc}       !update
 
103
         endif
 
104
         -delete x__x.fits{version}
 
105
      endif
 
106
   endif
 
107
endif