gdmemvarattradd.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine gdmemvarattradd (var, attrname, attrval)
 

Function/Subroutine Documentation

◆ gdmemvarattradd()

subroutine gdmemvarattradd ( type(gd_mem_variable), intent(in)  var,
character(*), intent(in)  attrname,
character(*), intent(in)  attrval 
)

Definition at line 2 of file gdmemvarattradd.f90.

4  use netcdf, only: nf90_noerr, nf90_enotatt
5  type(gd_mem_variable), intent(in):: var
6  character(*), intent(in):: attrname
7  character(*), intent(in):: attrval
8  type(gd_mem_variable_entry), pointer:: ent
9  type(gd_mem_attr_chain), pointer:: p
10  integer:: i, stat
11 
12  stat = memtab_lookup(var, ent)
13  if (stat == nf90_noerr) then
14  if (associated(ent%current)) then
15  if (ent%current%name == attrname) then
16  p => ent%current
17  goto 100
18  endif
19  endif
20  p => ent%attr
21  do
22  if (.not. associated(p)) exit
23  if (p%name == attrname) goto 100
24  p => p%next
25  enddo
26  stat = nf90_enotatt
27  endif
28  allocate(p)
29  nullify(p%next)
30  goto 120
31 
32 100 continue
33  if (associated(p%cbuf)) then
34  deallocate(p%cbuf)
35  endif
36 
37 120 continue
38  allocate(p%cbuf(len(attrval)))
39  do, i = 1, len(attrval)
40  p%cbuf(i) = attrval(i:i)
41  enddo
42  return