Skip to content

Commit 64b6aa3

Browse files
authored
Confirm backward compatibility for PIO reads on non-parallel files (#966)
Add ability for netcdf file reading to fall back to regular netcdf if a file is initially opened (for instance with hdf5 reading) and fails to open properly. For some versions of the PIO library (<2.5.10), attempting a parallel read with filetype netcdf4 (hdf5) of a file which does not support parallel reads fails. The expected behaviour (which is fixed in latest PIO versions) is to fall back to a serial read. The change ensures support for older PIO versions.
1 parent 350d34a commit 64b6aa3

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

cicecore/cicedyn/infrastructure/io/io_pio2/ice_pio.F90

+8-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,14 @@ subroutine ice_pio_init(mode, filename, File, clobber, fformat, &
236236
write(nu_diag,*) subname//' opening file for reading '//trim(filename)
237237
endif
238238
status = pio_openfile(ice_pio_subsystem, File, pio_iotype, trim(filename), pio_nowrite)
239-
call ice_pio_check( status, subname//' ERROR: Failed to open file '//trim(filename), &
240-
file=__FILE__,line=__LINE__)
239+
if (status /= PIO_NOERR) then
240+
if (my_task == master_task) then
241+
write(nu_diag,*) subname//' opening '//trim(filename)//' as type '//trim(fformat)//' failed, retrying as type cdf1'
242+
endif
243+
status = pio_openfile(ice_pio_subsystem, File, PIO_IOTYPE_NETCDF, trim(filename), pio_nowrite)
244+
call ice_pio_check( status, subname//' ERROR: Failed to open file '//trim(filename), &
245+
file=__FILE__,line=__LINE__)
246+
endif
241247
else
242248
if(my_task==master_task) then
243249
write(nu_diag,*) subname//' ERROR: file not found '//trim(filename)

cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90

+1-6
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,8 @@ subroutine init_restart_read(ice_ic)
7878
end if
7979

8080
File%fh=-1
81-
! tcraig, including fformat here causes some problems when restart_format=hdf5
82-
! and reading non hdf5 files with spack built PIO. Excluding the fformat
83-
! argument here defaults the PIO format to cdf1 which then reads
84-
! any netcdf format file fine.
8581
call ice_pio_init(mode='read', filename=trim(filename), File=File, &
86-
! fformat=trim(restart_format), rearr=trim(restart_rearranger), &
87-
rearr=trim(restart_rearranger), &
82+
fformat=trim(restart_format), rearr=trim(restart_rearranger), &
8883
iotasks=restart_iotasks, root=restart_root, stride=restart_stride, &
8984
debug=first_call)
9085

0 commit comments

Comments
 (0)