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

Mixed precision topography_mod #1250

Merged
merged 49 commits into from
Aug 31, 2023
Merged

Conversation

mcallic2
Copy link
Contributor

@mcallic2 mcallic2 commented Jun 7, 2023

Description
Adds mixed precision capabilities to topography_mod

Fixes # (issue)

How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also note
any relevant details for your test configuration (e.g. compiler, OS). Include
enough information so someone can reproduce your tests.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@mcallic2 mcallic2 marked this pull request as draft June 7, 2023 14:57
topography/include/topography.inc Outdated Show resolved Hide resolved
topography/include/topography.inc Outdated Show resolved Hide resolved
@@ -105,9 +110,9 @@ module gaussian_topog_mod
!! by variables in the namelist.
subroutine gaussian_topog_init ( lon, lat, zsurf )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this subroutine wasn't moved to the inc file?

wlat = 15.*dtr; if (present(wlatd)) wlat=wlatd*dtr
rlon = 0. ; if (present(rlond)) rlon=rlond*dtr
rlat = 0. ; if (present(rlatd)) rlat=rlatd*dtr
olon = 90.0_lkind*dtr; if (present(olond)) olon=olond*dtr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

olon=real(olond*dtr, lkind) and for below too


! compute gaussian-shaped mountain
do j=1,size(lat(:))
dy = abs(lat(j) - olat) ! dist from y origin
yy = max(0., dy-rlat)/wlat
yy = max(0.0_lkind, dy-rlat)/wlat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all module levels variables are declared as r8_kind. you need to convert them to lkind

integer :: namelen
function open_topog_file ( )
logical :: open_topog_file
real(kind=r8_kind) :: r_ipts, r_jpts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im wondering if these could be r4_kind if the whole purpose of this subroutine is to open the topog_file and get ipts and jpts

@mlee03
Copy link
Contributor

mlee03 commented Aug 29, 2023

@mcallic2 i made a PR to your branch

! The variables in this namelist are only used when routine
! <TT>gaussian_topog_init</TT> is called. The namelist variables
! are dimensioned (by 10), so that multiple mountains can be generated.
!> @brief Returns a simple surface height field that consists of a single
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this comment block to right above the function its documenting (get_gaussian_topog). If its not right above the routine it won't get parsed correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in b55e5da

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only moved the first 3 lines (the brief description), the rest ofit needs to be moved (lines 35-59)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still lost as to why the comments for get_gaussian_topog is moved here above gaussian_topog_init...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do lines 34-35 also need to be moved down?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are fine, it'll just read the first !> as the brief descriptions and the second part as the expanded.

topography/include/topography.inc Outdated Show resolved Hide resolved
! The variables in this namelist are only used when routine
! <TT>gaussian_topog_init</TT> is called. The namelist variables
! are dimensioned (by 10), so that multiple mountains can be generated.
!> The height, position, width, and elongation of the mountain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment block has been misplaced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rem1776 told me to move it for documentation, it's right above get_gaussian_topog now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to be above gaussian_topog_init?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its below end subroutine gaussian_topog_init

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcallic2
Copy link
Contributor Author

@mlee03 @rem1776 friends, I went back and read through the comments. I understand what both of you are saying. I "reorganized" the comment blocks (in be19229) to coincide with their respective routines. Let me know if ya'll agree.

olat = 45.0_r8_kind*dtr; if (present(olatd)) olat=real(olatd*dtr,r8_kind)
wlon = 15.0_r8_kind*dtr; if (present(wlond)) wlon=real(wlond*dtr,r8_kind)
wlat = 15.0_r8_kind*dtr; if (present(wlatd)) wlat=real(wlatd*dtr,r8_kind)
olon = 90.0_r8_kind*real(dtr, r8_kind); if (present(olond)) olon=real(olond*dtr,r8_kind)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

real(dtr,r8_kind) isn't necessary but ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran gcc with all the warnings and there were conversion errors, I can send you the path to it if you wanna look

@rem1776 rem1776 merged commit 497ab46 into NOAA-GFDL:mixedmode Aug 31, 2023
19 checks passed
rem1776 added a commit that referenced this pull request Sep 20, 2023
BREAKING CHANGE: In coupler_types.F90,  `coupler_nd_field_type` and `coupler_nd_values_type` have been renamed to indicate real kind value: `coupler_nd_real4/8_field_type` and `coupler_nd_real4/8_values_type`. The `bc` field within `coupler_nd_bc_type` was modified to use r8_kind within the value and field types, and an additional field added `bc_r4` to use r4_kind values.

Includes:

* feat: eliminate use of real numbers for mixed precision in `block_control` (#1195)

* feat: mixed precision field_manager  (#1205)

* feat: mixed precision random_numbers_mod (#1191)

* feat: mixed precision time_manager reals to r8 and clean up (#1196)

* feat: mixed Precision tracer_manager  (#1212)

* Mixed precision monin_obukhov (#1116)

* Mixed precision: `monin_obukhov` unit tests (#1272)

* mixed-precision diag_integral_mod  (#1217)

* mixed precision time_interp (#1252)

* mixed precision interpolator_mod  (#1305)

* Mixed precision astronomy (#1092)

* Mixed precision `data_override_mod` (#1323)

* mixed precision exchange (#1341)

* coupler mixed precision (#1353)

* Mixed precision topography_mod (#1250)

---------

Co-authored-by: rem1776 <[email protected]>
Co-authored-by: MiKyung Lee <[email protected]>
Co-authored-by: mlee03 <[email protected]>
Co-authored-by: Caitlyn McAllister <[email protected]>
Co-authored-by: Jesse Lentz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants