Subversion Repositories lagranto.wrf

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 11
Line 1... Line 1...
1
      program gettidiff
1
      program gettidiff
2
C     =================
2
C     =================
3
 
3
 
4
      implicit none
4
      implicit none
5
 
5
 
6
      integer   idate(5),irefdat(5)
6
       integer  idate(5),irefdat(5)
7
      real      ihdiff
7
       real      ihdiff
8
 
8
 
9
      integer   iargc
9
      integer   iargc
10
      character*(80) arg
10
      character*(80) arg
11
      integer	nc1,nc2,flag1,flag2
11
      integer	nc1,nc2,flag1,flag2,n,i
-
 
12
 
12
 
13
 
-
 
14
        do i=1,5
-
 
15
             idate(i)=0
-
 
16
             irefdat(i) = 0
-
 
17
        enddo
13
c     check for sufficient requested arguments
18
c     check for sufficient requested arguments
14
      if (iargc().ne.2) then
19
      if (iargc().ne.2) then
15
         print*,
20
         print*,
16
     >  'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
21
     >  'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
17
         call exit(1)
22
         call exit(1)
Line 20... Line 25...
20
c     read and transform input
25
c     read and transform input
21
      call getarg(1,arg)
26
      call getarg(1,arg)
22
      call lenchar(arg,nc1)
27
      call lenchar(arg,nc1)
23
      call checkchar(arg,'_',flag1)
28
      call checkchar(arg,'_',flag1)
24
 
29
 
-
 
30
 
-
 
31
c      print*,'arg: ', arg
-
 
32
c      print*,'nc1',nc1
-
 
33
c      print*,'flag1',flag1
-
 
34
 
25
      if (flag1.eq.7) then
35
      if (flag1.eq.7) then
26
        read(arg(1:2),'(i2)',err=120)idate(1)
36
        read(arg(1:2),'(i2)',err=120)idate(1)
27
        read(arg(3:4),'(i2)',err=120)idate(2)
37
        read(arg(3:4),'(i2)',err=120)idate(2)
28
        read(arg(5:6),'(i2)',err=120)idate(3)
38
        read(arg(5:6),'(i2)',err=120)idate(3)
29
        read(arg(8:9),'(i2)',err=120)idate(4)
39
        read(arg(8:9),'(i2)',err=120)idate(4)
Line 34... Line 44...
34
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
44
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
35
          call exit(1)
45
          call exit(1)
36
        endif
46
        endif
37
      else if (flag1.eq.9) then
47
      else if (flag1.eq.9) then
38
        read(arg(1:4),'(i4)',err=120)idate(1)
48
        read(arg(1:4),'(i4)',err=120)idate(1)
-
 
49
c        print*,'idate(1): ' ,idate(1)
-
 
50
 
39
        read(arg(5:6),'(i2)',err=120)idate(2)
51
        read(arg(5:6),'(i2)',err=120)idate(2)
-
 
52
c        print*,'idate(2): ' ,idate(2)
-
 
53
 
40
        read(arg(7:8),'(i2)',err=120)idate(3)
54
        read(arg(7:8),'(i2)',err=120)idate(3)
-
 
55
c        print*,'idate(3): ' ,idate(3)
-
 
56
 
41
        read(arg(10:11),'(i2)',err=120)idate(4)
57
        read(arg(10:11),'(i2)',err=120)idate(4)
-
 
58
c        print*,'idate(4): ' ,idate(4)
-
 
59
 
42
        if (nc1.eq.13) then
60
        if (nc1.eq.13) then
43
          read(arg(12:13),'(i2)',err=120)idate(5)
61
          read(arg(12:13),'(i2)',err=120)idate(5)
44
        else if (nc1.ne.11) then
62
        else if (nc1.ne.11) then
45
          print*,
63
          print*,
46
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
64
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
Line 73... Line 91...
73
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
91
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
74
          call exit(1)
92
          call exit(1)
75
        endif
93
        endif
76
      else if (flag2.eq.9) then
94
      else if (flag2.eq.9) then
77
        read(arg(1:4),'(i4)',err=120)irefdat(1)
95
        read(arg(1:4),'(i4)',err=120)irefdat(1)
-
 
96
c        print*,'irefdat(1): ' ,irefdat(1)
-
 
97
 
78
        read(arg(5:6),'(i2)',err=120)irefdat(2)
98
        read(arg(5:6),'(i2)',err=120)irefdat(2)
-
 
99
c        print*,'irefdat(2): ' ,irefdat(2)
-
 
100
 
79
        read(arg(7:8),'(i2)',err=120)irefdat(3)
101
        read(arg(7:8),'(i2)',err=120)irefdat(3)
-
 
102
c        print*,'irefdat(3): ' ,irefdat(3)
-
 
103
 
80
        read(arg(10:11),'(i2)',err=120)irefdat(4)
104
        read(arg(10:11),'(i2)',err=120)irefdat(4)
-
 
105
c        print*,'irefdat(4): ' ,irefdat(4)
-
 
106
 
81
        if (nc2.eq.13) then
107
        if (nc2.eq.13) then
82
          read(arg(12:13),'(i2)',err=120)irefdat(5)
108
          read(arg(12:13),'(i2)',err=120)irefdat(5)
83
        else if (nc2.ne.11) then
109
        else if (nc2.ne.11) then
84
          print*,
110
          print*,
85
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
111
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
Line 89... Line 115...
89
        print*,
115
        print*,
90
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
116
     >   'USAGE: gettidiff date1 date2 (format (YY)YYMMDD_HH(MM))'
91
        call exit(1)
117
        call exit(1)
92
      endif
118
      endif
93
 
119
 
-
 
120
 
-
 
121
c       do i=1,5
-
 
122
c         print*,'idate(',i,')',idate(i)
-
 
123
c        print*,'irefdat(',i,')',irefdat(i)
-
 
124
c       enddo
-
 
125
 
94
      call timediff(idate,irefdat,ihdiff)
126
      call timediff(idate,irefdat,ihdiff)
-
 
127
c      print*, int(ihdiff)
-
 
128
 
-
 
129
c       print*,'ihdiff',ihdiff
95
 
130
 
96
      if (int(100.*ihdiff).eq.100*int(ihdiff)) then
131
      if (int(100.*ihdiff).eq.100*int(ihdiff)) then
-
 
132
           print*, ifix(ihdiff)
97
        write(*,*)int(ihdiff)
133
c         write(*,'(f7.2)')ihdiff
98
      else
134
        else
99
        write(*,'(f7.2)')ihdiff
135
            write(*,'(f7.2)')ihdiff
-
 
136
c         write(*,*)ihdiff
100
      endif
137
         endif
101
 
138
 
102
      goto 200
139
      goto 200
103
 
140
 
104
 120  write(*,*)
141
 120  write(*,*)
105
     >"*** error: date must be in format (YY)YYMMDD_HH(MM) ***"
142
     >"*** error: date must be in format (YY)YYMMDD_HH(MM) ***"