Skip to content

Commit

Permalink
Required changes to enable IPD-only, CCPP-only and CCPP-IPD builds us…
Browse files Browse the repository at this point in the history
…ing CPP

preprocessor directives. Preparation for future metadata parsing by defining
cap source files as separate objects in the makefile. Ignore auto-generated
.inc files in git.
  • Loading branch information
DomHeinzeller committed Nov 30, 2017
1 parent 082d747 commit 5c16b7f
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto-generated include files in Fortran code
*.inc
103 changes: 103 additions & 0 deletions IPD_layer/IPD_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,27 @@ module IPD_driver

use physics_restart_layer, only: restart_populate

#ifdef CCPP_IPD
use fms_mod, only: error_mesg
use ccpp_types, only: ccpp_t
use ccpp, only: ccpp_init
use ccpp_fcall, only: ccpp_run
use ccpp_fields, only: ccpp_fields_add
! Begin include auto-generated list of modules for ccpp
! DH* #include "ccpp_modules.inc"
! End include auto-generated list of modules for ccpp
use iso_c_binding, only: c_loc
#endif

implicit none

#ifdef CCPP_IPD
!------------------------------------------------------!
! CCPP container !
!------------------------------------------------------!
type(ccpp_t), save, target :: cdata
#endif

!------------------------------------------------------!
! IPD containers !
!------------------------------------------------------!
Expand All @@ -32,6 +51,9 @@ module IPD_driver
public IPD_radiation_step
public IPD_physics_step1
public IPD_physics_step2
#ifdef CCPP_IPD
public IPD_step
#endif

CONTAINS
!*******************************************************************************************
Expand Down Expand Up @@ -138,4 +160,85 @@ subroutine IPD_physics_step2 (IPD_Control, IPD_Data, IPD_Diag, IPD_Restart)

end subroutine IPD_physics_step2


#ifdef CCPP_IPD
!----------------------
! IPD step generalized
!----------------------
subroutine IPD_step (IPD_Control, IPD_Data, IPD_Diag, IPD_Restart, Atm_block, Init_parm, l_salp_data, l_snupx, ccpp_suite, step)

use namelist_soilveg, only: salp_data, snupx, max_vegtyp
use block_control_mod, only: block_control_type
use IPD_typedefs, only: kind_phys

implicit none

type(IPD_control_type), intent(inout) :: IPD_Control
type(IPD_data_type), intent(inout) :: IPD_Data(:)
type(IPD_diag_type), intent(inout) :: IPD_Diag(:)
type(IPD_restart_type), intent(inout) :: IPD_Restart
type (block_control_type), intent(in) , optional :: Atm_block
type(IPD_init_type), intent(in) , optional :: Init_parm
real(kind=kind_phys), intent(inout), optional :: l_salp_data
real(kind=kind_phys), intent(inout), optional :: l_snupx(max_vegtyp)
character(len=256), intent(in), optional :: ccpp_suite
integer, intent(in) :: step
! Local variables
integer :: ierr

if (step==0) then
if (.not. present(Atm_block)) then
! DH* TODO - NEED PROPER ERROR HANDLING HERE
print *, "IPD init step called without mandatory Atm_block argument"
stop
else if (.not. present(Init_parm)) then
! DH* TODO - NEED PROPER ERROR HANDLING HERE
print *, "IPD init step called without mandatory Init_parm argument"
stop
else if (.not. present(l_salp_data)) then
! DH* TODO - NEED PROPER ERROR HANDLING HERE
print *, "IPD init step called without mandatory l_salp_data argument"
stop
else if (.not. present(l_snupx)) then
! DH* TODO - NEED PROPER ERROR HANDLING HERE
print *, "IPD init step called without mandatory l_snupx argument"
stop
else if (.not. present(ccpp_suite)) then
! DH* TODO - NEED PROPER ERROR HANDLING HERE
print *, "IPD init step called without mandatory ccpp_suite argument"
stop
end if

!--- Initialize CCPP
call ccpp_init(ccpp_suite, cdata, ierr)

! Begin include auto-generated list of calls to ccpp_fields_add
! DH* #include "ccpp_fields.inc"
! End include auto-generated list of calls to ccpp_fields_add

!--- Add the DDTs to the CCPP data structure
call ccpp_fields_add(cdata, 'IPD_Control', '', c_loc(IPD_Control), &
ierr=ierr)
call ccpp_fields_add(cdata, 'IPD_Data', '', c_loc(IPD_Data), &
size(IPD_Data), shape(IPD_Data), ierr)
call ccpp_fields_add(cdata, 'IPD_Diag', '', c_loc(IPD_Diag), &
size(IPD_Diag), shape(IPD_Diag), ierr)
call ccpp_fields_add(cdata, 'IPD_Restart', '', c_loc(IPD_Restart), ierr=ierr)
call ccpp_fields_add(cdata, 'Atm_block', '', c_loc(Atm_block), ierr=ierr)
call ccpp_fields_add(cdata, 'Init_parm', '', c_loc(Init_parm), ierr=ierr)
call ccpp_fields_add(cdata, 'nblks', Atm_block%nblks, ierr, '')
call ccpp_fields_add(cdata, 'salp_data', l_salp_data, ierr)
call ccpp_fields_add(cdata, 'snupx', l_snupx, ierr)

call ccpp_run(cdata%suite%init, cdata, ierr)
!else if (step==X) then
! !--- Finalize CCPP
! call ccpp_init(ccpp_suite, cdata, ierr)
else
call ccpp_run(cdata%suite%ipds(1)%subcycles(1)%schemes(step), cdata, ierr)
end if
end subroutine IPD_step
#endif


end module IPD_driver
29 changes: 23 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ VER_PATCH = 0

FFLAGS += -I../fms -I../fms/include -fPIC

CPPDEFS = -DNEW_TAUCTMAX -DSMALL_PE -DNEMS_GSM
CPPDEFS += -DNEW_TAUCTMAX -DSMALL_PE -DNEMS_GSM


ifneq (,$(findstring CCPP_DIRECT,$(CPPDEFS)))
# CCPP without IPD
IPD_DRIVER_CAP = ./IPD_layer/IPD_driver_cap.F90
else ifneq (,$(findstring CCPP_IPD,$(CPPDEFS)))
# IPD with CCPP
IPD_DRIVER_CAP = ./IPD_layer/IPD_driver_cap.F90
else
# IPD without CCPP
IPD_DRIVER_CAP =
endif


SRCS_f = \
./physics/cnvc90.f \
Expand Down Expand Up @@ -144,14 +157,15 @@ SRCS_F90 = \
./GFS_layer/GFS_radiation_driver.F90 \
./GFS_layer/GFS_restart.F90 \
./GFS_layer/GFS_typedefs.F90 \
./IPD_layer/IPD_driver_cap.F90 \
./IPD_layer/IPD_driver.F90 \
./IPD_layer/IPD_typedefs.F90


SRCS_c =

DEPEND_FILES = $(SRCS_f) $(SRCS_f90) $(SRCS_F) $(SRCS_F90)
CAPS_F90 = \
$(IPD_DRIVER_CAP)

DEPEND_FILES = $(SRCS_f) $(SRCS_f90) $(SRCS_F) $(SRCS_F90) $(CAPS_F90)

OBJS_f = $(SRCS_f:.f=.o)
OBJS_f90 = $(SRCS_f90:.f90=.o)
Expand All @@ -161,10 +175,13 @@ OBJS_c = $(SRCS_c:.c=.o)

OBJS = $(OBJS_f) $(OBJS_f90) $(OBJS_F) $(OBJS_F90) $(OBJS_c)

CAPS = $(CAPS_F90:.F90=.o)

all default: depend $(LIBRARY)

$(LIBRARY): $(OBJS)
$(FC) -shared -Wl,-soname,$(LIBRARY).$(VER_MAJOR) $(OBJS) $(LDFLAGS) $(NCEPLIBS) -o $(LIBRARY).$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
$(LIBRARY): $(OBJS) $(CAPS)
$(FC) -shared -Wl,-soname,$(LIBRARY).$(VER_MAJOR) $(OBJS) $(CAPS) $(LDFLAGS) $(NCEPLIBS) -o $(LIBRARY).$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
# DH* placeholder for PGI fix of cap object names in shared library
ln -sf $(LIBRARY).$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) $(LIBRARY)
ln -sf $(LIBRARY).$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) $(LIBRARY).$(VER_MAJOR)

Expand Down

0 comments on commit 5c16b7f

Please sign in to comment.