@@ -23,9 +23,15 @@ program rk_test_variable_step
23
23
type (pyplot) :: plt, plt2
24
24
integer :: istat
25
25
character (len= 3 ) :: rstr
26
+ real (wp),dimension (3 ) :: hsl
27
+ real (wp) :: hue_step
28
+ integer :: ilinestyle
26
29
27
30
integer ,parameter :: font_size = 30
28
- integer ,parameter :: legend_fontsize = 20
31
+ integer ,parameter :: legend_fontsize = 15
32
+ integer ,parameter :: max_number_of_methods = 40 ! ! defines the step size for the colors
33
+
34
+ character (len= 2 ),dimension (* ),parameter :: linestyle = [' - ' , ' --' , ' : ' ]
29
35
30
36
! initialize plot
31
37
call plt% initialize(grid= .true. ,xlabel= ' Relative Error' ,&
@@ -41,50 +47,55 @@ program rk_test_variable_step
41
47
legend_fontsize= legend_fontsize,&
42
48
title= ' Variable-Step Runge Kutta Methods [Fixed-Step Mode]' ,legend= .true. )
43
49
50
+ ! vary the hue and linestyle for each method in the plot:
51
+ hsl = [0.0_wp , 1.0_wp , 0.5_wp ]
52
+ hue_step = 1.0_wp / max_number_of_methods
53
+ ilinestyle = 0
54
+
55
+ ! test of this routine:
56
+ write (* ,* ) hslToRgb([0.9_wp , 1.0_wp , 0.5_wp ]) / 255.0_wp
57
+ ! 1.00000000000000 0.000000000000000E+000 0.600000000000000
58
+ ! python comparison:
59
+ ! >>> colorsys.hls_to_rgb(0.9, 0.5, 1)
60
+ ! (1.0, 0.0, 0.5999999999999999)
61
+
44
62
! test all the methods:
45
- allocate (rkbs32_class :: s); allocate (s2, source= s); call run_all_tests(' rkbs32' , [255 ,0 ,0 ]); call finish()
46
-
47
- allocate (rkf45_class :: s); allocate (s2, source= s); call run_all_tests(' rkf45' , [245 , 152 , 152 ]); call finish()
48
-
49
- allocate (rkck54_class :: s); allocate (s2, source= s); call run_all_tests(' rkck54' , [255 , 102 , 0 ]); call finish()
50
- allocate (rkdp54_class :: s); allocate (s2, source= s); call run_all_tests(' rkdp54' , [189 , 90 , 25 ]); call finish()
51
- allocate (rkt54_class :: s); allocate (s2, source= s); call run_all_tests(' rkt54' , [143 , 78 , 36 ]); call finish()
52
- allocate (rks54_class :: s); allocate (s2, source= s); call run_all_tests(' rks54' , [243 , 78 , 36 ]); call finish()
53
-
54
- allocate (rkdp65_class :: s); allocate (s2, source= s); call run_all_tests(' rkdp65' , [251 , 255 , 0 ]); call finish()
55
- allocate (rkc65_class :: s); allocate (s2, source= s); call run_all_tests(' rkc65' , [207 , 194 , 145 ]);call finish()
56
- allocate (rktp64_class :: s); allocate (s2, source= s); call run_all_tests(' rktp64' , [187 , 189 , 49 ]); call finish()
57
- allocate (rkv65e_class :: s); allocate (s2, source= s); call run_all_tests(' rkv65e' , [149 , 150 , 63 ]); call finish()
58
- allocate (rkv65r_class :: s); allocate (s2, source= s); call run_all_tests(' rkv65r' , [65 , 71 , 41 ]); call finish()
59
- allocate (rkv65_class :: s); allocate (s2, source= s); call run_all_tests(' rkv65' , [75 , 81 , 51 ]); call finish()
60
- allocate (rktf65_class :: s); allocate (s2, source= s); call run_all_tests(' rktf65' , [2 , 2 , 2 ]); call finish()
61
-
62
- allocate (rktp75_class :: s); allocate (s2, source= s); call run_all_tests(' rktp75' , [0 , 255 , 38 ]); call finish()
63
- allocate (rktmy7_class :: s); allocate (s2, source= s); call run_all_tests(' rktmy7' , [102 , 247 , 255 ]); call finish()
64
- allocate (rkv76e_class :: s); allocate (s2, source= s); call run_all_tests(' rkv76e' , [38 , 189 , 60 ]); call finish()
65
- allocate (rkv76r_class :: s); allocate (s2, source= s); call run_all_tests(' rkv76r' , [149 , 163 , 93 ]); call finish()
66
- allocate (rkf78_class :: s); allocate (s2, source= s); call run_all_tests(' rkf78' , [66 , 143 , 77 ]); call finish()
67
- allocate (rkv78_class :: s); allocate (s2, source= s); call run_all_tests(' rkv78' , [77 , 105 , 81 ]); call finish()
68
-
69
- allocate (rktp86_class :: s); allocate (s2, source= s); call run_all_tests(' rktp86' , [0 , 47 , 255 ]); call finish()
70
- allocate (rkdp87_class :: s); allocate (s2, source= s); call run_all_tests(' rkdp87' , [51 , 83 , 222 ]); call finish()
71
- allocate (rkv87e_class :: s); allocate (s2, source= s); call run_all_tests(' rkv87e' , [90 , 116 , 230 ]); call finish()
72
- allocate (rkv87r_class :: s); allocate (s2, source= s); call run_all_tests(' rkv87r' , [0 ,0 ,0 ]); call finish()
73
- allocate (rkk87_class :: s); allocate (s2, source= s); call run_all_tests(' rkk87' , [10 ,10 ,10 ]); call finish()
74
- allocate (rkf89_class :: s); allocate (s2, source= s); call run_all_tests(' rkf89' , [116 , 133 , 207 ]); call finish()
75
- allocate (rkv89_class :: s); allocate (s2, source= s); call run_all_tests(' rkv89' , [169 , 176 , 219 ]); call finish()
76
-
77
- allocate (rkt98a_class :: s); allocate (s2, source= s); call run_all_tests(' rkt98a' , [195 , 0 , 255 ]); call finish()
78
- allocate (rkv98e_class :: s); allocate (s2, source= s); call run_all_tests(' rkv98e' , [192 , 52 , 235 ]); call finish()
79
- allocate (rkv98r_class :: s); allocate (s2, source= s); call run_all_tests(' rkv98r' , [79 , 5 , 153 ]); call finish()
80
- allocate (rkf108_class :: s); allocate (s2, source= s); call run_all_tests(' rkf108' , [198 , 149 , 245 ]); call finish()
81
- allocate (rkc108_class :: s); allocate (s2, source= s); call run_all_tests(' rkc108' , [232 , 207 , 255 ]); call finish()
82
- allocate (rkb109_class :: s); allocate (s2, source= s); call run_all_tests(' rkb109' , [200 , 180 , 230 ]); call finish()
83
-
84
- allocate (rks1110a_class :: s); allocate (s2, source= s); call run_all_tests(' rks1110a' ,[0 ,0 ,0 ]); call finish()
85
- allocate (rkf1210_class :: s); allocate (s2, source= s); call run_all_tests(' rkf1210' , [94 ,94 ,94 ]); call finish()
86
- allocate (rko129_class :: s); allocate (s2, source= s); call run_all_tests(' rko129' , [145 , 145 , 145 ]); call finish()
87
- allocate (rkf1412_class :: s); allocate (s2, source= s); call run_all_tests(' rkf1412' , [225 , 230 , 230 ]); call finish()
63
+ allocate (rkbs32_class :: s); call run_all_tests(' rkbs32' )
64
+ allocate (rkf45_class :: s); call run_all_tests(' rkf45' )
65
+ allocate (rkck54_class :: s); call run_all_tests(' rkck54' )
66
+ allocate (rkdp54_class :: s); call run_all_tests(' rkdp54' )
67
+ allocate (rkt54_class :: s); call run_all_tests(' rkt54' )
68
+ allocate (rks54_class :: s); call run_all_tests(' rks54' )
69
+ allocate (rkdp65_class :: s); call run_all_tests(' rkdp65' )
70
+ allocate (rkc65_class :: s); call run_all_tests(' rkc65' )
71
+ allocate (rktp64_class :: s); call run_all_tests(' rktp64' )
72
+ allocate (rkv65e_class :: s); call run_all_tests(' rkv65e' )
73
+ allocate (rkv65r_class :: s); call run_all_tests(' rkv65r' )
74
+ allocate (rkv65_class :: s); call run_all_tests(' rkv65' )
75
+ allocate (rktf65_class :: s); call run_all_tests(' rktf65' )
76
+ allocate (rktp75_class :: s); call run_all_tests(' rktp75' )
77
+ allocate (rktmy7_class :: s); call run_all_tests(' rktmy7' )
78
+ allocate (rkv76e_class :: s); call run_all_tests(' rkv76e' )
79
+ allocate (rkv76r_class :: s); call run_all_tests(' rkv76r' )
80
+ allocate (rkf78_class :: s); call run_all_tests(' rkf78' )
81
+ allocate (rkv78_class :: s); call run_all_tests(' rkv78' )
82
+ allocate (rktp86_class :: s); call run_all_tests(' rktp86' )
83
+ allocate (rkdp87_class :: s); call run_all_tests(' rkdp87' )
84
+ allocate (rkv87e_class :: s); call run_all_tests(' rkv87e' )
85
+ allocate (rkv87r_class :: s); call run_all_tests(' rkv87r' )
86
+ allocate (rkk87_class :: s); call run_all_tests(' rkk87' )
87
+ allocate (rkf89_class :: s); call run_all_tests(' rkf89' )
88
+ allocate (rkv89_class :: s); call run_all_tests(' rkv89' )
89
+ allocate (rkt98a_class :: s); call run_all_tests(' rkt98a' )
90
+ allocate (rkv98e_class :: s); call run_all_tests(' rkv98e' )
91
+ allocate (rkv98r_class :: s); call run_all_tests(' rkv98r' )
92
+ allocate (rkf108_class :: s); call run_all_tests(' rkf108' )
93
+ allocate (rkc108_class :: s); call run_all_tests(' rkc108' )
94
+ allocate (rkb109_class :: s); call run_all_tests(' rkb109' )
95
+ allocate (rks1110a_class :: s); call run_all_tests(' rks1110a' )
96
+ allocate (rkf1210_class :: s); call run_all_tests(' rkf1210' )
97
+ allocate (rko129_class :: s); call run_all_tests(' rko129' )
98
+ allocate (rkf1412_class :: s); call run_all_tests(' rkf1412' )
88
99
89
100
! save plot:
90
101
write (rstr,' (I3)' ) wp
@@ -94,17 +105,25 @@ program rk_test_variable_step
94
105
contains
95
106
! *****************************************************************************************
96
107
97
- subroutine finish ()
98
- deallocate (s); deallocate (s2)
99
- end subroutine finish
100
-
101
- subroutine run_all_tests (method ,color )
108
+ subroutine run_all_tests (method )
102
109
! ! run all the tests
103
110
character (len=* ),intent (in ) :: method ! ! name of the RK method to use
104
- integer ,dimension (3 ),intent (in ) :: color ! ! color for the plot
111
+
112
+ integer ,dimension (3 ) :: color ! ! color for the plot
113
+
114
+ allocate (s2, source= s)
115
+
116
+ ! update color and linestyle:
117
+ hsl(1 ) = hsl(1 ) + hue_step
118
+ color = hslToRgb(hsl)
119
+ ilinestyle = ilinestyle + 1
120
+ if (ilinestyle> size (linestyle)) ilinestyle = 1
121
+
105
122
call performance_test(method,color)
106
123
call performance_test_fixed(method,color)
107
124
call run_test(method)
125
+ deallocate (s); deallocate (s2)
126
+
108
127
end subroutine run_all_tests
109
128
110
129
subroutine performance_test (method ,color )
@@ -186,7 +205,8 @@ subroutine performance_test(method,color)
186
205
! add to the plot:
187
206
call plt% add_plot(r_error,real (feval,wp),&
188
207
label= method,&
189
- linestyle= ' .-' ,color= real (color/ 255.0_wp ,wp),&
208
+ linestyle= linestyle(ilinestyle),&
209
+ color= real (color/ 255.0_wp ,wp),&
190
210
markersize= 5 ,linewidth= 4 ,istat= istat,&
191
211
xscale= ' log' ,yscale= ' log' )
192
212
@@ -257,7 +277,8 @@ subroutine performance_test_fixed(method,color)
257
277
! add to the plot:
258
278
call plt2% add_plot(r_error,real (feval,wp),&
259
279
label= method,&
260
- linestyle= ' .-' ,color= real (color/ 255.0_wp ,wp),&
280
+ linestyle= linestyle(ilinestyle),&
281
+ color= real (color/ 255.0_wp ,wp),&
261
282
markersize= 5 ,linewidth= 4 ,istat= istat,&
262
283
xscale= ' log' ,yscale= ' log' )
263
284
0 commit comments