forked from HYCOM/HYCOM-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_xc_sm.h
1629 lines (1598 loc) · 41.1 KB
/
mod_xc_sm.h
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
!
!-----------------------------------------------------------------------
!
! auxillary routines that involve off-processor communication.
! shared memory version, contained in module mod_xc.
!
! author: Alan J. Wallcraft, NRL.
!
!-----------------------------------------------------------------------
!
subroutine xcaget(aa, a, mnflg)
implicit none
!
real, intent(out) :: aa(itdm,jtdm)
real, intent(in) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: mnflg
!
!**********
!*
! 1) convert an entire 2-D array from tiled to non-tiled layout.
!
! 3) mnflg selects which nodes must return the array
! = 0; all nodes
! = n; node number n (mnproc=n)
!
! 4) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! aa real output non-tiled target array
! a real input tiled source array
! mnflg integer input node return flag
!*
!**********
!
integer j
#if defined(TIMER)
!
! call xctmr0( 1)
#endif
!
! use xclget for now.
!
do j= 1,jtdm
call xclget(aa(1,j),itdm, a, 1,j,1,0, mnflg)
enddo
#if defined(TIMER)
!
! call xctmr1( 1)
#endif
return
end subroutine xcaget
subroutine xcaput(aa, a, mnflg)
implicit none
!
real, intent(inout) :: aa(itdm,jtdm)
real, intent(out) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: mnflg
!
!**********
!*
! 1) convert an entire 2-D array from non-tiled to tiled layout.
!
! 3) mnflg selects which nodes must contain the non-tiled array
! = 0; all nodes
! = n; node number n (mnproc=n)
!
! 4) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! aa real input non-tiled source array
! a real output tiled target array
! mnflg integer input node source flag
!*
!**********
!
integer j
#if defined(TIMER)
!
! call xctmr0( 4)
#endif
!
! use xclput for now.
!
do j= 1,jtdm
call xclput(aa(1,j),itdm, a, 1,j,1,0)
enddo
#if defined(TIMER)
!
! call xctmr1( 4)
#endif
return
end subroutine xcaput
subroutine xcastr(a, mnflg)
implicit none
!
real, intent(inout) :: a(:)
integer, intent(in) :: mnflg
!
!**********
!*
! 1) broadcast array a to all tiles.
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target array
! mnflg integer input node originator flag
!*
!**********
!
#if defined(TIMER)
!
call xctmr0( 9)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1( 9)
#endif
return
end subroutine xcastr
subroutine xceget(aelem, a, ia,ja, mnflg)
implicit none
!
real, intent(out) :: aelem
real, intent(in) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: ia,ja
integer, intent(in), optional :: mnflg
!
!**********
!*
! 1) find the value of a(ia,ja) on the non-tiled 2-D grid.
!
! 2) mnflg selects which nodes must return the line
! = 0; all nodes (default)
! = n; node number n (mnproc=n)
! mnflg is ignored here (only have a single node).
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! aelem real output required element
! a real input source array
! ia integer input 1st index into a
! ja integer input 2nd index into a
! mnflg integer input node return flag
!*
!**********
#if defined(TIMER)
!
call xctmr0( 2)
#endif
!
! single node version - trivial indexing.
!
aelem = a(ia,ja)
#if defined(TIMER)
!
call xctmr1( 2)
#endif
return
end subroutine xceget
subroutine xceput(aelem, a, ia,ja, mnflg)
implicit none
!
integer, intent(in), optional :: mnflg
integer, intent(in) :: ia,ja
real, intent(in) :: aelem
real, intent(inout) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
!
!**********
!*
! 1) fill a single element in the non-tiled 2-D grid.
!
! 2) mnflg selects which nodes hold the element on entry
! = 0; all nodes (default)
! = n; node number n (mnproc=n)
! mnflg is ignored here (only have a single node).
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! aelem real input element value
! a real in/out target array
! ia integer input 1st index into a
! ja integer input 2nd index into a
! mnflg integer input node source flag
!*
!**********
#if defined(TIMER)
!
call xctmr0( 4)
#endif
!
! single node version - trivial indexing.
!
a(ia,ja) = aelem
#if defined(TIMER)
!
call xctmr1( 4)
#endif
return
end subroutine xceput
subroutine xchalt(cerror)
implicit none
!
character*(*), intent(in) :: cerror
!
!**********
!*
! 1) stop all processes.
!
! 2) only one processes need call this routine, i.e. it is for
! emergency stops. use 'xcstop' for ordinary stops called
! by all processes.
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! cerror char*(*) input error message
!*
!**********
!
! shared memory version, just stop.
!
if (cerror.ne.' ') then
write(lp,*) '**************************************************'
write(lp,*) cerror
write(lp,*) '**************************************************'
call flush(lp)
endif
stop '(xchalt)'
end subroutine xchalt
subroutine xciget(alist,nl, a, ia,ja, mnflg)
implicit none
!
integer, intent(in) :: nl
real, intent(out) :: alist(nl)
real, intent(in) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: ia(nl),ja(nl)
integer, intent(in), optional :: mnflg
!
!**********
!*
! 1) find the value of a(ia(:),ja(:)) on the non-tiled 2-D grid.
!
! 2) mnflg selects which nodes must return the list of elements
! = 0; all nodes (default)
! = n; node number n (mnproc=n)
! mnflg is ignored here (only have a single node).
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! alist real output required elements
! nl integer input dimension of alist
! a real input source array
! ia integer input 1st indexes into a
! ja integer input 2nd indexes into a
! mnflg integer input node return flag
!*
!**********
!
integer i
!
#if defined(TIMER)
!
call xctmr0( 2)
#endif
!
! single node version - trivial indexing.
!
do i= 1,nl
alist(i) = a(ia(i),ja(i))
enddo !i
#if defined(TIMER)
!
call xctmr1( 2)
#endif
return
end subroutine xciget
subroutine xciget_sm(alist,nl, a, ia,ja, mnflg)
implicit none
!
integer, intent(in) :: nl
real, intent(out) :: alist(nl)
real, intent(in) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: ia(nl),ja(nl)
integer, intent(in), optional :: mnflg
!
!**********
!*
! 1) find the value of a(ia(:),ja(:)) on the non-tiled 2-D grid.
! identical to xciget and never invoked (for compatibility only)
!
! 2) mnflg selects which nodes must return the list of elements
! = 0; all nodes (default)
! = n; node number n (mnproc=n)
! mnflg is ignored here (only have a single node).
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! alist real output required elements
! nl integer input dimension of alist
! a real input source array
! ia integer input 1st indexes into a
! ja integer input 2nd indexes into a
! mnflg integer input node return flag
!*
!**********
!
integer i
!
#if defined(TIMER)
!
call xctmr0( 2)
#endif
!
! single node version - trivial indexing.
!
do i= 1,nl
alist(i) = a(ia(i),ja(i))
enddo !i
#if defined(TIMER)
!
call xctmr1( 2)
#endif
return
end subroutine xciget_sm
subroutine xciput(alist,nl, a, ia,ja, mnflg)
implicit none
!
integer, intent(in) :: nl
integer, intent(in), optional :: mnflg
integer, intent(in) :: ia(nl),ja(nl)
real, intent(inout) :: alist(nl)
real, intent(inout) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
!
!**********
!*
! 1) fill a list of elements in the non-tiled 2-D grid.
!
! 2) mnflg selects which nodes hold the elements on entry
! = 0; all nodes (default)
! = n; node number n (mnproc=n)
! mnflg is ignored here (only have a single node).
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! alist real in/out element values
! nl integer input dimension of alist
! a real in/out target array
! ia integer input 1st indexes into a
! ja integer input 2nd indexes into a
! mnflg integer input node source flag
!*
!**********
!
integer i
#if defined(TIMER)
!
call xctmr0( 4)
#endif
!
! single node version - trivial indexing.
!
do i= 1,nl
a(ia(i),ja(i)) = alist(i)
enddo !1
#if defined(TIMER)
!
call xctmr1( 4)
#endif
return
end subroutine xciput
subroutine xclget(aline,nl, a, i1,j1,iinc,jinc, mnflg)
implicit none
!
integer, intent(in) :: nl,i1,j1,iinc,jinc,mnflg
real, intent(out) :: aline(nl)
real, intent(in) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
!
!**********
!*
! 1) extract a line of elements from the non-tiled 2-D grid.
!
! 2) aline(i) = a(i1+iinc*(i-1),j1+jinc*(i-1)), for i=1...nl.
! iinc and jinc can each be -1, 0, or +1.
!
! if jinc=0, j1 can be between jtdm+1 and jtdm+nbdy to return
! values from the top halo. This is for debugging the arctic
! patch halo exchange only.
!
! 3) mnflg selects which nodes must return the line
! =-n; node number n (mnproc=n), nl,i1,j1 only on node n
! = 0; all nodes
! = n; node number n (mnproc=n)
! normally all integer arguments must be identical on all nodes,
! but a negative mnflg indicates that only the target node is
! providing the nl,i1,j1 values. These are broadcast to all other
! nodes, and returned in nl,i1,j1 by all of them.
!
! mnflg is ignored here (only have a single node).
!
! 4) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! aline real output required line of elements
! nl integer in/out dimension of aline
! a real input source array
! i1 integer in/out 1st index into a
! j1 integer in/out 2nd index into a
! iinc integer input 1st index increment
! jinc integer input 2nd index increment
! mnflg integer input node return flag
!
! nl,i1,j1 are input only unless mnflg is negative.
!*
!**********
!
integer i
#if defined(TIMER)
!
call xctmr0( 3)
#endif
!
! single node version - trivial indexing and no error checking.
!
if (jinc.eq.0) then
do i= 1,nl
aline(i) = a(i1+iinc*(i-1),j1)
enddo
elseif (iinc.eq.0) then
do i= 1,nl
aline(i) = a(i1,j1+jinc*(i-1))
enddo
else
do i= 1,nl
aline(i) = a(i1+iinc*(i-1),j1+jinc*(i-1))
enddo
endif
#if defined(TIMER)
!
call xctmr1( 3)
#endif
return
end subroutine xclget
subroutine xclput(aline,nl, a, i1,j1,iinc,jinc, mnflg)
implicit none
!
integer, intent(in), optional :: mnflg
integer, intent(in) :: nl,i1,j1,iinc,jinc
real, intent(inout) :: aline(nl)
real, intent(inout) :: a(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
!
!**********
!*
! 1) fill a line of elements in the non-tiled 2-D grid.
!
! 2) aline(i) = a(i1+i1*(i-1),j1+j1*(i-1)), for i=1...nl.
! one of iinc and jinc must be 0, and the other must be 1.
!
! 3) mnflg selects which nodes hold the line on entry
! = 0; all nodes (default)
! = n; node number n (mnproc=n)
! mnflg is ignored here (only have a single node).
!
! 4) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! aline real in/out line of element values
! nl integer input dimension of aline
! a real in/out target array
! i1 integer input 1st index into a
! j1 integer input 2nd index into a
! iinc integer input 1st index increment
! jinc integer input 2nd index increment
! mnflg integer input node source flag
!*
!**********
!
integer i
#if defined(TIMER)
!
call xctmr0( 4)
#endif
!
! single node version - trivial indexing.
!
if (jinc.eq.0) then
do i= 1,nl
a(i1+i-1,j1) = aline(i)
enddo
elseif (iinc.eq.0) then
do i= 1,nl
a(i1,j1+i-1) = aline(i)
enddo
endif
#if defined(TIMER)
!
call xctmr1( 4)
#endif
return
end subroutine xclput
subroutine xcmaxr_0(a, mnflg)
implicit none
!
real, intent(inout) :: a
integer, intent(in) :: mnflg
!
!**********
!*
! 1) replace scalar a with its element-wise maximum over all tiles.
!
! 2) mnflg selects which nodes must return the minimum
! = 0; all nodes
! = n; node number n (mnproc=n)
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target variable
! mnflg integer input node return flag
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcmaxr_0
subroutine xcmaxr_1(a, mnflg)
implicit none
!
real, intent(inout) :: a(:)
integer, intent(in) :: mnflg
!
!**********
!*
! 1) replace array a with its element-wise maximum over all tiles.
!
! 2) mnflg selects which nodes must return the minimum
! = 0; all nodes
! = n; node number n (mnproc=n)
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target array
! mnflg integer input node return flag
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcmaxr_1
subroutine xcmaxr_0o(a)
implicit none
!
real, intent(inout) :: a
!
!**********
!*
! 1) replace scalar a with its element-wise maximum over all tiles.
!
! 2) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target variable
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcmaxr_0o
subroutine xcmaxr_1o(a)
implicit none
!
real, intent(inout) :: a(:)
!
!**********
!*
! 1) replace array a with its element-wise maximum over all tiles.
!
! 2) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target array
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcmaxr_1o
subroutine xcminr_0(a, mnflg)
implicit none
!
real, intent(inout) :: a
integer, intent(in) :: mnflg
!
!**********
!*
! 1) replace scalar a with its element-wise minimum over all tiles.
!
! 2) mnflg selects which nodes must return the minimum
! = 0; all nodes
! = n; node number n (mnproc=n)
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target variable
! mnflg integer input node return flag
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcminr_0
subroutine xcminr_1(a, mnflg)
implicit none
!
real, intent(inout) :: a(:)
integer, intent(in) :: mnflg
!
!**********
!*
! 1) replace array a with its element-wise minimum over all tiles.
!
! 2) mnflg selects which nodes must return the minimum
! = 0; all nodes
! = n; node number n (mnproc=n)
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target array
! mnflg integer input node return flag
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcminr_1
subroutine xcminr_0o(a)
implicit none
!
real, intent(inout) :: a
!
!**********
!*
! 1) replace scalar a with its element-wise minimum over all tiles.
!
! 2) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target variable
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcminr_0o
subroutine xcminr_1o(a)
implicit none
!
real, intent(inout) :: a(:)
!
!**********
!*
! 1) replace array a with its element-wise minimum over all tiles.
!
! 2) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! a real in/out target array
!*
!**********
!
#if defined(TIMER)
!
call xctmr0(10)
#endif
!
! single node version - do nothing.
#if defined(TIMER)
!
call xctmr1(10)
#endif
return
end subroutine xcminr_1o
subroutine xcspmd
implicit none
!
!**********
!*
! 1) initialize data structures that identify the tiles.
!
! 2) data structures:
! ipr - 1st 2-D node dimension
! jpr - 2nd 2-D node dimension
! ijpr - 1-D node dimension (ipr*jpr)
! mproc - 1st 2-D node index
! nproc - 2nd 2-D node index
! mnproc - 1-D node index
! i0 - 1st dimension tile offset
! ii - 1st dimension tile extent
! j0 - 2nd dimension tile offset
! jj - 2nd dimension tile extent
! nreg - region type
! vland - fill value for land (standard value 0.0)
!
! 3) ipr,jpr,ijpr are global (tile independent) values.
! all other values depend on the processor number,
! but in this case there is only one processor.
!*
!**********
!
! shared memory version, mproc=nproc=1.
!
if (iqr.ne.1 .or. jqr.ne.1 .or. ijqr.ne.1) then
call xcstop('Error in xcspmd: must have iqr=jqr=ijqr=1')
stop '(xcspmd)'
endif
!
lp = 6
!
ipr = 1
jpr = 1
ijpr = 1
mnproc = 1
mproc = 1
nproc = 1
!
#if defined(RELO)
! --- region's horizontal dimensions are from blkdat.input.
!
itdm = -1
jtdm = -1
#endif
!
i0 = 0
ii = itdm
j0 = 0
jj = jtdm
!
nreg = -1 ! unknown region type
!
vland = 0.0
vland4 = 0.0
!
! initialize timers.
!
call xctmri
#if defined(TIMER)
call xctmrn( 1,'xcaget')
call xctmrn( 2,'xceget')
call xctmrn( 3,'xclget')
call xctmrn( 4,'xcXput')
call xctmrn( 5,'xcsum ')
call xctmrn( 6,'xcrang')
call xctmrn( 9,'xcastr')
call xctmrn(10,'xcmaxr')
call xctmrn(12,'xctilr')
#if defined(ARCTIC)
call xctmrn(13,'xctila')
#endif
#endif
return
end subroutine xcspmd
subroutine xcstop(cerror)
implicit none
!
character*(*), intent(in) :: cerror
!
!**********
!*
! 1) stop all processes.
!
! 2) all processes must call this routine.
! use 'xchalt' for emergency stops.
!
! 3) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! cerror char*(*) input error message
!*
!**********
!
! print active timers.
!
call xctmrp
!
! shared memory version, just stop.
!
if (cerror.ne.' ') then
write(lp,*) '**************************************************'
write(lp,*) cerror
write(lp,*) '**************************************************'
call flush(lp)
endif
#if defined(STOP2003)
! --- Fortran 2003 STOP outputs many lines, replace with exit
call exit(0)
#else
stop '(xcstop)'
#endif
end subroutine xcstop
subroutine xcsum(sum, a,mask)
implicit none
!
real*8, intent(out) :: sum
real, intent(inout) :: a( 1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: mask(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
!
!**********
!*
! 1) sum a 2-d array, where mask==1
!
! 2) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! sum real*8 output sum of a
! a real input source array
! mask integer input mask array
!
! 3) sum is bit for bit reproducable for the same halo size, nbdy.
!*
!**********
!
real*8 zero8
parameter (zero8=0.0)
!
real*8 sum8,sum8p,sum8j(jdm)
integer i,i1,j
#if defined(TIMER)
!
call xctmr0( 5)
#endif
!
! row sums in 2*nbdy+1 wide strips.
!
!$OMP PARALLEL DO PRIVATE(j,i1,i,sum8,sum8p) &
!$OMP SCHEDULE(STATIC,jblk)
do j=1,jdm
sum8 = zero8
do i1=1,idm,2*nbdy+1
sum8p = zero8
do i= i1,min(i1+2*nbdy,idm)
if (mask(i,j).eq.1) then
sum8p = sum8p + a(i,j)
endif
enddo
sum8 = sum8 + sum8p
enddo
sum8j(j) = sum8 ! use of sum8 minimizes false sharing of sum8j
enddo
!$OMP END PARALLEL DO
!
! serial sum of rwo-sum loop.
!
sum8 = sum8j(1)
do j=2,jdm
sum8 = sum8 + sum8j(j)
enddo
sum = sum8
#if defined(TIMER)
!
call xctmr1( 5)
#endif
return
end subroutine xcsum
subroutine xcsumj(sumj, a,mask)
implicit none
!
real*8, intent(out) :: sumj(jtdm)
real, intent(inout) :: a( 1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
integer, intent(in) :: mask(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy)
!
!**********
!*
! 1) rwo-sum of a 2-d array, where mask==1, on first processor only
!
! 2) parameters:
! name type usage description
! ---------- ---------- ------- ----------------------------
! sumj real*8 output row-sum of a
! a real input source array
! mask integer input mask array
!
! 3) sum is bit for bit reproducable for the same halo size, nbdy.
!*
!**********
!
real*8 zero8
parameter (zero8=0.0)
!
real*8 sum8,sum8p
integer i,i1,j
#if defined(TIMER)
!
call xctmr0( 5)
#endif
!
! row sums in 2*nbdy+1 wide strips.
!
!$OMP PARALLEL DO PRIVATE(j,i1,i,sum8,sum8p) &
!$OMP SCHEDULE(STATIC,jblk)
do j=1,jdm
sum8 = zero8
do i1=1,idm,2*nbdy+1
sum8p = zero8
do i= i1,min(i1+2*nbdy,idm)
if (mask(i,j).eq.1) then