-
Notifications
You must be signed in to change notification settings - Fork 67
Add threading test to capgen_test; codee format test/capgen_test/*.F90
#722
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
Open
climbfuji
wants to merge
5
commits into
NCAR:develop
Choose a base branch
from
climbfuji:feature/capgen_threading_test
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
900069b
Add threading test to test/capgen_test
climbfuji a76f82c
Update codee to 2025.4.8 and simplify .github/workflows/fortran-forma…
climbfuji 24223ff
Codee format test/capgen_test/*.F90
climbfuji 419a6c2
Fix bug in test/capgen_test/test_host_mod.F90: set uninitialized cind…
climbfuji c221aaf
Revert formatting of certain constructs in test/capgen_test/temp_adju…
climbfuji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| module ddt2 | ||
|
|
||
| USE ccpp_kinds, ONLY: kind_phys | ||
| use ccpp_kinds, only: kind_phys | ||
|
|
||
| implicit none | ||
| implicit none | ||
|
|
||
| type ty_ddt2 | ||
| integer :: foo | ||
| real(kind_phys) :: bar | ||
| end type ty_ddt2 | ||
| type ty_ddt2 | ||
| integer :: foo | ||
| real(kind=kind_phys) :: bar | ||
| end type ty_ddt2 | ||
|
|
||
| end module ddt2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,143 +1,142 @@ | ||
| !Hello demonstration parameterization | ||
| ! | ||
|
|
||
| MODULE make_ddt | ||
|
|
||
| USE ccpp_kinds, ONLY: kind_phys | ||
| USE ddt2, only: ty_ddt2 | ||
|
|
||
| IMPLICIT NONE | ||
| PRIVATE | ||
|
|
||
| PUBLIC :: make_ddt_init | ||
| PUBLIC :: make_ddt_run | ||
| PUBLIC :: make_ddt_timestep_final | ||
| PUBLIC :: vmr_type | ||
|
|
||
| type ty_ddt3 | ||
| integer :: dont_lose | ||
| integer :: your_head | ||
| integer :: to_gain_a_minute | ||
| integer :: you_need_your_head | ||
| integer :: your_brains_are_in_it | ||
| end type ty_ddt3 | ||
|
|
||
| !> \section arg_table_vmr_type Argument Table | ||
| !! \htmlinclude arg_table_vmr_type.html | ||
| !! | ||
| type vmr_type | ||
| integer :: nvmr | ||
| real(kind_phys), allocatable :: vmr_array(:,:) | ||
| type(ty_ddt2) :: error_maybe | ||
| type(ty_ddt3) :: burma_shave | ||
| end type vmr_type | ||
|
|
||
|
|
||
| CONTAINS | ||
|
|
||
| !> \section arg_table_make_ddt_run Argument Table | ||
| !! \htmlinclude arg_table_make_ddt_run.html | ||
| !! | ||
| SUBROUTINE make_ddt_run(cols, cole, O3, HNO3, vmr, errmsg, errflg) | ||
| !---------------------------------------------------------------- | ||
| IMPLICIT NONE | ||
| !---------------------------------------------------------------- | ||
|
|
||
| ! Dummy arguments | ||
| integer, intent(in) :: cols | ||
| integer, intent(in) :: cole | ||
| REAL(kind_phys), intent(in) :: O3(:) | ||
| REAL(kind_phys), intent(in) :: HNO3(:) | ||
| type(vmr_type), intent(inout) :: vmr | ||
| character(len=512), intent(out) :: errmsg | ||
| integer, intent(out) :: errflg | ||
| ! Local variable | ||
| integer :: nbox | ||
| !---------------------------------------------------------------- | ||
|
|
||
| errmsg = '' | ||
| errflg = 0 | ||
|
|
||
| ! Check for correct threading behavior | ||
| nbox = cole - cols + 1 | ||
| if (SIZE(O3) /= nbox) then | ||
| errflg = 1 | ||
| write(errmsg, '(2(a,i0))') 'SIZE(O3) = ', SIZE(O3), ', should be ', nbox | ||
| else if (SIZE(HNO3) /= nbox) then | ||
| errflg = 1 | ||
| write(errmsg, '(2(a,i0))') 'SIZE(HNO3) = ', SIZE(HNO3), & | ||
| ', should be ', nbox | ||
| else | ||
| ! NOTE -- This is prototyping one approach to passing a large number of | ||
| ! chemical VMR values and is the predecssor for adding in methods and | ||
| ! maybe nesting DDTs (especially for aerosols) | ||
| vmr%vmr_array(cols:cole, 1) = O3(:) | ||
| vmr%vmr_array(cols:cole, 2) = HNO3(:) | ||
| end if | ||
|
|
||
| END SUBROUTINE make_ddt_run | ||
|
|
||
| !> \section arg_table_make_ddt_init Argument Table | ||
| !! \htmlinclude arg_table_make_ddt_init.html | ||
| !! | ||
| subroutine make_ddt_init(nbox, vmr, errmsg, errflg) | ||
|
|
||
| ! Dummy arguments | ||
| integer, intent(in) :: nbox | ||
| type(vmr_type), intent(out) :: vmr | ||
| character(len=512), intent(out) :: errmsg | ||
| integer, intent(out) :: errflg | ||
|
|
||
| ! This routine initializes the vmr array | ||
| vmr%nvmr = 2 | ||
| allocate(vmr%vmr_array(nbox, vmr%nvmr)) | ||
|
|
||
| errmsg = '' | ||
| errflg = 0 | ||
|
|
||
| end subroutine make_ddt_init | ||
|
|
||
| !> \section arg_table_make_ddt_timestep_final Argument Table | ||
| !! \htmlinclude arg_table_make_ddt_timestep_final.html | ||
| !! | ||
| subroutine make_ddt_timestep_final (ncols, vmr, errmsg, errflg) | ||
|
|
||
| ! Dummy arguments | ||
| integer, intent(in) :: ncols | ||
| type(vmr_type), intent(in) :: vmr | ||
| character(len=512), intent(out) :: errmsg | ||
| integer, intent(out) :: errflg | ||
| ! Local variables | ||
| integer :: index | ||
| real(kind_phys) :: rind | ||
|
|
||
| errmsg = '' | ||
| errflg = 0 | ||
|
|
||
| ! This routine checks the array values in vmr | ||
| if (SIZE(vmr%vmr_array, 1) /= ncols) then | ||
| errflg = 1 | ||
| write(errmsg, '(2(a,i0))') 'VMR%VMR_ARRAY first dimension size is, ', & | ||
| SIZE(vmr%vmr_array, 1), ', should be, ', ncols | ||
| else | ||
| do index = 1, ncols | ||
| rind = real(index, kind_phys) | ||
| if (vmr%vmr_array(index, 1) /= rind * 1.e-6_kind_phys) then | ||
| errflg = 1 | ||
| write(errmsg, '(a,i0,2(a,e12.4))') 'O3(', index, ') = ', & | ||
| vmr%vmr_array(index, 1), ', should be, ', & | ||
| rind * 1.e-6_kind_phys | ||
| exit | ||
| else if (vmr%vmr_array(index, 2) /= rind * 1.e-9_kind_phys) then | ||
| errflg = 1 | ||
| write(errmsg, '(a,i0,2(a,e12.4))') 'HNO3(', index, ') = ', & | ||
| vmr%vmr_array(index, 2), ', should be, ', & | ||
| rind * 1.e-9_kind_phys | ||
| exit | ||
| end if | ||
| end do | ||
| end if | ||
|
|
||
| end subroutine make_ddt_timestep_final | ||
|
|
||
| END MODULE make_ddt | ||
| module make_ddt | ||
|
|
||
| use ccpp_kinds, only: kind_phys | ||
| use ddt2, only: ty_ddt2 | ||
|
|
||
| implicit none | ||
| private | ||
|
|
||
| public :: make_ddt_init | ||
| public :: make_ddt_run | ||
| public :: make_ddt_timestep_final | ||
| public :: vmr_type | ||
|
|
||
| type ty_ddt3 | ||
| integer :: dont_lose | ||
| integer :: your_head | ||
| integer :: to_gain_a_minute | ||
| integer :: you_need_your_head | ||
| integer :: your_brains_are_in_it | ||
| end type ty_ddt3 | ||
|
|
||
| !> \section arg_table_vmr_type Argument Table | ||
| !! \htmlinclude arg_table_vmr_type.html | ||
| !! | ||
| type vmr_type | ||
| integer :: nvmr | ||
| real(kind=kind_phys), allocatable :: vmr_array(:, :) | ||
| type(ty_ddt2) :: error_maybe | ||
| type(ty_ddt3) :: burma_shave | ||
| end type vmr_type | ||
|
|
||
| contains | ||
|
|
||
| !> \section arg_table_make_ddt_run Argument Table | ||
| !! \htmlinclude arg_table_make_ddt_run.html | ||
| !! | ||
| subroutine make_ddt_run(cols, cole, o3, hno3, vmr, errmsg, errflg) | ||
| !---------------------------------------------------------------- | ||
| implicit none | ||
| !---------------------------------------------------------------- | ||
|
|
||
| ! Dummy arguments | ||
| integer, intent(in) :: cols | ||
| integer, intent(in) :: cole | ||
| real(kind=kind_phys), intent(in) :: o3(:) | ||
| real(kind=kind_phys), intent(in) :: hno3(:) | ||
| type(vmr_type), intent(inout) :: vmr | ||
| character(len=512), intent(out) :: errmsg | ||
| integer, intent(out) :: errflg | ||
| ! Local variable | ||
| integer :: nbox | ||
| !---------------------------------------------------------------- | ||
|
|
||
| errmsg = '' | ||
| errflg = 0 | ||
|
|
||
| ! Check for correct threading behavior | ||
| nbox = cole - cols + 1 | ||
| if (size(o3) /= nbox) then | ||
| errflg = 1 | ||
| write(errmsg, '(2(a,i0))') 'SIZE(O3) = ', size(o3), ', should be ', nbox | ||
| else if (size(hno3) /= nbox) then | ||
| errflg = 1 | ||
| write(errmsg, '(2(a,i0))') 'SIZE(HNO3) = ', size(hno3), & | ||
| ', should be ', nbox | ||
| else | ||
| ! NOTE -- This is prototyping one approach to passing a large number of | ||
| ! chemical VMR values and is the predecssor for adding in methods and | ||
| ! maybe nesting DDTs (especially for aerosols) | ||
| vmr%vmr_array(cols:cole, 1) = o3(:) | ||
| vmr%vmr_array(cols:cole, 2) = hno3(:) | ||
| end if | ||
|
|
||
| end subroutine make_ddt_run | ||
|
|
||
| !> \section arg_table_make_ddt_init Argument Table | ||
| !! \htmlinclude arg_table_make_ddt_init.html | ||
| !! | ||
| subroutine make_ddt_init(nbox, vmr, errmsg, errflg) | ||
|
|
||
| ! Dummy arguments | ||
| integer, intent(in) :: nbox | ||
| type(vmr_type), intent(out) :: vmr | ||
| character(len=512), intent(out) :: errmsg | ||
| integer, intent(out) :: errflg | ||
|
|
||
| ! This routine initializes the vmr array | ||
| vmr%nvmr = 2 | ||
| allocate(vmr%vmr_array(nbox, vmr%nvmr)) | ||
|
|
||
| errmsg = '' | ||
| errflg = 0 | ||
|
|
||
| end subroutine make_ddt_init | ||
|
|
||
| !> \section arg_table_make_ddt_timestep_final Argument Table | ||
| !! \htmlinclude arg_table_make_ddt_timestep_final.html | ||
| !! | ||
| subroutine make_ddt_timestep_final(ncols, vmr, errmsg, errflg) | ||
|
|
||
| ! Dummy arguments | ||
| integer, intent(in) :: ncols | ||
| type(vmr_type), intent(in) :: vmr | ||
| character(len=512), intent(out) :: errmsg | ||
| integer, intent(out) :: errflg | ||
| ! Local variables | ||
| integer :: index | ||
| real(kind=kind_phys) :: rind | ||
|
|
||
| errmsg = '' | ||
| errflg = 0 | ||
|
|
||
| ! This routine checks the array values in vmr | ||
| if (size(vmr%vmr_array, 1) /= ncols) then | ||
| errflg = 1 | ||
| write(errmsg, '(2(a,i0))') 'VMR%VMR_ARRAY first dimension size is, ', & | ||
| size(vmr%vmr_array, 1), ', should be, ', ncols | ||
| else | ||
| do index = 1, ncols | ||
| rind = real(index, kind_phys) | ||
| if (vmr%vmr_array(index, 1) /= rind * 1.e-6_kind_phys) then | ||
| errflg = 1 | ||
| write(errmsg, '(a,i0,2(a,e12.4))') 'O3(', index, ') = ', & | ||
| vmr%vmr_array(index, 1), ', should be, ', & | ||
| rind * 1.e-6_kind_phys | ||
| exit | ||
| else if (vmr%vmr_array(index, 2) /= rind * 1.e-9_kind_phys) then | ||
| errflg = 1 | ||
| write(errmsg, '(a,i0,2(a,e12.4))') 'HNO3(', index, ') = ', & | ||
| vmr%vmr_array(index, 2), ', should be, ', & | ||
| rind * 1.e-9_kind_phys | ||
| exit | ||
| end if | ||
| end do | ||
| end if | ||
|
|
||
| end subroutine make_ddt_timestep_final | ||
|
|
||
| end module make_ddt |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slick!