function ANVarToString(var) result(result)
use dc_types, only: STRING
use dc_string, only: cprintf
use an_vartable, only: an_variable_entry, vtable_lookup
use an_types, only: AN_VARIABLE
implicit none
character(string):: result
type(AN_VARIABLE), intent(in):: var
type(an_variable_entry):: ent
if (vtable_lookup(var, ent) /= 0) then
result = cprintf("AN_VARIABLE(bad id %d)", i=(/var%id/))
else
result = cprintf("AN_VARIABLE(file=%d, var=%d, dim=%d)", i=(/ent%fileid, ent%varid, ent%dimid/))
endif
end function