Skip to content

Commit 4a7c519

Browse files
authored
Merge pull request #153 from GEOS-ESM/feature/bmauer/ncread_2d_r8_interface
Update so that interp_restarts.x will build when FV_PRECISION=R8
2 parents d7fa899 + e6c8367 commit 4a7c519

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

fv_regrid_c2c.F90

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,48 @@ module fv_regrid_c2c
5959
integer :: IUNIT=15
6060
integer :: OUNIT=16
6161

62+
interface read_topo_file
63+
module procedure read_topo_file_r4
64+
module procedure read_topo_file_r8
65+
end interface
66+
6267
contains
68+
69+
subroutine read_topo_file_r4(fname,output,grid,rc)
70+
character(len=*), intent(in) :: fname
71+
type(ESMF_Grid), intent(in) :: grid
72+
real(real4), intent(inout) :: output(:,:)
73+
integer, intent(out), optional :: rc
74+
75+
integer :: status,dims(3),funit
76+
real, allocatable :: input(:,:)
77+
call MAPL_GridGet(grid,globalCellCountPerDim=dims,_RC)
78+
allocate(input(dims(1),dims(2)))
79+
open(newunit=funit,file=trim(fname),form='unformatted',iostat=status)
80+
_VERIFY(status)
81+
read(funit)input
82+
call ArrayScatter(local_array=output,global_array=input,grid=grid,_RC)
83+
_RETURN(_SUCCESS)
84+
end subroutine read_topo_file_r4
85+
86+
subroutine read_topo_file_r8(fname,output,grid,rc)
87+
character(len=*), intent(in) :: fname
88+
type(ESMF_Grid), intent(in) :: grid
89+
real(real8), intent(inout) :: output(:,:)
90+
integer, intent(out), optional :: rc
91+
92+
integer :: status,dims(3),funit
93+
real, allocatable :: input(:,:)
94+
real(real8), allocatable :: input_r8(:,:)
95+
call MAPL_GridGet(grid,globalCellCountPerDim=dims,_RC)
96+
allocate(input(dims(1),dims(2)),input_r8(dims(2),dims(2)))
97+
open(newunit=funit,file=trim(fname),form='unformatted',iostat=status)
98+
_VERIFY(status)
99+
read(funit)input
100+
input_r8 = input
101+
call ArrayScatter(local_array=output,global_array=input_r8,grid=grid,_RC)
102+
_RETURN(_SUCCESS)
103+
end subroutine read_topo_file_r8
63104

64105
subroutine get_geos_ic( Atm, extra_rst, rstcube, gridOut)
65106

@@ -1880,23 +1921,6 @@ end subroutine mpp_domain_decomp
18801921
!
18811922
! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !
18821923
!-------------------------------------------------------------------------------
1883-
1884-
subroutine read_topo_file(fname,output,grid,rc)
1885-
character(len=*), intent(in) :: fname
1886-
type(ESMF_Grid), intent(in) :: grid
1887-
real(real4), intent(inout) :: output(:,:)
1888-
integer, intent(out), optional :: rc
18891924

1890-
integer :: status,dims(3),funit
1891-
real, allocatable :: input(:,:)
1892-
call MAPL_GridGet(grid,globalCellCountPerDim=dims,_RC)
1893-
allocate(input(dims(1),dims(2)))
1894-
open(newunit=funit,file=trim(fname),form='unformatted',iostat=status)
1895-
_VERIFY(status)
1896-
read(funit)input
1897-
call ArrayScatter(local_array=output,global_array=input,grid=grid,_RC)
1898-
_RETURN(_SUCCESS)
1899-
end subroutine read_topo_file
1900-
19011925
end module fv_regrid_c2c
19021926

fv_regrid_c2c_bin.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ subroutine get_geos_ic_bin( Atm, extra_rst, rstcube, gridOut)
9797
if (extra_rst(i)%have_descriptor) then
9898
do j=1,size(extra_rst(i)%vars)
9999
if (extra_rst(i)%vars(j)%nLev/=1) then
100-
allocate(extra_rst(i)%vars(j)%ptr3d(isd:ied,jsd:jed,extra_rst(i)%vars(j)%nLev),source=0.0 )
100+
allocate(extra_rst(i)%vars(j)%ptr3d(isd:ied,jsd:jed,extra_rst(i)%vars(j)%nLev),source=0.0_FVPRC )
101101
else
102-
allocate(extra_rst(i)%vars(j)%ptr2d(isd:ied,jsd:jed), source=0.0 )
102+
allocate(extra_rst(i)%vars(j)%ptr2d(isd:ied,jsd:jed), source=0.0_FVPRC )
103103
end if
104104
enddo
105105
else
106106
do j=1,size(extra_rst(i)%vars)
107-
allocate(extra_rst(i)%vars(j)%ptr3d(isd:ied,jsd:jed,extra_rst(i)%vars(j)%nLev),source=0.0 )
107+
allocate(extra_rst(i)%vars(j)%ptr3d(isd:ied,jsd:jed,extra_rst(i)%vars(j)%nLev),source=0.0_FVPRC )
108108
enddo
109109
end if
110110
enddo

fv_regridding_utils.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ subroutine alloc_var(this,is,ie,js,je,km,rc)
7373
integer :: km_use
7474

7575
if (this%rank==2) then
76-
allocate(this%ptr2d(is:ie,js:je),source=0.0)
76+
allocate(this%ptr2d(is:ie,js:je),source=0.0_FVPRC)
7777
else if (this%rank==3) then
7878
if (this%n_ungrid > 0) then
79-
allocate(this%ptr3d(is:ie,js:je,this%n_ungrid),source=0.0)
79+
allocate(this%ptr3d(is:ie,js:je,this%n_ungrid),source=0.0_FVPRC)
8080
else if (this%n_ungrid == 0) then
8181
if (present(km)) then
8282
km_use = km
8383
else
8484
km_use = this%nlev
8585
end if
86-
allocate(this%ptr3d(is:ie,js:je,km_use),source=0.0)
86+
allocate(this%ptr3d(is:ie,js:je,km_use),source=0.0_FVPRC)
8787
end if
8888
else if (this%rank == 4) then
8989
if (present(km)) then
9090
km_use = km
9191
else
9292
km_use = this%nlev
9393
end if
94-
allocate(this%ptr4d(is:ie,js:je,km_use,this%n_ungrid),source=0.0)
94+
allocate(this%ptr4d(is:ie,js:je,km_use,this%n_ungrid),source=0.0_FVPRC)
9595
end if
9696
_RETURN(_SUCCESS)
9797

0 commit comments

Comments
 (0)