ESMF_CompSet Subroutine

public recursive subroutine ESMF_CompSet(compp, name, vm, vm_info, grid, gridList, mesh, meshList, locstream, locstreamList, xgrid, xgridList, clock, dirPath, configFile, config, hconfig, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_CompClass), pointer :: compp
character(len=*), intent(in), optional :: name
type(ESMF_VM), intent(in), optional :: vm
type(ESMF_Pointer), intent(in), optional :: vm_info
type(ESMF_Grid), intent(in), optional :: grid
type(ESMF_Grid), intent(in), optional :: gridList(:)
type(ESMF_Mesh), intent(in), optional :: mesh
type(ESMF_Mesh), intent(in), optional :: meshList(:)
type(ESMF_LocStream), intent(in), optional :: locstream
type(ESMF_LocStream), intent(in), optional :: locstreamList(:)
type(ESMF_XGrid), intent(in), optional :: xgrid
type(ESMF_XGrid), intent(in), optional :: xgridList(:)
type(ESMF_Clock), intent(in), optional :: clock
character(len=*), intent(in), optional :: dirPath
character(len=*), intent(in), optional :: configFile
type(ESMF_Config), intent(in), optional :: config
type(ESMF_HConfig), intent(in), optional :: hconfig
integer, intent(out), optional :: rc

Calls

proc~~esmf_compset~~CallsGraph proc~esmf_compset ESMF_CompSet interface~esmf_configcreate ESMF_ConfigCreate proc~esmf_compset->interface~esmf_configcreate proc~esmf_basegetstatus ESMF_BaseGetStatus proc~esmf_compset->proc~esmf_basegetstatus proc~esmf_compclassgetinit ESMF_CompClassGetInit proc~esmf_compset->proc~esmf_compclassgetinit proc~esmf_configloadfile ESMF_ConfigLoadFile proc~esmf_compset->proc~esmf_configloadfile proc~esmf_imerr ESMF_IMErr proc~esmf_compset->proc~esmf_imerr proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_compset->proc~esmf_logfounderror proc~esmf_logseterror ESMF_LogSetError proc~esmf_compset->proc~esmf_logseterror proc~esmf_setname ESMF_SetName proc~esmf_compset->proc~esmf_setname proc~esmf_configcreatedefault ESMF_ConfigCreateDefault interface~esmf_configcreate->proc~esmf_configcreatedefault proc~esmf_configcreatefromsection ESMF_ConfigCreateFromSection interface~esmf_configcreate->proc~esmf_configcreatefromsection proc~esmf_basegetstatus->proc~esmf_logfounderror c_esmc_basegetstatus c_esmc_basegetstatus proc~esmf_basegetstatus->c_esmc_basegetstatus proc~esmf_configloadfile->proc~esmf_imerr proc~esmf_configloadfile->proc~esmf_logfounderror c_esmc_hconfigtoconfig c_esmc_hconfigtoconfig proc~esmf_configloadfile->c_esmc_hconfigtoconfig proc~esmf_configgetinit ESMF_ConfigGetInit proc~esmf_configloadfile->proc~esmf_configgetinit proc~esmf_configloadfile_1proc_ ESMF_ConfigLoadFile_1proc_ proc~esmf_configloadfile->proc~esmf_configloadfile_1proc_ proc~esmf_configparseattributes ESMF_ConfigParseAttributes proc~esmf_configloadfile->proc~esmf_configparseattributes proc~esmf_hconfigfileload ESMF_HConfigFileLoad proc~esmf_configloadfile->proc~esmf_hconfigfileload proc~esmf_logwrite ESMF_LogWrite proc~esmf_configloadfile->proc~esmf_logwrite proc~esmf_utilstringlowercase ESMF_UtilStringLowerCase proc~esmf_configloadfile->proc~esmf_utilstringlowercase proc~esmf_imerr->proc~esmf_logfounderror proc~esmf_initcheckdeep ESMF_InitCheckDeep proc~esmf_imerr->proc~esmf_initcheckdeep esmf_breakpoint esmf_breakpoint proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logfounderror->proc~esmf_logwrite proc~esmf_logseterror->esmf_breakpoint proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logseterror->proc~esmf_logwrite c_esmc_setname c_esmc_setname proc~esmf_setname->c_esmc_setname proc~esmf_basecreate ESMF_BaseCreate proc~esmf_setname->proc~esmf_basecreate

Called by

proc~~esmf_compset~~CalledByGraph proc~esmf_compset ESMF_CompSet proc~esmf_cplcompset ESMF_CplCompSet proc~esmf_cplcompset->proc~esmf_compset proc~esmf_gridcompset ESMF_GridCompSet proc~esmf_gridcompset->proc~esmf_compset proc~esmf_scicompset ESMF_SciCompSet proc~esmf_scicompset->proc~esmf_compset proc~f_esmf_compinsertvm f_esmf_compinsertvm proc~f_esmf_compinsertvm->proc~esmf_compset proc~f_esmf_compreplicate f_esmf_compreplicate proc~f_esmf_compreplicate->proc~esmf_compset proc~f_esmf_compsetvminfo f_esmf_compsetvminfo proc~f_esmf_compsetvminfo->proc~esmf_compset proc~comp1_init comp1_init proc~comp1_init->proc~esmf_gridcompset proc~comp2_init comp2_init proc~comp2_init->proc~esmf_gridcompset proc~esmf_gridcompcreate ESMF_GridCompCreate proc~esmf_gridcompcreate->proc~esmf_gridcompset proc~esmfio_create ESMFIO_Create proc~esmfio_create->proc~esmf_gridcompset proc~f_esmf_cplcompset f_esmf_cplcompset proc~f_esmf_cplcompset->proc~esmf_cplcompset proc~f_esmf_gridcompset f_esmf_gridcompset proc~f_esmf_gridcompset->proc~esmf_gridcompset proc~f_esmf_scicompset f_esmf_scicompset proc~f_esmf_scicompset->proc~esmf_scicompset proc~nuopc_gridcompsetclock NUOPC_GridCompSetClock proc~nuopc_gridcompsetclock->proc~esmf_gridcompset proc~setmodelservices SetModelServices proc~setmodelservices->proc~esmf_gridcompset proc~setmodelservices~2 SetModelServices proc~setmodelservices~2->proc~esmf_gridcompset proc~testcplcompnamedalias TestCplCompNamedAlias proc~testcplcompnamedalias->proc~esmf_cplcompset proc~testgridcompnamedalias TestGridCompNamedAlias proc~testgridcompnamedalias->proc~esmf_gridcompset proc~testscicompnamedalias TestSciCompNamedAlias proc~testscicompnamedalias->proc~esmf_scicompset proc~user_init~62 user_init proc~user_init~62->proc~esmf_gridcompset proc~user_init~68 user_init proc~user_init~68->proc~esmf_gridcompset program~esmf_appdriver ESMF_AppDriver program~esmf_appdriver->proc~esmf_gridcompset

Source Code

  recursive subroutine ESMF_CompSet(compp, name, vm, vm_info, grid, gridList, &
    mesh, meshList, locstream, locstreamList, xgrid, xgridList, clock, &
    dirPath, configFile, config, hconfig, rc)
!
! !ARGUMENTS:
    type(ESMF_CompClass),    pointer               :: compp
    character(len=*),        intent(in),  optional :: name
    type(ESMF_VM),           intent(in),  optional :: vm
    type(ESMF_Pointer),      intent(in),  optional :: vm_info
    type(ESMF_Grid),         intent(in),  optional :: grid
    type(ESMF_Grid),         intent(in),  optional :: gridList(:)
    type(ESMF_Mesh),         intent(in),  optional :: mesh
    type(ESMF_Mesh),         intent(in),  optional :: meshList(:)
    type(ESMF_LocStream),    intent(in),  optional :: locstream
    type(ESMF_LocStream),    intent(in),  optional :: locstreamList(:)
    type(ESMF_XGrid),        intent(in),  optional :: xgrid
    type(ESMF_XGrid),        intent(in),  optional :: xgridList(:)
    type(ESMF_Clock),        intent(in),  optional :: clock
    character(len=*),        intent(in),  optional :: dirPath
    character(len=*),        intent(in),  optional :: configFile
    type(ESMF_Config),       intent(in),  optional :: config
    type(ESMF_HConfig),      intent(in),  optional :: hconfig
    integer,                 intent(out), optional :: rc

!
! !DESCRIPTION:
!      Sets or resets information about the component.  When the caller
!      only wants to set a single value specify the argument by name.
!      All the arguments after the component input are optional 
!      to facilitate this.
!
!EOPI
!------------------------------------------------------------------------------
    integer                         :: localrc      ! local return code
    type(ESMF_Status)               :: baseStatus
    character(len=ESMF_MAXPATHLEN)  :: fullpath     ! config file + dirPath
    character(len=ESMF_MAXSTR)      :: msgbuf

    ! Initialize return code; assume not implemented until success is certain
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Test incoming compp object
    if (.not.associated(compp)) then
      call ESMF_LogSetError(ESMF_RC_OBJ_BAD, &
        msg="Not a valid pointer to ESMF Component object", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    endif

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP(ESMF_CompClassGetInit, compp, rc)

    call ESMF_BaseGetStatus(compp%base, baseStatus, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
        
    if (baseStatus /= ESMF_STATUS_READY) then
      call ESMF_LogSetError(ESMF_RC_OBJ_BAD, &
        msg="uninitialized or destroyed Component object", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    endif

    if (present(name)) then
      call ESMF_SetName(compp%base, name, "Component", rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    if (present(vm)) then
      compp%vm = vm
      compp%compStatus%vmIsPresent = .true.
    endif

    if (present(vm_info)) then
      compp%vm_info = vm_info
    endif

    if (present(grid).and.present(gridList)) then
      call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
        msg="The 'grid' and 'gridList' arguments are mutually exclusive.", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    else if (present(grid)) then
      if (allocated(compp%gridList)) deallocate(compp%gridList)
      allocate(compp%gridList(1))
      compp%gridList(1) = grid
      compp%compStatus%gridIsPresent = .true.
    else if (present(gridList)) then
      if (allocated(compp%gridList)) deallocate(compp%gridList)
      allocate(compp%gridList(size(gridList)))
      compp%gridList = gridList
      if (size(gridList)>0) then
        compp%compStatus%gridIsPresent = .true.
      else
        compp%compStatus%gridIsPresent = .false.
      endif
    endif

    if (present(mesh).and.present(meshList)) then
      call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
        msg="The 'mesh' and 'meshList' arguments are mutually exclusive.", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    else if (present(mesh)) then
      if (allocated(compp%meshList)) deallocate(compp%meshList)
      allocate(compp%meshList(1))
      compp%meshList(1) = mesh
      compp%compStatus%meshIsPresent = .true.
    else if (present(meshList)) then
      if (allocated(compp%meshList)) deallocate(compp%meshList)
      allocate(compp%meshList(size(meshList)))
      compp%meshList = meshList
      if (size(meshList)>0) then
        compp%compStatus%meshIsPresent = .true.
      else
        compp%compStatus%meshIsPresent = .false.
      endif
    endif

    if (present(locstream).and.present(locstreamList)) then
      call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
        msg="The 'locstream' and 'locstreamList' arguments are mutually exclusive.", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    else if (present(locstream)) then
      if (allocated(compp%locstreamList)) deallocate(compp%locstreamList)
      allocate(compp%locstreamList(1))
      compp%locstreamList(1) = locstream
      compp%compStatus%locstreamIsPresent = .true.
    else if (present(locstreamList)) then
      if (allocated(compp%locstreamList)) deallocate(compp%locstreamList)
      allocate(compp%locstreamList(size(locstreamList)))
      compp%locstreamList = locstreamList
      if (size(locstreamList)>0) then
        compp%compStatus%locstreamIsPresent = .true.
      else
        compp%compStatus%locstreamIsPresent = .false.
      endif
    endif

    if (present(xgrid).and.present(xgridList)) then
      call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
        msg="The 'xgrid' and 'xgridList' arguments are mutually exclusive.", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    else if (present(xgrid)) then
      if (allocated(compp%xgridList)) deallocate(compp%xgridList)
      allocate(compp%xgridList(1))
      compp%xgridList(1) = xgrid
      compp%compStatus%xgridIsPresent = .true.
    else if (present(xgridList)) then
      if (allocated(compp%xgridList)) deallocate(compp%xgridList)
      allocate(compp%xgridList(size(xgridList)))
      compp%xgridList = xgridList
      if (size(xgridList)>0) then
        compp%compStatus%xgridIsPresent = .true.
      else
        compp%compStatus%xgridIsPresent = .false.
      endif
    endif

    if (present(clock)) then
      compp%clock = clock
      compp%compStatus%clockIsPresent = .true.
    endif

    if (present(dirPath)) then
      compp%dirPath = dirPath
    endif

    ! config handling
    if (present(hconfig)) then
      if (present(config).or.present(configFile)) then
        call ESMF_LogSetError(ESMF_RC_ARG_BAD, &
          msg="Must only specify one of: "// &
          "'hconfig', 'config', or 'configFile' arguments!", &
          ESMF_CONTEXT, rcToReturn=rc)
        return
      endif
      compp%config = ESMF_ConfigCreate(hconfig=hconfig, rc=localrc)
      if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      compp%compStatus%configIsPresent = .true.
    else if (present(config)) then
      if (present(configFile)) then
        call ESMF_LogSetError(ESMF_RC_ARG_BAD, &
          msg="Must only specify one of: "// &
          "'hconfig', 'config', or 'configFile' arguments!", &
          ESMF_CONTEXT, rcToReturn=rc)
        return
      endif
      compp%config = config
      compp%compStatus%configIsPresent = .true.
    else if (present(configFile)) then
      ! name of a specific config file.  open it and store the config object.
      compp%configFile = configFile
      compp%compStatus%configFileIsPresent = .true.
      compp%config = ESMF_ConfigCreate(rc=localrc)
      compp%compStatus%configIsPresent = .true.
      call ESMF_ConfigLoadFile(compp%config, configFile, rc=localrc)
      if (localrc /= ESMF_SUCCESS) then
        ! try again with the dirPath concatinated on front
        fullpath = trim(compp%dirPath) // '/' // trim(configFile)
        call ESMF_ConfigLoadFile(compp%config, fullpath, rc=localrc)
        ! TODO: construct a msg string and then call something here.
        ! if (ESMF_LogFoundError(status, msgstr, rc)) return
        if (localrc /= ESMF_SUCCESS) then
          write(msgbuf, *) &
            "ERROR: loading config file, unable to open either", &
            " name = ", trim(configFile), " or name = ", trim(fullpath)
          call ESMF_LogSetError(ESMF_RC_ARG_VALUE, &
            msg=msgbuf, &
            ESMF_CONTEXT, rcToReturn=rc)
          return
        endif
      endif
    endif

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_CompSet