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=80), 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    cdfid = ncopn(file, NCNOWRIT, rcode)
23 
24    if (rcode == 0) then
25       if (debug) write(unit=stdout,fmt=*) ' open netcdf file ', trim(file)
26    else
27       write(unit=stdout,fmt=*) ' error openiing netcdf file ', trim(file)
28       stop
29    end if
30 
31    id_time = ncvid(cdfid, 'Times', rcode)
32 
33    rcode = nf_inq_var(cdfid, id_time, varnam, ivtype, ndims, dimids, natts)
34    if (debug) then
35       write(unit=stdout,fmt=*) ' number of dims for Time ',ndims
36    end if
37    do i=1,ndims
38       rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
39       if (debug) write(unit=stdout,fmt=*) ' dimension ',i,idims(i)
40    end do
41 
42    !  get the times
43 
44    n_times = idims(2)
45    do i=1,idims(2)
46       istart(1) = 1
47       iend(1) = idims(1)
48       istart(2) = i
49       iend(2) = 1
50 
51       rcode = NF_GET_VARA_TEXT  (cdfid, id_time,  &
52                                  istart, iend,    &
53                                  times(i)         )
54       time1 = times(i)
55 
56       if (debug) write(unit=stdout,fmt=*) trim(file), time1(1:19)
57       times(i) = time1(1:19)
58    end do
59 
60    write(unit=stdout,fmt=*) ' exiting get_times_cdf '
61 
62    call ncclos(cdfid,rcode)
63 
64 end subroutine da_get_times_cdf
65 
66