From e6ce6a8865c83d67455402b8e20d5023dd5ad157 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Mon, 26 Apr 2021 11:50:36 -0600 Subject: [PATCH] use isPresent,isSet to conditionally retrieve configuration --- config_src/drivers/nuopc_cap/mom_cap.F90 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/config_src/drivers/nuopc_cap/mom_cap.F90 b/config_src/drivers/nuopc_cap/mom_cap.F90 index f5f7985e15..2d79674606 100644 --- a/config_src/drivers/nuopc_cap/mom_cap.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap.F90 @@ -418,6 +418,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) character(len=512) :: diro character(len=512) :: logfile character(ESMF_MAXSTR) :: cvalue + character(len=64) :: logmsg logical :: isPresent, isPresentDiro, isPresentLogfile, isSet logical :: existflag integer :: userRc @@ -467,13 +468,19 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if(localPeCount == 1) then - call NUOPC_CompAttributeGet(gcomp, "nthreads", value=cvalue, & + call NUOPC_CompAttributeGet(gcomp, name="nthreads", value=cvalue, & isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) nthrds + if (isPresent .and. isSet) then + read(cvalue,*) nthrds + else + nthrds = localPeCount + endif else nthrds = localPeCount endif + write(logmsg,*) nthrds + call ESMF_LogWrite(trim(subname)//': nthreads = '//trim(logmsg), ESMF_LOGMSG_INFO) !$ call omp_set_num_threads(nthrds) @@ -898,10 +905,14 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if(localPeCount == 1) then - call NUOPC_CompAttributeGet(gcomp, "nthreads", value=cvalue, & + call NUOPC_CompAttributeGet(gcomp, name="nthreads", value=cvalue, & isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) nthrds + if (isPresent .and. isSet) then + read(cvalue,*) nthrds + else + nthrds = localPeCount + endif else nthrds = localPeCount endif