da_get_bdytimestr_cdf.inc

References to this file elsewhere.
1 subroutine da_get_bdytimestr_cdf(file, time_flag, bdytimestr, max_times, debug)
2 
3    implicit none
4 
5 #include "netcdf.inc"
6 
7    integer,           intent(in) :: max_times
8    logical,           intent(in) :: debug
9    character(len=80), intent(in) :: file
10    character(len=*),  intent(in) :: time_flag
11    character(len=80), intent(out) :: bdytimestr(max_times)
12 
13    character(len=80) :: varnam, time1
14 
15    integer :: cdfid, rcode, id_time
16    integer :: ndims, natts, idims(10), istart(10),iend(10), dimids(10)
17    integer :: i, ivtype
18 
19    cdfid = ncopn(file, NCNOWRIT, rcode)
20 
21    if (rcode == 0) then
22       if (debug) write(unit=stdout,fmt=*) ' open netcdf file ', trim(file)
23    else
24       write(unit=stdout,fmt=*) ' error openiing netcdf file ', trim(file)
25       stop
26    end if
27 
28    varnam = 'md___' // trim(time_flag) // 'e_x_t_d_o_m_a_i_n_m_e_t_a_data_'
29 
30    id_time = ncvid(cdfid, varnam, rcode)
31 
32    rcode = nf_inq_var(cdfid, id_time, varnam, ivtype, ndims, dimids, natts)
33 
34    if (debug) then
35      write(unit=stdout,fmt=*) ' number of dims for bdytime ',ndims
36    end if
37 
38    do i=1,ndims
39       rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
40       if (debug) write(unit=stdout,fmt=*) ' dimension ',i,idims(i)
41    end do
42 
43    ! get the bdytime
44 
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                                  bdytimestr(i))
54       time1 = bdytimestr(i)
55 
56       if (debug) write(unit=stdout,fmt=*) trim(file), time1(1:19)
57       bdytimestr(i) = time1(1:19)
58    end do
59 
60    call ncclos(cdfid,rcode)
61 
62 end subroutine da_get_bdytimestr_cdf
63 
64