Skip to content

Commit

Permalink
Merge pull request #903 from peverwhee/history-split
Browse files Browse the repository at this point in the history
cam6_3_140: Separate history tapes into hXi and hXa
  • Loading branch information
peverwhee authored Dec 7, 2023
2 parents eaba9ff + 6c59437 commit 32f2772
Show file tree
Hide file tree
Showing 7 changed files with 1,866 additions and 1,263 deletions.
4 changes: 2 additions & 2 deletions cime_config/SystemTests/sct.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _case_two_setup(self):
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "MFILT = 1,7,1,1,1,1")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "nhtfrq = 1,1,1,1,1,1")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "fincl2='T','Q','TDIFF','QDIFF','LANDFRAC'")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "iopfile = '../"+case_name+".cam.h1."+RUN_STARTDATE+"-00000.nc'")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "iopfile = '../"+case_name+".cam.h1i."+RUN_STARTDATE+"-00000.nc'")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "inithist = 'YEARLY'")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "scm_cambfb_mode = .true.")
append_to_user_nl_files(caseroot = self._get_caseroot(), component = "cam", contents = "scm_use_obs_uv = .true.")
Expand All @@ -65,7 +65,7 @@ def _component_compare_test(self, suffix1, suffix2,
success_change=False,
ignore_fieldlist_diffs=False):
with self._test_status:
stat,netcdf_filename,err=run_cmd('ls ./run/case2run/*h1*8400.nc ')
stat,netcdf_filename,err=run_cmd('ls ./run/case2run/*h1i*8400.nc ')
stat,DIFFs,err=run_cmd('ncdump -ff -p 9,17 -v QDIFF,TDIFF '+netcdf_filename+' | egrep //\.\*DIFF | sed s/^\ \*// | sed s/^0,/0.0,/ | sed s/^0\;/0.0\;/ | sed s/\[,\;\].\*// | uniq')
array_of_DIFFs=DIFFs.split("\n")
answer=max([abs(float(x)) for x in array_of_DIFFs])
Expand Down
275 changes: 275 additions & 0 deletions doc/ChangeLog

Large diffs are not rendered by default.

2,521 changes: 1,374 additions & 1,147 deletions src/control/cam_history.F90

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/control/cam_history_support.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module cam_history_support
use cam_logfile, only: iulog
use spmd_utils, only: masterproc
use cam_grid_support, only: cam_grid_patch_t, cam_grid_header_info_t
use cam_grid_support, only: max_hcoordname_len
use cam_grid_support, only: max_hcoordname_len, maxsplitfiles
use cam_pio_utils, only: cam_pio_handle_error

implicit none
Expand Down Expand Up @@ -197,7 +197,7 @@ module cam_history_support
! PIO ids
!

type(file_desc_t) :: File ! PIO file id
type(file_desc_t) :: Files(maxsplitfiles) ! PIO file ids

type(var_desc_t) :: mdtid ! var id for timestep
type(var_desc_t) :: ndbaseid ! var id for base day
Expand All @@ -220,7 +220,7 @@ module cam_history_support
#endif
type(var_desc_t) :: nstephid ! var id for current timestep
type(var_desc_t) :: timeid ! var id for time
type(var_desc_t) :: tbndid ! var id for time_bnds
type(var_desc_t) :: tbndid ! var id for time_bounds
type(var_desc_t) :: date_writtenid ! var id for date time sample written
type(var_desc_t) :: time_writtenid ! var id for time time sample written
type(var_desc_t) :: f107id ! var id for f107
Expand Down
11 changes: 10 additions & 1 deletion src/control/filenames.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end function get_dir
!===============================================================================

character(len=cl) function interpret_filename_spec( filename_spec, number, prev, case, &
yr_spec, mon_spec, day_spec, sec_spec )
yr_spec, mon_spec, day_spec, sec_spec, flag_spec )

! Create a filename from a filename specifier. The
! filename specifyer includes codes for setting things such as the
Expand Down Expand Up @@ -77,12 +77,14 @@ end function get_dir
integer , intent(in), optional :: mon_spec ! Simulation month
integer , intent(in), optional :: day_spec ! Simulation day
integer , intent(in), optional :: sec_spec ! Seconds into current simulation day
character(len=*), intent(in), optional :: flag_spec ! flag for accumulated or instantaneous

! Local variables
integer :: year ! Simulation year
integer :: month ! Simulation month
integer :: day ! Simulation day
integer :: ncsec ! Seconds into current simulation day
character(len=1) :: flag
character(len=cl) :: string ! Temporary character string
character(len=cl) :: format ! Format character string
integer :: i, n ! Loop variables
Expand Down Expand Up @@ -116,6 +118,11 @@ end function get_dir
call get_curr_date(year, month, day, ncsec)
end if
end if
if (present(flag_spec)) then
flag = flag_spec
else
flag = ''
end if
!
! Go through each character in the filename specifyer and interpret if special string
!
Expand Down Expand Up @@ -170,6 +177,8 @@ end function get_dir
write(string,'(i2.2)') day
case( 's' ) ! second
write(string,'(i5.5)') ncsec
case( 'f' ) ! flag
write(string,'(a)') flag
case( '%' ) ! percent character
string = "%"
case default
Expand Down
60 changes: 30 additions & 30 deletions src/control/sat_hist.F90
Original file line number Diff line number Diff line change
Expand Up @@ -466,53 +466,53 @@ subroutine sat_hist_write( tape , nflds, nfils)
call get_indices( obs_lats, obs_lons, ncols, nocols, has_dyn_flds, col_ndxs, chk_ndxs, &
fdyn_ndxs, ldyn_ndxs, phs_owners, dyn_owners, mlats, mlons, phs_dists )

if ( .not. pio_file_is_open(tape%File) ) then
if ( .not. pio_file_is_open(tape%Files(1)) ) then
call endrun('sat file not open')
endif


ierr = pio_inq_dimid(tape%File,'ncol',coldim )
ierr = pio_inq_dimid(tape%Files(1),'ncol',coldim )

ierr = pio_inq_varid(tape%File, 'lat', out_latid )
ierr = pio_inq_varid(tape%File, 'lon', out_lonid )
ierr = pio_inq_varid(tape%File, 'distance', out_dstid )
ierr = pio_inq_varid(tape%Files(1), 'lat', out_latid )
ierr = pio_inq_varid(tape%Files(1), 'lon', out_lonid )
ierr = pio_inq_varid(tape%Files(1), 'distance', out_dstid )

call write_record_coord( tape, mlats(:), mlons(:), phs_dists(:), ncols, nfils )

! dump columns of 2D fields
if (has_phys_srf_flds) then
call dump_columns( tape%File, tape%hlist, nflds, nocols, 1, nfils, &
call dump_columns( tape%Files(1), tape%hlist, nflds, nocols, 1, nfils, &
col_ndxs, chk_ndxs, phs_owners, phys_decomp )
endif
if (has_dyn_srf_flds) then
call dump_columns( tape%File, tape%hlist, nflds, nocols, 1, nfils, &
call dump_columns( tape%Files(1), tape%hlist, nflds, nocols, 1, nfils, &
fdyn_ndxs, ldyn_ndxs, dyn_owners, dyn_decomp )
endif

! dump columns of 3D fields defined on mid pres levels
if (has_phys_lev_flds) then
call dump_columns( tape%File, tape%hlist, nflds, nocols, pver, nfils, &
call dump_columns( tape%Files(1), tape%hlist, nflds, nocols, pver, nfils, &
col_ndxs, chk_ndxs, phs_owners, phys_decomp )
endif
if (has_dyn_lev_flds) then
call dump_columns( tape%File, tape%hlist, nflds, nocols, pver, nfils, &
call dump_columns( tape%Files(1), tape%hlist, nflds, nocols, pver, nfils, &
fdyn_ndxs, ldyn_ndxs, dyn_owners, dyn_decomp )
endif

! dump columns of 3D fields defined on interface pres levels
if (has_phys_ilev_flds) then
call dump_columns( tape%File, tape%hlist, nflds, nocols, pverp, nfils, &
call dump_columns( tape%Files(1), tape%hlist, nflds, nocols, pverp, nfils, &
col_ndxs, chk_ndxs, phs_owners, phys_decomp )
endif
if (has_dyn_ilev_flds) then
call dump_columns( tape%File, tape%hlist, nflds, nocols, pverp, nfils, &
call dump_columns( tape%Files(1), tape%hlist, nflds, nocols, pverp, nfils, &
fdyn_ndxs, ldyn_ndxs, dyn_owners, dyn_decomp )
endif

deallocate( col_ndxs, chk_ndxs, fdyn_ndxs, ldyn_ndxs, phs_owners, dyn_owners )
deallocate( mlons, mlats, phs_dists )
deallocate( obs_lons, obs_lats )
call pio_syncfile(tape%File)
call pio_syncfile(tape%Files(1))

nfils = nfils + nocols

Expand Down Expand Up @@ -763,19 +763,19 @@ subroutine write_record_coord( tape, mod_lats, mod_lons, mod_dists, ncols, nfils
allocate( rtmp(ncols * sathist_nclosest) )

itmp(:) = ncdate
ierr = pio_put_var(tape%File, tape%dateid,(/nfils/), (/ncols * sathist_nclosest/),itmp)
ierr = pio_put_var(tape%Files(1), tape%dateid,(/nfils/), (/ncols * sathist_nclosest/),itmp)
itmp(:) = ncsec
ierr = pio_put_var(tape%File, tape%datesecid,(/nfils/),(/ncols * sathist_nclosest/),itmp)
ierr = pio_put_var(tape%Files(1), tape%datesecid,(/nfils/),(/ncols * sathist_nclosest/),itmp)
rtmp(:) = time
ierr = pio_put_var(tape%File, tape%timeid, (/nfils/),(/ncols * sathist_nclosest/),rtmp)
ierr = pio_put_var(tape%Files(1), tape%timeid, (/nfils/),(/ncols * sathist_nclosest/),rtmp)

deallocate(itmp)
deallocate(rtmp)

! output model column coordinates
ierr = pio_put_var(tape%File, out_latid, (/nfils/),(/ncols * sathist_nclosest/), mod_lats)
ierr = pio_put_var(tape%File, out_lonid, (/nfils/),(/ncols * sathist_nclosest/), mod_lons)
ierr = pio_put_var(tape%File, out_dstid, (/nfils/),(/ncols * sathist_nclosest/), mod_dists / 1000._r8)
ierr = pio_put_var(tape%Files(1), out_latid, (/nfils/),(/ncols * sathist_nclosest/), mod_lats)
ierr = pio_put_var(tape%Files(1), out_lonid, (/nfils/),(/ncols * sathist_nclosest/), mod_lons)
ierr = pio_put_var(tape%Files(1), out_dstid, (/nfils/),(/ncols * sathist_nclosest/), mod_dists / 1000._r8)

! output instrument location
allocate( out_lats(ncols * sathist_nclosest) )
Expand All @@ -786,40 +786,40 @@ subroutine write_record_coord( tape, mod_lats, mod_lons, mod_dists, ncols, nfils
out_lons(((i-1)*sathist_nclosest)+1 : (i*sathist_nclosest)) = obs_lons(i)
enddo

ierr = pio_put_var(tape%File, out_instr_lat_vid, (/nfils/),(/ncols * sathist_nclosest/), out_lats)
ierr = pio_put_var(tape%File, out_instr_lon_vid, (/nfils/),(/ncols * sathist_nclosest/), out_lons)
ierr = pio_put_var(tape%Files(1), out_instr_lat_vid, (/nfils/),(/ncols * sathist_nclosest/), out_lats)
ierr = pio_put_var(tape%Files(1), out_instr_lon_vid, (/nfils/),(/ncols * sathist_nclosest/), out_lons)

deallocate(out_lats)
deallocate(out_lons)


ierr = copy_data( infile, date_vid, tape%File, out_obs_date_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, time_vid, tape%File, out_obs_time_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, date_vid, tape%Files(1), out_obs_date_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, time_vid, tape%Files(1), out_obs_time_vid, in_start_col, nfils, ncols )

! output observation identifiers
if (instr_vid>0) then
ierr = copy_data( infile, instr_vid, tape%File, out_instrid, in_start_col, nfils, ncols )
ierr = copy_data( infile, instr_vid, tape%Files(1), out_instrid, in_start_col, nfils, ncols )
endif
if (orbit_vid>0) then
ierr = copy_data( infile, orbit_vid, tape%File, out_orbid, in_start_col, nfils, ncols )
ierr = copy_data( infile, orbit_vid, tape%Files(1), out_orbid, in_start_col, nfils, ncols )
endif
if (prof_vid>0) then
ierr = copy_data( infile, prof_vid, tape%File, out_profid, in_start_col, nfils, ncols )
ierr = copy_data( infile, prof_vid, tape%Files(1), out_profid, in_start_col, nfils, ncols )
endif
if (zenith_vid>0) then
ierr = copy_data( infile, zenith_vid, tape%File, out_zenithid, in_start_col, nfils, ncols )
ierr = copy_data( infile, zenith_vid, tape%Files(1), out_zenithid, in_start_col, nfils, ncols )
endif
if (in_julian_vid>0) then
ierr = copy_data( infile, in_julian_vid, tape%File, out_julian_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, in_julian_vid, tape%Files(1), out_julian_vid, in_start_col, nfils, ncols )
endif
if (in_occ_type_vid>0) then
ierr = copy_data( infile, in_occ_type_vid, tape%File, out_occ_type_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, in_occ_type_vid, tape%Files(1), out_occ_type_vid, in_start_col, nfils, ncols )
endif
if (in_localtime_vid>0) then
ierr = copy_data( infile, in_localtime_vid, tape%File, out_localtime_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, in_localtime_vid, tape%Files(1), out_localtime_vid, in_start_col, nfils, ncols )
endif
if (in_doy_vid>0) then
ierr = copy_data( infile, in_doy_vid, tape%File, out_doy_vid, in_start_col, nfils, ncols )
ierr = copy_data( infile, in_doy_vid, tape%Files(1), out_doy_vid, in_start_col, nfils, ncols )
endif

call t_stopf ('sat_hist::write_record_coord')
Expand Down
Loading

0 comments on commit 32f2772

Please sign in to comment.