Skip to content
2 changes: 1 addition & 1 deletion .codee-format
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ SpacesAroundOperators:
Relational: Both
RelationalLegacy: Both
LogicalBinary: Both
LogicalNot: NoTrailing
LogicalNot: Both

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is annoying of me since this was all originally my suggestion, but maybe this should actually be Trailing?

My nit-picky concern is that Both is resulting in lines like these:

if ( .not. thing) then

which has inconsistent parenthetical spacing. .not. is weird because sometimes it comes right after the parenthesis, but not always.

If Trailing is applied to the original code (rather than the modified code in this PR), I think it'd get at what I was looking for.

It's not really a hill I want to die on, but I imagine it'd be annoying if someone committed code like:

if (.not. thing) then

and got codee failures.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No problem, easy enough to revert.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done!

UnaryPlusMinus: NoTrailing
Comma: OnlyTrailing
Concat: Both
Expand Down
92 changes: 46 additions & 46 deletions doc/HelloWorld/hello_scheme.F90
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
!Hello demonstration parameterization
!

MODULE hello_scheme
module hello_scheme

USE ccpp_kinds, ONLY: kind_phys
use ccpp_kinds, only: kind_phys

IMPLICIT NONE
PRIVATE
implicit none
private

PUBLIC :: hello_scheme_init
PUBLIC :: hello_scheme_run
PUBLIC :: hello_scheme_finalize
public :: hello_scheme_init
public :: hello_scheme_run
public :: hello_scheme_finalize

CONTAINS
contains

!> \section arg_table_hello_scheme_run Argument Table
!! \htmlinclude arg_table_hello_scheme_run.html
!!
SUBROUTINE hello_scheme_run(ncol, lev, ilev, timestep, temp_level, &
temp_layer, errmsg, errflg)
!----------------------------------------------------------------
IMPLICIT NONE
!----------------------------------------------------------------
!> \section arg_table_hello_scheme_run Argument Table
!! \htmlinclude arg_table_hello_scheme_run.html
!!
subroutine hello_scheme_run(ncol, lev, ilev, timestep, temp_level, &
temp_layer, errmsg, errflg)
!----------------------------------------------------------------
implicit none
!----------------------------------------------------------------

integer, intent(in) :: ncol, lev, ilev
REAL(kind_phys), intent(inout) :: temp_level(:, :)
real(kind_phys), intent(in) :: timestep
REAL(kind_phys), INTENT(out) :: temp_layer(:, :)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
!----------------------------------------------------------------
integer, intent(in) :: ncol, lev, ilev
real(kind=kind_phys), intent(inout) :: temp_level(:, :)
real(kind=kind_phys), intent(in) :: timestep
real(kind=kind_phys), intent(out) :: temp_layer(:, :)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
!----------------------------------------------------------------

integer :: col_index
integer :: lev_index
integer :: col_index
integer :: lev_index

errmsg = ''
errflg = 0

if (ilev /= (lev + 1)) then
errflg = 1
errmsg = 'Invalid value for ilev, must be lev+1'
return
errflg = 1
errmsg = 'Invalid value for ilev, must be lev+1'
return
end if

do col_index = 1, ncol
do lev_index = 1, lev
temp_layer(col_index, lev_index) = (temp_level(col_index, lev_index) &
+ temp_level(col_index, lev_index + 1)) / 2.0_kind_phys
end do
do lev_index = 1, lev
temp_layer(col_index, lev_index) = (temp_level(col_index, lev_index) &
+ temp_level(col_index, lev_index + 1)) / 2.0_kind_phys
end do
end do

END SUBROUTINE hello_scheme_run
end subroutine hello_scheme_run

!> \section arg_table_hello_scheme_init Argument Table
!! \htmlinclude arg_table_hello_scheme_init.html
!!
subroutine hello_scheme_init (errmsg, errflg)
!> \section arg_table_hello_scheme_init Argument Table
!! \htmlinclude arg_table_hello_scheme_init.html
!!
subroutine hello_scheme_init(errmsg, errflg)

character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

! This routine currently does nothing

Expand All @@ -67,13 +67,13 @@ subroutine hello_scheme_init (errmsg, errflg)

end subroutine hello_scheme_init

!> \section arg_table_hello_scheme_finalize Argument Table
!! \htmlinclude arg_table_hello_scheme_finalize.html
!!
subroutine hello_scheme_finalize (errmsg, errflg)
!> \section arg_table_hello_scheme_finalize Argument Table
!! \htmlinclude arg_table_hello_scheme_finalize.html
!!
subroutine hello_scheme_finalize(errmsg, errflg)

character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

! This routine currently does nothing

Expand All @@ -82,4 +82,4 @@ subroutine hello_scheme_finalize (errmsg, errflg)

end subroutine hello_scheme_finalize

END MODULE hello_scheme
end module hello_scheme
45 changes: 23 additions & 22 deletions doc/HelloWorld/hello_world_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,51 @@ module hello_world_host

public hello_world_sub

CONTAINS
contains

!> \section arg_table_hello_world_sub Argument Table
!! \htmlinclude arg_table_hello_world_sub.html
!!
subroutine hello_world_sub()

use hello_world_mod, only: ncols
use HelloWorld_ccpp_cap, only: HelloWorld_ccpp_physics_initialize
use HelloWorld_ccpp_cap, only: HelloWorld_ccpp_physics_timestep_initial
use HelloWorld_ccpp_cap, only: HelloWorld_ccpp_physics_run
use HelloWorld_ccpp_cap, only: HelloWorld_ccpp_physics_timestep_final
use HelloWorld_ccpp_cap, only: HelloWorld_ccpp_physics_finalize
use HelloWorld_ccpp_cap, only: ccpp_physics_suite_list
use HelloWorld_ccpp_cap, only: ccpp_physics_suite_part_list
use hello_world_mod, only: init_temp, compare_temp

integer :: col_start, col_end
integer :: index
use hello_world_mod, only: ncols
use helloworld_ccpp_cap, only: helloworld_ccpp_physics_initialize
use helloworld_ccpp_cap, only: helloworld_ccpp_physics_timestep_initial
use helloworld_ccpp_cap, only: helloworld_ccpp_physics_run
use helloworld_ccpp_cap, only: helloworld_ccpp_physics_timestep_final
use helloworld_ccpp_cap, only: helloworld_ccpp_physics_finalize
use helloworld_ccpp_cap, only: ccpp_physics_suite_list
use helloworld_ccpp_cap, only: ccpp_physics_suite_part_list
use hello_world_mod, only: init_temp, &
compare_temp

integer :: col_start, col_end
integer :: index
character(len=128), allocatable :: part_names(:)
character(len=512) :: errmsg
integer :: errflg
character(len=512) :: errmsg
integer :: errflg

! Initialize our 'data'
call init_temp()

! Use the suite information to setup the run
call HelloWorld_ccpp_physics_initialize('hello_world_suite', errmsg, errflg)
call helloworld_ccpp_physics_initialize('hello_world_suite', errmsg, errflg)
if (errflg /= 0) then
write(6, *) trim(errmsg)
stop
end if

! Initialize the timestep
call HelloWorld_ccpp_physics_timestep_initial('hello_world_suite', errmsg, errflg)
call helloworld_ccpp_physics_timestep_initial('hello_world_suite', errmsg, errflg)
if (errflg /= 0) then
write(6, *) trim(errmsg)
stop
end if

do col_start = 1, ncols, 5
col_end = MIN(col_start + 4, ncols)
col_end = min(col_start + 4, ncols)

call HelloWorld_ccpp_physics_run('hello_world_suite', 'physics', col_start, col_end, errmsg, errflg)
call helloworld_ccpp_physics_run('hello_world_suite', 'physics', col_start, col_end, errmsg, errflg)
if (errflg /= 0) then
write(6, *) trim(errmsg)
call ccpp_physics_suite_part_list('hello_world_suite', part_names, errmsg, errflg)
Expand All @@ -62,12 +63,12 @@ subroutine hello_world_sub()
end if
end do

call HelloWorld_ccpp_physics_timestep_final('hello_world_suite', errmsg, errflg)
call helloworld_ccpp_physics_timestep_final('hello_world_suite', errmsg, errflg)

call HelloWorld_ccpp_physics_finalize('hello_world_suite', errmsg, errflg)
call helloworld_ccpp_physics_finalize('hello_world_suite', errmsg, errflg)
if (errflg /= 0) then
write(6, *) trim(errmsg)
write(6,'(a)') 'An error occurred in ccpp_timestep_final, Exiting...'
write(6, '(a)') 'An error occurred in ccpp_timestep_final, Exiting...'
stop
end if

Expand Down
78 changes: 39 additions & 39 deletions doc/HelloWorld/hello_world_mod.F90
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
module hello_world_mod

use ccpp_kinds, only: kind_phys
use ccpp_kinds, only: kind_phys

implicit none
public
implicit none
public

integer :: ntimes_loop
!> \section arg_table_hello_world_mod Argument Table
!! \htmlinclude arg_table_hello_world_host.html
!!
integer, parameter :: ncols = 10
integer, parameter :: pver = 5
integer, parameter :: pverp = 6
real(kind_phys) :: temp_midpoints(ncols, pver)
real(kind_phys) :: temp_interfaces(ncols, pverp)
real(kind_phys) :: dt
integer :: ntimes_loop
!> \section arg_table_hello_world_mod Argument Table
!! \htmlinclude arg_table_hello_world_host.html
!!
integer, parameter :: ncols = 10
integer, parameter :: pver = 5
integer, parameter :: pverp = 6
real(kind=kind_phys) :: temp_midpoints(ncols, pver)
real(kind=kind_phys) :: temp_interfaces(ncols, pverp)
real(kind=kind_phys) :: dt

public :: init_temp
public :: compare_temp
public :: init_temp
public :: compare_temp

contains

subroutine init_temp()
subroutine init_temp()

integer :: col
integer :: lev
integer :: col
integer :: lev

temp_midpoints = 0.0_kind_phys
do lev = 1, pverp
do col = 1, ncols
temp_interfaces(col, lev) = real(((lev - 1) * ncols) + col, kind=kind_phys)
end do
temp_midpoints = 0.0_kind_phys
do lev = 1, pverp
do col = 1, ncols
temp_interfaces(col, lev) = real(((lev - 1) * ncols) + col, kind=kind_phys)
end do
end do

end subroutine init_temp
end subroutine init_temp

logical function compare_temp()
logical function compare_temp()

integer :: col
integer :: lev
real(kind_phys) :: avg
integer :: col
integer :: lev
real(kind=kind_phys) :: avg

compare_temp = .true.
compare_temp = .true.

do lev = 1, pver
do col = 1, ncols
avg = (temp_interfaces(col,lev) + temp_interfaces(col,lev+1))
avg = 1.0_kind_phys + (avg / 2.0_kind_phys)
if (temp_midpoints(col, lev) /= avg) then
write(6, *) col, lev, temp_midpoints(col, lev), avg
compare_temp = .false.
end if
end do
do lev = 1, pver
do col = 1, ncols
avg = (temp_interfaces(col, lev) + temp_interfaces(col, lev + 1))
avg = 1.0_kind_phys + (avg / 2.0_kind_phys)
if (temp_midpoints(col, lev) /= avg) then
write(6, *) col, lev, temp_midpoints(col, lev), avg
compare_temp = .false.
end if
end do
end do

end function compare_temp
end function compare_temp

end module hello_world_mod
Loading
Loading