Skip to content

Commit

Permalink
Merge pull request CESM-Development#62 from ESMCI/mpicom_cleanup
Browse files Browse the repository at this point in the history
Mpicom cleanup
  • Loading branch information
rsdunlapiv authored Dec 3, 2018
2 parents f7e734e + fd500c8 commit 3c15820
Show file tree
Hide file tree
Showing 28 changed files with 813 additions and 1,947 deletions.
2 changes: 0 additions & 2 deletions scripts/lib/CIME/case/preview_namelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def create_namelists(self, component=None):

logger.info("Creating component namelists")

cime_model = self.get_value("MODEL")

# Create namelists - must have cpl last in the list below
# Note - cpl must be last in the loop below so that in generating its namelist,
# it can use xml vars potentially set by other component's buildnml scripts
Expand Down
8 changes: 4 additions & 4 deletions src/components/data_comps/datm/nuopc/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,15 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_nuopc_grid_ArrayToState(a2x%rattr, flds_a2x, exportState, grid_option='mesh', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDATM%nxg),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDATM%nxg),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDATM%nyg),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDATM%nyg),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -605,7 +605,7 @@ subroutine ModelAdvance(gcomp, rc)
call shr_nuopc_grid_ArrayToState(a2x%rattr, flds_a2x, exportState, grid_option='mesh', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
4 changes: 2 additions & 2 deletions src/components/data_comps/dice/nuopc/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

nx_global = SDICE%nxg
ny_global = SDICE%nyg
call shr_nuopc_methods_State_SetScalar(dble(nx_global),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(nx_global),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(ny_global),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(ny_global),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
4 changes: 2 additions & 2 deletions src/components/data_comps/dlnd/nuopc/lnd_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_nuopc_grid_ArrayToState(d2x%rattr, flds_l2x, exportState, grid_option='mesh', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDLND%nxg),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDLND%nxg),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDLND%nyg),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDLND%nyg),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
4 changes: 2 additions & 2 deletions src/components/data_comps/docn/nuopc/ocn_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_nuopc_grid_ArrayToState(o2x%rattr, flds_o2x, exportState, grid_option='mesh', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDOCN%nxg),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDOCN%nxg),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDOCN%nyg),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDOCN%nyg),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
4 changes: 2 additions & 2 deletions src/components/data_comps/drof/nuopc/rof_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_nuopc_grid_ArrayToState(r2x%rattr, flds_r2x, exportState, 'mesh', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDROF%nxg),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDROF%nxg),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDROF%nyg),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDROF%nyg),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
4 changes: 2 additions & 2 deletions src/components/data_comps/dwav/nuopc/wav_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_nuopc_grid_ArrayToState(w2x%rattr, flds_w2x, exportState, grid_option='mesh', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDWAV%nxg),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDWAV%nxg),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(SDWAV%nyg),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(SDWAV%nyg),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
48 changes: 21 additions & 27 deletions src/components/xcpl_comps/xatm/nuopc/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ module atm_comp_nuopc
character(CXX) :: flds_x2a = ''
integer :: nxg ! global dim i-direction
integer :: nyg ! global dim j-direction
integer :: mpicom ! mpi communicator
integer :: my_task ! my task in mpi communicator mpicom
integer :: my_task ! my task in mpi communicator
integer :: inst_index ! number of current instance (ie. 1)
character(len=12) :: inst_name ! fullname of current instance (ie. "lnd_0001")
character(len=5) :: inst_suffix ! char string associated with instance (ie. "_0001" or "")
integer :: logunit ! logging unit number
logical :: mastertask
integer :: dbrc
logical :: atm_prognostic

!----- formats -----
Expand All @@ -81,7 +79,8 @@ subroutine SetServices(gcomp, rc)
character(len=*),parameter :: subname=trim(modName)//':(SetServices) '

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=dbrc)
call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

! the NUOPC gcomp component will register the generic methods
call NUOPC_CompDerive(gcomp, model_routine_SS, rc=rc)
Expand Down Expand Up @@ -113,7 +112,8 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=model_label_Finalize, specRoutine=ModelFinalize, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=dbrc)
call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

end subroutine SetServices

Expand All @@ -130,7 +130,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

! local variables
type(ESMF_VM) :: vm
integer :: lmpicom
character(CL) :: cvalue
character(CS) :: stdname
integer :: n
Expand All @@ -145,19 +144,14 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=dbrc)

!----------------------------------------------------------------------------
! generate local mpi comm
!----------------------------------------------------------------------------
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc)

call ESMF_GridCompGet(gcomp, vm=vm, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_VMGet(vm, mpiCommunicator=lmpicom, localpet=my_task, rc=rc)
call ESMF_VMGet(vm, localpet=my_task, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call mpi_comm_dup(lmpicom, mpicom, ierr)
mastertask = my_task==0
!----------------------------------------------------------------------------
! determine instance information
Expand Down Expand Up @@ -229,7 +223,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry4' , flds_concat=flds_a2x)

do n = 1,fldsFrAtm_num
write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname)
if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname)
call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, &
TransferOfferGeomObject='will provide', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -262,7 +256,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' , flds_concat=flds_x2a)

do n = 1,fldsToAtm_num
write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname)
if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname)
call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, &
TransferOfferGeomObject='will provide', rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -279,7 +273,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_file_setLogLevel(shrloglev)
call shr_file_setLogUnit (shrlogunit)

if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=dbrc)
if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc)

end subroutine InitializeAdvertise

Expand All @@ -303,7 +297,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=dbrc)
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc)

!----------------------------------------------------------------------------
! Reset shr logging to my log file
Expand All @@ -318,7 +312,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! generate the mesh
!--------------------------------

call shr_nuopc_grid_MeshInit(gcomp, nxg, nyg, mpicom, gindex, lon, lat, Emesh, rc)
call shr_nuopc_grid_MeshInit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

!--------------------------------
Expand Down Expand Up @@ -360,11 +354,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
end if
end do

call shr_nuopc_methods_State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand All @@ -375,7 +369,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call ESMF_TimeGet(nextTime, dayOfYear_r8=nextsw_cday)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, mpicom, &
call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, &
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -408,7 +402,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_file_setLogLevel(shrloglev)
call shr_file_setLogUnit (shrlogunit)

if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=dbrc)
if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc)

end subroutine InitializeRealize

Expand All @@ -432,7 +426,7 @@ subroutine ModelAdvance(gcomp, rc)
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=dbrc)
call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc)
call shr_nuopc_memcheck(subname, 3, mastertask)
call shr_file_getLogUnit (shrlogunit)
call shr_file_getLogLevel(shrloglev)
Expand Down Expand Up @@ -484,7 +478,7 @@ subroutine ModelAdvance(gcomp, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_nuopc_methods_State_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, &
mpicom, flds_scalar_name, flds_scalar_num, rc)
flds_scalar_name, flds_scalar_num, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

!--------------------------------
Expand All @@ -502,7 +496,7 @@ subroutine ModelAdvance(gcomp, rc)
if(mastertask) then
call shr_nuopc_log_clock_advance(clock, 'ATM', logunit)
endif
call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=dbrc)
call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc)

end subroutine ModelAdvance

Expand All @@ -521,11 +515,11 @@ subroutine ModelFinalize(gcomp, rc)
!--------------------------------

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=dbrc)
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc)

call dead_final_nuopc('atm', logunit)

if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=dbrc)
if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc)

end subroutine ModelFinalize

Expand Down
Loading

0 comments on commit 3c15820

Please sign in to comment.