diff --git a/io/post_gfs.F90 b/io/post_gfs.F90 index 4fb16535d..0907d7d76 100644 --- a/io/post_gfs.F90 +++ b/io/post_gfs.F90 @@ -156,15 +156,19 @@ subroutine post_run_gfs(wrt_int_state,mypei,mpicomp,lead_write, & if(mype==0) print *,'af read_xml at fh00,name=',trim(filenameflat) else if(ifhr > 0) then filenameflat = 'postxconfig-NT.txt' - if(size(paramset)>0) then - do i=1,size(paramset) - if (size(paramset(i)%param)>0) then - deallocate(paramset(i)%param) - nullify(paramset(i)%param) - endif - enddo - deallocate(paramset) - nullify(paramset) + if(associated(paramset)) then + if( size(paramset)>0) then + do i=1,size(paramset) + if (associated(paramset(i)%param)) then + if (size(paramset(i)%param)>0) then + deallocate(paramset(i)%param) + nullify(paramset(i)%param) + endif + endif + enddo + deallocate(paramset) + nullify(paramset) + endif endif num_pset = 0 call read_xml() diff --git a/io/post_regional.F90 b/io/post_regional.F90 index 34c6ffcd5..773e8dcc4 100644 --- a/io/post_regional.F90 +++ b/io/post_regional.F90 @@ -160,13 +160,17 @@ subroutine post_run_regional(wrt_int_state,mypei,mpicomp,lead_write, & if(mype==0) print *,'af read_xml at fh00,name=',trim(filenameflat) else if(ifhr > 0) then filenameflat = 'postxconfig-NT.txt' - if(size(paramset)>0) then - do i=1,size(paramset) - if (size(paramset(i)%param)>0) then - deallocate(paramset(i)%param) - nullify(paramset(i)%param) - endif - enddo + if(associated(paramset)) then + if(size(paramset)>0) then + do i=1,size(paramset) + if (associated(paramset(i)%param)) then + if (size(paramset(i)%param)>0) then + deallocate(paramset(i)%param) + nullify(paramset(i)%param) + endif + endif + enddo + endif deallocate(paramset) nullify(paramset) endif