-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_fnode.f90
116 lines (92 loc) · 2.68 KB
/
test_fnode.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
include 'globals/parameter_module.f90'
include 'object_node/fnode_module.f90'
program test_fnode
! Purpose:
! to perform unit testing on fnode_module
!
!
! Record of revision:
! Date Programmer Description of change
! ======== ==================== ========================================
! 11/04/15 B. Y. Chen Original code
!
!
use parameter_module, only : DP, ZERO, ONE, MSGLENGTH, STAT_SUCCESS, STAT_FAILURE
use fnode_module ! use everything
implicit none
integer, parameter :: ndim = 3, ndof = 2
type(fnode) :: node1, node2, node3
real(DP), allocatable :: x(:)
real(DP), allocatable :: u(:), du(:)
real(DP), allocatable :: v(:), a(:)
real(DP), allocatable :: dof(:), ddof(:)
integer :: istat
character(MSGLENGTH) :: emsg
character(len=20) :: display_fmt
character(len=10) :: cndim, cndof
! initialize local variables
! all derived types have been initialized in definition
allocate(x(ndim), u(ndim), du(ndim), v(ndim), a(ndim))
allocate(dof(ndof), ddof(ndof))
x = ZERO
u = ZERO
du = ZERO
v = ZERO
a = ZERO
dof = ZERO
ddof = ZERO
x = ONE
u = ONE
du = ONE
v = ONE
a = ONE
dof = ONE
ddof = ONE
istat = STAT_SUCCESS
emsg = ''
display_fmt = ''
cndim = ''
cndof = ''
! store ndim and ndof as strings in cndim and cndof
write(cndim,'(i5)') ndim
write(cndof,'(i5)') ndof
write(*,*) 'display node 1 before any update:'
call display (node1)
call update (node1, istat=istat, emsg=emsg, x=x, u=u)
if (istat == STAT_FAILURE) then
write(*,*) emsg
return
end if
write(*,*) 'display node 1 after updates on x and u:'
call display (node1)
call update (node1, istat=istat, emsg=emsg, du=du, v=v, a=a, dof=dof, ddof=ddof)
if (istat == STAT_FAILURE) then
write(*,*) emsg
return
end if
write(*,*) 'display node 1 after updates on all components:'
call display (node1)
node2 = 0.6_DP * node1
write(*,*) 'display node 2 as 0.6 * node1:'
call display (node2)
node3 = node1 + node2
write(*,*) 'display node 3 as a sum of node1 and node2:'
call display (node3)
node3 = node1 - 0.5_DP * node2
write(*,*) 'display node 3 as node1 - 0.5 * node2:'
call display (node3)
write(*,*) 'check extracted values of node3:'
call extract(node3, x=x, u=u, du=du, v=v, a=a, dof=dof, ddof=ddof)
display_fmt = '(1X, A,'//trim(adjustl(cndim))//'ES10.3)'
write(*,display_fmt) '- x :', x
write(*,display_fmt) '- u :', u
write(*,display_fmt) '- du :', du
write(*,display_fmt) '- v :', v
write(*,display_fmt) '- a :', a
display_fmt = '(1X, A,'//trim(adjustl(cndof))//'ES10.3)'
write(*,display_fmt) '- dof :', dof
write(*,display_fmt) '- ddof :', ddof
call empty (node3)
write(*,*) 'display node 3 after being emptied:'
call display (node3)
end program test_fnode