11 integer(I4B) :: nr_models
12 integer(I4B),
dimension(:),
pointer,
contiguous :: model_ids => null()
13 character(len=LENMODELNAME),
dimension(:), &
14 pointer,
contiguous :: model_names => null()
15 integer(I4B) :: nr_exchanges
16 integer(I4B),
dimension(:),
pointer,
contiguous :: exchange_ids => null()
17 character(len=LENEXCHANGENAME),
dimension(:), &
18 pointer,
contiguous :: exchange_names => null()
19 integer(I4B) :: prim_exg_idx
34 subroutine init(this, nr_models, nr_exchanges)
36 integer(I4B) :: nr_models
37 integer(I4B) :: nr_exchanges
39 this%nr_models = nr_models
40 this%nr_exchanges = nr_exchanges
42 allocate (this%model_ids(nr_models))
43 allocate (this%model_names(nr_models))
44 allocate (this%exchange_ids(nr_exchanges))
45 allocate (this%exchange_names(nr_exchanges))
47 allocate (this%node_maps(nr_models))
48 allocate (this%conn_maps(nr_models))
49 allocate (this%exchange_maps(nr_exchanges))
53 this%exchange_ids = -1
63 subroutine add(this, map_to_add)
67 integer(I4B) :: im, ie
68 integer(I4B) :: m_id, m_index
69 integer(I4B) :: e_id, e_index
72 do im = 1, map_to_add%nr_models
73 m_id = map_to_add%model_ids(im)
74 m_index =
ifind(this%model_ids, m_id)
77 call this%node_maps(m_index)%add(map_to_add%node_maps(im))
78 call this%conn_maps(m_index)%add(map_to_add%conn_maps(im))
81 m_index =
ifind(this%model_ids, -1)
82 this%model_ids(m_index) = m_id
83 this%model_names(m_index) = map_to_add%model_names(im)
84 call this%node_maps(m_index)%copy(map_to_add%node_maps(im))
85 call this%conn_maps(m_index)%copy(map_to_add%conn_maps(im))
90 do ie = 1, map_to_add%nr_exchanges
91 e_id = map_to_add%exchange_ids(ie)
92 e_index =
ifind(this%exchange_ids, e_id)
95 call this%exchange_maps(e_index)%add(map_to_add%exchange_maps(ie))
98 e_index =
ifind(this%exchange_ids, -1)
99 this%exchange_ids(e_index) = e_id
100 this%exchange_names(e_index) = map_to_add%exchange_names(ie)
101 call this%exchange_maps(e_index)%copy(map_to_add%exchange_maps(ie))
110 integer(I4B) :: model_id
113 integer(I4B) :: m_idx
116 m_idx =
ifind(this%model_ids, model_id)
118 node_map => this%node_maps(m_idx)
120 call ustop(
"Internal error. Can't find node map in interface")
127 integer(I4B) :: model_id
130 integer(I4B) :: m_idx
132 connection_map => null()
133 m_idx =
ifind(this%model_ids, model_id)
135 connection_map => this%conn_maps(m_idx)
144 integer(I4B) :: outunit
148 write (outunit,
'(a,i0)')
"nr. models: ", this%nr_models
149 write (outunit,
'(a,i0)')
"nr. exchanges: ", this%nr_exchanges
150 do i = 1, this%nr_models
151 if (this%model_ids(i) == -1) cycle
152 write (outunit,
'(3a,i0,a)')
"model: ", trim(this%model_names(i)), &
153 "[", this%model_ids(i),
"]"
154 write (outunit, *)
"node map:"
155 do n = 1,
size(this%node_maps(i)%src_idx)
156 write (outunit,
'(i7,a,i7)') this%node_maps(i)%src_idx(n), &
157 " ", this%node_maps(i)%tgt_idx(n)
159 write (outunit, *)
"connection map:"
160 do n = 1,
size(this%conn_maps(i)%src_idx)
161 write (outunit,
'(i7,a,i7)') this%conn_maps(i)%src_idx(n), &
162 " ", this%conn_maps(i)%tgt_idx(n)
166 do i = 1, this%nr_exchanges
167 if (this%exchange_ids(i) == -1) cycle
168 write (outunit,
'(3a,i0,a)')
"exchange: ", trim(this%exchange_names(i)), &
169 "[", this%exchange_ids(i),
"]"
170 write (outunit, *)
"exchange map:"
171 do n = 1,
size(this%exchange_maps(i)%src_idx)
172 write (outunit,
'(i7,a,i7,a,i7)') this%exchange_maps(i)%src_idx(n), &
173 " ", this%exchange_maps(i)%tgt_idx(n), &
174 " ", this%exchange_maps(i)%sign(n)
185 do i = 1, this%nr_models
186 if (this%model_ids(i) == -1) cycle
187 deallocate (this%node_maps(i)%src_idx)
188 deallocate (this%node_maps(i)%tgt_idx)
189 deallocate (this%conn_maps(i)%src_idx)
190 deallocate (this%conn_maps(i)%tgt_idx)
192 deallocate (this%node_maps)
193 deallocate (this%conn_maps)
195 do i = 1, this%nr_exchanges
196 if (this%exchange_ids(i) == -1) cycle
197 deallocate (this%exchange_maps(i)%src_idx)
198 deallocate (this%exchange_maps(i)%tgt_idx)
199 deallocate (this%exchange_maps(i)%sign)
201 deallocate (this%exchange_maps)
203 deallocate (this%model_ids)
204 deallocate (this%model_names)
205 deallocate (this%exchange_ids)
206 deallocate (this%exchange_names)
This module contains simulation constants.
integer(i4b), parameter lenmodelname
maximum length of the model name
integer(i4b), parameter lenexchangename
maximum length of the exchange name
type(indexmaptype) function, pointer get_connection_map(this, model_id)
subroutine print_interface(this, outunit)
Dumps interface data to the screen.
subroutine add(this, map_to_add)
@ Adds a map, either by extending the existing map for a certain model or exchange,...
subroutine init(this, nr_models, nr_exchanges)
type(indexmaptype) function, pointer get_node_map(this, model_id)
This module defines variable data types.
This module contains simulation methods.
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.