simple_xy_par_wr2.f90 (netcdf-fortran-4.4.4) | : | simple_xy_par_wr2.f90 (netcdf-fortran-4.4.5) | ||
---|---|---|---|---|
skipping to change at line 94 | skipping to change at line 94 | |||
call check(nf90_def_dim(ncid, "x", p, x_dimid)) | call check(nf90_def_dim(ncid, "x", p, x_dimid)) | |||
call check(nf90_def_dim(ncid, "y", p, y_dimid)) | call check(nf90_def_dim(ncid, "y", p, y_dimid)) | |||
call check(nf90_def_dim(ncid, "t", NF90_UNLIMITED, t_dimid)) | call check(nf90_def_dim(ncid, "t", NF90_UNLIMITED, t_dimid)) | |||
! The dimids array is used to pass the IDs of the dimensions of | ! The dimids array is used to pass the IDs of the dimensions of | |||
! the variables. Note that in fortran arrays are stored in | ! the variables. Note that in fortran arrays are stored in | |||
! column-major format. | ! column-major format. | |||
dimids = (/ y_dimid, x_dimid, t_dimid /) | dimids = (/ y_dimid, x_dimid, t_dimid /) | |||
! define the chunk size (1 along unlimited time dimension) | ! define the chunk size (1 along unlimited time dimension) | |||
chunk_size = (/p , 1, 1 /) | chunk_size = (/ p, 1, 1 /) | |||
! Define the variable. The type of the variable in this case is | ! Define the variable. The type of the variable in this case is | |||
! NF90_INT (4-byte integer). | ! NF90_INT (4-byte integer). | |||
call check(nf90_def_var(ncid, "data", NF90_INT, dimids, varid, chunksizes=chun k_size)) | call check(nf90_def_var(ncid, "data", NF90_INT, dimids, varid, chunksizes=chun k_size)) | |||
! End define mode. This tells netCDF we are done defining | ! End define mode. This tells netCDF we are done defining | |||
! metadata. This operation is collective and all processors will | ! metadata. This operation is collective and all processors will | |||
! write their metadata to disk. | ! write their metadata to disk. | |||
call check(nf90_enddef(ncid)) | call check(nf90_enddef(ncid)) | |||
! Write the pretend data to the file. Each processor writes one row. | ! Write the pretend data to the file. Each processor writes one row. | |||
start = (/ 1, my_rank + 1, 1/) | start = (/ 1, my_rank + 1, 1/) | |||
count = (/ p, 1, 1 /) | count = (/ p, 1, 1 /) | |||
! force independent write (does not help, however) | ! Unlimited dimensions require collective writes | |||
call check(nf90_var_par_access(ncid, varid, nf90_independent)) | call check(nf90_var_par_access(ncid, varid, nf90_collective)) | |||
! Do NOT write to first process (test independent writes) | ! The unlimited axis prevents independent write tests | |||
! this works fine if all processes take part of the write (comment out the if( | ! Re-enable the rank test if independent writes are used in the future | |||
) statement below) | !if (my_rank.ne.0) & | |||
if (my_rank.ne.0) & | ||||
call check(nf90_put_var(ncid, varid, data_out, start = start, & | call check(nf90_put_var(ncid, varid, data_out, start = start, & | |||
count = count)) | count = count)) | |||
! Close the file. This frees up any internal netCDF resources | ! Close the file. This frees up any internal netCDF resources | |||
! associated with the file, and flushes any buffers. | ! associated with the file, and flushes any buffers. | |||
call check( nf90_close(ncid) ) | call check( nf90_close(ncid) ) | |||
! Free my local memory. | ! Free my local memory. | |||
deallocate(data_out) | deallocate(data_out) | |||
End of changes. 3 change blocks. | ||||
7 lines changed or deleted | 6 lines changed or added |