Skip to content

Commit

Permalink
fix namelist issue and refactor for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Jul 27, 2017
1 parent 8eb4ed0 commit f39a228
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
7 changes: 5 additions & 2 deletions src/drivers/mct/main/component_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ end subroutine comp_init
endif

if (.not. associated(comp(eci)%x2c_cc)) allocate(comp(eci)%x2c_cc)
if (.not. associated(comp(eci)%c2x_cc)) allocate(comp(eci)%c2x_cc)

if (.not. associated(comp(eci)%c2x_cc)) then
allocate(comp(eci)%c2x_cc)
! this is needed for check_fields
nullify(comp(eci)%c2x_cc%rattr)
endif
if (comp(eci)%iamin_compid .and. comp(eci)%present) then
if (drv_threading) call seq_comm_setnthreads(comp(eci)%nthreads_compid)
call shr_sys_flush(logunit)
Expand Down
41 changes: 20 additions & 21 deletions src/drivers/mct/main/component_type_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -239,28 +239,27 @@ subroutine check_fields(comp, comp_index)
integer(IN) :: ierr
integer(IN), pointer :: gpts(:)
character(len=CL) :: msg
real(r8), pointer :: rattr(:,:)

lsize = mct_avect_lsize(comp%c2x_cc)
nflds = size(comp%c2x_cc%rattr,1)

! c2x_cc is allocated even if not used such as in stub models
! do not test this case.

if(lsize <= 1 .and. nflds <= 1) return
rattr => comp%c2x_cc%rattr
do fld=1,nflds
do n=1,lsize
if(shr_infnan_isnan(rattr(fld,n))) then
call mpi_comm_rank(comp%mpicom_compid, rank, ierr)
call mct_gsMap_orderedPoints(comp%gsmap_cc, rank, gpts)
write(msg,*)'component_mod:check_fields NaN found in ',trim(comp%name),' instance: ',&
comp_index,' field ',trim(mct_avect_getRList2c(fld, comp%c2x_cc)), ' 1d global index: ',gpts(n)
call shr_sys_abort(msg)
endif
enddo
enddo

if(associated(comp%c2x_cc) .and. associated(comp%c2x_cc%rattr)) then
lsize = mct_avect_lsize(comp%c2x_cc)
nflds = size(comp%c2x_cc%rattr,1)
! c2x_cc is allocated even if not used such as in stub models
! do not test this case.
if(lsize <= 1 .and. nflds <= 1) return
if(any(shr_infnan_isnan(comp%c2x_cc%rattr))) then
do fld=1,nflds
do n=1,lsize
if(shr_infnan_isnan(comp%c2x_cc%rattr(fld,n))) then
call mpi_comm_rank(comp%mpicom_compid, rank, ierr)
call mct_gsMap_orderedPoints(comp%gsmap_cc, rank, gpts)
write(msg,*)'component_mod:check_fields NaN found in ',trim(comp%name),' instance: ',&
comp_index,' field ',trim(mct_avect_getRList2c(fld, comp%c2x_cc)), ' 1d global index: ',gpts(n)
call shr_sys_abort(msg)
endif
enddo
enddo
endif
endif
end subroutine check_fields

end module component_type_mod
4 changes: 3 additions & 1 deletion src/drivers/mct/shr/seq_flds_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ module seq_flds_mod
character(32) :: wavname='wav'
character(32) :: rofname='rof'

! namelist variables
logical :: nan_check_component_fields

!----------------------------------------------------------------------------
contains
!----------------------------------------------------------------------------
Expand Down Expand Up @@ -335,7 +338,6 @@ subroutine seq_flds_set(nmlfile, ID, infodata)
character(len=CSS) :: fldname, fldflow
logical :: is_state, is_flux
integer :: i,n
logical :: nan_check_component_fields

! use cases namelists
logical :: flds_co2a
Expand Down

0 comments on commit f39a228

Please sign in to comment.