Skip to content

Commit

Permalink
Merge branch 'NOAA-EMC:develop' into gaea_build
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBurrows-NCO authored May 23, 2024
2 parents fa2eaa2 + bb03e17 commit 8b68f57
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ program getsigensmeanp_smooth
filenameout = trim(adjustl(datapath)) // trim(adjustl(filenameout))
! if a 5th arg present, it's a filename to write out ensemble spread
! (only used for ncio)
write_spread_ncio = .false.
if (iargc() > 4) then
call getarg(5,filenameoutsprd)
write_spread_ncio = .true.
Expand All @@ -107,7 +108,7 @@ program getsigensmeanp_smooth
endif

if ( mype == 0 ) then
write(6,'(a)') 'Command line input'
write(6,'(a,i3,a)') 'Command line input for ',iargc(),' arguments'
write(6,'(a,a)')' datapath = ',trim(datapath)
write(6,'(a,a)')' filenameout = ',trim(filenameout)
write(6,'(a,a)')' fileprefix = ',trim(fileprefix)
Expand Down Expand Up @@ -588,22 +589,27 @@ program getsigensmeanp_smooth
endif
endif ! ndims > 2
enddo ! nvars
deallocate(values_2d, values_3d, values_2d_avg, values_3d_avg)
deallocate(values_2d_tmp, values_3d_tmp)
if (allocated(values_2d)) deallocate(values_2d)
if (allocated(values_3d)) deallocate(values_3d)
if (allocated(values_2d_avg)) deallocate(values_2d_avg)
if (allocated(values_3d_avg)) deallocate(values_3d_avg)
if (allocated(values_2d_tmp)) deallocate(values_2d_tmp)
if (allocated(values_3d_tmp)) deallocate(values_3d_tmp)
if (dosmooth) then
deallocate(rwork_spc)
call close_dataset(dseto_smooth)
endif
if (write_spread_ncio) then
deallocate(values_2d_sprd, values_3d_sprd)
if (allocated(values_2d_sprd)) deallocate(values_2d_sprd)
if (allocated(values_3d_sprd)) deallocate(values_3d_sprd)
endif
if (mype == 0) then
call close_dataset(dseto)
call close_dataset(dseto, errcode=iret)
t2 = mpi_wtime()
print *,'time to write ens mean on root',t2-t1
write(6,'(3a,i5)')'Write ncio ensemble mean ',trim(filenameout),' iret = ', iret
if (write_spread_ncio) then
call close_dataset(dseto_sprd)
call close_dataset(dseto_sprd, errcode=iret)
write(6,'(3a,i5)')'Write ncio ensemble spread ',trim(filenameoutsprd),' iret = ', iret
endif
endif
Expand Down Expand Up @@ -648,18 +654,19 @@ program getsigensmeanp_smooth
end if
end if ! end if 3D var
end do ! end loop through variables
deallocate(values_3d, values_3d_avg)
deallocate(values_3d_tmp)
if (allocated(values_3d)) deallocate(values_3d)
if (allocated(values_3d_avg)) deallocate(values_3d_avg)
if (allocated(values_3d_tmp)) deallocate(values_3d_tmp)
if (write_spread_ncio) then
deallocate(values_3d_sprd)
if (allocated(values_3d_sprd)) deallocate(values_3d_sprd)
endif
if (mype == 0) then
call close_dataset(dseto)
call close_dataset(dseto,errcode=iret)
t2 = mpi_wtime()
print *,'time to write ens mean on root',t2-t1
write(6,'(3a,i5)')'Write increment ensemble mean ',trim(filenameout),' iret = ', iret
if (write_spread_ncio) then
call close_dataset(dseto_sprd)
call close_dataset(dseto_sprd,errcode=iret)
write(6,'(3a,i5)')'Write increment ensemble spread ',trim(filenameoutsprd),' iret = ', iret
endif
endif
Expand Down
16 changes: 13 additions & 3 deletions src/EnKF/gfs/src/recentersigp.fd/recentersigp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ program recentersigp
call write_vardata(dseto,trim(dseti%variables(nvar)%name),values_3d)
end if
end do
deallocate(values_3d,values_3d_i,values_3d_mi,values_3d_mb,values_3d_anl)
if (allocated(values_3d)) deallocate(values_3d)
if (allocated(values_3d_i)) deallocate(values_3d_i)
if (allocated(values_3d_mi)) deallocate(values_3d_mi)
if (allocated(values_3d_mb)) deallocate(values_3d_mb)
if (allocated(values_3d_anl)) deallocate(values_3d_anl)
call write_attribute(dseto,'comment','recentered analysis increment using recentersigp')
call close_dataset(dsetmi)
call close_dataset(dsetmo)
Expand Down Expand Up @@ -369,8 +373,14 @@ program recentersigp
endif ! ndims > 2
enddo ! nvars

deallocate(values_2d,values_2d_i,values_2d_mi,values_2d_mo)
deallocate(values_3d,values_3d_i,values_3d_mi,values_3d_mo)
if (allocated(values_2d)) deallocate(values_2d)
if (allocated(values_2d_i)) deallocate(values_2d_i)
if (allocated(values_2d_mi)) deallocate(values_2d_mi)
if (allocated(values_2d_mo)) deallocate(values_2d_mo)
if (allocated(values_3d)) deallocate(values_3d)
if (allocated(values_3d_i)) deallocate(values_3d_i)
if (allocated(values_3d_mi)) deallocate(values_3d_mi)
if (allocated(values_3d_mo)) deallocate(values_3d_mo)
call close_dataset(dsetmi)
call close_dataset(dsetmo)
call close_dataset(dseti)
Expand Down

0 comments on commit 8b68f57

Please sign in to comment.