1 subroutine da_get_gl_att_real_cdf(file, att_name, value, debug, return_code)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
11 character (len=*), intent(in) :: file
12 character (len=*), intent(in) :: att_name
13 logical, intent(in) :: debug
14 real, intent(out) :: value
15 integer, optional, intent(out) :: return_code
19 integer :: cdfid, rcode, ivtype
21 ! if (trace_use_dull) call da_trace_entry("da_get_gl_att_real_cdf")
23 cdfid = ncopn(file, NCNOWRIT, rcode)
26 if (debug) write(unit=stdout,fmt=*) ' open netcdf file ', trim(file)
28 write(unit=stdout,fmt=*) ' error openiing netcdf file ', trim(file)
32 rcode = NF_inQ_ATTtype(cdfid, nf_global, att_name, ivtype)
34 write(unit=stdout, fmt='(a, i6)') &
36 'NF_real=', NF_real, &
37 'NF_DOUBLE=', NF_DOUBLE, &
38 'kind(value)=', kind(value)
40 if ((ivtype == NF_real) .and. (kind(value) == 4)) then
41 rcode = NF_GET_ATT_real(cdfid, nf_global, att_name, value)
42 else if ((ivtype == NF_DOUBLE) .and. (kind(value) == 4)) then
43 rcode = NF_GET_ATT_real(cdfid, nf_global, att_name, tmp)
45 else if ((ivtype == NF_DOUBLE) .and. (kind(value) == 8)) then
46 rcode = NF_GET_ATT_real(cdfid, nf_global, att_name, value)
47 else if ((ivtype == NF_REAL) .and. (kind(value) == 8)) then
48 rcode = NF_GET_ATT_real(cdfid, nf_global, att_name, tmp4)
51 write(unit=stdout, fmt='(a, i6)') &
52 'Unrecognizable ivtype:', ivtype
56 if ( present(return_code) ) then
60 call ncclos(cdfid,rcode)
62 if (debug) write(unit=stdout,fmt=*) ' global attribute ',att_name,' is ',value
64 ! if (trace_use_dull) call da_trace_exit("da_get_gl_att_real_cdf")
66 end subroutine da_get_gl_att_real_cdf