-
Notifications
You must be signed in to change notification settings - Fork 0
/
swanparll.ftn
5798 lines (5542 loc) · 197 KB
/
swanparll.ftn
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
!
! SWAN - routines for distributed-memory approach based on MPI
!
! Contents of this file
!
! SWINITMPI
! SWEXITMPI
! SWSYNC
! SWSENDNB
! SWRECVNB
! SWBROADC
! SWGATHER
! SWREDUCE
! SWREDUCI
! SWREDUCR
! SWSTRIP
!JAC! SWORB
! SWPARTIT
! SWBLADM
! SWDECOMP
! SWEXCHG
!WFR! SWRECVAC
!WFR! SWSENDAC
! SWCOLLECT
! SWCOLOUT
! SWCOLTAB
! SWCOLSPC
! SWCOLBLK
!JAC! SWBLKCOL
!
!****************************************************************
!
SUBROUTINE SWINITMPI
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
USE M_PARALL 40.31
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!COH! 41.61: Homayoon Komijani
!
! 1. Updates
!
! 40.30, Jan. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!COH! 41.61, Aug. 14: coupling with COHERENS
!
! 2. Purpose
!
! Join parallel application
!
! 3. Method
!
! Start MPI and initialize some variables
!
! 4. Argument variables
!
! ---
!
! 5. Parameter variables
!
! ---
!
! 6. Local variables
!
! CHARS : array to pass character info to MSGERR
! IERR : error value of MPI call
! IF1 : first non-character in string1
! IF2 : first non-character in string2
! IL1 : last non-character in string1
! IL2 : last non-character in string2
! MSGSTR: string to pass message to call MSGERR
!
INTEGER IERR, IF1, IF2, IL1, IL2
CHARACTER*20 INTSTR, CHARS(2)
CHARACTER*80 MSGSTR
!
! 8. Subroutines used
!
! INTSTR Converts integer to string
!MPI! MPI_COMM_RANK Get rank of processes in MPI communication context
!MPI! MPI_COMM_SIZE Get number of processes in MPI communication context
!MPI! MPI_INIT Enroll in MPI
! MSGERR Writes error message
! TXPBLA Removes leading and trailing blanks in string
!
! 9. Subroutines calling
!
! Main program SWAN
!
! 10. Error messages
!
! ---
!
! 12. Structure
!
! Start MPI and initialize some common variables in module M_PARALL
!
! 13. Source text
!
LEVERR = 0
MAXERR = 1
ITRACE = 0
!MPI! --- enroll in MPI
!MPI
!MPI!NCOH CALL MPI_INIT ( IERR )
!MPI!COH IERR = MPI_SUCCESS 41.61
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS(1) = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS(1),IF1,IL1)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(1)(IF1:IL1)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
! --- initialize common variables
INODE = 0
NPROC = 1
!MPI! --- get node number INODE
!MPI
!MPI!NCOH CALL MPI_COMM_RANK ( MPI_COMM_WORLD, INODE, IERR )
!MPI!COH CALL MPI_COMM_RANK ( COMM, INODE, IERR )
INODE = INODE + 1
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS(1) = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS(1),IF1,IL1)
!MPI CHARS(2) = INTSTR(INODE)
!MPI CALL TXPBLA(CHARS(2),IF2,IL2)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(1)(IF1:IL1)//
!MPI & ' and node number is '//CHARS(2)(IF2:IL2)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
!MPI
!MPI! --- determine total number of processes
!MPI
!MPI!NCOH CALL MPI_COMM_SIZE ( MPI_COMM_WORLD, NPROC, IERR )
!MPI!COH CALL MPI_COMM_SIZE ( COMM, NPROC, IERR )
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS(1) = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS(1),IF1,IL1)
!MPI CHARS(2) = INTSTR(INODE)
!MPI CALL TXPBLA(CHARS(2),IF2,IL2)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(1)(IF1:IL1)//
!MPI & ' and node number is '//CHARS(2)(IF2:IL2)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
! --- determine whether this is a parallel run or not
IF ( NPROC.GT.1 ) THEN
PARLL = .TRUE.
ELSE
PARLL = .FALSE.
END IF
! --- am I master?
IAMMASTER = INODE.EQ.MASTER
!MPI! --- define MPI constants for communication within SWAN
!MPI
!MPI SWCHAR = MPI_CHARACTER
!MPI SWINT = MPI_INTEGER
!MPI SWREAL = MPI_REAL
!MPI SWMAX = MPI_MAX
!MPI SWMIN = MPI_MIN
!MPI SWSUM = MPI_SUM
RETURN
END
!****************************************************************
!
SUBROUTINE SWEXITMPI
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
!COH USE M_PARALL, ONLY: COMM 41.61
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!COH! 41.61: Homayoon Komijani
!
! 1. Updates
!
! 40.30, Jan. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!COH! 41.61, Aug. 14: coupling with COHERENS
!
! 2. Purpose
!
! Exit parallel application
!
! 3. Method
!
! Wrapper for MPI_FINALIZE
!
! 4. Argument variables
!
! ---
!
! 6. Local variables
!
! IERR : error value of MPI call
! PARALMPI: if true, parallel process is carried out with MPI
!
INTEGER IERR
LOGICAL PARALMPI
!
! 8. Subroutines used
!
!MPI! MPI_ABORT Abort MPI if severe error occurs
!MPI! MPI_BARRIER Blocks until all nodes have called this routine
!MPI! MPI_INITIALIZED Indicates whether MPI_Init has been called
!MPI! MPI_FINALIZE Cleans up the MPI state and exits
!
! 9. Subroutines calling
!
! Main program SWAN
!
! 10. Error messages
!
! ---
!
! 12. Structure
!
!MPI! if MPI has been initialized
!MPI! synchronize nodes
!MPI! if severe error
!MPI! abort MPI
!MPI! else
!MPI! close MPI
!MPI!
! 13. Source text
!
!MPI CALL MPI_INITIALIZED ( PARALMPI, IERR )
!MPI IF ( PARALMPI ) THEN
!MPI
!MPI!NCOH CALL MPI_BARRIER ( MPI_COMM_WORLD, IERR )
!MPI!COH CALL MPI_BARRIER ( COMM, IERR )
!MPI
!MPI IF ( LEVERR.GE.4 ) THEN
!MPI
!MPI! --- in case of a severe error abort all MPI processes
!MPI
!MPI!NCOH CALL MPI_ABORT ( MPI_COMM_WORLD, LEVERR, IERR )
!MPI!COH CALL MPI_ABORT ( COMM, LEVERR, IERR )
!MPI
!MPI ELSE
!MPI
!MPI! --- otherwise stop MPI operations on this computer
!MPI
!MPI!NCOH CALL MPI_FINALIZE ( IERR )
!MPI
!MPI END IF
!MPI
!MPI END IF
!MPI
RETURN
END
!****************************************************************
!
SUBROUTINE SWSYNC
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
USE M_PARALL 40.31
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 40.30, Jan. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose
!
! Synchronize nodes
!
! 3. Method
!
! Wrapper for MPI_BARRIER
!
! 4. Argument variables
!
! ---
!
! 5. Parameter variables
!
! ---
!
! 6. Local variables
!
! CHARS : array to pass character info to MSGERR
! IENT : number of entries
! IERR : error value of MPI call
! IF1 : first non-character in string1
! IF2 : first non-character in string2
! IL1 : last non-character in string1
! IL2 : last non-character in string2
! MSGSTR: string to pass message to call MSGERR
!
INTEGER IENT, IERR, IF1, IF2, IL1, IL2
CHARACTER*20 INTSTR, CHARS(2)
CHARACTER*80 MSGSTR
!
! 8. Subroutines used
!
! INTSTR Converts integer to string
!MPI! MPI_BARRIER Blocks until all nodes have called this routine
! MSGERR Writes error message
! STRACE Tracing routine for debugging
! TXPBLA Removes leading and trailing blanks in string
!
! 9. Subroutines calling
!
! SWMAIN
!
! 10. Error messages
!
! ---
!
! 12. Structure
!
! Blocks until all nodes have called MPI_BARRIER routine.
! In this way, all nodes are synchronized
!
! 13. Source text
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'SWSYNC')
!MPI! --- blocks until all nodes have called this routine
!MPI
!MPI!NCOH CALL MPI_BARRIER ( MPI_COMM_WORLD, IERR )
!MPI!COH CALL MPI_BARRIER ( COMM, IERR )
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS(1) = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS(1),IF1,IL1)
!MPI CHARS(2) = INTSTR(INODE)
!MPI CALL TXPBLA(CHARS(2),IF2,IL2)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(1)(IF1:IL1)//
!MPI & ' and node number is '//CHARS(2)(IF2:IL2)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
RETURN
END
!****************************************************************
!
SUBROUTINE SWSENDNB ( IPTR, ILEN, ITYPE, IDEST, ITAG )
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
USE M_PARALL 40.31
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 40.30, Feb. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose
!
! Data is sent to a neighbour
!
! 3. Method
!
! Wrapper for MPI_SEND
!
! 4. Argument variables
!
! IDEST rank of the destination process
! ILEN length of array to be sent
! IPTR pointer to first element of array to be sent
! ITAG message type
! ITYPE type of data
!
INTEGER IPTR, ILEN, ITYPE, IDEST, ITAG
!
! 5. Parameter variables
!
! ---
!
! 6. Local variables
!
! CHARS : array to pass character info to MSGERR
! IENT : number of entries
! IERR : error value of MPI call
! IF1 : first non-character in string1
! IF2 : first non-character in string2
! IL1 : last non-character in string1
! IL2 : last non-character in string2
! MSGSTR: string to pass message to call MSGERR
!
INTEGER IENT, IERR, IF1, IF2, IL1, IL2
CHARACTER*20 INTSTR, CHARS(2)
CHARACTER*80 MSGSTR
!
! 8. Subroutines used
!
! INTSTR Converts integer to string
!MPI! MPI_SEND Immediately sends the data in the active
!MPI! MPI message buffer
! MSGERR Writes error message
! STRACE Tracing routine for debugging
! TXPBLA Removes leading and trailing blanks in string
!
! 9. Subroutines calling
!
! SWEXCHG
!
! 10. Error messages
!
! ---
!
! 12. Structure
!
!MPI! Data is sent to a neighbour with command MPI_SEND
!
! 13. Source text
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'SWSENDNB')
! --- if not parallel, return
IF (.NOT.PARLL) RETURN
!MPI!NCOH CALL MPI_SEND ( IPTR, ILEN, ITYPE, IDEST-1,
!MPI!NCOH & ITAG, MPI_COMM_WORLD, IERR )
!MPI!COH CALL MPI_SEND ( IPTR, ILEN, ITYPE, IDEST-1,
!MPI!COH & ITAG, COMM, IERR )
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS(1) = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS(1),IF1,IL1)
!MPI CHARS(2) = INTSTR(INODE)
!MPI CALL TXPBLA(CHARS(2),IF2,IL2)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(1)(IF1:IL1)//
!MPI & ' and node number is '//CHARS(2)(IF2:IL2)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
RETURN
END
!****************************************************************
!
SUBROUTINE SWRECVNB ( IPTR, ILEN, ITYPE, ISOURCE, ITAG )
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
USE M_PARALL 40.31
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 40.30, Feb. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose
!
! Data is received from a neighbour
!
! 3. Method
!
! Wrapper for MPI_RECV
!
! 4. Argument variables
!
! ILEN length of array to be received
! IPTR pointer to first element of array to be received
! ISOURCE rank of the source process
! ITAG message type
! ITYPE type of data
!
INTEGER IPTR, ILEN, ITYPE, ISOURCE, ITAG
!
! 5. Parameter variables
!
! ---
!
! 6. Local variables
!
! CHARS : array to pass character info to MSGERR
! IENT : number of entries
! IERR : error value of MPI call
! IF1 : first non-character in string1
! IF2 : first non-character in string2
! IL1 : last non-character in string1
! IL2 : last non-character in string2
!MPI! ISTAT : MPI status array
! MSGSTR: string to pass message to call MSGERR
!
INTEGER IENT, IERR, IF1, IF2, IL1, IL2
!MPI INTEGER ISTAT(MPI_STATUS_SIZE)
CHARACTER*20 INTSTR, CHARS(2)
CHARACTER*80 MSGSTR
!
! 8. Subroutines used
!
! INTSTR Converts integer to string
!MPI! MPI_RECV Immediately receives the data in the active
!MPI! MPI message buffer
! MSGERR Writes error message
! STRACE Tracing routine for debugging
! TXPBLA Removes leading and trailing blanks in string
!
! 9. Subroutines calling
!
! SWEXCHG
!
! 10. Error messages
!
! ---
!
! 11. Remarks
!
! ---
!
! 12. Structure
!
!MPI! Data is received from a neighbour with command MPI_RECV
!
! 13. Source text
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'SWRECVNB')
! --- if not parallel, return
IF (.NOT.PARLL) RETURN
!MPI!NCOH CALL MPI_RECV ( IPTR, ILEN, ITYPE, ISOURCE-1, ITAG,
!MPI!NCOH & MPI_COMM_WORLD, ISTAT, IERR )
!MPI!COH CALL MPI_RECV ( IPTR, ILEN, ITYPE, ISOURCE-1, ITAG,
!MPI!COH & COMM, ISTAT, IERR )
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS(1) = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS(1),IF1,IL1)
!MPI CHARS(2) = INTSTR(INODE)
!MPI CALL TXPBLA(CHARS(2),IF2,IL2)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(1)(IF1:IL1)//
!MPI & ' and node number is '//CHARS(2)(IF2:IL2)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
RETURN
END
!****************************************************************
!
SUBROUTINE SWBROADC ( IPTR, ILEN, ITYPE )
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
USE M_PARALL 40.31
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 40.30, Feb. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose
!
! Broadcasts data from the master to all other processes
!
! 3. Method
!
! Wrapper for MPI_BCAST
!
! 4. Argument variables
!
! ILEN length of array to be sent
! IPTR pointer to first element of array to be sent
! ITYPE type of data
!
INTEGER IPTR, ILEN, ITYPE
!
! 5. Parameter variables
!
! ---
!
! 6. Local variables
!
! CHARS : character for passing info to MSGERR
! IENT : number of entries
! IERR : error value of MPI call
! IF : first non-character in string
! IL : last non-character in string
! MSGSTR: string to pass message to call MSGERR
!
INTEGER IENT, IERR, IF, IL
CHARACTER*20 INTSTR, CHARS
CHARACTER*80 MSGSTR
!
! 8. Subroutines used
!
! INTSTR Converts integer to string
!MPI! MPI_BCAST Broadcasts a message from the master
!MPI! to all other processes of the group
! MSGERR Writes error message
! STRACE Tracing routine for debugging
!TIMG! SWTSTA Start timing for a section of code
!TIMG! SWTSTO Stop timing for a section of code
! TXPBLA Removes leading and trailing blanks in string
!
! 9. Subroutines calling
!
! SNEXTI
! FLFILE
!
! 10. Error messages
!
! ---
!
! 12. Structure
!
!MPI! Broadcasts data from the master to all other nodes
!MPI! with command MPI_BCAST
!
! 13. Source text
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'SWBROADC')
! --- if not parallel, return
IF (.NOT.PARLL) RETURN
!TIMG CALL SWTSTA(201)
!MPI!NCOH CALL MPI_BCAST ( IPTR, ILEN, ITYPE, MASTER-1,
!MPI!NCOH & MPI_COMM_WORLD, IERR )
!MPI!COH CALL MPI_BCAST ( IPTR, ILEN, ITYPE, MASTER-1,
!MPI!COH & COMM, IERR )
!MPI IF ( IERR.NE.MPI_SUCCESS ) THEN
!MPI CHARS = INTSTR(IERR)
!MPI CALL TXPBLA(CHARS,IF,IL)
!MPI MSGSTR = 'MPI produces some internal error - '//
!MPI & 'return code is '//CHARS(IF:IL)
!MPI CALL MSGERR ( 4, MSGSTR )
!MPI RETURN
!MPI END IF
!TIMG CALL SWTSTO(201)
RETURN
END
!****************************************************************
!
SUBROUTINE SWGATHER ( IOPTR, IOLEN, IIPTR, IILEN, ITYPE )
!
!****************************************************************
!
!MPI USE MPI
USE OCPCOMM4 40.41
USE M_PARALL 40.31
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmer: Marcel Zijlema |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 40.30, Feb. 03: New subroutine
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose
!
! Gathers different amounts of data from each processor
! to the master
!
! 3. Method
!
! Wrapper for MPI_GATHERV
!
! 4. Argument variables
!
! IILEN length of input array
! IIPTR pointer to first element of input array (local)
! IOLEN length of output array
! IOPTR pointer to first element of output array (global)
! ITYPE type of data
!
INTEGER IILEN, IIPTR, IOLEN, IOPTR, ITYPE
!
! 5. Parameter variables
!
! ---
!
! 6. Local variables
!
! CHARS : character for passing info to MSGERR
! I : loop counter
! ICOUNT: array specifying array size of data received
! from each processor
! IDSPLC: array specifying the starting address of the
! incoming data from each processor, relative
! to the global array
! IENT : number of entries
! IERR : error value of MPI call
! IF : first non-character in string
! IL : last non-character in string
! MSGSTR: string to pass message to call MSGERR
!
INTEGER I, IENT, IERR, IF, IL
INTEGER, ALLOCATABLE :: ICOUNT(:), IDSPLC(:)
CHARACTER*20 INTSTR, CHARS
CHARACTER*80 MSGSTR
!
! 8. Subroutines used
!
! INTSTR Converts integer to string
!MPI! MPI_GATHER Gathers data from all nodes to the master
!MPI! MPI_GATHERV Gathers different amounts of data from
!MPI! all nodes to the master
! MSGERR Writes error message
! STRACE Tracing routine for debugging
! TXPBLA Removes leading and trailing blanks in string
!
! 9. Subroutines calling
!
! 10. Error messages
!
! ---
!
! 12. Structure
!
! if not parallel, return
!
!MPI! gather the array sizes to the master
!MPI!
! check whether enough space has been allocated
! for gathered data
!
! calculate starting address of each local array
! with respect to the global array
!
!MPI! gather different amounts of data from each processor
!MPI! to the master
!MPI!
! 13. Source text
!
SAVE IENT
DATA IENT/0/