5 use netcdf
, only: nf90_close, nf90_enotnc, nf90_noerr
7 use dc_trace
, only: beginsub, endsub, dbgmessage
8 integer,
intent(in):: fileid
9 logical,
intent(out),
optional:: err
10 type(gd_nc_file_id_entry),
pointer:: identptr, prev
12 character(*),
parameter:: subname =
"GDNcFileClose" 14 call beginsub(subname)
20 if (.not.
associated(identptr))
goto 999
21 if (identptr % id == fileid)
exit 23 identptr => identptr % next
25 identptr % count = identptr % count - 1
26 if (identptr % count <= 0)
then 27 stat = nf90_close(fileid)
28 if (
associated(prev))
then 29 prev%next => identptr % next
34 call dbgmessage(subname //
': <%c> closed', c1=trim(identptr % filename))
37 call dbgmessage(subname //
': %d<%c> skipped for refcount=%d', &
38 & c1=trim(identptr % filename), i=(/fileid, identptr % count/))
subroutine gdncfileclose(fileid, err)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
type(gd_nc_file_id_entry), pointer, save id_head