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

CCPP API and SDF update #33

Merged
merged 5 commits into from
Apr 25, 2018
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
57 changes: 43 additions & 14 deletions scm/src/gmtb_scm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ subroutine gmtb_scm_main_sub()
use gmtb_scm_time_integration
use gmtb_scm_output

use :: ccpp_types, &
only: ccpp_t
use :: ccpp, &
only: ccpp_init
use :: ccpp_fcall, &
only: ccpp_run
use :: ccpp_fields, &
only: ccpp_field_add
use :: ccpp_api, &
only: ccpp_t, &
ccpp_init, &
ccpp_finalize, &
ccpp_physics_init, &
ccpp_physics_run, &
ccpp_physics_finalize, &
ccpp_field_add

use iso_c_binding, only: c_loc
use :: iso_c_binding, only: c_loc

#include "ccpp_modules.inc"

Expand Down Expand Up @@ -103,9 +103,13 @@ subroutine gmtb_scm_main_sub()

do i = 1, scm_state%n_cols
!set up each column's physics suite (which may be different)
call ccpp_init( &
trim(adjustl(scm_state%physics_suite_dir))//trim(adjustl(scm_state%physics_suite_name(i)))//'.xml', &
cdata(i), ierr)
call ccpp_init( &
trim(adjustl(scm_state%physics_suite_dir))//trim(adjustl(scm_state%physics_suite_name(i)))//'.xml', &
cdata(i), ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_init for column ', i, '. Exiting...'
stop
end if

physics%Init_parm(i)%levs = scm_state%n_levels
physics%Init_parm(i)%bdat(1) = scm_state%init_year
Expand Down Expand Up @@ -147,7 +151,12 @@ subroutine gmtb_scm_main_sub()
call ccpp_field_add(cdata(i), 'error_message', physics%Interstitial(i)%errmsg, ierr, 'none')
call ccpp_field_add(cdata(i), 'error_flag', physics%Interstitial(i)%errflg, ierr, 'flag')

call ccpp_run(cdata(i)%suite%init, cdata(i), ierr)
!initialize easch column's physics
call ccpp_physics_init(cdata(i), ierr=ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_init for column ', i, '. Exiting...'
stop
end if

call physics%associate(scm_state, i)
!use ccpp_fields.inc to call ccpp_field_add for all variables to be exposed to CCPP (this is auto-generated from /src/ccpp/scripts/ccpp_prebuild.py - the script parses tables in gmtb_scm_type_defs.f90)
Expand Down Expand Up @@ -195,7 +204,11 @@ subroutine gmtb_scm_main_sub()
scm_state%state_v(:,:,:,2) = scm_state%state_v(:,:,:,1)

do i=1, scm_state%n_cols
call ccpp_run(cdata(i)%suite, cdata(i), ierr)
call ccpp_physics_run(cdata(i), ierr=ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_run for column ', i, '. Exiting...'
stop
end if
end do

!the filter routine (called after the following leapfrog time step) expects time level 2 in temp_tracer to be the updated, unfiltered state after the previous time step
Expand Down Expand Up @@ -281,6 +294,22 @@ subroutine gmtb_scm_main_sub()
end if
end do

do i=1, scm_state%n_cols
call ccpp_physics_finalize(cdata(i), ierr=ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_finalize for column ', i, '. Exiting...'
stop
end if
end do

do i=1, scm_state%n_cols
call ccpp_finalize(cdata(i), ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_finalize for column ', i, '. Exiting...'
stop
end if
end do

end subroutine gmtb_scm_main_sub

end module gmtb_scm_main
Expand Down
9 changes: 6 additions & 3 deletions scm/src/gmtb_scm_time_integration.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ module gmtb_scm_time_integration
use gmtb_scm_kinds, only: sp, dp, qp
use gmtb_scm_forcing

use :: ccpp_types, only: ccpp_t
use :: ccpp_fcall, only: ccpp_run
use ccpp_api, only: ccpp_t, ccpp_physics_run

implicit none

Expand Down Expand Up @@ -79,7 +78,11 @@ subroutine do_time_step(scm_state, cdata)
end if

do i=1, scm_state%n_cols
call ccpp_run(cdata(i)%suite, cdata(i), ierr)
call ccpp_physics_run(cdata(i), ierr=ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_run for column ', i, '. Exiting...'
stop
end if
end do


Expand Down