Skip to content

Commit

Permalink
add fixme note, handle error, and update test
Browse files Browse the repository at this point in the history
- Updated default filename spec
- Handled error from put call
- Added note to improve code
- Updated test to ERS
  • Loading branch information
mahf708 committed Sep 25, 2024
1 parent b5c3c7f commit a60ae93
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cime_config/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"REP_Ln5.ne4pg2_oQU480.F2010",
"SMS_Ld3.ne4pg2_oQU480.F2010.eam-thetahy_sl_pg2_mass",
"ERP_Ld3.ne4pg2_ne4pg2.FIDEAL.allactive-pioroot1",
"SMS_Ld5.ne4pg2_oQU480.F2010.eam-sathist_F2010",
"ERS_Ld5.ne4pg2_oQU480.F2010.eam-sathist_F2010",
)
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
&satellite_options_nl
sathist_mfilt = 10000,
sathist_track_infile = '$DIN_LOC_ROOT/atm/waccm/sat/sathist_master_19700410-20150419_c20150616.nc'
sathist_hfilename_spec = '%c.sathist_master_19700410-20150419_c20150616.%y-%m-%d-%s.nc'
sathist_hfilename_spec = '%c.eam.h9.sathist.%y-%m-%d-%s.nc'
sathist_nclosest = 1
sathist_ntimestep = 1
sathist_fincl = 'T', 'PS'
19 changes: 18 additions & 1 deletion components/eam/src/control/sat_hist.F90
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ subroutine sat_hist_readnl(nlfile, hfilename_spec, mfilt, fincl, nhtfrq, avgflag
! set defaults

sathist_track_infile = ' '
sathist_hfilename_spec = '%c.cam' // trim(inst_suffix) // '.hs.%y-%m-%d-%s.nc'
sathist_hfilename_spec = '%c.eam.hs.' // trim(inst_suffix) // '.%y-%m-%d-%s.nc'
sathist_fincl(:) = ' '
sathist_mfilt = 100000
sathist_nclosest = 1
Expand Down Expand Up @@ -522,6 +522,13 @@ subroutine sat_hist_write( tape , nflds, nfils)
end subroutine sat_hist_write

!-------------------------------------------------------------------------------
! FIXME extra work >
! dump_columns routine is doing unnecessary extra work serially
! this happens because there is an unneeded mpi_allreduce call
! and then the gathered data is written in a serial manner; this
! could be improved by avoiding the mpi_allreduce call, and then
! writing local data out using pio_write_darray, which is parallel
! FIXME extra work <
subroutine dump_columns( File, hitems, nflds, ncols, nlevs, nfils, fdims, ldims, owners, decomp )
use cam_history_support, only: field_info, hentry, fillvalue
use pio, only: pio_setframe, pio_offset_kind
Expand Down Expand Up @@ -565,9 +572,14 @@ subroutine dump_columns( File, hitems, nflds, ncols, nlevs, nfils, fdims, ldims,
sbuf1d(i) = hitems(f)%hbuf( fdims(i), 1, ldims(i) )
endif
enddo
! FIXME extra work: unnecessary mpi call, then serial write
! FIXME extra work: can use pio_write_darray on local data instead
call mpi_allreduce(sbuf1d,rbuf1d,ncols,mpi_real8, mpi_sum, mpicom, ierr)
buf1d(:) = real(rbuf1d(:),r4)
ierr = pio_put_var(File, vardesc, (/nfils/),(/ncols/), buf1d(:))
if ( ierr /= PIO_NOERR ) then
call endrun('sat_hist::dump_columns: pio_put_var error')
endif
else
sbuf2d = 0.0_r8
rbuf2d = 0.0_r8
Expand All @@ -578,9 +590,14 @@ subroutine dump_columns( File, hitems, nflds, ncols, nlevs, nfils, fdims, ldims,
enddo
endif
enddo
! FIXME extra work: unnecessary mpi call, then serial write
! FIXME extra work: can use pio_write_darray on local data instead
call mpi_allreduce(sbuf2d,rbuf2d,ncols*nlevs,mpi_real8, mpi_sum, mpicom, ierr)
buf2d(:,:) = real(rbuf2d(:,:),r4)
ierr = pio_put_var(File, vardesc, (/1,nfils/),(/nlevs,ncols/), buf2d(:,:))
if ( ierr /= PIO_NOERR ) then
call endrun('sat_hist::dump_columns: pio_put_var error')
endif
endif

endif
Expand Down

0 comments on commit a60ae93

Please sign in to comment.