FrontISTR  6.0.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 
305  subroutine append_new_groups(hecMESH, grp_type_name, n, names, index, list, first_id)
306  implicit none
307  type(hecmwst_local_mesh), pointer :: hecMESH
308  character(len=*), intent(in) :: grp_type_name
309  integer(kind=kint), intent(in) :: n
310  character(len=HECMW_NAME_LEN), intent(in) :: names(:)
311  integer(kind=kint), intent(in) :: index(0:)
312  integer(kind=kint), intent(in) :: list(:)
313  integer(kind=kint), intent(out) :: first_id
314  integer(kind=kint) :: old_grp_number, old_item_number, i, id
315 
316  call set_group_pointers( hecmesh, grp_type_name )
317  do i = 1, n
318  do id = 1, n_grp
319  if( hecmw_streqr(grp_name%s(id), names(i)) ) then
320  write(*,*) '### Error: Group already exists: ', names(i)
321  stop
322  endif
323  enddo
324  do id = 1, i - 1
325  if( hecmw_streqr(names(id), names(i)) ) then
326  write(*,*) '### Error: Group already exists: ', names(i)
327  stop
328  endif
329  enddo
330  enddo
331 
332  old_grp_number = n_grp
333  old_item_number = grp_index(n_grp)
334 
335  call hecmw_expand_name_array( grp_name, old_grp_number, old_grp_number + n )
336  call hecmw_expand_index_array( grp_index, old_grp_number + 1, old_grp_number + n + 1 )
337  call hecmw_expand_integer_array( grp_item, old_item_number, old_item_number + index(n) )
338 
339  n_grp = old_grp_number + n
340  first_id = old_grp_number + 1
341  do i = 1, n
342  grp_name%s(old_grp_number + i) = names(i)
343  grp_index(old_grp_number + i) = old_item_number + index(i)
344  enddo
345  grp_item(old_item_number + 1:old_item_number + index(n)) = list(1:index(n))
346  call backset_group_pointers( hecmesh, grp_type_name )
347  end subroutine append_new_groups
348 
349  !------------------------------------------------------------------------------
350  ! JP-0
351  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
352  ! name : group name
353  ! return : number of member in specified group
354 
355  function get_grp_member_n( hecMESH, grp_type_name, name )
356  implicit none
357  integer(kind=kint) :: get_grp_member_n
358  type (hecmwst_local_mesh),target :: hecmesh
359  character(len=*) :: grp_type_name
360  character(len=*) :: name
361  integer(kind=kint) :: i
362 
363  call set_group_pointers( hecmesh, grp_type_name )
364 
365  do i = 1, n_grp
366  if( hecmw_streqr(grp_name%s(i),name)) then
367  get_grp_member_n = grp_index(i) - grp_index(i-1)
368  return
369  end if
370  end do
371  get_grp_member_n = 0
372  return
373  end function get_grp_member_n
374 
375  !------------------------------------------------------------------------------
376  ! JP-1
377  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
378  ! name : group name
379  ! return : number of member in specified group
380 
381  function get_grp_id( hecMESH, grp_type_name, name )
382  implicit none
383  integer(kind=kint) :: get_grp_id
384  type (hecmwst_local_mesh),target :: hecmesh
385  character(len=*) :: grp_type_name
386  character(len=*) :: name
387  integer(kind=kint) :: i
388 
389  call set_group_pointers( hecmesh, grp_type_name )
390 
391  do i = 1, n_grp
392  if( hecmw_streqr(grp_name%s(i), name)) then
393  get_grp_id = i
394  return
395  end if
396  end do
397  get_grp_id = 0
398  return
399  end function get_grp_id
400 
401  !------------------------------------------------------------------------------
402  ! JP-2
403  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
404  ! name : group name
405  ! member1 : id list for node or element
406  ! member2 : id list for surface ( only 'surf_grp' specified )
407  ! return : number of member in specified group
408 
409  function get_grp_member( hecMESH, grp_type_name, name, member1, member2 )
410  implicit none
411  integer(kind=kint) :: get_grp_member
412  type (hecmwst_local_mesh),target :: hecmesh
413  character(len=*) :: grp_type_name
414  character(len=*) :: name
415  integer(kind=kint),pointer :: member1(:)
416  integer(kind=kint),pointer, optional :: member2(:)
417  integer(kind=kint) :: i, j, k, sn, en
418 
419  get_grp_member = -1
420  if( grp_type_name == 'surf_grp' .and. (.not. present( member2 ))) then
421  stop 'assert in get_grp_member: not present member2 '
422  end if
423 
424  call set_group_pointers( hecmesh, grp_type_name )
425 
426  do i = 1, n_grp
427  if( hecmw_streqr(grp_name%s(i), name)) then
428  sn = grp_index(i-1) + 1
429  en = grp_index(i)
430  k = 1
431  if( grp_type == 3 ) then ! == surf_grp
432  do j = sn, en
433  member1(k) = grp_item(2*j-1)
434  member2(k) = grp_item(2*j)
435  k = k + 1
436  end do
437  else
438  do j = sn, en
439  member1(k) = grp_item(j)
440  k = k + 1
441  end do
442  end if
443  get_grp_member = en - sn + 1
444  return
445  end if
446  end do
447  get_grp_member = 0
448  return
449  end function get_grp_member
450 
451  subroutine node_grp_name_to_id( hecMESH, header_name, n, grp_id_name, grp_ID )
452  implicit none
453  type (hecmwST_local_mesh) :: hecMESH
454  character(len=*) :: header_name
455  character(HECMW_NAME_LEN) :: grp_id_name(:)
456  integer(kind=kint),pointer :: grp_ID(:)
457  integer(kind=kint) :: n
458  integer(kind=kint) :: i, id
459  character(len=256) :: msg
460 
461  do i = 1, n
462  grp_id(i) = -1
463  do id = 1, hecmesh%node_group%n_grp
464  if( hecmw_streqr(hecmesh%node_group%grp_name(id),grp_id_name(i))) then
465  grp_id(i) = id
466  exit
467  end if
468  end do
469  if( grp_id(i) == -1 ) then
470  write(msg,*) '### Error: ', header_name,' : Node group "',&
471  grp_id_name(i),'" does not exist.'
472  call hecmw_setup_util_err_stop(msg)
473  end if
474  end do
475  end subroutine node_grp_name_to_id
476 
477  subroutine elem_grp_name_to_id( hecMESH, header_name, n, grp_id_name, grp_ID )
478  implicit none
479  type (hecmwST_local_mesh) :: hecMESH
480  character(len=*) :: header_name
481  character(HECMW_NAME_LEN) :: grp_id_name(:)
482  integer(kind=kint) :: grp_ID(:)
483  integer(kind=kint) :: n
484  integer(kind=kint) :: i, id
485  character(len=256) :: msg
486 
487  do i = 1, n
488  grp_id(i) = -1
489  do id = 1, hecmesh%elem_group%n_grp
490  if (hecmw_streqr(hecmesh%elem_group%grp_name(id), grp_id_name(i))) then
491  grp_id(i) = id
492  exit
493  end if
494  end do
495  if( grp_id(i) == -1 ) then
496  write(msg,*) '### Error: ', header_name,' : Element group "',&
497  grp_id_name(i),'" does not exist.'
498  call hecmw_setup_util_err_stop(msg)
499  end if
500  end do
501  end subroutine elem_grp_name_to_id
502 
503  !------------------------------------------------------------------------------
504  ! JP-5
505  ! JP-6
506  !
507 
508  subroutine node_grp_name_to_id_ex( hecMESH, header_name, n, grp_id_name, grp_ID )
509  implicit none
510  type (hecmwST_local_mesh),target :: hecMESH
511  character(len=*) :: header_name
512  integer(kind=kint) :: n
513  character(len=HECMW_NAME_LEN) :: grp_id_name(:)
514  integer(kind=kint) :: grp_ID(:)
515 
516  integer(kind=kint) :: i, id
517  integer(kind=kint) :: no, no_count, exist_n
518  integer(kind=kint),pointer :: no_list(:)
519  character(HECMW_NAME_LEN) :: name
520  character(len=256) :: msg
521 
522  allocate( no_list( n ))
523  no_count = 0
524  do i = 1, n
525  if( hecmw_str2index( grp_id_name(i), no )) then
526  no_count = no_count + 1
527  no_list(no_count) = no
528  grp_id(i) = hecmesh%node_group%n_grp + no_count
529  else
530  grp_id(i) = -1
531  do id = 1, hecmesh%node_group%n_grp
532  if (hecmw_streqr(hecmesh%node_group%grp_name(id), grp_id_name(i))) then
533  grp_id(i) = id
534  exit
535  end if
536  end do
537  if( grp_id(i) == -1 ) then
538  write(msg,*) '### Error: ', header_name,' : Node group "',grp_id_name(i),'" does not exist.'
539  call hecmw_setup_util_err_stop(msg)
540  end if
541  end if
542  end do
543 
544  if( no_count > 0 ) then
545  name = 'node_grp'
546  exist_n = append_single_group( hecmesh, name, no_count, no_list )
547  ! if( exist_n < no_count ) then
548  ! write(*,*) '### Warning: ', header_name, ': following nodes are not exist'
549  ! write(imsg,*) '### Warning: ', header_name, ': following nodes are not exist'
550  ! do i=1, no_count
551  ! if( no_list(i)<0 ) then
552  ! write(*,*) -no_list(i)
553  ! write(imsg,*) -no_list(i)
554  ! end if
555  ! end do
556  ! end if
557  end if
558 
559  deallocate( no_list )
560  end subroutine node_grp_name_to_id_ex
561 
562  subroutine elem_grp_name_to_id_ex( hecMESH, header_name, n, grp_id_name, grp_ID )
563  implicit none
564  type (hecmwST_local_mesh),target :: hecMESH
565  character(len=*) :: header_name
566  integer(kind=kint) :: n
567  character(HECMW_NAME_LEN) :: grp_id_name(:)
568  integer(kind=kint) :: grp_ID(:)
569  integer(kind=kint) :: i, id
570  integer(kind=kint) :: no, no_count, exist_n
571  integer(kind=kint),pointer :: no_list(:)
572  character(HECMW_NAME_LEN) :: name
573  character(len=256) :: msg
574 
575  allocate( no_list( n ))
576  no_count = 0
577  do i = 1, n
578  if( hecmw_str2index( grp_id_name(i), no )) then
579  no_count = no_count + 1
580  no_list(no_count) = no
581  grp_id(i) = hecmesh%elem_group%n_grp + no_count
582  else
583  grp_id(i) = -1
584  do id = 1, hecmesh%elem_group%n_grp
585  if (hecmw_streqr(hecmesh%elem_group%grp_name(id), grp_id_name(i))) then
586  grp_id(i) = id
587  exit
588  end if
589  end do
590  if( grp_id(i) == -1 ) then
591  write(msg,*) '### Error: ', header_name,' : Element group "',&
592  grp_id_name(i),'" does not exist.'
593  call hecmw_setup_util_err_stop(msg)
594  end if
595  end if
596  end do
597 
598  if( no_count > 0 ) then
599  name = 'elem_grp'
600  exist_n = append_single_group( hecmesh, name, no_count, no_list )
601  if( exist_n < no_count ) then
602  write(*,*) '### Warning: ', header_name, ': following elements are not exist'
603 ! write(imsg,*) '### Warning: ', header_name, ': following elements are not exist'
604  do i=1, no_count
605  if( no_list(i)<0 ) then
606  write(*,*) -no_list(i)
607 ! write(imsg,*) -no_list(i)
608  end if
609  end do
610  end if
611  end if
612 
613  deallocate( no_list )
614  end subroutine elem_grp_name_to_id_ex
615 
616  !------------------------------------------------------------------------------
617 
618  subroutine surf_grp_name_to_id_ex( hecMESH, header_name, n, grp_id_name, grp_ID )
619  implicit none
620  type (hecmwST_local_mesh),target :: hecMESH
621  character(len=*) :: header_name
622  integer(kind=kint) :: n
623  character(len=HECMW_NAME_LEN) :: grp_id_name(:)
624  integer(kind=kint) :: grp_ID(:)
625  integer(kind=kint) :: i, id
626  character(len=256) :: msg
627 
628  do i = 1, n
629  grp_id(i) = -1
630  do id = 1, hecmesh%surf_group%n_grp
631  if (hecmw_streqr(hecmesh%surf_group%grp_name(id), grp_id_name(i))) then
632  grp_id(i) = id
633  exit
634  end if
635  end do
636  if( grp_id(i) == -1 ) then
637  write(msg,*) '### Error: ', header_name,' : Surface group "',grp_id_name(i),'" does not exist.'
638  call hecmw_setup_util_err_stop(msg)
639  end if
640  end do
641  end subroutine surf_grp_name_to_id_ex
642 
643  !------------------------------------------------------------------------------
644  ! JP-8
645 
646  function get_node_grp_member_n( hecMESH, grp_name_array, n )
647  implicit none
648  integer(kind=kint) :: get_node_grp_member_n
649  type (hecmwst_local_mesh), target :: hecmesh
650  type(hecmw_str_arr) :: grp_name_array
651  integer(kind=kint) :: n
652  integer(kind=kint) :: i,j, m
653 
654  m = 0;
655  do i = 1, n
656  call set_group_pointers( hecmesh, grp_name_array%s(i) )
657  do j = 1, n_grp
658  if( hecmw_streqr(grp_name%s(j), grp_name_array%s(i))) then
659  m = m + grp_index(j) - grp_index(j-1)
660  end if
661  end do
662  end do
664  return
665  end function get_node_grp_member_n
666 
667  !------------------------------------------------------------------------------
668 
669  subroutine hecmw_expand_index_array( array, old_size, new_size )
670  implicit none
671  integer(kind=kint), pointer :: array(:)
672  integer(kind=kint) :: old_size, new_size,i
673  integer(kind=kint), pointer :: temp(:)
674 
675  if( old_size >= new_size ) then
676  return
677  end if
678 
679  if( associated( array ) ) then
680  allocate(temp(0:old_size-1))
681  do i=0, old_size-1
682  temp(i) = array(i)
683  end do
684  deallocate(array)
685  allocate(array(0:new_size-1))
686  array = 0
687  do i=0, old_size-1
688  array(i) = temp(i)
689  end do
690  deallocate(temp)
691  else
692  allocate(array(0:new_size-1))
693  array = 0
694  end if
695  end subroutine hecmw_expand_index_array
696 
697  subroutine hecmw_expand_char_array( array, old_size, new_size )
698  implicit none
699  character(len=HECMW_NAME_LEN), pointer :: array(:)
700  integer(kind=kint) :: old_size, new_size,i
701  character(len=HECMW_NAME_LEN), pointer :: temp(:)
702 
703  if( old_size >= new_size ) then
704  return
705  end if
706 
707  if( associated( array ) ) then
708  allocate(temp(old_size))
709  do i=1, old_size
710  temp(i) = array(i)
711  end do
712  deallocate(array)
713  allocate(array(new_size))
714  array = ''
715  do i=1, old_size
716  array(i) = temp(i)
717  end do
718  deallocate(temp)
719  else
720  allocate(array(new_size))
721  array = ''
722  end if
723  end subroutine hecmw_expand_char_array
724 
725  subroutine hecmw_expand_integer_array( array, old_size, new_size )
726  implicit none
727  integer(kind=kint), pointer :: array(:)
728  integer(kind=kint) :: old_size, new_size,i
729  integer(kind=kint), pointer :: temp(:)
730 
731  if( old_size >= new_size ) then
732  return
733  end if
734 
735  if( associated( array ) ) then
736  allocate(temp(old_size))
737  do i=1, old_size
738  temp(i) = array(i)
739  end do
740  deallocate(array)
741  allocate(array(new_size))
742  array = 0
743  do i=1, old_size
744  array(i) = temp(i)
745  end do
746  deallocate(temp)
747  else
748  allocate(array(new_size))
749  array = 0
750  end if
751  end subroutine hecmw_expand_integer_array
752 
753  subroutine hecmw_expand_real_array( array, old_size, new_size )
754  implicit none
755  real(kind=kreal), pointer :: array(:)
756  integer(kind=kint) :: old_size, new_size, i
757  real(kind=kreal), pointer :: temp(:)
758 
759  if( old_size >= new_size ) then
760  return
761  end if
762 
763  if( associated( array ) ) then
764  allocate(temp(old_size))
765  do i=1, old_size
766  temp(i) = array(i)
767  end do
768  deallocate(array)
769  allocate(array(new_size))
770  array = 0
771  do i=1, old_size
772  array(i) = temp(i)
773  end do
774  deallocate(temp)
775  else
776  allocate(array(new_size))
777  array = 0
778  end if
779  end subroutine hecmw_expand_real_array
780 
781  ! array( old_size, column ) -> array( new_size, column )
782  subroutine hecmw_expand_integer_array2( array, column, old_size, new_size )
783  implicit none
784  integer(kind=kint), pointer :: array(:,:)
785  integer(kind=kint) :: column, old_size, new_size, i,j
786  integer(kind=kint), pointer :: temp(:,:)
787 
788  if( old_size >= new_size ) then
789  return
790  end if
791 
792  if( associated( array ) ) then
793  allocate(temp(old_size,column))
794  do i=1, old_size
795  do j=1,column
796  temp(i,j) = array(i,j)
797  end do
798  end do
799  deallocate(array)
800  allocate(array(new_size,column))
801  array = 0
802  do i=1, old_size
803  do j=1,column
804  array(i,j) = temp(i,j)
805  end do
806  end do
807  deallocate(temp)
808  else
809  allocate(array(new_size, column))
810  array = 0
811  end if
812  end subroutine hecmw_expand_integer_array2
813 
814 
815  ! array( old_size, column ) -> array( new_size, column )
816 
817  subroutine hecmw_expand_real_array2( array, column, old_size, new_size )
818  implicit none
819  real(kind=kreal), pointer :: array(:,:)
820  integer(kind=kint) :: column, old_size, new_size, i,j
821  real(kind=kreal), pointer :: temp(:,:)
822 
823  if( old_size >= new_size ) then
824  return
825  end if
826 
827  if( associated( array ) ) then
828  allocate(temp(old_size,column))
829  do i=1, old_size
830  do j=1,column
831  temp(i,j) = array(i,j)
832  end do
833  end do
834  deallocate(array)
835  allocate(array(new_size,column))
836  array = 0
837  do i=1, old_size
838  do j=1,column
839  array(i,j) = temp(i,j)
840  end do
841  end do
842  deallocate(temp)
843  else
844  allocate(array(new_size, column))
845  array = 0
846  end if
847  end subroutine hecmw_expand_real_array2
848 
849  subroutine hecmw_expand_name_array( array, old_size, new_size )
850  implicit none
851  type(hecmw_str_arr) :: array
852  integer(kind=kint) :: old_size, new_size, i
853  character(len=HECMW_NAME_LEN), pointer :: temp(:)
854 
855  if( old_size >= new_size ) then
856  return
857  end if
858 
859  if( associated( array%s ) ) then
860  allocate(temp(old_size))
861  do i=1, old_size
862  temp(i) = array%s(i)
863  end do
864  deallocate(array%s)
865  allocate(array%s(new_size))
866  do i=1, old_size
867  array%s(i) = temp(i)
868  end do
869  deallocate(temp)
870  else
871  allocate(array%s(new_size))
872  end if
873  end subroutine hecmw_expand_name_array
874 
875  subroutine hecmw_delete_index_array( array, old_size, nindex )
876  implicit none
877  integer(kind=kint), pointer :: array(:)
878  integer(kind=kint), intent(in) :: old_size
879  integer(kind=kint), intent(in) :: nindex
880  integer(kind=kint) :: i
881  integer(kind=kint), pointer :: temp(:)
882 
883  if( old_size < nindex ) then
884  return
885  end if
886 
887  if( old_size == nindex ) then
888  deallocate( array )
889  return
890  endif
891 
892  allocate(temp(0:old_size-1))
893  do i=0, old_size-nindex-1
894  temp(i) = array(i)
895  end do
896  deallocate(array)
897  allocate(array(0:old_size-nindex-1))
898  array = 0
899  do i=0, old_size-nindex-1
900  array(i) = temp(i)
901  end do
902  deallocate(temp)
903  end subroutine hecmw_delete_index_array
904 
905  subroutine hecmw_delete_integer_array( array, old_size, nitem )
906  implicit none
907  integer(kind=kint), pointer :: array(:)
908  integer(kind=kint), intent(in) :: old_size
909  integer(kind=kint), intent(in) :: nitem
910  integer(kind=kint) :: i
911  integer(kind=kint), pointer :: temp(:)
912 
913  if( old_size < nitem ) then
914  return
915  end if
916 
917  if( old_size == nitem ) then
918  deallocate( array )
919  return
920  endif
921 
922  allocate(temp(old_size))
923  do i=1, old_size-nitem
924  temp(i) = array(i)
925  end do
926  deallocate(array)
927  allocate(array(old_size-nitem))
928  array = 0
929  do i=1, old_size-nitem
930  array(i) = temp(i)
931  end do
932  deallocate(temp)
933  end subroutine hecmw_delete_integer_array
934 
935  subroutine hecmw_delete_real_array( array, old_size, nitem )
936  implicit none
937  real(kind=kreal), pointer :: array(:)
938  integer(kind=kint), intent(in) :: old_size
939  integer(kind=kint), intent(in) :: nitem
940  integer(kind=kint) :: i
941  real(kind=kreal), pointer :: temp(:)
942 
943  if( old_size < nitem ) then
944  return
945  end if
946 
947  if( old_size == nitem ) then
948  deallocate( array )
949  return
950  endif
951 
952  allocate(temp(old_size))
953  do i=1, old_size-nitem
954  temp(i) = array(i)
955  end do
956  deallocate(array)
957  allocate(array(old_size-nitem))
958  array = 0
959  do i=1, old_size-nitem
960  array(i) = temp(i)
961  end do
962  deallocate(temp)
963  end subroutine hecmw_delete_real_array
964 
965  !-----------------------------------------------------------------------------!
966 
967  subroutine reallocate_integer( array, n )
968  implicit none
969  integer(kind=kint),pointer :: array(:)
970  integer(kind=kint) :: n;
971 
972  if( associated( array )) deallocate(array)
973  allocate( array(n));
974  end subroutine reallocate_integer
975 
976  subroutine reallocate_real( array, n )
977  implicit none
978  real(kind=kreal),pointer :: array(:)
979  integer(kind=kint) :: n;
980 
981  if( associated( array )) deallocate(array)
982  allocate( array(n));
983  end subroutine reallocate_real
984 
985 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 append_new_groups(hecMESH, grp_type_name, n, names, index, list, first_id)
Append n groups at once; group i holds list(index(i-1)+1:index(i)).
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