12 use iso_c_binding,
only : c_int, c_float, c_bool, c_double
29 integer (c_int) :: count = 0
34 procedure :: catalog_add_entry_sub
35 procedure :: catalog_delete_entry_sub
36 procedure :: catalog_find_key_fn
37 procedure :: catalog_find_next_key_fn
38 procedure :: catalog_get_entry_at_index_fn
39 procedure :: catalog_print_sub
40 procedure :: catalog_set_all_proj4_string_sub
41 procedure :: catalog_set_all_start_year_sub
42 procedure :: catalog_set_all_end_year_sub
45 generic,
public :: add => catalog_add_entry_sub
47 generic,
public :: delete => catalog_delete_entry_sub
49 generic,
public :: find => catalog_find_key_fn
51 generic,
public :: next => catalog_find_next_key_fn
53 generic,
public :: get => catalog_get_entry_at_index_fn
55 generic,
public :: print => catalog_print_sub
56 generic,
public :: set_proj4 => catalog_set_all_proj4_string_sub
57 generic,
public :: set_endyear => catalog_set_all_end_year_sub
58 generic,
public :: set_startyear => catalog_set_all_start_year_sub
72 subroutine catalog_set_all_start_year_sub( this, iStartYear )
76 integer (c_int),
intent(in) :: istartyear
81 if (
associated( this%first ) )
then
85 do while (
associated(current) )
87 current%iStartYear = istartyear
89 current => current%next
95 end subroutine catalog_set_all_start_year_sub
100 subroutine catalog_set_all_end_year_sub( this, iEndYear )
104 integer (c_int),
intent(in) :: iendyear
109 if (
associated( this%first ) )
then
111 current => this%first
113 do while (
associated(current) )
115 current%iEndYear = iendyear
117 current => current%next
123 end subroutine catalog_set_all_end_year_sub
128 subroutine catalog_set_all_proj4_string_sub( this, PROJ4_string )
132 character (len=*),
intent(in) :: proj4_string
137 if (
associated( this%first ) )
then
139 current => this%first
141 do while (
associated(current) )
143 call current%set_source_PROJ4( proj4_string )
145 current => current%next
153 end subroutine catalog_set_all_proj4_string_sub
158 subroutine catalog_add_entry_sub( this, key, data )
161 character (len=*),
intent(in) :: key
164 if (this%count == 0 )
then
166 if (
associated (data) )
then
168 call data%setkey( key )
172 data%previous => null()
177 else if(
associated(data) )
then
179 call data%setkey( key )
180 this%last%next =>
data
181 data%previous => this%last
185 this%count = this%count + 1
191 end subroutine catalog_add_entry_sub
196 subroutine catalog_delete_entry_sub( this, key )
199 character (len=*),
intent(in) :: key
207 current => catalog_find_key_fn(this, key)
209 if (
associated (current) )
then
211 previous => current%previous
214 previous%next => next
215 next%previous => previous
217 deallocate( current )
220 this%count = this%count - 1
224 end subroutine catalog_delete_entry_sub
229 function catalog_get_entry_at_index_fn(this, index)
result(data)
232 integer (c_int),
intent(in) :: index
236 integer (c_int) :: icount
241 if (
associated( this%first ) )
then
245 do while (
associated(data) )
251 if ( icount == index )
exit
258 end function catalog_get_entry_at_index_fn
263 function catalog_find_key_fn( this, key)
result( data )
266 character (len=*),
intent(in) :: key
271 if (
associated( this%first ) )
then
275 this%current => this%first
277 do while (
associated(data) )
279 if ( data%sKeyword .strequal. key )
exit
287 end function catalog_find_key_fn
291 function catalog_find_next_key_fn( this, key)
result( data )
294 character (len=*),
intent(in) :: key
299 if (
associated( this%current ) )
then
301 this%current => this%current%next
304 do while (
associated(data) )
306 if ( data%sKeyword .strequal. key )
exit
315 end function catalog_find_next_key_fn
321 subroutine catalog_print_sub(this)
327 if (
associated( this%first ) )
then
329 current => this%first
331 do while (
associated(current) )
333 call logs%write(
"Catalog key: "//
dquote(current%sKeyword), ilinesbefore=1, &
336 call current%dump_data_structure()
338 current => current%next
344 end subroutine catalog_print_sub
Defines the DATA_CATALOG_T data type, which contains type-bound procedures to add,...
type(data_catalog_t), public dat
DAT is a global to hold data catalog entries.
type(logfile_t), public logs