FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_setup_util_f.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2019 FrontISTR Commons
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
6 
8  use hecmw_util
9 
12  character(len=HECMW_NAME_LEN), pointer :: s(:)
13  end type hecmw_str_arr
14 
16  integer(kind=kint),private :: grp_type ! 1:node_grp, 2:elem_grp, 3:surf_grp
17  integer(kind=kint),pointer,private :: n_grp
18  integer(kind=kint),pointer,private :: grp_index(:)
19  integer(kind=kint),pointer,private :: grp_item(:)
20  type(hecmw_str_arr),private :: grp_name
21 
22  ! private subroutines ------------
23  private :: set_group_pointers
24 ! private :: append_single_group
25 
26 contains
27 
28  function hecmw_str2index( s, x )
29  implicit none
30  logical hecmw_str2index
31  character(*) :: s
32  integer :: i, n, a, i0,i9, m, x, b
33  logical :: fg
34 
35  hecmw_str2index = .false.
36  i0 = iachar('0')
37  i9 = iachar('9')
38  n = len_trim(s)
39  x = 0
40  b = 1
41  fg = .true.
42  do i=n,1,-1
43  fg = .false.
44  a = iachar(s(i:i))
45  if( a < i0 .or. a > i9 ) return
46  m = a-i0
47  x = x + b * m
48  b = b*10
49  end do
50  hecmw_str2index = .true.
51  end function hecmw_str2index
52 
53  subroutine hecmw_strupr( s )
54  implicit none
55  character(*) :: s
56  integer :: i, n, a
57 
58  n = len_trim(s)
59  do i = 1, n
60  a = iachar(s(i:i))
61  if( a >= iachar('a') .and. a <= iachar('z')) then
62  s(i:i) = achar(a - 32)
63  end if
64  end do
65  end subroutine hecmw_strupr
66 
67  function hecmw_streqr( s1, s2 )
68  implicit none
69  character(*), intent(in) :: s1, s2
70  logical :: hecmw_streqr
71  integer :: i, n, a1, a2
72 
73  hecmw_streqr = .false.
74  n = len_trim(s1)
75  if( n /= len_trim(s2)) return
76  do i = 1, n
77  a1 = iachar(s1(i:i))
78  a2 = iachar(s2(i:i))
79  if( a1 >= iachar('a') .and. a1 <= iachar('z')) a1 = a1 - 32
80  if( a2 >= iachar('a') .and. a2 <= iachar('z')) a2 = a2 - 32
81  if( a1 /= a2 ) then
82  return
83  end if
84  end do
85  hecmw_streqr = .true.
86  end function hecmw_streqr
87 
88  subroutine hecmw_setup_util_err_stop( msg )
89  implicit none
90  character(*) :: msg
91 
92  write(*,*) msg
93 ! write(imsg,*) msg
95  end subroutine hecmw_setup_util_err_stop
96 
97  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
98 
99  subroutine set_group_pointers( hecMESH, grp_type_name )
100  type (hecmwST_local_mesh),target :: hecMESH
101  character(len=*) :: grp_type_name
102 
103  if( grp_type_name == 'node_grp' ) then
104  grp_type = 1
105  n_grp => hecmesh%node_group%n_grp
106  grp_name%s => hecmesh%node_group%grp_name
107  grp_index => hecmesh%node_group%grp_index
108  grp_item => hecmesh%node_group%grp_item
109  else if( grp_type_name == 'elem_grp' ) then
110  grp_type = 2
111  n_grp => hecmesh%elem_group%n_grp
112  grp_name%s => hecmesh%elem_group%grp_name
113  grp_index => hecmesh%elem_group%grp_index
114  grp_item => hecmesh%elem_group%grp_item
115  else if( grp_type_name == 'surf_grp' ) then
116  grp_type = 3
117  n_grp => hecmesh%surf_group%n_grp
118  grp_name%s => hecmesh%surf_group%grp_name
119  grp_index => hecmesh%surf_group%grp_index
120  grp_item => hecmesh%surf_group%grp_item
121  else
122  stop 'assert in set_group_pointers'
123  end if
124  end subroutine set_group_pointers
125 
126  subroutine backset_group_pointers( hecMESH, grp_type_name )
127  type (hecmwST_local_mesh),target :: hecMESH
128  character(len=*) :: grp_type_name
129 
130  if( grp_type_name == 'node_grp' ) then
131  grp_type = 1
132  hecmesh%node_group%grp_name => grp_name%s
133  hecmesh%node_group%grp_index => grp_index
134  hecmesh%node_group%grp_item => grp_item
135  else if( grp_type_name == 'elem_grp' ) then
136  grp_type = 2
137  hecmesh%elem_group%grp_name => grp_name%s
138  hecmesh%elem_group%grp_index => grp_index
139  hecmesh%elem_group%grp_item => grp_item
140  else if( grp_type_name == 'surf_grp' ) then
141  grp_type = 3
142  hecmesh%surf_group%grp_name => grp_name%s
143  hecmesh%surf_group%grp_index => grp_index
144  hecmesh%surf_group%grp_item => grp_item
145  else
146  stop 'assert in backset_group_pointers'
147  end if
148  end subroutine backset_group_pointers
149 
150  function node_global_to_local( hecMESH, list, n )
151  implicit none
152  type (hecmwst_local_mesh), target :: hecmesh
153  integer(kind=kint) :: list(:)
154  integer(kind=kint) :: n, i, j, cache
155  logical:: fg
156  integer(kind=kint):: node_global_to_local
157 
159  cache = 1
160  aa:do j=1, n
161  fg = .false.
162 
163  do i=cache, hecmesh%n_node
164  if( hecmesh%global_node_ID(i) == list(j)) then
165  list(j) = i
166  cache = i+1
167  fg = .true.
169  cycle aa
170  endif
171  enddo
172 
173  do i=1, cache-1
174  if( hecmesh%global_node_ID(i) == list(j)) then
175  list(j) = i
176  cache = i+1
177  fg = .true.
179  cycle aa
180  endif
181  enddo
182 
183  if( .not. fg ) then
184  list(j) = -1 ! not exist node
185  endif
186  enddo aa
187  end function node_global_to_local
188 
189  function elem_global_to_local( hecMESH, list, n )
190  implicit none
191  type (hecmwst_local_mesh), target :: hecmesh
192  integer(kind=kint), pointer :: list(:)
193  integer(kind=kint) :: n, i, j
194  logical :: fg
195  integer(kind=kint) :: elem_global_to_local
196 
198  do j=1, n
199  fg = .false.
200  do i=1, hecmesh%n_elem
201  if( hecmesh%global_elem_ID(i) == list(j)) then
202  list(j) = i
203  fg = .true.
205  exit
206  endif
207  end do
208  if( .not. fg ) then
209  list(j) = -1
210  endif
211  end do
212  end function elem_global_to_local
213 
214  function append_single_group( hecMESH, grp_type_name, no_count, no_list )
215  implicit none
216  type (hecmwst_local_mesh), target :: hecmesh
217  character(len=*) :: grp_type_name
218  integer(kind=kint) :: no_count
219  integer(kind=kint),pointer :: no_list(:)
220  integer(kind=kint):: append_single_group
221  integer(kind=kint) :: old_grp_number, new_grp_number
222  integer(kind=kint) :: old_item_number, new_item_number
223  integer(kind=kint) :: i,j,k, exist_n
224  integer(kind=kint), save :: grp_count = 1
225  character(50) :: grp_name_s
226 
227  exist_n = 0
228  call set_group_pointers( hecmesh, grp_type_name )
229  if( grp_type_name == 'node_grp') then
230  exist_n = node_global_to_local( hecmesh, no_list, no_count )
231  else if( grp_type_name == 'elem_grp') then
232  exist_n = elem_global_to_local( hecmesh, no_list, no_count )
233  endif
234 
235  old_grp_number = n_grp
236  new_grp_number = old_grp_number + no_count
237 
238  old_item_number = grp_index(n_grp)
239  new_item_number = old_item_number + exist_n
240 
241  call hecmw_expand_name_array( grp_name, old_grp_number, new_grp_number )
242  call hecmw_expand_index_array( grp_index, old_grp_number + 1, new_grp_number+1)
243  call hecmw_expand_integer_array( grp_item, old_item_number, new_item_number )
244 
245  n_grp = new_grp_number
246 
247  j = old_grp_number + 1
248  k = old_item_number + 1
249  do i = 1, no_count
250  write( grp_name_s, '(a,i0,a,i0)') 'FSTR_', grp_count, '_', i
251  grp_name%s(j) = grp_name_s
252  if( no_list(i) >= 0) then
253  grp_item(k) = no_list(i)
254  grp_index(j) = grp_index(j-1)+1
255  k = k + 1
256  else
257  grp_index(j) = grp_index(j-1)
258  endif
259  j = j + 1
260  end do
261  grp_count = grp_count + 1
262  call backset_group_pointers( hecmesh, grp_type_name )
263  append_single_group = exist_n
264  end function append_single_group
265 
266  subroutine append_new_group(hecMESH, grp_type_name, name, count, list, grp_id)
267  implicit none
268  type(hecmwst_local_mesh), pointer :: hecMESH
269  character(len=*), intent(in) :: grp_type_name
270  character(len=HECMW_NAME_LEN), intent(in) :: name
271  integer(kind=kint), intent(in) :: count
272  integer(kind=kint), intent(in) :: list(:)
273  integer(kind=kint), intent(out) :: grp_id
274  integer(kind=kint) :: id, old_grp_number, new_grp_number, old_item_number, new_item_number, k
275 
276  call set_group_pointers( hecmesh, grp_type_name )
277  do id = 1, n_grp
278  if( hecmw_streqr(grp_name%s(id), name) ) then
279  write(*,*) '### Error: Group already exists: ', name
280  stop
281  endif
282  enddo
283 
284  old_grp_number = n_grp
285  new_grp_number = old_grp_number + 1
286 
287  old_item_number = grp_index(n_grp)
288  new_item_number = old_item_number + count
289 
290  call hecmw_expand_name_array( grp_name, old_grp_number, new_grp_number )
291  call hecmw_expand_index_array( grp_index, old_grp_number + 1, new_grp_number + 1)
292  call hecmw_expand_integer_array( grp_item, old_item_number, new_item_number )
293 
294  n_grp = new_grp_number
295  grp_id = new_grp_number
296  grp_name%s(grp_id) = name
297  do k = 1, count
298  grp_item(old_item_number + k) = list(k)
299  enddo
300  grp_index(grp_id) = grp_index(grp_id-1) + count
301  call backset_group_pointers( hecmesh, grp_type_name )
302  end subroutine append_new_group
303 
304  !------------------------------------------------------------------------------
305  ! JP-0
306  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
307  ! name : group name
308  ! return : number of member in specified group
309 
310  function get_grp_member_n( hecMESH, grp_type_name, name )
311  implicit none
312  integer(kind=kint) :: get_grp_member_n
313  type (hecmwst_local_mesh),target :: hecmesh
314  character(len=*) :: grp_type_name
315  character(len=*) :: name
316  integer(kind=kint) :: i
317 
318  call set_group_pointers( hecmesh, grp_type_name )
319 
320  do i = 1, n_grp
321  if( hecmw_streqr(grp_name%s(i),name)) then
322  get_grp_member_n = grp_index(i) - grp_index(i-1)
323  return
324  end if
325  end do
326  get_grp_member_n = 0
327  return
328  end function get_grp_member_n
329 
330  !------------------------------------------------------------------------------
331  ! JP-1
332  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
333  ! name : group name
334  ! return : number of member in specified group
335 
336  function get_grp_id( hecMESH, grp_type_name, name )
337  implicit none
338  integer(kind=kint) :: get_grp_id
339  type (hecmwst_local_mesh),target :: hecmesh
340  character(len=*) :: grp_type_name
341  character(len=*) :: name
342  integer(kind=kint) :: i
343 
344  call set_group_pointers( hecmesh, grp_type_name )
345 
346  do i = 1, n_grp
347  if( hecmw_streqr(grp_name%s(i), name)) then
348  get_grp_id = i
349  return
350  end if
351  end do
352  get_grp_id = 0
353  return
354  end function get_grp_id
355 
356  !------------------------------------------------------------------------------
357  ! JP-2
358  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
359  ! name : group name
360  ! member1 : id list for node or element
361  ! member2 : id list for surface ( only 'surf_grp' specified )
362  ! return : number of member in specified group
363 
364  function get_grp_member( hecMESH, grp_type_name, name, member1, member2 )
365  implicit none
366  integer(kind=kint) :: get_grp_member
367  type (hecmwst_local_mesh),target :: hecmesh
368  character(len=*) :: grp_type_name
369  character(len=*) :: name
370  integer(kind=kint),pointer :: member1(:)
371  integer(kind=kint),pointer, optional :: member2(:)
372  integer(kind=kint) :: i, j, k, sn, en
373 
374  get_grp_member = -1
375  if( grp_type_name == 'surf_grp' .and. (.not. present( member2 ))) then
376  stop 'assert in get_grp_member: not present member2 '
377  end if
378 
379  call set_group_pointers( hecmesh, grp_type_name )
380 
381  do i = 1, n_grp
382  if( hecmw_streqr(grp_name%s(i), name)) then
383  sn = grp_index(i-1) + 1
384  en = grp_index(i)
385  k = 1
386  if( grp_type == 3 ) then ! == surf_grp
387  do j = sn, en
388  member1(k) = grp_item(2*j-1)
389  member2(k) = grp_item(2*j)
390  k = k + 1
391  end do
392  else
393  do j = sn, en
394  member1(k) = grp_item(j)
395  k = k + 1
396  end do
397  end if
398  get_grp_member = en - sn + 1
399  return
400  end if
401  end do
402  get_grp_member = 0
403  return
404  end function get_grp_member
405 
406  subroutine node_grp_name_to_id( hecMESH, header_name, n, grp_id_name, grp_ID )
407  implicit none
408  type (hecmwST_local_mesh) :: hecMESH
409  character(len=*) :: header_name
410  character(HECMW_NAME_LEN) :: grp_id_name(:)
411  integer(kind=kint),pointer :: grp_ID(:)
412  integer(kind=kint) :: n
413  integer(kind=kint) :: i, id
414  character(len=256) :: msg
415 
416  do i = 1, n
417  grp_id(i) = -1
418  do id = 1, hecmesh%node_group%n_grp
419  if( hecmw_streqr(hecmesh%node_group%grp_name(id),grp_id_name(i))) then
420  grp_id(i) = id
421  exit
422  end if
423  end do
424  if( grp_id(i) == -1 ) then
425  write(msg,*) '### Error: ', header_name,' : Node group "',&
426  grp_id_name(i),'" does not exist.'
427  call hecmw_setup_util_err_stop(msg)
428  end if
429  end do
430  end subroutine node_grp_name_to_id
431 
432  subroutine elem_grp_name_to_id( hecMESH, header_name, n, grp_id_name, grp_ID )
433  implicit none
434  type (hecmwST_local_mesh) :: hecMESH
435  character(len=*) :: header_name
436  character(HECMW_NAME_LEN) :: grp_id_name(:)
437  integer(kind=kint) :: grp_ID(:)
438  integer(kind=kint) :: n
439  integer(kind=kint) :: i, id
440  character(len=256) :: msg
441 
442  do i = 1, n
443  grp_id(i) = -1
444  do id = 1, hecmesh%elem_group%n_grp
445  if (hecmw_streqr(hecmesh%elem_group%grp_name(id), grp_id_name(i))) then
446  grp_id(i) = id
447  exit
448  end if
449  end do
450  if( grp_id(i) == -1 ) then
451  write(msg,*) '### Error: ', header_name,' : Element group "',&
452  grp_id_name(i),'" does not exist.'
453  call hecmw_setup_util_err_stop(msg)
454  end if
455  end do
456  end subroutine elem_grp_name_to_id
457 
458  !------------------------------------------------------------------------------
459  ! JP-5
460  ! JP-6
461  !
462 
463  subroutine node_grp_name_to_id_ex( hecMESH, header_name, n, grp_id_name, grp_ID )
464  implicit none
465  type (hecmwST_local_mesh),target :: hecMESH
466  character(len=*) :: header_name
467  integer(kind=kint) :: n
468  character(len=HECMW_NAME_LEN) :: grp_id_name(:)
469  integer(kind=kint) :: grp_ID(:)
470 
471  integer(kind=kint) :: i, id
472  integer(kind=kint) :: no, no_count, exist_n
473  integer(kind=kint),pointer :: no_list(:)
474  character(HECMW_NAME_LEN) :: name
475  character(len=256) :: msg
476 
477  allocate( no_list( n ))
478  no_count = 0
479  do i = 1, n
480  if( hecmw_str2index( grp_id_name(i), no )) then
481  no_count = no_count + 1
482  no_list(no_count) = no
483  grp_id(i) = hecmesh%node_group%n_grp + no_count
484  else
485  grp_id(i) = -1
486  do id = 1, hecmesh%node_group%n_grp
487  if (hecmw_streqr(hecmesh%node_group%grp_name(id), grp_id_name(i))) then
488  grp_id(i) = id
489  exit
490  end if
491  end do
492  if( grp_id(i) == -1 ) then
493  write(msg,*) '### Error: ', header_name,' : Node group "',grp_id_name(i),'" does not exist.'
494  call hecmw_setup_util_err_stop(msg)
495  end if
496  end if
497  end do
498 
499  if( no_count > 0 ) then
500  name = 'node_grp'
501  exist_n = append_single_group( hecmesh, name, no_count, no_list )
502  ! if( exist_n < no_count ) then
503  ! write(*,*) '### Warning: ', header_name, ': following nodes are not exist'
504  ! write(imsg,*) '### Warning: ', header_name, ': following nodes are not exist'
505  ! do i=1, no_count
506  ! if( no_list(i)<0 ) then
507  ! write(*,*) -no_list(i)
508  ! write(imsg,*) -no_list(i)
509  ! end if
510  ! end do
511  ! end if
512  end if
513 
514  deallocate( no_list )
515  end subroutine node_grp_name_to_id_ex
516 
517  subroutine elem_grp_name_to_id_ex( hecMESH, header_name, n, grp_id_name, grp_ID )
518  implicit none
519  type (hecmwST_local_mesh),target :: hecMESH
520  character(len=*) :: header_name
521  integer(kind=kint) :: n
522  character(HECMW_NAME_LEN) :: grp_id_name(:)
523  integer(kind=kint) :: grp_ID(:)
524  integer(kind=kint) :: i, id
525  integer(kind=kint) :: no, no_count, exist_n
526  integer(kind=kint),pointer :: no_list(:)
527  character(HECMW_NAME_LEN) :: name
528  character(len=256) :: msg
529 
530  allocate( no_list( n ))
531  no_count = 0
532  do i = 1, n
533  if( hecmw_str2index( grp_id_name(i), no )) then
534  no_count = no_count + 1
535  no_list(no_count) = no
536  grp_id(i) = hecmesh%elem_group%n_grp + no_count
537  else
538  grp_id(i) = -1
539  do id = 1, hecmesh%elem_group%n_grp
540  if (hecmw_streqr(hecmesh%elem_group%grp_name(id), grp_id_name(i))) then
541  grp_id(i) = id
542  exit
543  end if
544  end do
545  if( grp_id(i) == -1 ) then
546  write(msg,*) '### Error: ', header_name,' : Element group "',&
547  grp_id_name(i),'" does not exist.'
548  call hecmw_setup_util_err_stop(msg)
549  end if
550  end if
551  end do
552 
553  if( no_count > 0 ) then
554  name = 'elem_grp'
555  exist_n = append_single_group( hecmesh, name, no_count, no_list )
556  if( exist_n < no_count ) then
557  write(*,*) '### Warning: ', header_name, ': following elements are not exist'
558 ! write(imsg,*) '### Warning: ', header_name, ': following elements are not exist'
559  do i=1, no_count
560  if( no_list(i)<0 ) then
561  write(*,*) -no_list(i)
562 ! write(imsg,*) -no_list(i)
563  end if
564  end do
565  end if
566  end if
567 
568  deallocate( no_list )
569  end subroutine elem_grp_name_to_id_ex
570 
571  !------------------------------------------------------------------------------
572 
573  subroutine surf_grp_name_to_id_ex( hecMESH, header_name, n, grp_id_name, grp_ID )
574  implicit none
575  type (hecmwST_local_mesh),target :: hecMESH
576  character(len=*) :: header_name
577  integer(kind=kint) :: n
578  character(len=HECMW_NAME_LEN) :: grp_id_name(:)
579  integer(kind=kint) :: grp_ID(:)
580  integer(kind=kint) :: i, id
581  character(len=256) :: msg
582 
583  do i = 1, n
584  grp_id(i) = -1
585  do id = 1, hecmesh%surf_group%n_grp
586  if (hecmw_streqr(hecmesh%surf_group%grp_name(id), grp_id_name(i))) then
587  grp_id(i) = id
588  exit
589  end if
590  end do
591  if( grp_id(i) == -1 ) then
592  write(msg,*) '### Error: ', header_name,' : Surface group "',grp_id_name(i),'" does not exist.'
593  call hecmw_setup_util_err_stop(msg)
594  end if
595  end do
596  end subroutine surf_grp_name_to_id_ex
597 
598  !------------------------------------------------------------------------------
599  ! JP-8
600 
601  function get_node_grp_member_n( hecMESH, grp_name_array, n )
602  implicit none
603  integer(kind=kint) :: get_node_grp_member_n
604  type (hecmwst_local_mesh), target :: hecmesh
605  type(hecmw_str_arr) :: grp_name_array
606  integer(kind=kint) :: n
607  integer(kind=kint) :: i,j, m
608 
609  m = 0;
610  do i = 1, n
611  call set_group_pointers( hecmesh, grp_name_array%s(i) )
612  do j = 1, n_grp
613  if( hecmw_streqr(grp_name%s(j), grp_name_array%s(i))) then
614  m = m + grp_index(j) - grp_index(j-1)
615  end if
616  end do
617  end do
619  return
620  end function get_node_grp_member_n
621 
622  !------------------------------------------------------------------------------
623 
624  subroutine hecmw_expand_index_array( array, old_size, new_size )
625  implicit none
626  integer(kind=kint), pointer :: array(:)
627  integer(kind=kint) :: old_size, new_size,i
628  integer(kind=kint), pointer :: temp(:)
629 
630  if( old_size >= new_size ) then
631  return
632  end if
633 
634  if( associated( array ) ) then
635  allocate(temp(0:old_size-1))
636  do i=0, old_size-1
637  temp(i) = array(i)
638  end do
639  deallocate(array)
640  allocate(array(0:new_size-1))
641  array = 0
642  do i=0, old_size-1
643  array(i) = temp(i)
644  end do
645  deallocate(temp)
646  else
647  allocate(array(0:new_size-1))
648  array = 0
649  end if
650  end subroutine hecmw_expand_index_array
651 
652  subroutine hecmw_expand_char_array( array, old_size, new_size )
653  implicit none
654  character(len=HECMW_NAME_LEN), pointer :: array(:)
655  integer(kind=kint) :: old_size, new_size,i
656  character(len=HECMW_NAME_LEN), pointer :: temp(:)
657 
658  if( old_size >= new_size ) then
659  return
660  end if
661 
662  if( associated( array ) ) then
663  allocate(temp(old_size))
664  do i=1, old_size
665  temp(i) = array(i)
666  end do
667  deallocate(array)
668  allocate(array(new_size))
669  array = ''
670  do i=1, old_size
671  array(i) = temp(i)
672  end do
673  deallocate(temp)
674  else
675  allocate(array(new_size))
676  array = ''
677  end if
678  end subroutine hecmw_expand_char_array
679 
680  subroutine hecmw_expand_integer_array( array, old_size, new_size )
681  implicit none
682  integer(kind=kint), pointer :: array(:)
683  integer(kind=kint) :: old_size, new_size,i
684  integer(kind=kint), pointer :: temp(:)
685 
686  if( old_size >= new_size ) then
687  return
688  end if
689 
690  if( associated( array ) ) then
691  allocate(temp(old_size))
692  do i=1, old_size
693  temp(i) = array(i)
694  end do
695  deallocate(array)
696  allocate(array(new_size))
697  array = 0
698  do i=1, old_size
699  array(i) = temp(i)
700  end do
701  deallocate(temp)
702  else
703  allocate(array(new_size))
704  array = 0
705  end if
706  end subroutine hecmw_expand_integer_array
707 
708  subroutine hecmw_expand_real_array( array, old_size, new_size )
709  implicit none
710  real(kind=kreal), pointer :: array(:)
711  integer(kind=kint) :: old_size, new_size, i
712  real(kind=kreal), pointer :: temp(:)
713 
714  if( old_size >= new_size ) then
715  return
716  end if
717 
718  if( associated( array ) ) then
719  allocate(temp(old_size))
720  do i=1, old_size
721  temp(i) = array(i)
722  end do
723  deallocate(array)
724  allocate(array(new_size))
725  array = 0
726  do i=1, old_size
727  array(i) = temp(i)
728  end do
729  deallocate(temp)
730  else
731  allocate(array(new_size))
732  array = 0
733  end if
734  end subroutine hecmw_expand_real_array
735 
736  ! array( old_size, column ) -> array( new_size, column )
737  subroutine hecmw_expand_integer_array2( array, column, old_size, new_size )
738  implicit none
739  integer(kind=kint), pointer :: array(:,:)
740  integer(kind=kint) :: column, old_size, new_size, i,j
741  integer(kind=kint), pointer :: temp(:,:)
742 
743  if( old_size >= new_size ) then
744  return
745  end if
746 
747  if( associated( array ) ) then
748  allocate(temp(old_size,column))
749  do i=1, old_size
750  do j=1,column
751  temp(i,j) = array(i,j)
752  end do
753  end do
754  deallocate(array)
755  allocate(array(new_size,column))
756  array = 0
757  do i=1, old_size
758  do j=1,column
759  array(i,j) = temp(i,j)
760  end do
761  end do
762  deallocate(temp)
763  else
764  allocate(array(new_size, column))
765  array = 0
766  end if
767  end subroutine hecmw_expand_integer_array2
768 
769 
770  ! array( old_size, column ) -> array( new_size, column )
771 
772  subroutine hecmw_expand_real_array2( array, column, old_size, new_size )
773  implicit none
774  real(kind=kreal), pointer :: array(:,:)
775  integer(kind=kint) :: column, old_size, new_size, i,j
776  real(kind=kreal), pointer :: temp(:,:)
777 
778  if( old_size >= new_size ) then
779  return
780  end if
781 
782  if( associated( array ) ) then
783  allocate(temp(old_size,column))
784  do i=1, old_size
785  do j=1,column
786  temp(i,j) = array(i,j)
787  end do
788  end do
789  deallocate(array)
790  allocate(array(new_size,column))
791  array = 0
792  do i=1, old_size
793  do j=1,column
794  array(i,j) = temp(i,j)
795  end do
796  end do
797  deallocate(temp)
798  else
799  allocate(array(new_size, column))
800  array = 0
801  end if
802  end subroutine hecmw_expand_real_array2
803 
804  subroutine hecmw_expand_name_array( array, old_size, new_size )
805  implicit none
806  type(hecmw_str_arr) :: array
807  integer(kind=kint) :: old_size, new_size, i
808  character(len=HECMW_NAME_LEN), pointer :: temp(:)
809 
810  if( old_size >= new_size ) then
811  return
812  end if
813 
814  if( associated( array%s ) ) then
815  allocate(temp(old_size))
816  do i=1, old_size
817  temp(i) = array%s(i)
818  end do
819  deallocate(array%s)
820  allocate(array%s(new_size))
821  do i=1, old_size
822  array%s(i) = temp(i)
823  end do
824  deallocate(temp)
825  else
826  allocate(array%s(new_size))
827  end if
828  end subroutine hecmw_expand_name_array
829 
830  subroutine hecmw_delete_index_array( array, old_size, nindex )
831  implicit none
832  integer(kind=kint), pointer :: array(:)
833  integer(kind=kint), intent(in) :: old_size
834  integer(kind=kint), intent(in) :: nindex
835  integer(kind=kint) :: i
836  integer(kind=kint), pointer :: temp(:)
837 
838  if( old_size < nindex ) then
839  return
840  end if
841 
842  if( old_size == nindex ) then
843  deallocate( array )
844  return
845  endif
846 
847  allocate(temp(0:old_size-1))
848  do i=0, old_size-nindex-1
849  temp(i) = array(i)
850  end do
851  deallocate(array)
852  allocate(array(0:old_size-nindex-1))
853  array = 0
854  do i=0, old_size-nindex-1
855  array(i) = temp(i)
856  end do
857  deallocate(temp)
858  end subroutine hecmw_delete_index_array
859 
860  subroutine hecmw_delete_integer_array( array, old_size, nitem )
861  implicit none
862  integer(kind=kint), pointer :: array(:)
863  integer(kind=kint), intent(in) :: old_size
864  integer(kind=kint), intent(in) :: nitem
865  integer(kind=kint) :: i
866  integer(kind=kint), pointer :: temp(:)
867 
868  if( old_size < nitem ) then
869  return
870  end if
871 
872  if( old_size == nitem ) then
873  deallocate( array )
874  return
875  endif
876 
877  allocate(temp(old_size))
878  do i=1, old_size-nitem
879  temp(i) = array(i)
880  end do
881  deallocate(array)
882  allocate(array(old_size-nitem))
883  array = 0
884  do i=1, old_size-nitem
885  array(i) = temp(i)
886  end do
887  deallocate(temp)
888  end subroutine hecmw_delete_integer_array
889 
890  subroutine hecmw_delete_real_array( array, old_size, nitem )
891  implicit none
892  real(kind=kreal), pointer :: array(:)
893  integer(kind=kint), intent(in) :: old_size
894  integer(kind=kint), intent(in) :: nitem
895  integer(kind=kint) :: i
896  real(kind=kreal), pointer :: temp(:)
897 
898  if( old_size < nitem ) then
899  return
900  end if
901 
902  if( old_size == nitem ) then
903  deallocate( array )
904  return
905  endif
906 
907  allocate(temp(old_size))
908  do i=1, old_size-nitem
909  temp(i) = array(i)
910  end do
911  deallocate(array)
912  allocate(array(old_size-nitem))
913  array = 0
914  do i=1, old_size-nitem
915  array(i) = temp(i)
916  end do
917  deallocate(temp)
918  end subroutine hecmw_delete_real_array
919 
920  !-----------------------------------------------------------------------------!
921 
922  subroutine reallocate_integer( array, n )
923  implicit none
924  integer(kind=kint),pointer :: array(:)
925  integer(kind=kint) :: n;
926 
927  if( associated( array )) deallocate(array)
928  allocate( array(n));
929  end subroutine reallocate_integer
930 
931  subroutine reallocate_real( array, n )
932  implicit none
933  real(kind=kreal),pointer :: array(:)
934  integer(kind=kint) :: n;
935 
936  if( associated( array )) deallocate(array)
937  allocate( array(n));
938  end subroutine reallocate_real
939 
940 end module
This module contains auxiliary functions in calculation setup.
subroutine elem_grp_name_to_id(hecMESH, header_name, n, grp_id_name, grp_ID)
integer(kind=kint) function append_single_group(hecMESH, grp_type_name, no_count, no_list)
subroutine hecmw_strupr(s)
logical function hecmw_str2index(s, x)
integer(kind=kint) function elem_global_to_local(hecMESH, list, n)
subroutine hecmw_setup_util_err_stop(msg)
subroutine reallocate_integer(array, n)
subroutine hecmw_expand_real_array2(array, column, old_size, new_size)
integer(kind=kint) function node_global_to_local(hecMESH, list, n)
subroutine reallocate_real(array, n)
subroutine node_grp_name_to_id(hecMESH, header_name, n, grp_id_name, grp_ID)
subroutine hecmw_expand_integer_array(array, old_size, new_size)
subroutine backset_group_pointers(hecMESH, grp_type_name)
subroutine hecmw_expand_name_array(array, old_size, new_size)
subroutine node_grp_name_to_id_ex(hecMESH, header_name, n, grp_id_name, grp_ID)
subroutine hecmw_expand_real_array(array, old_size, new_size)
integer(kind=kint) function get_grp_member(hecMESH, grp_type_name, name, member1, member2)
subroutine hecmw_expand_integer_array2(array, column, old_size, new_size)
subroutine append_new_group(hecMESH, grp_type_name, name, count, list, grp_id)
subroutine hecmw_delete_integer_array(array, old_size, nitem)
subroutine surf_grp_name_to_id_ex(hecMESH, header_name, n, grp_id_name, grp_ID)
integer(kind=kint) function get_grp_id(hecMESH, grp_type_name, name)
subroutine hecmw_expand_char_array(array, old_size, new_size)
integer(kind=kint) function get_node_grp_member_n(hecMESH, grp_name_array, n)
integer(kind=kint) function get_grp_member_n(hecMESH, grp_type_name, name)
logical function hecmw_streqr(s1, s2)
subroutine hecmw_expand_index_array(array, old_size, new_size)
subroutine hecmw_delete_real_array(array, old_size, nitem)
subroutine elem_grp_name_to_id_ex(hecMESH, header_name, n, grp_id_name, grp_ID)
subroutine hecmw_delete_index_array(array, old_size, nindex)
I/O and Utility.
Definition: hecmw_util_f.F90:7
subroutine hecmw_abort(comm, code)
integer(kind=kint) function hecmw_comm_get_comm()
integer(kind=4), parameter kreal
container of character array pointer, because of gfortran's bug