Skip to content

Commit

Permalink
fixed plain old PIO fortran program
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 27, 2019
1 parent 6d92938 commit c64584f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 38 deletions.
65 changes: 29 additions & 36 deletions tests/fncint/ftst_pio_orig.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ program ftst_pio
type(iosystem_desc_t) :: ioSystem
type(file_desc_t) :: pioFileDesc
type(io_desc_t) :: iodesc
type(var_desc_t) :: var
integer(kind=pio_offset_kind) :: recnum = 1
integer :: maplen
integer :: decompid, iosysid
integer :: varid, i
Expand All @@ -36,18 +38,17 @@ program ftst_pio
call MPI_Comm_size(MPI_COMM_WORLD, ntasks, ierr)

! These control logging in the PIO and netCDF libraries.
ierr = pio_set_log_level(3)
ierr = nf_set_log_level(2)
if (ierr .ne. nf_noerr) call handle_err(ierr)
! ierr = pio_set_log_level(3)
! ierr = nf_set_log_level(2)

! Define an IOSystem.
call PIO_init(my_rank, MPI_COMM_WORLD, niotasks, numAggregator, stride, &
PIO_rearr_subset, ioSystem, base=base)

! Define a 2D decomposition.
dims(1) = NLAT * 2 / ntasks
dims(2) = NLON * 2 / ntasks
maplen = dims(1) * dims(2)
dims(1) = 4
dims(2) = 4
maplen = 4
print *, 'dims: ', dims
print *, 'maplen: ', maplen
print *, 'my_rank: ', my_rank
Expand All @@ -57,51 +58,43 @@ program ftst_pio
! in fortran. Also recall that compdof is 1-based for fortran.
do i = 1, maplen
compdof(i) = i + my_rank * maplen
!data_buffer(i) = my_rank * 10 + i
data_buffer(i) = my_rank
data_buffer(i) = my_rank * 10 + i
end do
print *, 'compdof', my_rank, compdof

call PIO_initdecomp(ioSystem, PIO_int, dims, compdof, iodesc)


! ierr = nf_def_decomp(iosysid, PIO_int, dims, compdof, decompid)
! if (ierr .ne. nf_noerr) call handle_err(ierr)

! Create a file.
ierr = PIO_createfile(ioSystem, pioFileDesc, PIO_IOTYPE_PNETCDF, FILE_NAME, PIO_clobber)
! ierr = nf_create(FILE_NAME, 64, ncid)
! if (ierr .ne. nf_noerr) call handle_err(ierr)

! ! Define dimensions.
! ierr = nf_def_dim(ncid, LAT_NAME, NLAT, var_dim(1))
! if (ierr .ne. nf_noerr) call handle_err(ierr)
! ierr = nf_def_dim(ncid, LON_NAME, NLON, var_dim(2))
! if (ierr .ne. nf_noerr) call handle_err(ierr)
! ierr = nf_def_dim(ncid, REC_NAME, NF_UNLIMITED, var_dim(3))
! if (ierr .ne. nf_noerr) call handle_err(ierr)

! ! Define a data variable.
! ierr = nf_def_var(ncid, VAR_NAME, NF_INT, NDIM3, var_dim, varid)
! if (ierr .ne. nf_noerr) call handle_err(ierr)
! ierr = nf_enddef(ncid)
! if (ierr .ne. nf_noerr) call handle_err(ierr)

! ! Write 1st record with distributed arrays.
! ierr = nf_put_vard_int(ncid, varid, decompid, 1, data_buffer)
! if (ierr .ne. nf_noerr) call handle_err(ierr)
if (ierr .ne. nf_noerr) call handle_err(ierr)

! Define dimensions.
ierr = PIO_def_dim(pioFileDesc%fh, LAT_NAME, NLAT, var_dim(1))
if (ierr .ne. nf_noerr) call handle_err(ierr)
ierr = PIO_def_dim(pioFileDesc%fh, LON_NAME, NLON, var_dim(2))
if (ierr .ne. nf_noerr) call handle_err(ierr)
ierr = PIO_def_dim(pioFileDesc%fh, REC_NAME, NF_UNLIMITED, var_dim(3))
if (ierr .ne. nf_noerr) call handle_err(ierr)

! Define a data variable.
ierr = PIO_def_var(pioFileDesc, VAR_NAME, NF_INT, var_dim, var)
if (ierr .ne. nf_noerr) call handle_err(ierr)
ierr = PIO_enddef(pioFileDesc%fh)
if (ierr .ne. nf_noerr) call handle_err(ierr)

! Write 1st record with distributed arrays.
call PIO_setframe(pioFileDesc, var, recnum)
call PIO_write_darray(pioFileDesc, var, iodesc, data_buffer, ierr)
if (ierr .ne. nf_noerr) call handle_err(ierr)

! Close the file.
call PIO_closefile(pioFileDesc)
! ierr = nf_close(ncid)
if (ierr .ne. nf_noerr) call handle_err(ierr)

! Free resources.
! ierr = nf_free_decomp(decompid)
! if (ierr .ne. nf_noerr) call handle_err(ierr)
deallocate(compdof)
deallocate(data_buffer)
! call PIO_freedecomp(ioSystem, iodesc)
call PIO_freedecomp(ioSystem, iodesc)
call pio_finalize(ioSystem, ierr)

! We're done!
Expand Down
4 changes: 2 additions & 2 deletions tests/fncint/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ trap exit INT TERM
printf 'running Fortran tests for PIO netCDF integration...\n'

#PIO_TESTS='ftst_pio_orig ftst_pio'
#PIO_TESTS='tst_c_pio ftst_pio_orig'
PIO_TESTS='tst_c_pio'
PIO_TESTS='tst_c_pio ftst_pio_orig'
#PIO_TESTS='tst_c_pio'

success1=true
for TEST in $PIO_TESTS
Expand Down

0 comments on commit c64584f

Please sign in to comment.