da_get_times_cdf.inc
References to this file elsewhere.
1 subroutine da_get_times_cdf(file, times, n_times, max_times, debug)
2
3 !-----------------------------------------------------------------------
4 ! Purpose: TBD
5 !-----------------------------------------------------------------------
6
7 implicit none
8
9 #include "netcdf.inc"
10
11 integer, intent(in) :: max_times
12 integer, intent(out) :: n_times
13 character (len=*), intent(in) :: file
14 character (len=80), intent(out) :: times(max_times)
15 logical, intent(in) :: debug
16
17 integer :: cdfid, rcode, id_time
18 character (len=80) :: varnam, time1
19 integer :: ndims, natts, idims(10), istart(10),iend(10), dimids(10)
20 integer :: i, ivtype
21
22 ! if (trace_use) call da_trace_entry("da_get_times_cdf")
23
24 cdfid = ncopn(file, NCNOWRIT, rcode)
25
26 if (rcode == 0) then
27 if (debug) write(unit=stdout,fmt=*) ' open netcdf file ', trim(file)
28 else
29 write(unit=stdout,fmt=*) ' error openiing netcdf file ', trim(file)
30 stop
31 end if
32
33 id_time = ncvid(cdfid, 'Times', rcode)
34
35 rcode = nf_inq_var(cdfid, id_time, varnam, ivtype, ndims, dimids, natts)
36 if (debug) then
37 write(unit=stdout,fmt=*) ' number of dims for Time ',ndims
38 end if
39 do i=1,ndims
40 rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
41 if (debug) write(unit=stdout,fmt=*) ' dimension ',i,idims(i)
42 end do
43
44 ! get the times
45
46 n_times = idims(2)
47 do i=1,idims(2)
48 istart(1) = 1
49 iend(1) = idims(1)
50 istart(2) = i
51 iend(2) = 1
52
53 rcode = NF_GET_VARA_TEXT (cdfid, id_time, &
54 istart, iend, &
55 times(i) )
56 time1 = times(i)
57
58 if (debug) write(unit=stdout,fmt=*) trim(file), time1(1:19)
59 times(i) = time1(1:19)
60 end do
61
62 write(unit=stdout,fmt=*) ' exiting get_times_cdf '
63
64 call ncclos(cdfid,rcode)
65
66 ! if (trace_use) call da_trace_exit("da_get_times_cdf")
67
68 end subroutine da_get_times_cdf
69
70