Skip to content

Commit 69a6a08

Browse files
committed
This is a temporary fix for the 'original' dangling pointer bug
1 parent f4b4675 commit 69a6a08

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

geom/GridGet.F90

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include "MAPL.h"
22

33
module mapl3g_GridGet
4+
45
use esmf
56
use mapl_KeywordEnforcer
67
use mapl_ErrorHandling
8+
79
implicit none
810
private
911

@@ -30,18 +32,18 @@ subroutine grid_get(grid, unusable, &
3032

3133
type(esmf_Grid), intent(in) :: grid
3234
class(KeywordEnforcer), optional, intent(in) :: unusable
33-
character(:), optional, allocatable :: name
35+
character(:), optional, allocatable, intent(out) :: name
3436
integer, optional, intent(out) :: dimCount
3537
integer, optional, allocatable, intent(out) :: coordDimCount(:)
3638
integer, optional, intent(out) :: im, jm
37-
real(kind=ESMF_KIND_R4), optional, pointer :: longitudes(:,:), latitudes(:,:)
39+
real(kind=ESMF_KIND_R4), optional, allocatable, intent(out) :: longitudes(:,:)
40+
real(kind=ESMF_KIND_R4), optional, allocatable, intent(out) :: latitudes(:,:)
3841
integer, optional, intent(out) :: rc
3942

4043
integer :: dimCount_
4144
character(ESMF_MAXSTR) :: name_
4245
integer :: status
4346
real(kind=ESMF_KIND_R8), pointer :: coords(:,:)
44-
real(kind=ESMF_KIND_R4), allocatable, target :: lons(:,:), lats(:,:)
4547
logical :: has_de
4648

4749
call esmf_GridGet(grid, dimCount=dimCount_, _RC)
@@ -66,15 +68,11 @@ subroutine grid_get(grid, unusable, &
6668
end if
6769

6870
if (present(longitudes) .or. present(latitudes)) then
69-
call GridGetCoordinates(grid, longitudes=lons, latitudes=lats, _RC)
70-
if (present(longitudes)) then
71-
longitudes => lons
72-
end if
73-
if (present(latitudes)) then
74-
latitudes => lats
75-
end if
71+
call GridGetCoordinates(grid, longitudes=longitudes, latitudes=latitudes, _RC)
7672
end if
73+
7774
_RETURN(_SUCCESS)
75+
_UNUSED_DUMMY(unusable)
7876
end subroutine grid_get
7977

8078
logical function grid_has_DE(grid,rc) result(has_DE)
@@ -128,7 +126,6 @@ subroutine grid_get_coordinates_r8(grid, longitudes, latitudes, rc)
128126
latitudes = ptr
129127

130128
_RETURN(_SUCCESS)
131-
132129
end subroutine grid_get_coordinates_r8
133130

134131
end module mapl3g_GridGet

0 commit comments

Comments
 (0)