Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix initialization issue for moving nest grid in debug mode #622

Merged
merged 5 commits into from
Feb 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 53 additions & 40 deletions io/module_wrt_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,14 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
allocate( wrt_int_state%out_grid_info(n)%latPtr(wrt_int_state%out_grid_info(n)%i_start:wrt_int_state%out_grid_info(n)%i_end, &
wrt_int_state%out_grid_info(n)%j_start:wrt_int_state%out_grid_info(n)%j_end) )

do j=wrt_int_state%out_grid_info(n)%j_start, wrt_int_state%out_grid_info(n)%j_end
do i=wrt_int_state%out_grid_info(n)%i_start, wrt_int_state%out_grid_info(n)%i_end
wrt_int_state%out_grid_info(n)%latPtr(i,j) = latPtr(i,j)
wrt_int_state%out_grid_info(n)%lonPtr(i,j) = lonPtr(i,j)
enddo
enddo
if ( trim(output_grid(n)) /= 'regional_latlon_moving' .and. trim(output_grid(n)) /= 'rotated_latlon_moving' ) then
do j=wrt_int_state%out_grid_info(n)%j_start, wrt_int_state%out_grid_info(n)%j_end
do i=wrt_int_state%out_grid_info(n)%i_start, wrt_int_state%out_grid_info(n)%i_end
wrt_int_state%out_grid_info(n)%latPtr(i,j) = latPtr(i,j)
wrt_int_state%out_grid_info(n)%lonPtr(i,j) = lonPtr(i,j)
enddo
junwang-noaa marked this conversation as resolved.
Show resolved Hide resolved
enddo
endif

wrt_int_state%out_grid_info(n)%im = imo(n)
wrt_int_state%out_grid_info(n)%jm = jmo(n)
Expand Down Expand Up @@ -1076,19 +1078,20 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
name="grid", value="latlon", rc=rc)
call ESMF_AttributeAdd(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
attrList=(/"lon1","lat1","lon2","lat2","dlon","dlat"/), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon1", value=lon1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat1", value=lat1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon2", value=lon2(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat2", value=lat2(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="dlon", value=dlon(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="dlat", value=dlat(grid_id), rc=rc)

if (trim(output_grid(grid_id)) /= 'regional_latlon_moving') then
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon1", value=lon1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat1", value=lat1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon2", value=lon2(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat2", value=lat2(grid_id), rc=rc)
endif
else if (trim(output_grid(grid_id)) == 'rotated_latlon' &
.or. trim(output_grid(grid_id)) == 'rotated_latlon_moving') then

Expand All @@ -1108,19 +1111,20 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
name="cen_lon", value=cen_lon(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="cen_lat", value=cen_lat(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon1", value=lon1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat1", value=lat1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon2", value=lon2(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat2", value=lat2(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="dlon", value=dlon(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="dlat", value=dlat(grid_id), rc=rc)

if (trim(output_grid(grid_id)) /= 'rotated_latlon_moving') then
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon1", value=lon1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat1", value=lat1(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lon2", value=lon2(grid_id), rc=rc)
call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
name="lat2", value=lat2(grid_id), rc=rc)
endif
else if (trim(output_grid(grid_id)) == 'lambert_conformal') then

call ESMF_AttributeSet(wrt_int_state%wrtFB(i), convention="NetCDF", purpose="FV3", &
Expand Down Expand Up @@ -1393,7 +1397,7 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,

deallocate(attNameList, attNameList2, typekindList)
!
! write_init_tim = MPI_Wtime() - btim0
! write_init_tim = MPI_Wtime() - btim0
!
!-----------------------------------------------------------------------
!
Expand Down Expand Up @@ -1931,22 +1935,31 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)
#ifdef INLINE_POST
wbeg = MPI_Wtime()
do n=1,ngrids
if (trim(output_grid(n)) == 'regional_latlon' .or. &
trim(output_grid(n)) == 'regional_latlon_moving' .or. &
trim(output_grid(n)) == 'rotated_latlon' .or. &
trim(output_grid(n)) == 'rotated_latlon_moving' .or. &
trim(output_grid(n)) == 'lambert_conformal') then

!mask fields according to sfc pressure
do nbdl=1, wrt_int_state%FBCount
call mask_fields(wrt_int_state%wrtFB(nbdl),rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
enddo
lmask_fields = .true.
endif

call post_run_fv3(wrt_int_state, n, mype, wrt_mpi_comm, lead_write_task, &
itasks, jtasks, nf_hours, nf_minutes, nf_seconds)
if (trim(output_grid(n)) /= 'cubed_sphere_grid') then

if (trim(output_grid(n)) == 'regional_latlon' .or. &
trim(output_grid(n)) == 'regional_latlon_moving' .or. &
trim(output_grid(n)) == 'rotated_latlon' .or. &
trim(output_grid(n)) == 'rotated_latlon_moving' .or. &
trim(output_grid(n)) == 'lambert_conformal') then

!mask fields according to sfc pressure
do nbdl=1, wrt_int_state%FBCount
call mask_fields(wrt_int_state%wrtFB(nbdl),rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
enddo
lmask_fields = .true.
endif

call post_run_fv3(wrt_int_state, n, mype, wrt_mpi_comm, lead_write_task, &
itasks, jtasks, nf_hours, nf_minutes, nf_seconds)
else
rc = ESMF_RC_NOT_IMPL
print *,'Inline post not available for cubed_sphere_grid'
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
endif
enddo
wend = MPI_Wtime()
if (lprnt) then
Expand Down