Skip to content

Commit adebc78

Browse files
authored
Remove obsolete commented writer code
1 parent 72fa4ed commit adebc78

1 file changed

Lines changed: 26 additions & 38 deletions

File tree

src/cece_cap.F90

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -643,48 +643,36 @@ subroutine CECE_InitializeRealize(comp, importState, exportState, clock, rc)
643643
g_start_time_seconds = real(yy*365*24*3600 + mm*30*24*3600 + dd*24*3600 + &
644644
h*3600 + m*60 + s, c_double)
645645

646-
! Extract coordinates from ESMF grid and call enhanced writer initialization
646+
! Build 1-D cell-center coordinates directly from configured YAML grid bounds.
647+
! This keeps standalone NetCDF output lon/lat metadata consistent with the
648+
! configured CECE output grid and avoids falling back to the legacy writer,
649+
! which hard-codes global -180..180 / -90..90 coordinates.
647650
block
648-
real(ESMF_KIND_R8), pointer :: grid_lon(:,:), grid_lat(:,:)
649651
real(c_double), allocatable :: lon_coords(:), lat_coords(:)
652+
real(c_double) :: dlon, dlat
650653
integer :: i
651654

652-
! Get coordinates from ESMF grid (2D arrays)
653-
call ESMF_GridGetCoord(grid, coordDim=1, localDE=0, staggerloc=ESMF_STAGGERLOC_CENTER, &
654-
farrayptr=grid_lon, rc=rc)
655-
if (rc /= ESMF_SUCCESS) then
656-
write(*,'(A,I0)') "WARNING: [CECE] Failed to get longitude coordinates: rc=", rc
657-
! Fall back to legacy initialization
658-
call cece_core_writer_initialize(g_cece_data_ptr, int(nx, c_int), int(ny, c_int), &
659-
int(nz, c_int), start_time_str, int(len_trim(start_time_str), c_int), c_rc)
660-
else
661-
call ESMF_GridGetCoord(grid, coordDim=2, localDE=0, staggerloc=ESMF_STAGGERLOC_CENTER, &
662-
farrayptr=grid_lat, rc=rc)
663-
if (rc /= ESMF_SUCCESS) then
664-
write(*,'(A,I0)') "WARNING: [CECE] Failed to get latitude coordinates: rc=", rc
665-
! Fall back to legacy initialization
666-
call cece_core_writer_initialize(g_cece_data_ptr, int(nx, c_int), int(ny, c_int), &
667-
int(nz, c_int), start_time_str, int(len_trim(start_time_str), c_int), c_rc)
668-
else
669-
! Extract 1D coordinate arrays from 2D ESMF grid coordinates
670-
allocate(lon_coords(nx), lat_coords(ny))
671-
do i = 1, nx
672-
lon_coords(i) = real(grid_lon(i,1), c_double) ! First row, all columns
673-
end do
674-
do i = 1, ny
675-
lat_coords(i) = real(grid_lat(1,i), c_double) ! First column, all rows
676-
end do
677-
678-
write(*,'(A,2F10.3)') "INFO: [CECE] Grid longitude range: ", lon_coords(1), lon_coords(nx)
679-
write(*,'(A,2F10.3)') "INFO: [CECE] Grid latitude range: ", lat_coords(1), lat_coords(ny)
680-
681-
! Call enhanced writer initialization with coordinates
682-
call cece_core_writer_initialize_with_coords(g_cece_data_ptr, int(nx, c_int), int(ny, c_int), &
683-
int(nz, c_int), lon_coords, lat_coords, &
684-
start_time_str, int(len_trim(start_time_str), c_int), c_rc)
685-
deallocate(lon_coords, lat_coords)
686-
end if
687-
end if
655+
allocate(lon_coords(nx), lat_coords(ny))
656+
657+
dlon = real(lon_max - lon_min, c_double) / real(nx, c_double)
658+
dlat = real(lat_max - lat_min, c_double) / real(ny, c_double)
659+
660+
do i = 1, nx
661+
lon_coords(i) = real(lon_min, c_double) + dlon * (real(i, c_double) - 0.5_c_double)
662+
end do
663+
664+
do i = 1, ny
665+
lat_coords(i) = real(lat_min, c_double) + dlat * (real(i, c_double) - 0.5_c_double)
666+
end do
667+
668+
write(*,'(A,2F12.5)') "INFO: [CECE] Writer longitude range: ", lon_coords(1), lon_coords(nx)
669+
write(*,'(A,2F12.5)') "INFO: [CECE] Writer latitude range: ", lat_coords(1), lat_coords(ny)
670+
671+
call cece_core_writer_initialize_with_coords(g_cece_data_ptr, int(nx, c_int), int(ny, c_int), &
672+
int(nz, c_int), lon_coords, lat_coords, &
673+
start_time_str, int(len_trim(start_time_str), c_int), c_rc)
674+
675+
deallocate(lon_coords, lat_coords)
688676
end block
689677

690678
rc = int(c_rc)

0 commit comments

Comments
 (0)