-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_za_mp.h+98
executable file
·1433 lines (1416 loc) · 39.5 KB
/
mod_za_mp.h+98
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
#if defined(NOMPIR8) /* LAM does not support mpi_real[48] */
# define MTYPE4 mpi_real
#else /* most MPI's allow mpi_real[48] */
# define MTYPE4 mpi_real4
#endif
c
c-----------------------------------------------------------------------
c
c machine dependent I/O routines.
c MPI-2 I/O version, with I/O from first processor in each row.
c contained in module mod_za.
c
c author: Alan J. Wallcraft, NRL.
c
c-----------------------------------------------------------------------
c
subroutine zagetc(cline,ios, iunit)
implicit none
c
character*80, intent(out) :: cline
integer, intent(out) :: ios
integer, intent(in) :: iunit
c
c**********
c*
c 1) machine specific routine for reading one text line from a file.
c
c 2) The read is performed on the first processor only.
c*
c**********
c
integer iline,ibuf
common/czgetc/ iline(81,0:1),ibuf
save /czgetc/
c
integer i
c
c --- I/O from first processor only
c
ibuf = mod(ibuf+1,2) !initialized in zaiost
c
if (mnproc.eq.1) then
read(iunit,'(a)',iostat=ios) cline
do i= 1,80
iline(i,ibuf) = ichar(cline(i:i))
enddo
iline(81,ibuf) = ios
endif
c
c broadcast to all other processors
c
call xcgetc(iline(:,ibuf))
do i= 1,80
cline(i:i) = char(iline(i,ibuf))
enddo
ios = iline(81,ibuf) ! iostat value
return
end subroutine zagetc
subroutine zaiopn(cstat, iaunit)
implicit none
c
integer, intent(in) :: iaunit
character*(*), intent(in) :: cstat
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for opening a file for array i/o.
c
c must call zaiost before first call to zaiopn.
c see also 'zaiope' and 'zaiopf'.
c
c 2) the filename is taken from the environment variable FORxxxA,
c where xxx = iaunit, with default fort.xxxa.
c
c array i/o is mpi-2 i/o.
c
c 3) iaunit+uaoff is the i/o unit used for arrays. array i/o might not
c use fortran i/o units, but, for compatability, assume that
c iaunit+uaoff refers to a fortran i/o unit anyway.
c cstat indicates the file type, it can be 'scratch', 'old', or
c 'new'.
c all i/o to iaunit must be performed by zaiord and zaiowr.
c the file should be closed using zaiocl.
c*
c**********
c
c --- spval = data void marker, 2^100 or about 1.2676506e30
c --- n2drec = size of output 2-d array, multiple of 4096
real*4 spval
parameter (spval=2.0**100)
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
c
integer(kind=mpi_offset_kind) disp
integer iamode,iahint
character cfile*256,cenv*7
#if defined(TIMER)
c
call xctmr0(16)
#endif
c
c test file state.
c
if (iarec(iaunit).ne.-1) then
write(lp,9000) iaunit
call xcstop('(zaiopn)')
stop '(zaiopn)'
endif
c
iarec(iaunit) = 0
c
c --- I/O from first processor in each row.
c
if (mproc.eq.mp_1st) then
*
* if (mnproc.eq.1) then
* write(lp,*) 'zaiopn - iaunit = ',iaunit
* call flush(lp)
* endif
c
c get filename.
c
write(cenv,"('FOR',i3.3,'A')") iaunit
cfile = ' '
call getenv(cenv,cfile)
if (cfile.eq.' ') then
write(cfile,"('fort.',i3.3,'a')") iaunit
endif
c
c open file.
c
if (cstat.eq.'OLD' .or.
& cstat.eq.'old' ) then
iamode = MPI_MODE_RDONLY +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiord !see zaiost
file_count_zaiord = file_count_zaiord + 1
elseif (cstat.eq.'NEW' .or.
& cstat.eq.'new' ) then
iamode = MPI_MODE_WRONLY +
& MPI_MODE_CREATE +
& MPI_MODE_EXCL +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiowr !see zaiost
file_count_zaiowr = file_count_zaiowr + 1
else !scratch file
iamode = MPI_MODE_RDWR +
& MPI_MODE_DELETE_ON_CLOSE +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiowr !see zaiost
file_count_zaiowr = file_count_zaiowr + 1
endif
call mpi_file_open(group_1st_in_row,
& trim(cfile),
& iamode,
& iahint,
& iahand(iaunit),
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iaunit
write(lp,*) 'mpi_file_open - mpierr = ',mpierr
call flush(lp)
call xchalt('(zaiopn)')
stop '(zaiopn)'
endif !mpierr
disp = 0
call mpi_file_set_view(iahand(iaunit),
& disp,
& MTYPE4,
& MTYPE4,
& "native", !1st convert to big-endian if necessary
& iahint,
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iaunit
write(lp,*) 'mpi_file_set_view - mpierr = ',mpierr
call flush(lp)
call xchalt('(zaiopn)')
stop '(zaiopn)'
endif !mpierr
c
endif ! I/O from first processor in each row
call xcsync(no_flush)
#if defined(TIMER)
c
call xctmr1(16)
#endif
return
c
9000 format(/ /10x,'error in zaiopn - array I/O unit ',
& i3,' is not marked as available.'/ /)
9100 format(/ /10x,'error in zaiopn - can''t open unit ',i3,
& ', for array I/O.'/ /)
end subroutine zaiopn
subroutine zaiope(cenv,cstat, iaunit)
implicit none
c
integer, intent(in) :: iaunit
character*(*), intent(in) :: cenv,cstat
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for opening a file for array i/o.
c
c must call zaiost before first call to zaiope.
c see also 'zaiopn' and 'zaiopf'.
c
c 2) the filename is taken from environment variable 'cenv'.
c
c array i/o is mpi-2 i/o.
c
c 3) iaunit+uaoff is the i/o unit used for arrays. array i/o might not
c use fortran i/o units, but, for compatability, assume that
c iaunit+uaoff refers to a fortran i/o unit anyway.
c cstat indicates the file type, it can be 'scratch', 'old', or
c 'new'.
c all i/o to iaunit must be performed by zaiord and zaiowr.
c arrays passed to these routines must conform to 'h'.
c the file should be closed using zaiocl.
c*
c**********
c
c --- spval = data void marker, 2^100 or about 1.2676506e30
c --- n2drec = size of output 2-d array, multiple of 4096
real*4 spval
parameter (spval=2.0**100)
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
c
integer(kind=mpi_offset_kind) disp
integer iamode,iahint
character cfile*256
c
#if defined(TIMER)
c
call xctmr0(16)
#endif
c
c test file state.
c
if (iarec(iaunit).ne.-1) then
write(lp,9000) iaunit
call xcstop('(zaiope)')
stop '(zaiope)'
endif
c
iarec(iaunit) = 0
c
c --- I/O from first processor in each row.
c
if (mproc.eq.mp_1st) then
*
* if (mnproc.eq.1) then
* write(lp,*) 'zaiope - iaunit = ',iaunit
* call flush(lp)
* endif
c
c get filename.
c
cfile = ' '
call getenv(cenv,cfile)
if (cfile.eq.' ') then
write(lp,9300) trim(cenv)
write(lp,*) 'iaunit = ',iaunit
call flush(lp)
call xchalt('(zaiope)')
stop '(zaiope)'
endif
c
c open file.
c
if (cstat.eq.'OLD' .or.
& cstat.eq.'old' ) then
iamode = MPI_MODE_RDONLY +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiord !see zaiost
file_count_zaiord = file_count_zaiord + 1
elseif (cstat.eq.'NEW' .or.
& cstat.eq.'new' ) then
iamode = MPI_MODE_WRONLY +
& MPI_MODE_CREATE +
& MPI_MODE_EXCL +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiowr !see zaiost
file_count_zaiowr = file_count_zaiowr + 1
else !scratch file
iamode = MPI_MODE_RDWR +
& MPI_MODE_DELETE_ON_CLOSE +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiowr !see zaiost
file_count_zaiowr = file_count_zaiowr + 1
endif
call mpi_file_open(group_1st_in_row,
& trim(cfile),
& iamode,
& iahint,
& iahand(iaunit),
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iaunit,trim(cfile)
write(lp,*) 'mpi_file_open - mpierr = ',mpierr
write(lp,*) 'cenv = ',trim(cenv)
call flush(lp)
call xchalt('(zaiope)')
stop '(zaiope)'
endif !mpierr
disp = 0
call mpi_file_set_view(iahand(iaunit),
& disp,
& MTYPE4,
& MTYPE4,
& "native", !1st convert to big-endian if necessary
& iahint,
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iaunit,trim(cfile)
write(lp,*) 'mpi_file_set_view - mpierr = ',mpierr
write(lp,*) 'cenv = ',trim(cenv)
call flush(lp)
call xchalt('(zaiope)')
stop '(zaiope)'
endif !mpierr
c
endif ! I/O from first processor in each row
call xcsync(no_flush)
#if defined(TIMER)
c
call xctmr1(16)
#endif
return
c
9000 format(/ /10x,'error in zaiope - array I/O unit ',
& i3,' is not marked as available.'/ /)
9100 format(/ /10x,'error in zaiope - can''t open unit ',i3,
& ', for array I/O.' /
& 10x,'cfile = ',a/ /)
9300 format(/ /10x,'error in zaiope - environment variable ',a,
& ' not defined'/ /)
end subroutine zaiope
subroutine zaiopf(cfile,cstat, iaunit)
implicit none
c
integer, intent(in) :: iaunit
character*(*), intent(in) :: cfile,cstat
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for opening a file for array i/o.
c
c must call zaiost before first call to zaiopf.
c see also 'zaiopn' and 'zaiope'.
c
c 2) the filename is taken from 'cfile'.
c
c array i/o is mpi-2 i/o.
c
c 3) iaunit+uaoff is the i/o unit used for arrays. array i/o might not
c use fortran i/o units, but, for compatability, assume that
c iaunit+uaoff refers to a fortran i/o unit anyway.
c cstat indicates the file type, it can be 'scratch', 'old', or
c 'new'.
c all i/o to iaunit must be performed by zaiord and zaiowr.
c arrays passed to these routines must conform to 'h'.
c the file should be closed using zaiocl.
c*
c**********
c
c --- spval = data void marker, 2^100 or about 1.2676506e30
c --- n2drec = size of output 2-d array, multiple of 4096
real*4 spval
parameter (spval=2.0**100)
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
c
integer(kind=mpi_offset_kind) disp
integer iamode,iahint
logical lphint
#if defined(TIMER)
c
call xctmr0(16)
#endif
c
c test file state.
c
if (iarec(iaunit).ne.-1) then
write(lp,9000) iaunit
call xcstop('(zaiopf)')
stop '(zaiopf)'
endif
c
iarec(iaunit) = 0
c
c --- I/O from first processor in each row.
c
if (mproc.eq.mp_1st) then
*
* if (mnproc.eq.1) then
* write(lp,*) 'zaiopf - iaunit = ',iaunit
* call flush(lp)
* endif
c
c open file.
c
if (cstat.eq.'OLD' .or.
& cstat.eq.'old' ) then
iamode = MPI_MODE_RDONLY +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiord !see zaiost
file_count_zaiord = file_count_zaiord + 1
lphint = file_count_zaiord .eq. 1
elseif (cstat.eq.'NEW' .or.
& cstat.eq.'new' ) then
iamode = MPI_MODE_WRONLY +
& MPI_MODE_CREATE +
& MPI_MODE_EXCL +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiowr !see zaiost
file_count_zaiowr = file_count_zaiowr + 1
lphint = file_count_zaiowr .eq. 1
else !scratch file
iamode = MPI_MODE_RDWR +
& MPI_MODE_DELETE_ON_CLOSE +
& MPI_MODE_UNIQUE_OPEN
iahint = file_info_zaiowr !see zaiost
file_count_zaiowr = file_count_zaiowr + 1
lphint = .true.
endif
call mpi_file_open(group_1st_in_row,
& trim(cfile),
& iamode,
& iahint,
& iahand(iaunit),
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iaunit,trim(cfile)
write(lp,*) 'mpi_file_open - mpierr = ',mpierr
call flush(lp)
call xchalt('(zaiopf)')
stop '(zaiopf)'
endif !mpierr
disp = 0
call mpi_file_set_view(iahand(iaunit),
& disp,
& MTYPE4,
& MTYPE4,
& "native", !1st convert to big-endian if necessary
& iahint,
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iaunit,trim(cfile)
write(lp,*) 'mpi_file_set_view - mpierr = ',mpierr
call flush(lp)
call xchalt('(zaiopf)')
stop '(zaiopf)'
endif !mpierr
if (lphint .and. mnproc.eq.1) then
call zaio_hints(iahand(iaunit))
endif
c
endif ! I/O from first processor in each row
call xcsync(no_flush)
#if defined(TIMER)
c
call xctmr1(16)
#endif
return
c
9000 format(/ /10x,'error in zaiopf - array I/O unit ',
& i3,' is not marked as available.'/ /)
9100 format(/ /10x,'error in zaiopf - can''t open unit ',i3,
& ', for array I/O.' /
& 10x,'cfile = ',a/ /)
end subroutine zaiopf
subroutine zaio_hints(file_handle)
implicit none
c
integer, intent(in) :: file_handle
c
c**********
c*
c 1) prints current hints.
c*
c**********
c
logical flag
integer hints,i,mpierr,nkeys
character*256 key,value
c
call MPI_File_get_info(file_handle, hints, mpierr)
call MPI_Info_get_nkeys(hints, nkeys, mpierr)
c
write(6,"(/a)") 'zaio_hints:'
do i= 0,nkeys-1
call MPI_Info_get_nthkey(hints, i, key, mpierr)
call MPI_Info_get(hints, key, 256, value, flag, mpierr)
write(6,"(4a)")
& ' key=',trim(key),
& ' value=',trim(value)
enddo
write(6,*)
return
end subroutine zaio_hints
subroutine zaiopi(lopen, iaunit)
implicit none
c
logical, intent(out) :: lopen
integer, intent(in) :: iaunit
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) is an array i/o unit open?
c
c 2) must call zaiost before first call to zaiopi.
c*
c**********
c
lopen = iarec(iaunit).ne.-1
return
end subroutine zaiopi
subroutine zaiost
implicit none
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for initializing array i/o.
c
c 2) see also zaiopn, zaiord, zaiowr, and zaiocl.
c*
c**********
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
c
integer iline,ibuf
common/czgetc/ iline(81,0:1),ibuf
save /czgetc/
c
integer i
character*256 value
c
c mpi-2 hints for array i/o
c
file_count_zaiord = 0
file_count_zaiowr = 0
call mpi_info_create(file_info_zaiord,
& mpierr)
call mpi_info_create(file_info_zaiowr,
& mpierr)
#if defined(AIX)
call mpi_info_set(file_info_zaiord,
& 'IBM_largeblock_io', !read on calling task
& 'true',
& mpierr)
write(value,'(i10)') (((itdm*jtdm+4095)/4096)*4096)*4
call mpi_info_set(file_info_zaiowr,
& 'IBM_io_buffer_size',
& trim(value), !write from a single task
& mpierr)
#else
call mpi_info_free(file_info_zaiord, !set to mpi_info_null
& mpierr)
call mpi_info_free(file_info_zaiowr, !set to mpi_info_null
& mpierr)
#endif
c
if (mnproc.eq.1) then
write(lp,'(/a/)')
& 'zaiost - Array I/O is MPI-2 I/O from one task per row'
endif
c
do i= 1,999
iarec(i) = -1
enddo
c
ibuf = 0
#if defined(RELO)
c
c --- n2drec = size of output 2-d array, multiple of 4096
n2drec = ((itdm*jtdm+4095)/4096)*4096
c
allocate( w(n2drec),wminy(jtdm),wmaxy(jtdm),htmp(idm*jdm) )
call mem_stat_add( (n2drec+2*jtdm+idm*jdm)/2 ) !real*4, so /2
#endif
#if defined(TIMER)
c
c initialize timers.
c
call xctmrn(16,'zaio**')
call xctmrn(17,'zaiord')
call xctmrn(18,'zaiowr')
#endif
return
end subroutine zaiost
subroutine zaiocl(iaunit)
implicit none
c
integer, intent(in) :: iaunit
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for array i/o file closing.
c
c must call zaiopn for this array unit before calling zaiocl.
c
c 2) array i/o is mpi-2 i/o.
c*
c**********
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
#if defined(TIMER)
c
call xctmr0(16)
#endif
c
if (iarec(iaunit).lt.0) then
write(lp,9000) iaunit
call xcstop('(zaiocl)')
stop '(zaiocl)'
endif
c
iarec(iaunit) = -1
c
c --- I/O from first processor in each row
c
if (mproc.eq.mp_1st) then
*
* if (mnproc.eq.1) then
* write(lp,*) 'zaiocl - iaunit = ',iaunit
* call flush(lp)
* endif
c
call mpi_file_close(iahand(iaunit),mpierr)
c
endif ! I/O from first processor in each row
call xcsync(no_flush)
#if defined(TIMER)
c
call xctmr1(16)
#endif
return
c
9000 format(/ /10x,'error in zaiocl - array I/O unit ',
& i3,' is not marked as open.'/ /)
end subroutine zaiocl
subroutine zaiofl(iaunit)
implicit none
c
integer, intent(in) :: iaunit
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for array i/o buffer flushing.
c
c must call zaiopn for this array unit before calling zaiocl.
c
c 2) array i/o is mpi-2 i/o.
c*
c**********
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
#if defined(TIMER)
c
call xctmr0(16)
#endif
c
if (iarec(iaunit).lt.0) then
write(lp,9000) iaunit
call xcstop('(zaiofl)')
stop '(zaiofl)'
endif
c
c --- I/O from first processor in each row
c
if (mproc.eq.mp_1st) then
call mpi_file_sync(iahand(iaunit),mpierr)
endif ! I/O from first processor in each row
call xcsync(no_flush)
#if defined(TIMER)
c
call xctmr1(16)
#endif
return
c
9000 format(/ /10x,'error in zaiofl - array I/O unit ',
& i3,' is not marked as open.'/ /)
end subroutine zaiofl
subroutine zaioiq(iaunit, irec)
implicit none
c
integer, intent(in) :: iaunit
integer, intent(out) :: irec
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for array i/o inquiry.
c
c 2) returns the number of records processed, or -1 for a closed file.
c*
c**********
c
irec = iarec(iaunit)
return
end subroutine zaioiq
subroutine zaiorw(iaunit)
implicit none
c
integer, intent(in) :: iaunit
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for array i/o file rewinding.
c
c must call zaiopn for this array unit before calling zaiocl.
c
c 2) array i/o is mpi-2 i/o.
c*
c**********
#if defined(TIMER)
c
call xctmr0(16)
#endif
c
if (iarec(iaunit).lt.0) then
write(lp,9000) iaunit
call xcstop('(zaiorw)')
stop '(zaiorw)'
endif
c
iarec(iaunit) = 0
*
* if (mnproc.eq.1) then
* write(lp,*) 'zaiorw - iaunit,rec = ',iaunit,iarec(iaunit)
* call flush(lp)
* endif
call xcsync(no_flush)
#if defined(TIMER)
c
call xctmr1(16)
#endif
return
c
9000 format(/ /10x,'error in zaiorw - array I/O unit ',
& i3,' is not marked as open.'/ /)
end subroutine zaiorw
subroutine zaiord3(h, l, mask,lmask, hmin,hmax, iaunit)
implicit none
c
logical, intent(in) :: lmask
integer, intent(in) :: l,iaunit
integer, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),
& intent(in) :: mask
#if defined(REAL4)
real*4, intent(out) :: hmin(l),hmax(l)
real*4, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy,l),
& intent(out) :: h
#else
real, intent(out) :: hmin(l),hmax(l)
real, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy,l),
& intent(out) :: h
#endif
c
c**********
c*
c 1) machine specific routine for 3-d array reading.
c
c must call zaiopn for this array unit before calling zaiord.
c
c 2) array i/o is mpi-2 i/o.
c
c 3) iaunit+uaoff is the i/o unit used for arrays. array i/o might not
c use fortran i/o units, but, for compatability, assume that
c iaunit+uaoff refers to a fortran i/o unit anyway.
c the array, 'h', must conform to that passed in the associated
c call to zaiopn.
c
c 4) hmin,hmax are returned as the minimum and maximum value in the
c array, ignoring array elements set to 2.0**100.
c if lmask==.true. the range is calculated only where mask.ne.0,
c with all other values unchanged in h on exit. It is then an
c error if mask.ne.0 anywhere the input is 2.0**100.
c*
c**********
c
c this version just calls zaiord l times.
c
integer k
c
do k= 1,l
call zaiord(h(1-nbdy,1-nbdy,k), mask,lmask,
& hmin(k),hmax(k), iaunit)
enddo
c
return
end subroutine zaiord3
subroutine zaiord(h, mask,lmask, hmin,hmax, iaunit)
implicit none
c
logical, intent(in) :: lmask
integer, intent(in) :: iaunit
integer, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),
& intent(in) :: mask
#if defined(REAL4)
real*4, intent(out) :: hmin,hmax
real*4, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),
& intent(out) :: h
#else
real, intent(out) :: hmin,hmax
real, dimension (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),
& intent(out) :: h
#endif
c
integer iarec
common/czioxx/ iarec(999)
save /czioxx/
integer iahand
common/cziox2/ iahand(999)
save /cziox2/
c
c**********
c*
c 1) machine specific routine for array reading.
c
c must call zaiopn for this array unit before calling zaiord.
c
c 2) array i/o is mpi-2 i/o.
c
c 3) iaunit+uaoff is the i/o unit used for arrays. array i/o might not
c use fortran i/o units, but, for compatability, assume that
c iaunit+uaoff refers to a fortran i/o unit anyway.
c the array, 'h', must conform to that passed in the associated
c call to zaiopn.
c
c 4) hmin,hmax are returned as the minimum and maximum value in the
c array, ignoring array elements set to 2.0**100.
c if lmask==.true. the range is calculated only where mask.ne.0,
c with all other values unchanged in h on exit. It is then an
c error if mask.ne.0 anywhere the input is 2.0**100.
c*
c**********
c
c --- spval = data void marker, 2^100 or about 1.2676506e30
c --- n2drec = size of output 2-d array, multiple of 4096
real*4 spval
parameter (spval=2.0**100)
c
include 'mpif.h'
integer mpierr,mpireq,mpistat
common/xcmpii/ mpierr,mpireq(4),
& mpistat(mpi_status_size,4*iqr)
save /xcmpii/
c
integer(kind=mpi_offset_kind) disp
integer i,j
real*4 wmin,wmax
real rmin(1),rmax(1)
#if defined(TIMER)
c
call xctmr0(17)
#endif
c
if (iarec(iaunit).lt.0) then
write(lp,9000) iaunit
call xcstop('(zaiord)')
stop '(zaiord)'
endif
c
iarec(iaunit) = iarec(iaunit) + 1
c
wmin = spval
wmax = -spval
c
c --- I/O from first processor in each row
c
if (mproc.eq.mp_1st) then
*
* if (mnproc.eq.1) then
* write(lp,*) 'zaiord - iaunit,rec = ',iaunit,iarec(iaunit)
* write(lp,*) 'zaiord - mask.1,1 = ',amsk(1,1)
* write(lp,*) 'zaiord - h.1,1 = ',atmp(1,1)
* call flush(lp)
* endif
c
disp = n2drec
disp = (iarec(iaunit)-1)*disp + itdm*j0
call mpi_file_read_at(iahand(iaunit),
& disp,
& w(1+j0*itdm),
& itdm*jj,
& MTYPE4,
& mpistat(1,1),
& mpierr)
if (mpierr.ne.0) then
write(lp,9100) iarec(iaunit),iaunit
write(lp,*) 'mpierr = ',mpierr
call flush(lp)
call xchalt('(zaiord)')
stop '(zaiord)'
endif !mpierr
if (.not.lmask) then
c Get min and max of input array section.