-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathising_2d_simulation.f
1658 lines (1479 loc) · 35.9 KB
/
ising_2d_simulation.f
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
program main
c*********************************************************************72
c
cc MAIN is the main program for ISING_2D_SIMULATION.
c
c Usage:
c
c ising_2d_simulation m n iterations thresh seed
c
c * M, N, the number of rows and columns.
c * ITERATIONS, the number of iterations.
c * THRESH, the threshhold.
c * SEED, a seed for the random number generator.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 29 June 2013
c
c Author:
c
c John Burkardt
c
implicit none
integer i
integer iterations
integer m
integer n
double precision prob(5)
integer seed
integer step
double precision thresh
save prob
data prob /
& 0.98D+00, 0.85D+00, 0.50D+00, 0.15D+00, 0.02D+00 /
call timestamp ( )
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'ISING_2D_SIMULATION'
write ( *, '(a)' ) ' FORTRAN77 version'
write ( *, '(a)' ) ' Monte Carlo simulation of a 2D Ising model.'
c
c Get input from commandline or user.
c
call get_input ( m, n, iterations, thresh, seed )
write ( *, '(a)' ) ' '
write ( *, '(a,i8)' ) ' The number of rows is M = ', m
write ( *, '(a,i8)' ) ' The number of columns is N = ', n
write ( *, '(a,i8)' )
& ' The number of iterations taken is ITERATIONS = ', iterations
write ( *, '(a,g14.6)' ) ' The threshhold THRESH = ', thresh
write ( *, '(a,i12)' ) ' The seed SEED = ', seed
write ( *, '(a)' ) ' '
write ( *, '(a)' )
& ' The transition probability table, based on the number of'
write ( *, '(a)' ) ' neighbors with the same spin.'
write ( *, '(a)' ) ' '
write ( *, '(a)' )
& ' 1 2 3 4 5'
write ( *, '(a)' ) ' '
write ( *, '(7f10.4)' ) ( prob(i), i = 1, 5 )
c
c Do the simulation.
c I have to do this in a subroutine, so that I can dimension C1 on the fly.
c
call handle ( m, n, iterations, prob, thresh, seed )
c
c Terminate.
c
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'ISING_2D_SIMULATION'
write ( *, '(a)' ) ' Normal end of execution.'
write ( *, '(a)' ) ' '
call timestamp ( )
stop
end
subroutine ch_cap ( ch )
c*********************************************************************72
c
cc CH_CAP capitalizes a single character.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 03 January 2007
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input/output, character CH, the character to capitalize.
c
implicit none
character ch
integer itemp
itemp = ichar ( ch )
if ( 97 .le. itemp .and. itemp .le. 122 ) then
ch = char ( itemp - 32 )
end if
return
end
function ch_eqi ( c1, c2 )
c*********************************************************************72
c
cc CH_EQI is a case insensitive comparison of two characters for equality.
c
c Example:
c
c CH_EQI ( 'A', 'a' ) is TRUE.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 03 January 2007
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, character C1, C2, the characters to compare.
c
c Output, logical CH_EQI, the result of the comparison.
c
implicit none
character c1
character c1_cap
character c2
character c2_cap
logical ch_eqi
c1_cap = c1
c2_cap = c2
call ch_cap ( c1_cap )
call ch_cap ( c2_cap )
if ( c1_cap == c2_cap ) then
ch_eqi = .true.
else
ch_eqi = .false.
end if
return
end
subroutine ch_to_digit ( c, digit )
c*********************************************************************72
c
cc CH_TO_DIGIT returns the integer value of a base 10 digit.
c
c Example:
c
c C DIGIT
c --- -----
c '0' 0
c '1' 1
c ... ...
c '9' 9
c ' ' 0
c 'X' -1
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 04 August 1999
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, character C, the decimal digit, '0' through '9' or blank
c are legal.
c
c Output, integer DIGIT, the corresponding integer value. If C was
c 'illegal', then DIGIT is -1.
c
implicit none
character c
integer digit
if ( lge ( c, '0' ) .and. lle ( c, '9' ) ) then
digit = ichar ( c ) - 48
else if ( c .eq. ' ' ) then
digit = 0
else
digit = -1
end if
return
end
subroutine get_input ( m, n, iterations, thresh, seed )
c*********************************************************************72
c
cc GET_INPUT gets input parameters.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 02 November 2011
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Output, integer M, N, the number of rows and columns.
c
c Output, integer ITERATIONS, the number of iterations.
c
c Output, double precision THRESH, the threshhold.
c
c Output, integer SEED, a seed for the random
c number generator.
c
implicit none
integer arg_num
integer iarg
integer iargc
integer ierror
integer iterations
integer last
integer m
integer n
integer seed
character * ( 80 ) string
double precision thresh
arg_num = iargc ( )
if ( 1 .le. arg_num ) then
iarg = 1
call getarg ( iarg, string )
call s_to_i4 ( string, m, ierror, last )
else if ( .true. ) then
m = 10
else
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Enter M, the number of rows:'
read ( *, * ) m
end if
if ( 2 .le. arg_num ) then
iarg = 2
call getarg ( iarg, string )
call s_to_i4 ( string, n, ierror, last )
else if ( .true. ) then
n = 10
else
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Enter N, the number of columns:'
read ( *, * ) n
end if
if ( 3 .le. arg_num ) then
iarg = 3
call getarg ( iarg, string )
call s_to_i4 ( string, iterations, ierror, last )
else if ( .true. ) then
iterations = 15
else
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Enter the number of iterations to take.'
read ( *, * ) iterations
end if
if ( 4 .le. arg_num ) then
iarg = 4
call getarg ( iarg, string )
call s_to_r8 ( string, thresh, ierror, last )
else if ( .true. ) then
thresh = 0.50D+00
else
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Enter the threshhold.'
read ( *, * ) thresh
end if
if ( 5 .le. arg_num ) then
iarg = 5
call getarg ( iarg, string )
call s_to_i4 ( string, seed, ierror, last )
else if ( .true. ) then
seed = 123456789
else
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Enter the random number seed.'
read ( *, * ) seed
end if
return
end
subroutine get_unit ( iunit )
c*********************************************************************72
c
cc GET_UNIT returns a free FORTRAN unit number.
c
c Discussion:
c
c A "free" FORTRAN unit number is a value between 1 and 99 which
c is not currently associated with an I/O device. A free FORTRAN unit
c number is needed in order to open a file with the OPEN command.
c
c If IUNIT = 0, then no free FORTRAN unit could be found, although
c all 99 units were checked (except for units 5, 6 and 9, which
c are commonly reserved for console I/O).
c
c Otherwise, IUNIT is a value between 1 and 99, representing a
c free FORTRAN unit. Note that GET_UNIT assumes that units 5 and 6
c are special, and will never return those values.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 02 September 2013
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Output, integer IUNIT, the free unit number.
c
implicit none
integer i
integer iunit
logical value
iunit = 0
do i = 1, 99
if ( i .ne. 5 .and. i .ne. 6 .and. i .ne. 9 ) then
inquire ( unit = i, opened = value, err = 10 )
if ( .not. value ) then
iunit = i
return
end if
end if
10 continue
end do
return
end
subroutine handle ( m, n, iterations, prob, thresh, seed )
c*********************************************************************72
c
cc HANDLE does initialization, computation and output.
c
c Discussion:
c
c The main program picks up the dimensions M and N, so we have to
c call this subroutine so we can essentially allocate C1 on the fly.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 29 June 2013
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer M, N, the number of rows and columns.
c
c Input, integer ITERATIONS, the number of iterations.
c
c Input, double precision PROB(1:5). PROB(I) represents the probability
c that the spin of a given cell will be reversed, given that it has I
c immediate neighbors (including itself) with spin the same as its own.
c
c Input, double precision THRESH, the threshhold.
c
c Input/output, integer SEED, a seed for the random number
c generator.
c
implicit none
integer m
integer n
integer c1(m,n)
integer iterations
double precision prob(1:5)
integer seed
double precision thresh
c
c Initialize the system.
c
call ising_2d_initialize ( m, n, thresh, seed, c1 )
!
! Write the initial state to a gnuplot file.
!
call plot_file ( m, n, c1, 'Initial Configuration',
& 'ising_2d_initial.txt', 'ising_2d_initial.png' )
!
! Do the simulation.
!
call transition ( m, n, iterations, prob, seed, c1 )
!
! Write the final state to a gnuplot file.
!
call plot_file ( m, n, c1, 'Final Configuration',
& 'ising_2d_final.txt', 'ising_2d_final.png' )
return
end
function i4_modp ( i, j )
c*********************************************************************72
c
cc I4_MODP returns the nonnegative remainder of integer division.
c
c Discussion:
c
c If
c NREM = I4_MODP ( I, J )
c NMULT = ( I - NREM ) / J
c then
c I = J * NMULT + NREM
c where NREM is always nonnegative.
c
c The MOD function computes a result with the same sign as the
c quantity being divided. Thus, suppose you had an angle A,
c and you wanted to ensure that it was between 0 and 360.
c Then mod(A,360) would do, if A was positive, but if A
c was negative, your result would be between -360 and 0.
c
c On the other hand, I4_MODP(A,360) is between 0 and 360, always.
c
c Example:
c
c I J MOD I4_MODP Factorization
c
c 107 50 7 7 107 = 2 * 50 + 7
c 107 -50 7 7 107 = -2 * -50 + 7
c -107 50 -7 43 -107 = -3 * 50 + 43
c -107 -50 -7 43 -107 = 3 * -50 + 43
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 30 December 2006
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer I, the number to be divided.
c
c Input, integer J, the number that divides I.
c
c Output, integer I4_MODP, the nonnegative remainder when I is
c divided by J.
c
implicit none
integer i
integer i4_modp
integer j
integer value
if ( j .eq. 0 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'I4_MODP - Fatal error!'
write ( *, '(a,i8)' ) ' Illegal divisor J = ', j
stop
end if
value = mod ( i, j )
if ( value .lt. 0 ) then
value = value + abs ( j )
end if
i4_modp = value
return
end
function i4_wrap ( ival, ilo, ihi )
c*********************************************************************72
c
cc I4_WRAP forces an I4 to lie between given limits by wrapping.
c
c Example:
c
c ILO = 4, IHI = 8
c
c I Value
c
c -2 8
c -1 4
c 0 5
c 1 6
c 2 7
c 3 8
c 4 4
c 5 5
c 6 6
c 7 7
c 8 8
c 9 4
c 10 5
c 11 6
c 12 7
c 13 8
c 14 4
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 31 December 2006
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer IVAL, an integer value.
c
c Input, integer ILO, IHI, the desired bounds for the integer value.
c
c Output, integer I4_WRAP, a "wrapped" version of IVAL.
c
implicit none
integer i4_modp
integer i4_wrap
integer ihi
integer ilo
integer ival
integer jhi
integer jlo
integer value
integer wide
jlo = min ( ilo, ihi )
jhi = max ( ilo, ihi )
wide = jhi - jlo + 1
if ( wide .eq. 1 ) then
value = jlo
else
value = jlo + i4_modp ( ival - jlo, wide )
end if
i4_wrap = value
return
end
subroutine ising_2d_agree ( m, n, c1, c5 )
c*********************************************************************72
c
cc ISING_2D_AGREE returns the number of neighbors agreeing with each cell.
c
c Discussion:
c
c The count includes the cell itself, so it is between 1 and 5.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 22 November 2011
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer M, N, the number of cells in each
c spatial dimension.
c
c Input, integer C1(M,N), an array of 1's and -1's.
c
c Output, integer C5(M,N), the number of neighbors
c that agree. 1, 2, 3, 4, or 5.
c
implicit none
integer m
integer n
integer c1(m,n)
integer c5(m,n)
integer i
integer i4_wrap
integer im
integer ip
integer j
integer jm
integer jp
do j = 1, n
jp = i4_wrap ( j + 1, 1, n )
jm = i4_wrap ( j - 1, 1, n )
do i = 1, m
ip = i4_wrap ( i + 1, 1, m )
im = i4_wrap ( i - 1, 1, m )
c5(i,j) = c1(i,j) + c1(ip,j) + c1(im,j) + c1(i,jm) + c1(i,jp)
end do
end do
do j = 1, n
do i = 1, m
if ( 0 .lt. c1(i,j) ) then
c5(i,j) = ( 5 + c5(i,j) ) / 2
else
c5(i,j) = ( 5 - c5(i,j) ) / 2
end if
end do
end do
return
end
subroutine ising_2d_initialize ( m, n, thresh, seed, c1 )
c*********************************************************************72
c
cc ISING_2D_INITIALIZE initializes the Ising array.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 22 November 2011
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer M, N, the number of rows and columns.
c
c Input, double precision THRESH, the threshhold.
c
c Input/output, integer SEED, a seed for the random
c number generator.
c
c Output, integer C1(M,N), the initial Ising array.
c
implicit none
integer m
integer n
integer c1(m,n)
integer i
integer j
double precision r(m,n)
double precision thresh
integer seed
call r8mat_uniform_01 ( m, n, seed, r )
do j = 1, n
do i = 1, m
if ( r(i,j) .le. thresh ) then
c1(i,j) = -1
else
c1(i,j) = +1
end if
end do
end do
return
end
subroutine ising_2d_stats ( step, m, n, c1 )
c*********************************************************************72
c
cc ISING_2D_STATS prints information about the current step.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 22 November 2011
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer STEP, the step number.
c
c Input, integer M, N, the number of rows and columns.
c
c Input, integer C1(M,N), the current state of the system.
c
implicit none
integer m
integer n
integer c1(m,n)
integer i
integer j
integer pos_count
double precision pos_percent
integer step
integer neg_count
double precision neg_percent
if ( step == 0 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Step Positives Negatives'
write ( *, '(a)' ) ' # % # %'
write ( *, '(a)' ) ' '
end if
pos_count = 0
do j = 1, n
do i = 1, m
if ( 0 .lt. c1(i,j) ) then
pos_count = pos_count + 1
end if
end do
end do
neg_count = m * n - pos_count
pos_percent = dble ( 100 * pos_count ) / dble ( m * n )
neg_percent = dble ( 100 * neg_count ) / dble ( m * n )
write ( *, '(2x,i4,2x,i6,2x,f6.2,2x,i6,2x,f6.2)' )
& step, pos_count, pos_percent, neg_count, neg_percent
return
end
subroutine neighbor_2d_stats ( step, m, n, c1, c5 )
c*********************************************************************72
c
cc NEIGHBOR_2D_STATS prints neighbor statistics about the current step.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 22 November 2011
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer STEP, the step number.
c
c Input, integer M, N, the number of rows and columns.
c
c Input, integer C1(M,N), the current state of the system.
c
c Input, integer C5(M,N), the number of agreeable neighbors.
c
implicit none
integer m
integer n
integer c1(m,n)
integer c5(m,n)
integer i
integer j
integer k
integer stats(-5:5)
integer step
if ( step .eq. 0 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Step Neighborhood Charge:'
write ( *, '(a)' )
& ' -5 -4 -3 -2 -1' //
& ' +1 +2 +3 +4 +5'
write ( *, '(a)' ) ' '
end if
do i = -5, 5
stats(i) = 0
end do
do j = 1, n
do i = 1, m
stats(c5(i,j)) = stats(c5(i,j)) + 1
end do
end do
write ( *, '(2x,i4,10(2x,i4))' )
& step, ( stats(i), i = -5,-1), ( stats(i), i = 1, 5)
return
end
subroutine plot_file ( m, n, c1, title, plot_filename,
& png_filename )
c*********************************************************************72
c
cc PLOT_FILE writes the current configuration to a GNUPLOT plot file.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 29 June 2013
c
c Author:
c
c John Burkardt
c
c Parameters:
c
c Input, integer M, N, the number of rows and columns.
c
c Input, integer C1(M,N), the current state of the system.
c
c Input, character * ( * ) TITLE, a title for the plot.
c
c Input, character * ( * ) PLOT_FILENAME, a name for the GNUPLOT
c command file to be created.
c
c Input, character * ( * ) PNG_FILENAME, the name of the PNG graphics
c file to be created.
c
implicit none
integer m
integer n
integer c1(m,n)
integer i
integer j
character * ( * ) plot_filename
integer plot_unit
character * ( * ) png_filename
double precision ratio
character * ( * ) title
integer x1
integer x2
integer y1
integer y2
call get_unit ( plot_unit )
open ( unit = plot_unit, file = plot_filename,
& status = 'replace' )
ratio = dble ( n ) / dble ( m )
write ( plot_unit, '(a)' ) 'set term png'
write ( plot_unit, '(a)' )
& 'set output "' // trim ( png_filename ) // '"'
write ( plot_unit, '(a,i4,a)' ) 'set xrange [ 0 : ', m, ' ]'
write ( plot_unit, '(a,i4,a)' ) 'set yrange [ 0 : ', n, ' ]'
write ( plot_unit, '(a)' ) 'set nokey'
write ( plot_unit, '(a)' ) 'set title "' // trim ( title ) // '"'
write ( plot_unit, '(a)' ) 'unset tics'
write ( plot_unit, '(a,g14.6)' ) 'set size ratio ', ratio
do j = 1, n
y1 = j - 1
y2 = j
do i = 1, m
x1 = m - i
x2 = m + 1 - i
if ( c1(i,j) .lt. 0 ) then
write ( plot_unit, '(a,i3,a,i3,a,i3,a,i3,a)' )
& 'set object rectangle from ',
& x1, ',', y1, ' to ', x2, ',', y2, ' fc rgb "blue"'
else
write ( plot_unit, '(a,i3,a,i3,a,i3,a,i3,a)' )
& 'set object rectangle from ',
& x1, ',', y1, ' to ', x2, ',', y2, ' fc rgb "red"'
end if
end do
end do
write ( plot_unit, '(a)' ) 'plot 1'
write ( plot_unit, '(a)' ) 'quit'
close ( unit = plot_unit )
write ( *, '(a)' ) ' '
write ( *, '(a)' ) ' Created the gnuplot graphics file "' //
& trim ( plot_filename ) // '".'
return
end
subroutine r8mat_uniform_01 ( m, n, seed, r )
c*********************************************************************72
c
cc R8MAT_UNIFORM_01 returns a unit pseudorandom R8MAT.
c
c Discussion:
c
c An R8MAT is an array of R8's.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 11 August 2004
c
c Author:
c
c John Burkardt
c
c Reference:
c
c Paul Bratley, Bennett Fox, Linus Schrage,
c A Guide to Simulation,
c Springer Verlag, pages 201-202, 1983.
c