diff --git a/interp.F90 b/interp.F90 index 7fcef59..42bf5cd 100644 --- a/interp.F90 +++ b/interp.F90 @@ -127,7 +127,7 @@ subroutine fill_missing_bundle(localpet,in_bundle,out_bundle,nd,nx,ny, & type(realptr_2d),allocatable :: fptr2(:) type(realptr_3d),allocatable :: fptr3(:) character(len=50) :: fname - integer :: num_fields, i, j, k, ij, l(1), u(1), rc + integer :: num_fields, i, j, k, ij, l(1), u(1), rc, ndims integer :: isrctermprocessing isrctermprocessing = 1 @@ -156,11 +156,8 @@ subroutine fill_missing_bundle(localpet,in_bundle,out_bundle,nd,nx,ny, & if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldBundleGet", rc) - if (nd==2) then - allocate(fptr2(num_fields)) - elseif (nd==3) then - allocate(fptr3(num_fields)) - endif + allocate(fptr2(num_fields)) + allocate(fptr3(num_fields)) do i=1, num_fields call ESMF_FieldBundleGet(out_bundle,i,field,rc=rc) @@ -169,12 +166,17 @@ subroutine fill_missing_bundle(localpet,in_bundle,out_bundle,nd,nx,ny, & call ESMF_FieldGet(field,name=fname,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) - if (nd==2) then + if (fname=="REFL_10CM") then + ndims = 3 + else + ndims = nd + endif + if (ndims==2) then if(localpet==0) print*, '- FIELDGET 2D', fname call ESMF_FieldGet(field,farrayPtr=fptr2(i)%p,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) - elseif (nd==3) then + elseif (ndims==3) then if(localpet==0) print*, '- FIELDGET 3D', fname call ESMF_FieldGet(field,farrayPtr=fptr3(i)%p,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& @@ -186,8 +188,20 @@ subroutine fill_missing_bundle(localpet,in_bundle,out_bundle,nd,nx,ny, & do ij = l(1), u(1) call ij_to_i_j(unmapped_ptr(ij), nx, ny, i, j) do k = 1, num_fields - if (nd==2) fptr2(k)%p(i,j) = missing_value - if (nd==3) fptr3(k)%p(i,j,:) = missing_value + call ESMF_FieldBundleGet(out_bundle,k,field,rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& + call error_handler("IN FieldBundleGet", rc) + call ESMF_FieldGet(field,name=fname,rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& + call error_handler("IN FieldGet", rc) + if (fname=="REFL_10CM") then + ndims = 3 + else + ndims = nd + endif + if(localpet==0) print*, k, ndims + if (ndims==2) fptr2(k)%p(i,j) = missing_value + if (ndims==3) fptr3(k)%p(i,j,:) = missing_value enddo enddo if (allocated(fptr2)) deallocate(fptr2) diff --git a/model_grid.F90 b/model_grid.F90 index eb5ae5b..0bfcc90 100644 --- a/model_grid.F90 +++ b/model_grid.F90 @@ -179,7 +179,7 @@ module model_grid !< with vertical dimension nVertLevelsp1 integer, public :: n_hist_fields_soil !< number of soil fields read from the hist file - integer, public :: diag_out_interval + real, public :: diag_out_interval !< output_interval from diag file integer, public :: do_u_interp !< whether 3d u is requested for interpolation diff --git a/write_data.F90 b/write_data.F90 index 224184f..28789c9 100644 --- a/write_data.F90 +++ b/write_data.F90 @@ -26,7 +26,7 @@ subroutine write_to_file(localpet) use program_setup, only: interp_diag, interp_hist, & wrf_mod_vars, truelat1, truelat2, & stand_lon, proj_code, map_proj_char, & - i_target, j_target, dx, & + i_target, j_target, dxkm, & ref_lat, ref_lon, pole_lat, & pole_lon, missing_value @@ -183,10 +183,10 @@ subroutine write_to_file(localpet) error = nf90_put_att(ncid, NF90_GLOBAL, 'START_DATE', start_time) call netcdf_err(error, 'DEFINING START DATE GLOBAL ATTRIBUTE') - error = nf90_put_att(ncid, NF90_GLOBAL, 'DX', dx) + error = nf90_put_att(ncid, NF90_GLOBAL, 'DX', dxkm) call netcdf_err(error, 'DEFINING DX GLOBAL ATTRIBUTE') - error = nf90_put_att(ncid, NF90_GLOBAL, 'DY', dx) + error = nf90_put_att(ncid, NF90_GLOBAL, 'DY', dxkm) call netcdf_err(error, 'DEFINING DY GLOBAL ATTRIBUTE') error = nf90_put_att(ncid, NF90_GLOBAL, 'DT', config_dt) @@ -1314,6 +1314,8 @@ subroutine write_to_file(localpet) ! 3d fields from diaglist + if (allocated(dum3d)) deallocate(dum3d) + allocate(dum3d(clb(1):cub(1),clb(2):cub(2),nz_input)) if (n3d > 0) then print *, "Loop writing over ", n3d, "3-d nz vars" do i = 1, n3d