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

Add class(*) back to mixedmode diag_manager #1123

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
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
24 changes: 20 additions & 4 deletions diag_manager/diag_axis.F90
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ MODULE diag_axis_mod
INTEGER FUNCTION diag_axis_init(name, DATA, units, cart_name, long_name, direction,&
& set_name, edges, Domain, Domain2, DomainU, aux, req, tile_count, domain_position )
CHARACTER(len=*), INTENT(in) :: name !< Short name for axis
REAL, DIMENSION(:), INTENT(in) :: DATA !< Array of coordinate values
CLASS(*), DIMENSION(:), INTENT(in) :: DATA !< Array of coordinate values
CHARACTER(len=*), INTENT(in) :: units !< Units for the axis
CHARACTER(len=*), INTENT(in) :: cart_name !< Cartesian axis ("X", "Y", "Z", "T")
CHARACTER(len=*), INTENT(in), OPTIONAL :: long_name !< Long name for the axis.
Expand Down Expand Up @@ -228,7 +228,15 @@ INTEGER FUNCTION diag_axis_init(name, DATA, units, cart_name, long_name, directi

! Initialize Axes(diag_axis_init)
Axes(diag_axis_init)%name = TRIM(name)
Axes(diag_axis_init)%data = DATA(1:axlen)
SELECT TYPE (DATA)
TYPE IS (real(kind=r4_kind))
Axes(diag_axis_init)%data = DATA(1:axlen)
TYPE IS (real(kind=r8_kind))
Axes(diag_axis_init)%data = real(DATA(1:axlen))
CLASS DEFAULT
CALL error_mesg('diag_axis_mod::diag_axis_init',&
& 'The axis data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT
Axes(diag_axis_init)%units = units
Axes(diag_axis_init)%length = axlen
Axes(diag_axis_init)%set = set
Expand Down Expand Up @@ -457,7 +465,7 @@ SUBROUTINE get_diag_axis(id, name, units, long_name, cart_name,&
INTEGER, INTENT(out) :: direction !< Direction of data. (See <TT>@ref diag_axis_init</TT> for a description of
!! allowed values)
INTEGER, INTENT(out) :: edges !< Axis ID for the previously defined "edges axis".
REAL, DIMENSION(:), INTENT(out) :: DATA !< Array of coordinate values for this axis.
CLASS(*), DIMENSION(:), INTENT(out) :: DATA !< Array of coordinate values for this axis.
INTEGER, INTENT(out), OPTIONAL :: num_attributes
TYPE(diag_atttype), ALLOCATABLE, DIMENSION(:), INTENT(out), OPTIONAL :: attributes
INTEGER, INTENT(out), OPTIONAL :: domain_position
Expand All @@ -478,7 +486,15 @@ SUBROUTINE get_diag_axis(id, name, units, long_name, cart_name,&
! <ERROR STATUS="FATAL">array data is too small.</ERROR>
CALL error_mesg('diag_axis_mod::get_diag_axis', 'array data is too small', FATAL)
ELSE
DATA(1:Axes(id)%length) = Axes(id)%data(1:Axes(id)%length)
SELECT TYPE (DATA)
TYPE IS (real(kind=r4_kind))
DATA(1:Axes(id)%length) = real(Axes(id)%data(1:Axes(id)%length), kind=r4_kind)
TYPE IS (real(kind=r8_kind))
DATA(1:Axes(id)%length) = Axes(id)%data(1:Axes(id)%length)
CLASS DEFAULT
CALL error_mesg('diag_axis_mod::get_diag_axis',&
& 'The axis data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT
END IF
IF ( PRESENT(num_attributes) ) THEN
num_attributes = Axes(id)%num_attributes
Expand Down
73 changes: 63 additions & 10 deletions diag_manager/diag_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ MODULE diag_grid_mod
!! and before the first call to register the fields.
SUBROUTINE diag_grid_init(domain, glo_lat, glo_lon, aglo_lat, aglo_lon)
TYPE(domain2d), INTENT(in) :: domain !< The domain to which the grid data corresponds.
REAL, INTENT(in), DIMENSION(:,:) :: glo_lat !< The latitude information for the grid tile.
REAL, INTENT(in), DIMENSION(:,:) :: glo_lon !< The longitude information for the grid tile.
REAL, INTENT(in), DIMENSION(:,:) :: aglo_lat !< The latitude information for the a-grid tile.
REAL, INTENT(in), DIMENSION(:,:) :: aglo_lon !< The longitude information for the a-grid tile.
CLASS(*), INTENT(in), DIMENSION(:,:) :: glo_lat !< The latitude information for the grid tile.
CLASS(*), INTENT(in), DIMENSION(:,:) :: glo_lon !< The longitude information for the grid tile.
CLASS(*), INTENT(in), DIMENSION(:,:) :: aglo_lat !< The latitude information for the a-grid tile.
CLASS(*), INTENT(in), DIMENSION(:,:) :: aglo_lon !< The longitude information for the a-grid tile.

INTEGER, DIMENSION(1) :: tile
INTEGER :: ntiles
Expand Down Expand Up @@ -252,14 +252,67 @@ SUBROUTINE diag_grid_init(domain, glo_lat, glo_lon, aglo_lat, aglo_lon)
! If we are on tile 4 or 5, we need to transpose the grid to get
! this to work.
IF ( tile(1) == 4 .OR. tile(1) == 5 ) THEN
diag_global_grid%aglo_lat = TRANSPOSE(aglo_lat)
diag_global_grid%aglo_lon = TRANSPOSE(aglo_lon)
SELECT TYPE (aglo_lat)
TYPE IS (real(kind=r4_kind))
diag_global_grid%aglo_lat = TRANSPOSE(aglo_lat)
TYPE IS (real(kind=r8_kind))
diag_global_grid%aglo_lat = TRANSPOSE(real(aglo_lat))
CLASS DEFAULT
CALL error_mesg('diag_grid_mod::diag_grid_init',&
& 'The a-grid latitude data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT

SELECT TYPE (aglo_lon)
TYPE IS (real(kind=r4_kind))
diag_global_grid%aglo_lon = TRANSPOSE(aglo_lon)
TYPE IS (real(kind=r8_kind))
diag_global_grid%aglo_lon = TRANSPOSE(real(aglo_lon))
CLASS DEFAULT
CALL error_mesg('diag_grid_mod::diag_grid_init',&
& 'The a-grid longitude data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT
ELSE
diag_global_grid%aglo_lat = aglo_lat
diag_global_grid%aglo_lon = aglo_lon
SELECT TYPE (aglo_lat)
TYPE IS (real(kind=r4_kind))
diag_global_grid%aglo_lat = aglo_lat
TYPE IS (real(kind=r8_kind))
diag_global_grid%aglo_lat = real(aglo_lat)
CLASS DEFAULT
CALL error_mesg('diag_grid_mod::diag_grid_init',&
& 'The a-grid latitude data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT

SELECT TYPE (aglo_lon)
TYPE IS (real(kind=r4_kind))
diag_global_grid%aglo_lon = aglo_lon
TYPE IS (real(kind=r8_kind))
diag_global_grid%aglo_lon = real(aglo_lon)
CLASS DEFAULT
CALL error_mesg('diag_grid_mod::diag_grid_init',&
& 'The a-grid longitude data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT
END IF
diag_global_grid%glo_lat = glo_lat
diag_global_grid%glo_lon = glo_lon

SELECT TYPE (glo_lat)
TYPE IS (real(kind=r4_kind))
diag_global_grid%glo_lat = glo_lat
TYPE IS (real(kind=r8_kind))
diag_global_grid%glo_lat = real(glo_lat)
CLASS DEFAULT
CALL error_mesg('diag_grid_mod::diag_grid_init',&
& 'The grid latitude data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT

SELECT TYPE (glo_lon)
TYPE IS (real(kind=r4_kind))
diag_global_grid%glo_lon = glo_lon
TYPE IS (real(kind=r8_kind))
diag_global_grid%glo_lon = real(glo_lon)
CLASS DEFAULT
CALL error_mesg('diag_grid_mod::diag_grid_init',&
& 'The grid longitude data is not one of the supported types of real(kind=4) or real(kind=8)', FATAL)
END SELECT

diag_global_grid%dimI = i_dim
diag_global_grid%dimJ = j_dim
diag_global_grid%adimI = ai_dim
Expand Down
Loading