Skip to content

Commit

Permalink
bug fix: disable concurrency in GFS_phys_time_vary_init NetCDF calls (
Browse files Browse the repository at this point in the history
…#735)

* Remove nfhout, nfhout_hf, nsout

* Do not open 'coupler.res' file with status 'new'

* bug fix: no concurrent NetCDF calls in GFS_phys_time_vary_init

---------

Co-authored-by: Dusan Jovic <[email protected]>
  • Loading branch information
SamuelTrahanNOAA and DusanJovic-NOAA authored Dec 19, 2023
1 parent a82381c commit f221fc5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 78 deletions.
4 changes: 2 additions & 2 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module atmos_model_mod
use fv_ufs_restart_io_mod, only: fv_dyn_restart_register, &
fv_dyn_restart_output
use fv_iau_mod, only: iau_external_data_type,getiauforcing,iau_initialize
use module_fv3_config, only: first_kdt, nsout, output_fh, &
use module_fv3_config, only: first_kdt, output_fh, &
fcst_mpi_comm, fcst_ntasks, &
quilting_restart
use module_block_data, only: block_atmos_copy, block_data_copy, &
Expand Down Expand Up @@ -976,7 +976,7 @@ subroutine update_atmos_model_state (Atmos, rc)
call get_time (Atmos%Time - diag_time, isec)
call get_time (Atmos%Time - Atmos%Time_init, seconds)
call atmosphere_nggps_diag(Atmos%Time,ltavg=.true.,avg_max_length=avg_max_length)
if (ANY(nint(output_fh(:)*3600.0) == seconds) .or. (GFS_control%kdt == first_kdt) .or. nsout > 0) then
if (ANY(nint(output_fh(:)*3600.0) == seconds) .or. (GFS_control%kdt == first_kdt)) then
if (mpp_pe() == mpp_root_pe()) write(6,*) "---isec,seconds",isec,seconds
time_int = real(isec)
if(Atmos%iau_offset > zero) then
Expand Down
2 changes: 1 addition & 1 deletion ccpp/physics
73 changes: 3 additions & 70 deletions fv3_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ module fv3atm_cap_mod
NUOPC_ModelGet
!
use module_fv3_config, only: quilting, quilting_restart, output_fh, &
nfhout, nfhout_hf, nsout, dt_atmos, &
dt_atmos, &
calendar, cpl_grid_id, &
cplprint_flag, first_kdt

use module_fv3_io_def, only: num_pes_fcst,write_groups, &
num_files, filename_base, &
wrttasks_per_group, n_group, &
lead_wrttask, last_wrttask, &
nsout_io, iau_offset, lflname_fulltime, &
iau_offset, lflname_fulltime, &
time_unlimited
!
use module_fcst_grid_comp, only: fcstSS => SetServices
Expand Down Expand Up @@ -301,7 +301,6 @@ subroutine InitializeAdvertise(gcomp, rc)
if(mype == 0) print *,'af ufs config,quilting=',quilting,' calendar=', trim(calendar),' iau_offset=',iau_offset, &
' noutput_fh=',noutput_fh
!
nfhout = 0 ; nfhmax_hf = 0 ; nfhout_hf = 0 ; nsout = 0
if ( quilting ) then
call ESMF_ConfigGetAttribute(config=CF,value=use_saved_routehandles, &
label ='use_saved_routehandles:', &
Expand Down Expand Up @@ -334,15 +333,6 @@ subroutine InitializeAdvertise(gcomp, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
enddo

! variables for output
call ESMF_ConfigGetAttribute(config=CF, value=nfhout, label ='nfhout:', default=-1,rc=rc)
call ESMF_ConfigGetAttribute(config=CF, value=nfhmax_hf,label ='nfhmax_hf:',default=-1,rc=rc)
call ESMF_ConfigGetAttribute(config=CF, value=nfhout_hf,label ='nfhout_hf:',default=-1,rc=rc)
call ESMF_ConfigGetAttribute(config=CF, value=nsout, label ='nsout:', default=-1,rc=rc)
nsout_io = nsout
!
if(mype==0) print *,'af ufs config,nfhout,nsout=',nfhout,nfhmax_hf,nfhout_hf, nsout,noutput_fh

call ESMF_ConfigGetAttribute(config=CF, value=time_unlimited, label ='time_unlimited:', default=.false., rc=rc)

endif ! quilting
Expand Down Expand Up @@ -819,64 +809,7 @@ subroutine InitializeAdvertise(gcomp, rc)
if(iau_offset > 0) then
output_startfh = iau_offset
endif
if(mype==0) print *,'in fv3 cap init, output_startfh=',output_startfh,'nsout=',nsout, &
'iau_offset=',iau_offset,'nfhmax_hf=',nfhmax_hf,'nfhout_hf=',nfhout_hf, &
'nfhout=',nfhout
!
!--- set up output_fh with output forecast hours
! if the run does not have iau, it will have output after first step integration as fh00
! if the run has iau, it will start output at fh=00 at the cycle time (usually StartTime+IAU_offsetTI)
if(nsout > 0) then
!--- use nsout for output frequency nsout*dt_atmos
nfh = 0
if( nfhmax > output_startfh ) nfh = nint((nfhmax-output_startfh)/(nsout*dt_atmos/3600.))+1
if(nfh >0) then
allocate(output_fh(nfh))
if( output_startfh == 0) then
output_fh(1) = dt_atmos/3600.
else
output_fh(1) = output_startfh
endif
do i=2,nfh
output_fh(i) = (i-1)*nsout*dt_atmos/3600. + output_startfh
enddo
endif
elseif (nfhmax_hf > 0 ) then
!--- use high frequency output and low frequency for output forecast time
nfh = 0
if( nfhout_hf>0 .and. nfhmax_hf>output_startfh) nfh = nint((nfhmax_hf-output_startfh)/nfhout_hf)+1
nfh2 = 0
if( nfhout>0 .and. nfhmax>nfhmax_hf) nfh2 = nint((nfhmax-nfhmax_hf)/nfhout)
if( nfh+nfh2 > 0) then
allocate(output_fh(nfh+nfh2))
if( output_startfh == 0) then
output_fh(1) = dt_atmos/3600.
else
output_fh(1) = output_startfh
endif
do i=2,nfh
output_fh(i) = (i-1)*nfhout_hf + output_startfh
enddo
do i=1,nfh2
output_fh(nfh+i) = nfhmax_hf + i*nfhout
enddo
endif
elseif (nfhout > 0 ) then
!--- use one output freqency
nfh = 0
if( nfhout > 0 .and. nfhmax>output_startfh) nfh = nint((nfhmax-output_startfh)/nfhout) + 1
if( nfh > 0 ) then
allocate(output_fh(nfh))
if( output_startfh == 0) then
output_fh(1) = dt_atmos/3600.
else
output_fh(1) = output_startfh
endif
do i=2,nfh
output_fh(i) = (i-1)*nfhout + output_startfh
enddo
endif
endif
if(mype==0) print *,'in fv3 cap init, output_startfh=',output_startfh,' iau_offset=',iau_offset
!
!-----------------------------------------------------------------------
!*** SET THE FIRST WRITE GROUP AS THE FIRST ONE TO ACT.
Expand Down
2 changes: 1 addition & 1 deletion io/module_fv3_io_def.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module module_fv3_io_def
integer :: n_group
integer :: num_files
integer :: nbdlphys
integer :: nsout_io, iau_offset
integer :: iau_offset
logical :: lflname_fulltime
logical :: time_unlimited

Expand Down
5 changes: 2 additions & 3 deletions io/module_wrt_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ module module_wrt_grid_comp
imo,jmo,ichunk2d,jchunk2d, &
ichunk3d,jchunk3d,kchunk3d, &
quantize_mode,quantize_nsd, &
nsout => nsout_io, &
cen_lon, cen_lat, &
lon1, lat1, lon2, lat2, dlon, dlat, &
stdlat1, stdlat2, dx, dy, iau_offset, &
Expand Down Expand Up @@ -1876,7 +1875,7 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)

if (nf_hours < 0) return

if (nsout > 0 .or. lflname_fulltime) then
if (lflname_fulltime) then
ndig = max(log10(nf_hours+0.5)+1., 3.)
write(cform, '("(I",I1,".",I1,",A1,I2.2,A1,I2.2)")') ndig, ndig
write(cfhour, cform) nf_hours,'-',nf_minutes,'-',nf_seconds
Expand Down Expand Up @@ -2448,7 +2447,7 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)

if (out_phase == 2 .and. restart_written .and. mype == lead_write_task) then
!** write coupler.res log file
open(newunit=nolog, file='RESTART/'//trim(time_restart)//'.coupler.res', status='new')
open(newunit=nolog, file='RESTART/'//trim(time_restart)//'.coupler.res')
write(nolog,"(i6,8x,a)") calendar_type , &
'(Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4)'
write(nolog,"(6i6,8x,a)") start_time(1:6), &
Expand Down
2 changes: 1 addition & 1 deletion module_fv3_config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module module_fv3_config

implicit none
!
integer :: nfhout, nfhout_hf, nsout, dt_atmos
integer :: dt_atmos
integer :: first_kdt
integer :: fcst_mpi_comm, fcst_ntasks
!
Expand Down

0 comments on commit f221fc5

Please sign in to comment.