@@ -24,6 +24,7 @@ program flash_benchmark_io
2424#endif
2525 integer i, argc, ierr
2626 character (len= 128 ) executable
27+ character (len= 8 ) opt
2728 logical verbose, isArgvRight
2829
2930 double precision time_io(3 ), time_begin
@@ -42,48 +43,46 @@ program flash_benchmark_io
4243 MasterPE = 0
4344 verbose = .TRUE.
4445 indep_io = .FALSE.
46+ use_nonblocking_io = .TRUE.
47+ basenm(1 :1 ) = ' '
4548
4649 ! root process reads command-line arguments
4750 if (MyPE .EQ. MasterPE) then
4851 isArgvRight = .TRUE.
4952 argc = IARGC() ! IARGC() does not count the executable name
5053 call getarg(0 , executable)
51- if (argc .EQ. 0 ) then
52- ! default file name prefix
53- basenm = " flash_io_test_"
54- else if (argc .EQ. 1 ) then
55- call getarg(1 , basenm)
56- if (basenm(1 :2 ) .EQ. ' -q' ) then
54+ do i= 1 , argc
55+ call getarg(i, opt)
56+ if (opt(1 :2 ) .EQ. ' -h' ) then
57+ isArgvRight = .FALSE.
58+ else if (opt(1 :2 ) .EQ. ' -q' ) then
5759 verbose = .FALSE.
58- basenm = " flash_io_test_"
59- else if (basenm(1 :2 ) .EQ. ' -i' ) then
60+ else if (opt(1 :2 ) .EQ. ' -b' ) then
61+ use_nonblocking_io = .FALSE.
62+ else if (opt(1 :2 ) .EQ. ' -i' ) then
6063 indep_io = .TRUE.
61- basenm = " flash_io_test_"
62- endif
63- else if (argc .EQ. 2 ) then
64- call getarg(1 , basenm)
65- if (basenm(1 :2 ) .EQ. ' -q' ) then
66- verbose = .FALSE.
67- call getarg(2 , basenm)
68- else if (basenm(1 :2 ) .EQ. ' -i' ) then
69- indep_io = .TRUE.
70- call getarg(2 , basenm)
71- else
72- isArgvRight = .FALSE.
64+ else if (opt(1 :2 ) .EQ. ' -f' ) then
65+ call getarg(i+1 , basenm)
66+ if (i .EQ. argc) then
67+ isArgvRight = .FALSE.
68+ else if (basenm(1 :1 ) .EQ. ' -' ) then
69+ isArgvRight = .FALSE.
70+ else if (LEN_TRIM (basenm(:)) .EQ. 0 ) then
71+ isArgvRight = .FALSE.
72+ endif
7373 endif
74- else if (argc .EQ. 3 ) then
75- call getarg(3 , basenm)
76- if (basenm(1 :2 ) .EQ. ' -q' .OR. basenm(1 :2 ) .EQ. ' -i' ) then
77- isArgvRight = .FALSE.
78- endif
79- verbose = .FALSE.
80- indep_io = .TRUE.
81- else if (argc .GT. 2 ) then
82- isArgvRight = .FALSE.
83- endif
74+ enddo
75+
8476 if (.NOT. isArgvRight) then
77+ isArgvRight = .FALSE.
78+ i = INDEX (executable, " /" , .TRUE. )
8579 print * , &
86- ' Usage: ' ,trim (executable),' [-q] <ouput file base name>'
80+ ' Usage: ' ,trim (executable(i+1 :)),' [-hqbi] -f <ouput file prefix name>'
81+ print * , ' -h: print this message'
82+ print * , ' -q: quiet mode'
83+ print * , ' -b: use PnetCDF blocking APIs (default: nonblocking)'
84+ print * , ' -i: use MPI independent I/O (default: collective)'
85+ print * , ' -f prefix: output file prefix name (required)'
8786 endif
8887 endif
8988
@@ -92,7 +91,11 @@ program flash_benchmark_io
9291 MPI_COMM_WORLD, ierr)
9392 if (.NOT. isArgvRight) goto 999
9493
95- ! broadcast if independent I/O should be used
94+ ! broadcast whether nonblocking APIs should be used
95+ call MPI_Bcast(use_nonblocking_io, 1 , MPI_LOGICAL, MasterPE, &
96+ MPI_COMM_WORLD, ierr)
97+
98+ ! broadcast whether independent I/O should be used
9699 call MPI_Bcast(indep_io, 1 , MPI_LOGICAL, MasterPE, &
97100 MPI_COMM_WORLD, ierr)
98101
@@ -119,9 +122,6 @@ program flash_benchmark_io
119122 neigh(:,:,:) = - 1
120123 empty(:) = 0
121124
122- ! use nonblocking APIs
123- use_nonblocking_io = .TRUE.
124-
125125! initialize the unknowns with the index of the variable
126126 do i = 1 , nvar
127127 unk(i,:,:,:,:) = float(i)
@@ -285,6 +285,19 @@ subroutine report_io_performance(verbose, local_blocks, time_io, &
285285 1006 format (I5, 3x , i3,' x ' ,i3,' x ' ,i3, 3x , F7.2 , 2x ,F10.2 / )
286286 1007 format (A,A)
287287
288+ print 1004
289+ if (use_nonblocking_io) then
290+ print * ,' Using PnetCDF nonblocking APIs'
291+ else
292+ print * ,' Using PnetCDF blocking APIs'
293+ endif
294+ if (indep_io) then
295+ print * ,' Using MPI independent I/O'
296+ else
297+ print * ,' Using MPI collective I/O'
298+ endif
299+ print 1004
300+ print 1001 ,' number of guards : ' ,nguard
288301 print 1001 ,' number of guards : ' ,nguard
289302 print 1001 ,' number of blocks : ' ,local_blocks
290303 print 1001 ,' number of variables : ' ,nvar
0 commit comments