Skip to content

Commit

Permalink
Add pio_finalize calls for CICE history and restart files when runnin…
Browse files Browse the repository at this point in the history
…g with PIO. This

cleans up some PIO internal data.  The code was aborting when trying to write
lots of files (>600) because we reinitialize PIO for each file.  This is a short term
fix.  A longer term fix is to initialize PIO once and reuse as much as possible.

Add a new test that runs CICE for a year writing hourly files (>8000 files).  Test with
pio2 and netcdf.
  • Loading branch information
apcraig committed Nov 14, 2024
1 parent b3d5813 commit 884ed66
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,12 @@ subroutine ice_write_hist (ns)
write(nu_diag,*) 'Finished writing ',trim(ncfile)
endif

!-----------------------------------------------------------------
! clean up PIO
!-----------------------------------------------------------------

call ice_pio_finalize()

first_call = .false.

end subroutine ice_write_hist
Expand Down
14 changes: 14 additions & 0 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_pio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module ice_pio

public ice_pio_init
public ice_pio_initdecomp
public ice_pio_finalize
public ice_pio_check

#ifdef CESMCOUPLED
Expand Down Expand Up @@ -529,6 +530,19 @@ subroutine ice_pio_initdecomp_4d (ndim3, ndim4, iodesc, precision)
end subroutine ice_pio_initdecomp_4d


!================================================================================

! PIO Finalize

subroutine ice_pio_finalize()

integer(kind=int_kind) :: ierr
character(len=*), parameter :: subname = '(ice_pio_finalize)'

call pio_finalize(ice_pio_subsystem,ierr)

end subroutine ice_pio_finalize

!================================================================================

! PIO Error handling
Expand Down
1 change: 1 addition & 0 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ subroutine final_restart()
call PIO_freeDecomp(File,iodesc2d)
call PIO_freeDecomp(File,iodesc3d_ncat)
call pio_closefile(File)
call ice_pio_finalize()

if (my_task == master_task) then
write(nu_diag,'(a,i8,4x,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
Expand Down
8 changes: 8 additions & 0 deletions configuration/scripts/options/set_nml.histhrly
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
histfreq = 'm','h','x','x','x'
histfreq_n = 1,1,1,1,1
histfreq_base = 'zero','zero','zero','zero','zero'
write_ic = .true.
f_aice = 'mh'
f_hi = 'hm'
f_hs = 'mh'
f_Tsfc = 'mh'
3 changes: 3 additions & 0 deletions configuration/scripts/tests/io_suite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Test Grid PEs Sets BFB-compare
smoke gx3 32x1 run1year,histhrly,ionetcdf,iocdf2,short
smoke gx3 32x1 run1year,histhrly,iopio2,iocdf5,short

# some iobinary configurations fail due to bathymetry netcdf file requirement, remove them
# iobinary cannot work with JRA55 because netcdf is turned off
restart gx3 8x4 gx3ncarbulk,debug,histall,iobinary,precision8
Expand Down

0 comments on commit 884ed66

Please sign in to comment.