17d0a6c19SBarry Smith 21a1499c8SBarry Smith 353acd3b1SBarry Smith /* 43fc1eb6aSBarry Smith Implements the higher-level options database querying methods. These are self-documenting and can attach at runtime to 53fc1eb6aSBarry Smith GUI code to display the options and get values from the users. 653acd3b1SBarry Smith 753acd3b1SBarry Smith */ 853acd3b1SBarry Smith 9af0996ceSBarry Smith #include <petsc/private/petscimpl.h> /*I "petscsys.h" I*/ 10665c2dedSJed Brown #include <petscviewer.h> 1153acd3b1SBarry Smith 122aa6d131SJed Brown #define ManSection(str) ((str) ? (str) : "None") 132aa6d131SJed Brown 1453acd3b1SBarry Smith /* 1553acd3b1SBarry Smith Keep a linked list of options that have been posted and we are waiting for 163fc1eb6aSBarry Smith user selection. See the manual page for PetscOptionsBegin() 1753acd3b1SBarry Smith 1853acd3b1SBarry Smith Eventually we'll attach this beast to a MPI_Comm 1953acd3b1SBarry Smith */ 20e55864a3SBarry Smith 2153acd3b1SBarry Smith 2253acd3b1SBarry Smith /* 2353acd3b1SBarry Smith Handles setting up the data structure in a call to PetscOptionsBegin() 2453acd3b1SBarry Smith */ 254416b707SBarry Smith PetscErrorCode PetscOptionsBegin_Private(PetscOptionItems *PetscOptionsObject,MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 2653acd3b1SBarry Smith { 2753acd3b1SBarry Smith PetscErrorCode ierr; 2853acd3b1SBarry Smith 2953acd3b1SBarry Smith PetscFunctionBegin; 300eb63584SBarry Smith if (!PetscOptionsObject->alreadyprinted) { 319de0f6ecSBarry Smith if (!PetscOptionsHelpPrintedSingleton) { 329de0f6ecSBarry Smith ierr = PetscOptionsHelpPrintedCreate(&PetscOptionsHelpPrintedSingleton);CHKERRQ(ierr); 339de0f6ecSBarry Smith } 349de0f6ecSBarry Smith ierr = PetscOptionsHelpPrintedCheck(PetscOptionsHelpPrintedSingleton,prefix,title,&PetscOptionsObject->alreadyprinted);CHKERRQ(ierr); 350eb63584SBarry Smith } 36e55864a3SBarry Smith PetscOptionsObject->next = 0; 37e55864a3SBarry Smith PetscOptionsObject->comm = comm; 38e55864a3SBarry Smith PetscOptionsObject->changedmethod = PETSC_FALSE; 39a297a907SKarl Rupp 40e55864a3SBarry Smith ierr = PetscStrallocpy(prefix,&PetscOptionsObject->prefix);CHKERRQ(ierr); 41e55864a3SBarry Smith ierr = PetscStrallocpy(title,&PetscOptionsObject->title);CHKERRQ(ierr); 4253acd3b1SBarry Smith 432d747510SLisandro Dalcin ierr = PetscOptionsHasHelp(PetscOptionsObject->options,&PetscOptionsObject->printhelp);CHKERRQ(ierr); 44e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1) { 45e55864a3SBarry Smith if (!PetscOptionsObject->alreadyprinted) { 4653acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr); 4753acd3b1SBarry Smith } 4861b37b28SSatish Balay } 4953acd3b1SBarry Smith PetscFunctionReturn(0); 5053acd3b1SBarry Smith } 5153acd3b1SBarry Smith 523194b578SJed Brown /* 533194b578SJed Brown Handles setting up the data structure in a call to PetscObjectOptionsBegin() 543194b578SJed Brown */ 554416b707SBarry Smith PetscErrorCode PetscObjectOptionsBegin_Private(PetscOptionItems *PetscOptionsObject,PetscObject obj) 563194b578SJed Brown { 573194b578SJed Brown PetscErrorCode ierr; 583194b578SJed Brown char title[256]; 593194b578SJed Brown PetscBool flg; 603194b578SJed Brown 613194b578SJed Brown PetscFunctionBegin; 623194b578SJed Brown PetscValidHeader(obj,1); 63e55864a3SBarry Smith PetscOptionsObject->object = obj; 64e55864a3SBarry Smith PetscOptionsObject->alreadyprinted = obj->optionsprinted; 65a297a907SKarl Rupp 663194b578SJed Brown ierr = PetscStrcmp(obj->description,obj->class_name,&flg);CHKERRQ(ierr); 673194b578SJed Brown if (flg) { 688caf3d72SBarry Smith ierr = PetscSNPrintf(title,sizeof(title),"%s options",obj->class_name);CHKERRQ(ierr); 693194b578SJed Brown } else { 708caf3d72SBarry Smith ierr = PetscSNPrintf(title,sizeof(title),"%s (%s) options",obj->description,obj->class_name);CHKERRQ(ierr); 713194b578SJed Brown } 72e55864a3SBarry Smith ierr = PetscOptionsBegin_Private(PetscOptionsObject,obj->comm,obj->prefix,title,obj->mansec);CHKERRQ(ierr); 733194b578SJed Brown PetscFunctionReturn(0); 743194b578SJed Brown } 753194b578SJed Brown 7653acd3b1SBarry Smith /* 7753acd3b1SBarry Smith Handles adding another option to the list of options within this particular PetscOptionsBegin() PetscOptionsEnd() 7853acd3b1SBarry Smith */ 794416b707SBarry Smith static int PetscOptionItemCreate_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptionItem *amsopt) 8053acd3b1SBarry Smith { 8153acd3b1SBarry Smith int ierr; 824416b707SBarry Smith PetscOptionItem next; 833be6e4c3SJed Brown PetscBool valid; 8453acd3b1SBarry Smith 8553acd3b1SBarry Smith PetscFunctionBegin; 863be6e4c3SJed Brown ierr = PetscOptionsValidKey(opt,&valid);CHKERRQ(ierr); 873be6e4c3SJed Brown if (!valid) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_ARG_INCOMP,"The option '%s' is not a valid key",opt); 883be6e4c3SJed Brown 89b00a9115SJed Brown ierr = PetscNew(amsopt);CHKERRQ(ierr); 9053acd3b1SBarry Smith (*amsopt)->next = 0; 9153acd3b1SBarry Smith (*amsopt)->set = PETSC_FALSE; 926356e834SBarry Smith (*amsopt)->type = t; 9353acd3b1SBarry Smith (*amsopt)->data = 0; 9461b37b28SSatish Balay 9553acd3b1SBarry Smith ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr); 9653acd3b1SBarry Smith ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr); 976356e834SBarry Smith ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr); 9853acd3b1SBarry Smith 99e55864a3SBarry Smith if (!PetscOptionsObject->next) PetscOptionsObject->next = *amsopt; 100a297a907SKarl Rupp else { 101e55864a3SBarry Smith next = PetscOptionsObject->next; 10253acd3b1SBarry Smith while (next->next) next = next->next; 10353acd3b1SBarry Smith next->next = *amsopt; 10453acd3b1SBarry Smith } 10553acd3b1SBarry Smith PetscFunctionReturn(0); 10653acd3b1SBarry Smith } 10753acd3b1SBarry Smith 108aee2cecaSBarry Smith /* 1093fc1eb6aSBarry Smith PetscScanString - Gets user input via stdin from process and broadcasts to all processes 1103fc1eb6aSBarry Smith 1113fc1eb6aSBarry Smith Collective on MPI_Comm 1123fc1eb6aSBarry Smith 1133fc1eb6aSBarry Smith Input Parameters: 1143fc1eb6aSBarry Smith + commm - communicator for the broadcast, must be PETSC_COMM_WORLD 1153fc1eb6aSBarry Smith . n - length of the string, must be the same on all processes 1163fc1eb6aSBarry Smith - str - location to store input 117aee2cecaSBarry Smith 118aee2cecaSBarry Smith Bugs: 119aee2cecaSBarry Smith . Assumes process 0 of the given communicator has access to stdin 120aee2cecaSBarry Smith 121aee2cecaSBarry Smith */ 1223fc1eb6aSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[]) 123aee2cecaSBarry Smith { 124330cf3c9SBarry Smith size_t i; 125aee2cecaSBarry Smith char c; 1263fc1eb6aSBarry Smith PetscMPIInt rank,nm; 127aee2cecaSBarry Smith PetscErrorCode ierr; 128aee2cecaSBarry Smith 129aee2cecaSBarry Smith PetscFunctionBegin; 130aee2cecaSBarry Smith ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 131aee2cecaSBarry Smith if (!rank) { 132aee2cecaSBarry Smith c = (char) getchar(); 133aee2cecaSBarry Smith i = 0; 134aee2cecaSBarry Smith while (c != '\n' && i < n-1) { 135aee2cecaSBarry Smith str[i++] = c; 136aee2cecaSBarry Smith c = (char)getchar(); 137aee2cecaSBarry Smith } 138aee2cecaSBarry Smith str[i] = 0; 139aee2cecaSBarry Smith } 1404dc2109aSBarry Smith ierr = PetscMPIIntCast(n,&nm);CHKERRQ(ierr); 1413fc1eb6aSBarry Smith ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr); 142aee2cecaSBarry Smith PetscFunctionReturn(0); 143aee2cecaSBarry Smith } 144aee2cecaSBarry Smith 1455b02f95dSBarry Smith /* 1465b02f95dSBarry Smith This is needed because certain strings may be freed by SAWs, hence we cannot use PetscStrallocpy() 1475b02f95dSBarry Smith */ 1485b02f95dSBarry Smith static PetscErrorCode PetscStrdup(const char s[],char *t[]) 1495b02f95dSBarry Smith { 1505b02f95dSBarry Smith PetscErrorCode ierr; 1515b02f95dSBarry Smith size_t len; 1525b02f95dSBarry Smith char *tmp = 0; 1535b02f95dSBarry Smith 1545b02f95dSBarry Smith PetscFunctionBegin; 1555b02f95dSBarry Smith if (s) { 1565b02f95dSBarry Smith ierr = PetscStrlen(s,&len);CHKERRQ(ierr); 157f416af30SBarry Smith tmp = (char*) malloc((len+1)*sizeof(char)); 1585b02f95dSBarry Smith if (!tmp) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_MEM,"No memory to duplicate string"); 1595b02f95dSBarry Smith ierr = PetscStrcpy(tmp,s);CHKERRQ(ierr); 1605b02f95dSBarry Smith } 1615b02f95dSBarry Smith *t = tmp; 1625b02f95dSBarry Smith PetscFunctionReturn(0); 1635b02f95dSBarry Smith } 1645b02f95dSBarry Smith 1655b02f95dSBarry Smith 166aee2cecaSBarry Smith /* 1673cc1e11dSBarry Smith PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime 168aee2cecaSBarry Smith 16995452b02SPatrick Sanan Notes: 17095452b02SPatrick Sanan this isn't really practical, it is just to demonstrate the principle 171aee2cecaSBarry Smith 1727781c08eSBarry Smith A carriage return indicates no change from the default; but this like -ksp_monitor <stdout> the default is actually not stdout the default 1737781c08eSBarry Smith is to do nothing so to get it to use stdout you need to type stdout. This is kind of bug? 1747781c08eSBarry Smith 175aee2cecaSBarry Smith Bugs: 1767781c08eSBarry Smith + All processes must traverse through the exact same set of option queries due to the call to PetscScanString() 1773cc1e11dSBarry Smith . Internal strings have arbitrary length and string copies are not checked that they fit into string space 178aee2cecaSBarry Smith - Only works for PetscInt == int, PetscReal == double etc 179aee2cecaSBarry Smith 18095452b02SPatrick Sanan Developer Notes: 18195452b02SPatrick Sanan Normally the GUI that presents the options the user and retrieves the values would be running in a different 1823cc1e11dSBarry Smith address space and communicating with the PETSc program 1833cc1e11dSBarry Smith 184aee2cecaSBarry Smith */ 1854416b707SBarry Smith PetscErrorCode PetscOptionsGetFromTextInput(PetscOptionItems *PetscOptionsObject) 1866356e834SBarry Smith { 1876356e834SBarry Smith PetscErrorCode ierr; 1884416b707SBarry Smith PetscOptionItem next = PetscOptionsObject->next; 1896356e834SBarry Smith char str[512]; 1907781c08eSBarry Smith PetscBool bid; 191a4404d99SBarry Smith PetscReal ir,*valr; 192330cf3c9SBarry Smith PetscInt *vald; 193330cf3c9SBarry Smith size_t i; 1946356e834SBarry Smith 1952a409bb0SBarry Smith PetscFunctionBegin; 196e55864a3SBarry Smith ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject->title);CHKERRQ(ierr); 1976356e834SBarry Smith while (next) { 1986356e834SBarry Smith switch (next->type) { 1996356e834SBarry Smith case OPTION_HEAD: 2006356e834SBarry Smith break; 201e26ddf31SBarry Smith case OPTION_INT_ARRAY: 202e55864a3SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1);CHKERRQ(ierr); 203e26ddf31SBarry Smith vald = (PetscInt*) next->data; 204e26ddf31SBarry Smith for (i=0; i<next->arraylength; i++) { 205e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr); 206e26ddf31SBarry Smith if (i < next->arraylength-1) { 207e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr); 208e26ddf31SBarry Smith } 209e26ddf31SBarry Smith } 210e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s) ",next->text,next->man);CHKERRQ(ierr); 211e26ddf31SBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 212e26ddf31SBarry Smith if (str[0]) { 213e26ddf31SBarry Smith PetscToken token; 214e26ddf31SBarry Smith PetscInt n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end; 215e26ddf31SBarry Smith size_t len; 216e26ddf31SBarry Smith char *value; 217ace3abfcSBarry Smith PetscBool foundrange; 218e26ddf31SBarry Smith 219e26ddf31SBarry Smith next->set = PETSC_TRUE; 220e26ddf31SBarry Smith value = str; 221e26ddf31SBarry Smith ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr); 222e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 223e26ddf31SBarry Smith while (n < nmax) { 224e26ddf31SBarry Smith if (!value) break; 225e26ddf31SBarry Smith 226e26ddf31SBarry Smith /* look for form d-D where d and D are integers */ 227e26ddf31SBarry Smith foundrange = PETSC_FALSE; 228e26ddf31SBarry Smith ierr = PetscStrlen(value,&len);CHKERRQ(ierr); 229e26ddf31SBarry Smith if (value[0] == '-') i=2; 230e26ddf31SBarry Smith else i=1; 231330cf3c9SBarry Smith for (;i<len; i++) { 232e26ddf31SBarry Smith if (value[i] == '-') { 233e32f2f54SBarry Smith if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value); 234e26ddf31SBarry Smith value[i] = 0; 235cfbddea1SSatish Balay ierr = PetscOptionsStringToInt(value,&start);CHKERRQ(ierr); 236cfbddea1SSatish Balay ierr = PetscOptionsStringToInt(value+i+1,&end);CHKERRQ(ierr); 237e32f2f54SBarry Smith if (end <= start) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry, %s-%s cannot have decreasing list",n,value,value+i+1); 238e32f2f54SBarry Smith if (n + end - start - 1 >= nmax) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry, not enough space in left in array (%D) to contain entire range from %D to %D",n,nmax-n,start,end); 239e26ddf31SBarry Smith for (; start<end; start++) { 240e26ddf31SBarry Smith *dvalue = start; dvalue++;n++; 241e26ddf31SBarry Smith } 242e26ddf31SBarry Smith foundrange = PETSC_TRUE; 243e26ddf31SBarry Smith break; 244e26ddf31SBarry Smith } 245e26ddf31SBarry Smith } 246e26ddf31SBarry Smith if (!foundrange) { 247cfbddea1SSatish Balay ierr = PetscOptionsStringToInt(value,dvalue);CHKERRQ(ierr); 248e26ddf31SBarry Smith dvalue++; 249e26ddf31SBarry Smith n++; 250e26ddf31SBarry Smith } 251e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 252e26ddf31SBarry Smith } 2538c74ee41SBarry Smith ierr = PetscTokenDestroy(&token);CHKERRQ(ierr); 254e26ddf31SBarry Smith } 255e26ddf31SBarry Smith break; 256e26ddf31SBarry Smith case OPTION_REAL_ARRAY: 257e55864a3SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1);CHKERRQ(ierr); 258e26ddf31SBarry Smith valr = (PetscReal*) next->data; 259e26ddf31SBarry Smith for (i=0; i<next->arraylength; i++) { 260e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr); 261e26ddf31SBarry Smith if (i < next->arraylength-1) { 262e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr); 263e26ddf31SBarry Smith } 264e26ddf31SBarry Smith } 265e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s) ",next->text,next->man);CHKERRQ(ierr); 266e26ddf31SBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 267e26ddf31SBarry Smith if (str[0]) { 268e26ddf31SBarry Smith PetscToken token; 269e26ddf31SBarry Smith PetscInt n = 0,nmax = next->arraylength; 270e26ddf31SBarry Smith PetscReal *dvalue = (PetscReal*)next->data; 271e26ddf31SBarry Smith char *value; 272e26ddf31SBarry Smith 273e26ddf31SBarry Smith next->set = PETSC_TRUE; 274e26ddf31SBarry Smith value = str; 275e26ddf31SBarry Smith ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr); 276e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 277e26ddf31SBarry Smith while (n < nmax) { 278e26ddf31SBarry Smith if (!value) break; 279cfbddea1SSatish Balay ierr = PetscOptionsStringToReal(value,dvalue);CHKERRQ(ierr); 280e26ddf31SBarry Smith dvalue++; 281e26ddf31SBarry Smith n++; 282e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 283e26ddf31SBarry Smith } 2848c74ee41SBarry Smith ierr = PetscTokenDestroy(&token);CHKERRQ(ierr); 285e26ddf31SBarry Smith } 286e26ddf31SBarry Smith break; 2876356e834SBarry Smith case OPTION_INT: 288e55864a3SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%d>: %s (%s) ",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,*(int*)next->data,next->text,next->man);CHKERRQ(ierr); 2893fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 2903fc1eb6aSBarry Smith if (str[0]) { 291d25d7f95SJed Brown #if defined(PETSC_SIZEOF_LONG_LONG) 292d25d7f95SJed Brown long long lid; 293d25d7f95SJed Brown sscanf(str,"%lld",&lid); 2941a1499c8SBarry Smith if (lid > PETSC_MAX_INT || lid < PETSC_MIN_INT) SETERRQ3(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Argument: -%s%s %lld",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,lid); 295c272547aSJed Brown #else 296d25d7f95SJed Brown long lid; 297d25d7f95SJed Brown sscanf(str,"%ld",&lid); 2981a1499c8SBarry Smith if (lid > PETSC_MAX_INT || lid < PETSC_MIN_INT) SETERRQ3(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Argument: -%s%s %ld",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,lid); 299c272547aSJed Brown #endif 300a297a907SKarl Rupp 301d25d7f95SJed Brown next->set = PETSC_TRUE; 302d25d7f95SJed Brown *((PetscInt*)next->data) = (PetscInt)lid; 303aee2cecaSBarry Smith } 304aee2cecaSBarry Smith break; 305aee2cecaSBarry Smith case OPTION_REAL: 306e55864a3SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%g>: %s (%s) ",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,*(double*)next->data,next->text,next->man);CHKERRQ(ierr); 3073fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 3083fc1eb6aSBarry Smith if (str[0]) { 309ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE) 310a4404d99SBarry Smith sscanf(str,"%e",&ir); 311570b7f6dSBarry Smith #elif defined(PETSC_USE_REAL___FP16) 312570b7f6dSBarry Smith float irtemp; 313570b7f6dSBarry Smith sscanf(str,"%e",&irtemp); 314570b7f6dSBarry Smith ir = irtemp; 315ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE) 316aee2cecaSBarry Smith sscanf(str,"%le",&ir); 317ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128) 318d9822059SBarry Smith ir = strtoflt128(str,0); 319d9822059SBarry Smith #else 320513dbe71SLisandro Dalcin SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Unknown scalar type"); 321a4404d99SBarry Smith #endif 322aee2cecaSBarry Smith next->set = PETSC_TRUE; 323aee2cecaSBarry Smith *((PetscReal*)next->data) = ir; 324aee2cecaSBarry Smith } 325aee2cecaSBarry Smith break; 3267781c08eSBarry Smith case OPTION_BOOL: 32783355fc5SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%s>: %s (%s) ",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,*(PetscBool*)next->data ? "true": "false",next->text,next->man);CHKERRQ(ierr); 3287781c08eSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 3297781c08eSBarry Smith if (str[0]) { 3307781c08eSBarry Smith ierr = PetscOptionsStringToBool(str,&bid);CHKERRQ(ierr); 3317781c08eSBarry Smith next->set = PETSC_TRUE; 3327781c08eSBarry Smith *((PetscBool*)next->data) = bid; 3337781c08eSBarry Smith } 3347781c08eSBarry Smith break; 335aee2cecaSBarry Smith case OPTION_STRING: 336e55864a3SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <%s>: %s (%s) ",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",next->option+1,(char*)next->data,next->text,next->man);CHKERRQ(ierr); 3373fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 3383fc1eb6aSBarry Smith if (str[0]) { 339aee2cecaSBarry Smith next->set = PETSC_TRUE; 34064facd6cSBarry Smith /* must use system malloc since SAWs may free this */ 3415b02f95dSBarry Smith ierr = PetscStrdup(str,(char**)&next->data);CHKERRQ(ierr); 3426356e834SBarry Smith } 3436356e834SBarry Smith break; 344a264d7a6SBarry Smith case OPTION_FLIST: 345e55864a3SBarry Smith ierr = PetscFunctionListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject->prefix,next->option,next->text,next->man,next->flist,(char*)next->data);CHKERRQ(ierr); 3463cc1e11dSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 3473cc1e11dSBarry Smith if (str[0]) { 348e55864a3SBarry Smith PetscOptionsObject->changedmethod = PETSC_TRUE; 3493cc1e11dSBarry Smith next->set = PETSC_TRUE; 35064facd6cSBarry Smith /* must use system malloc since SAWs may free this */ 3515b02f95dSBarry Smith ierr = PetscStrdup(str,(char**)&next->data);CHKERRQ(ierr); 3523cc1e11dSBarry Smith } 3533cc1e11dSBarry Smith break; 354b432afdaSMatthew Knepley default: 355b432afdaSMatthew Knepley break; 3566356e834SBarry Smith } 3576356e834SBarry Smith next = next->next; 3586356e834SBarry Smith } 3596356e834SBarry Smith PetscFunctionReturn(0); 3606356e834SBarry Smith } 3616356e834SBarry Smith 362e04113cfSBarry Smith #if defined(PETSC_HAVE_SAWS) 363e04113cfSBarry Smith #include <petscviewersaws.h> 364d5649816SBarry Smith 365d5649816SBarry Smith static int count = 0; 366d5649816SBarry Smith 367e04113cfSBarry Smith PetscErrorCode PetscOptionsSAWsDestroy(void) 368d5649816SBarry Smith { 3692657e9d9SBarry Smith PetscFunctionBegin; 370d5649816SBarry Smith PetscFunctionReturn(0); 371d5649816SBarry Smith } 372d5649816SBarry Smith 3739c1e0ce8SBarry Smith static const char *OptionsHeader = "<head>\n" 37423a1ff79SBarry Smith "<script type=\"text/javascript\" src=\"http://www.mcs.anl.gov/research/projects/saws/js/jquery-1.9.1.js\"></script>\n" 37523a1ff79SBarry Smith "<script type=\"text/javascript\" src=\"http://www.mcs.anl.gov/research/projects/saws/js/SAWs.js\"></script>\n" 376d1fc0251SBarry Smith "<script type=\"text/javascript\" src=\"js/PETSc.js\"></script>\n" 37764bbc9efSBarry Smith "<script>\n" 37864bbc9efSBarry Smith "jQuery(document).ready(function() {\n" 37964bbc9efSBarry Smith "PETSc.getAndDisplayDirectory(null,\"#variablesInfo\")\n" 38064bbc9efSBarry Smith "})\n" 38164bbc9efSBarry Smith "</script>\n" 38264bbc9efSBarry Smith "</head>\n"; 3831423471aSBarry Smith 3841423471aSBarry Smith /* Determines the size and style of the scroll region where PETSc options selectable from users are displayed */ 3851423471aSBarry Smith static const char *OptionsBodyBottom = "<div id=\"variablesInfo\" style=\"background-color:lightblue;height:auto;max-height:500px;overflow:scroll;\"></div>\n<br>\n</body>"; 38664bbc9efSBarry Smith 387b3506946SBarry Smith /* 3887781c08eSBarry Smith PetscOptionsSAWsInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the SAWs 389b3506946SBarry Smith 390b3506946SBarry Smith Bugs: 391b3506946SBarry Smith + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 392b3506946SBarry Smith . Internal strings have arbitrary length and string copies are not checked that they fit into string space 393b3506946SBarry Smith - Only works for PetscInt == int, PetscReal == double etc 394b3506946SBarry Smith 395b3506946SBarry Smith 396b3506946SBarry Smith */ 3974416b707SBarry Smith PetscErrorCode PetscOptionsSAWsInput(PetscOptionItems *PetscOptionsObject) 398b3506946SBarry Smith { 399b3506946SBarry Smith PetscErrorCode ierr; 4004416b707SBarry Smith PetscOptionItem next = PetscOptionsObject->next; 401d5649816SBarry Smith static int mancount = 0; 402b3506946SBarry Smith char options[16]; 4037aab2a10SBarry Smith PetscBool changedmethod = PETSC_FALSE; 404a23eb982SSurtai Han PetscBool stopasking = PETSC_FALSE; 40588a9752cSBarry Smith char manname[16],textname[16]; 4062657e9d9SBarry Smith char dir[1024]; 407b3506946SBarry Smith 4082a409bb0SBarry Smith PetscFunctionBegin; 409b3506946SBarry Smith /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */ 410b3506946SBarry Smith sprintf(options,"Options_%d",count++); 411a297a907SKarl Rupp 4127325c4a4SBarry Smith PetscOptionsObject->pprefix = PetscOptionsObject->prefix; /* SAWs will change this, so cannot pass prefix directly */ 4131bc75a8dSBarry Smith 414d50831c4SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s","_title");CHKERRQ(ierr); 41583355fc5SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject->title,1,SAWs_READ,SAWs_STRING)); 4167781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s","prefix");CHKERRQ(ierr); 41783355fc5SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject->pprefix,1,SAWs_READ,SAWs_STRING)); 4182657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/ChangedMethod",&changedmethod,1,SAWs_WRITE,SAWs_BOOLEAN)); 419a23eb982SSurtai Han PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/StopAsking",&stopasking,1,SAWs_WRITE,SAWs_BOOLEAN)); 420b3506946SBarry Smith 421b3506946SBarry Smith while (next) { 422d50831c4SBarry Smith sprintf(manname,"_man_%d",mancount); 4232657e9d9SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",manname);CHKERRQ(ierr); 4247781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->man,1,SAWs_READ,SAWs_STRING)); 425d50831c4SBarry Smith sprintf(textname,"_text_%d",mancount++); 4267781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",textname);CHKERRQ(ierr); 4277781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->text,1,SAWs_READ,SAWs_STRING)); 4289f32e415SBarry Smith 429b3506946SBarry Smith switch (next->type) { 430b3506946SBarry Smith case OPTION_HEAD: 431b3506946SBarry Smith break; 432b3506946SBarry Smith case OPTION_INT_ARRAY: 4337781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4342657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_INT)); 435b3506946SBarry Smith break; 436b3506946SBarry Smith case OPTION_REAL_ARRAY: 4377781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4382657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_DOUBLE)); 439b3506946SBarry Smith break; 440b3506946SBarry Smith case OPTION_INT: 4417781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4422657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_INT)); 443b3506946SBarry Smith break; 444b3506946SBarry Smith case OPTION_REAL: 4457781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4462657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_DOUBLE)); 447b3506946SBarry Smith break; 4487781c08eSBarry Smith case OPTION_BOOL: 4497781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4502657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_BOOLEAN)); 4511ae3d29cSBarry Smith break; 4527781c08eSBarry Smith case OPTION_BOOL_ARRAY: 4537781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4542657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_BOOLEAN)); 45571f08665SBarry Smith break; 456b3506946SBarry Smith case OPTION_STRING: 4577781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4587781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING)); 4591ae3d29cSBarry Smith break; 4601ae3d29cSBarry Smith case OPTION_STRING_ARRAY: 4617781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4622657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_STRING)); 463b3506946SBarry Smith break; 464a264d7a6SBarry Smith case OPTION_FLIST: 465a264d7a6SBarry Smith { 466a264d7a6SBarry Smith PetscInt ntext; 4677781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4687781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING)); 469a264d7a6SBarry Smith ierr = PetscFunctionListGet(next->flist,(const char***)&next->edata,&ntext);CHKERRQ(ierr); 470a264d7a6SBarry Smith PetscStackCallSAWs(SAWs_Set_Legal_Variable_Values,(dir,ntext,next->edata)); 471a264d7a6SBarry Smith } 472a264d7a6SBarry Smith break; 4731ae3d29cSBarry Smith case OPTION_ELIST: 474a264d7a6SBarry Smith { 475a264d7a6SBarry Smith PetscInt ntext = next->nlist; 4767781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4777781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING)); 478ead66b60SBarry Smith ierr = PetscMalloc1((ntext+1),(char***)&next->edata);CHKERRQ(ierr); 4791ae3d29cSBarry Smith ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr); 480a264d7a6SBarry Smith PetscStackCallSAWs(SAWs_Set_Legal_Variable_Values,(dir,ntext,next->edata)); 481a264d7a6SBarry Smith } 482a264d7a6SBarry Smith break; 483b3506946SBarry Smith default: 484b3506946SBarry Smith break; 485b3506946SBarry Smith } 486b3506946SBarry Smith next = next->next; 487b3506946SBarry Smith } 488b3506946SBarry Smith 489b3506946SBarry Smith /* wait until accessor has unlocked the memory */ 49064bbc9efSBarry Smith PetscStackCallSAWs(SAWs_Push_Header,("index.html",OptionsHeader)); 49164bbc9efSBarry Smith PetscStackCallSAWs(SAWs_Push_Body,("index.html",2,OptionsBodyBottom)); 4927aab2a10SBarry Smith ierr = PetscSAWsBlock();CHKERRQ(ierr); 49364bbc9efSBarry Smith PetscStackCallSAWs(SAWs_Pop_Header,("index.html")); 49464bbc9efSBarry Smith PetscStackCallSAWs(SAWs_Pop_Body,("index.html",2)); 495b3506946SBarry Smith 49688a9752cSBarry Smith /* determine if any values have been set in GUI */ 49783355fc5SBarry Smith next = PetscOptionsObject->next; 49888a9752cSBarry Smith while (next) { 49988a9752cSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 500f7b25cf6SBarry Smith PetscStackCallSAWs(SAWs_Selected,(dir,(int*)&next->set)); 50188a9752cSBarry Smith next = next->next; 50288a9752cSBarry Smith } 50388a9752cSBarry Smith 504b3506946SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 505f7b25cf6SBarry Smith if (changedmethod) PetscOptionsObject->count = -2; 506b3506946SBarry Smith 507a23eb982SSurtai Han if (stopasking) { 508a23eb982SSurtai Han PetscOptionsPublish = PETSC_FALSE; 50912655325SBarry Smith PetscOptionsObject->count = 0;//do not ask for same thing again 510a23eb982SSurtai Han } 511a23eb982SSurtai Han 5129a492a5cSBarry Smith PetscStackCallSAWs(SAWs_Delete,("/PETSc/Options")); 513b3506946SBarry Smith PetscFunctionReturn(0); 514b3506946SBarry Smith } 515b3506946SBarry Smith #endif 516b3506946SBarry Smith 5174416b707SBarry Smith PetscErrorCode PetscOptionsEnd_Private(PetscOptionItems *PetscOptionsObject) 51853acd3b1SBarry Smith { 51953acd3b1SBarry Smith PetscErrorCode ierr; 5204416b707SBarry Smith PetscOptionItem last; 5216356e834SBarry Smith char option[256],value[1024],tmp[32]; 522330cf3c9SBarry Smith size_t j; 52353acd3b1SBarry Smith 52453acd3b1SBarry Smith PetscFunctionBegin; 52583355fc5SBarry Smith if (PetscOptionsObject->next) { 52683355fc5SBarry Smith if (!PetscOptionsObject->count) { 527a264d7a6SBarry Smith #if defined(PETSC_HAVE_SAWS) 528f7b25cf6SBarry Smith ierr = PetscOptionsSAWsInput(PetscOptionsObject);CHKERRQ(ierr); 529b3506946SBarry Smith #else 530e55864a3SBarry Smith ierr = PetscOptionsGetFromTextInput(PetscOptionsObject);CHKERRQ(ierr); 531b3506946SBarry Smith #endif 532aee2cecaSBarry Smith } 533aee2cecaSBarry Smith } 5346356e834SBarry Smith 535e55864a3SBarry Smith ierr = PetscFree(PetscOptionsObject->title);CHKERRQ(ierr); 5366356e834SBarry Smith 537e26ddf31SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 538e55864a3SBarry Smith if (PetscOptionsObject->changedmethod) PetscOptionsObject->count = -2; 5397a72a596SBarry Smith /* reset alreadyprinted flag */ 540e55864a3SBarry Smith PetscOptionsObject->alreadyprinted = PETSC_FALSE; 541e55864a3SBarry Smith if (PetscOptionsObject->object) PetscOptionsObject->object->optionsprinted = PETSC_TRUE; 542e55864a3SBarry Smith PetscOptionsObject->object = NULL; 54353acd3b1SBarry Smith 544e55864a3SBarry Smith while (PetscOptionsObject->next) { 545e55864a3SBarry Smith if (PetscOptionsObject->next->set) { 546e55864a3SBarry Smith if (PetscOptionsObject->prefix) { 54753acd3b1SBarry Smith ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 548e55864a3SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject->prefix);CHKERRQ(ierr); 549e55864a3SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject->next->option+1);CHKERRQ(ierr); 5506356e834SBarry Smith } else { 551e55864a3SBarry Smith ierr = PetscStrcpy(option,PetscOptionsObject->next->option);CHKERRQ(ierr); 5526356e834SBarry Smith } 5536356e834SBarry Smith 554e55864a3SBarry Smith switch (PetscOptionsObject->next->type) { 5556356e834SBarry Smith case OPTION_HEAD: 5566356e834SBarry Smith break; 5576356e834SBarry Smith case OPTION_INT_ARRAY: 558e55864a3SBarry Smith sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject->next->data)[0]); 559e55864a3SBarry Smith for (j=1; j<PetscOptionsObject->next->arraylength; j++) { 560e55864a3SBarry Smith sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject->next->data)[j]); 5616356e834SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 5626356e834SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 5636356e834SBarry Smith } 5646356e834SBarry Smith break; 5656356e834SBarry Smith case OPTION_INT: 566e55864a3SBarry Smith sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject->next->data); 5676356e834SBarry Smith break; 5686356e834SBarry Smith case OPTION_REAL: 569e55864a3SBarry Smith sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject->next->data); 5706356e834SBarry Smith break; 5716356e834SBarry Smith case OPTION_REAL_ARRAY: 572e55864a3SBarry Smith sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject->next->data)[0]); 573e55864a3SBarry Smith for (j=1; j<PetscOptionsObject->next->arraylength; j++) { 574e55864a3SBarry Smith sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject->next->data)[j]); 5756356e834SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 5766356e834SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 5776356e834SBarry Smith } 5786356e834SBarry Smith break; 579050cccc3SHong Zhang case OPTION_SCALAR_ARRAY: 58095f3a755SJose E. Roman sprintf(value,"%g+%gi",(double)PetscRealPart(((PetscScalar*)PetscOptionsObject->next->data)[0]),(double)PetscImaginaryPart(((PetscScalar*)PetscOptionsObject->next->data)[0])); 581050cccc3SHong Zhang for (j=1; j<PetscOptionsObject->next->arraylength; j++) { 58295f3a755SJose E. Roman sprintf(tmp,"%g+%gi",(double)PetscRealPart(((PetscScalar*)PetscOptionsObject->next->data)[j]),(double)PetscImaginaryPart(((PetscScalar*)PetscOptionsObject->next->data)[j])); 583050cccc3SHong Zhang ierr = PetscStrcat(value,",");CHKERRQ(ierr); 584050cccc3SHong Zhang ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 585050cccc3SHong Zhang } 586050cccc3SHong Zhang break; 5877781c08eSBarry Smith case OPTION_BOOL: 588e55864a3SBarry Smith sprintf(value,"%d",*(int*)PetscOptionsObject->next->data); 5896356e834SBarry Smith break; 5907781c08eSBarry Smith case OPTION_BOOL_ARRAY: 591e55864a3SBarry Smith sprintf(value,"%d",(int)((PetscBool*)PetscOptionsObject->next->data)[0]); 592e55864a3SBarry Smith for (j=1; j<PetscOptionsObject->next->arraylength; j++) { 593e55864a3SBarry Smith sprintf(tmp,"%d",(int)((PetscBool*)PetscOptionsObject->next->data)[j]); 5941ae3d29cSBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 5951ae3d29cSBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 5961ae3d29cSBarry Smith } 5971ae3d29cSBarry Smith break; 598a264d7a6SBarry Smith case OPTION_FLIST: 5996991f827SBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject->next->data);CHKERRQ(ierr); 6006991f827SBarry Smith break; 6011ae3d29cSBarry Smith case OPTION_ELIST: 602e55864a3SBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject->next->data);CHKERRQ(ierr); 6036356e834SBarry Smith break; 6041ae3d29cSBarry Smith case OPTION_STRING: 605e55864a3SBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject->next->data);CHKERRQ(ierr); 606d51da6bfSBarry Smith break; 6071ae3d29cSBarry Smith case OPTION_STRING_ARRAY: 608e55864a3SBarry Smith sprintf(value,"%s",((char**)PetscOptionsObject->next->data)[0]); 609e55864a3SBarry Smith for (j=1; j<PetscOptionsObject->next->arraylength; j++) { 610e55864a3SBarry Smith sprintf(tmp,"%s",((char**)PetscOptionsObject->next->data)[j]); 6111ae3d29cSBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 6121ae3d29cSBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 6131ae3d29cSBarry Smith } 6146356e834SBarry Smith break; 6156356e834SBarry Smith } 616c5929fdfSBarry Smith ierr = PetscOptionsSetValue(PetscOptionsObject->options,option,value);CHKERRQ(ierr); 6176356e834SBarry Smith } 6186991f827SBarry Smith if (PetscOptionsObject->next->type == OPTION_ELIST) { 6196991f827SBarry Smith ierr = PetscStrNArrayDestroy(PetscOptionsObject->next->nlist,(char ***)&PetscOptionsObject->next->list);CHKERRQ(ierr); 6206991f827SBarry Smith } 621e55864a3SBarry Smith ierr = PetscFree(PetscOptionsObject->next->text);CHKERRQ(ierr); 622e55864a3SBarry Smith ierr = PetscFree(PetscOptionsObject->next->option);CHKERRQ(ierr); 623e55864a3SBarry Smith ierr = PetscFree(PetscOptionsObject->next->man);CHKERRQ(ierr); 624e55864a3SBarry Smith ierr = PetscFree(PetscOptionsObject->next->edata);CHKERRQ(ierr); 625c979a496SBarry Smith 62683355fc5SBarry Smith if ((PetscOptionsObject->next->type == OPTION_STRING) || (PetscOptionsObject->next->type == OPTION_FLIST) || (PetscOptionsObject->next->type == OPTION_ELIST)){ 62783355fc5SBarry Smith free(PetscOptionsObject->next->data); 628c979a496SBarry Smith } else { 62983355fc5SBarry Smith ierr = PetscFree(PetscOptionsObject->next->data);CHKERRQ(ierr); 630c979a496SBarry Smith } 6317781c08eSBarry Smith 63283355fc5SBarry Smith last = PetscOptionsObject->next; 63383355fc5SBarry Smith PetscOptionsObject->next = PetscOptionsObject->next->next; 6346356e834SBarry Smith ierr = PetscFree(last);CHKERRQ(ierr); 6356356e834SBarry Smith } 636f59f755dSBarry Smith ierr = PetscFree(PetscOptionsObject->prefix);CHKERRQ(ierr); 637e55864a3SBarry Smith PetscOptionsObject->next = 0; 63853acd3b1SBarry Smith PetscFunctionReturn(0); 63953acd3b1SBarry Smith } 64053acd3b1SBarry Smith 64153acd3b1SBarry Smith /*@C 64253acd3b1SBarry Smith PetscOptionsEnum - Gets the enum value for a particular option in the database. 64353acd3b1SBarry Smith 6443f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 64553acd3b1SBarry Smith 64653acd3b1SBarry Smith Input Parameters: 64753acd3b1SBarry Smith + opt - option name 64853acd3b1SBarry Smith . text - short string that describes the option 64953acd3b1SBarry Smith . man - manual page with additional information on option 65053acd3b1SBarry Smith . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 6510fdccdaeSBarry Smith - currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either 6520fdccdaeSBarry Smith $ PetscOptionsEnum(..., obj->value,&object->value,...) or 6530fdccdaeSBarry Smith $ value = defaultvalue 6540fdccdaeSBarry Smith $ PetscOptionsEnum(..., value,&value,&flg); 6550fdccdaeSBarry Smith $ if (flg) { 65653acd3b1SBarry Smith 65753acd3b1SBarry Smith Output Parameter: 65853acd3b1SBarry Smith + value - the value to return 659b32e0204SMatthew G Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 66053acd3b1SBarry Smith 66153acd3b1SBarry Smith Level: beginner 66253acd3b1SBarry Smith 66353acd3b1SBarry Smith Concepts: options database 66453acd3b1SBarry Smith 66595452b02SPatrick Sanan Notes: 66695452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 66753acd3b1SBarry Smith 66853acd3b1SBarry Smith list is usually something like PCASMTypes or some other predefined list of enum names 66953acd3b1SBarry Smith 6702efd9cb1SBarry Smith If the user does not supply the option at all value is NOT changed. Thus 6712efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 6722efd9cb1SBarry Smith 673989712b9SBarry Smith The default/currentvalue passed into this routine does not get transferred to the output value variable automatically. 674989712b9SBarry Smith 67553acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 676acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 677acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 67853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 67953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 680acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 681a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 68253acd3b1SBarry Smith @*/ 6834416b707SBarry Smith PetscErrorCode PetscOptionsEnum_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],const char *const *list,PetscEnum currentvalue,PetscEnum *value,PetscBool *set) 68453acd3b1SBarry Smith { 68553acd3b1SBarry Smith PetscErrorCode ierr; 68653acd3b1SBarry Smith PetscInt ntext = 0; 687aa5bb8c0SSatish Balay PetscInt tval; 688ace3abfcSBarry Smith PetscBool tflg; 68953acd3b1SBarry Smith 69053acd3b1SBarry Smith PetscFunctionBegin; 69153acd3b1SBarry Smith while (list[ntext++]) { 692e32f2f54SBarry Smith if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 69353acd3b1SBarry Smith } 694e32f2f54SBarry Smith if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 69553acd3b1SBarry Smith ntext -= 3; 696e55864a3SBarry Smith ierr = PetscOptionsEList_Private(PetscOptionsObject,opt,text,man,list,ntext,list[currentvalue],&tval,&tflg);CHKERRQ(ierr); 697aa5bb8c0SSatish Balay /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 698aa5bb8c0SSatish Balay if (tflg) *value = (PetscEnum)tval; 699aa5bb8c0SSatish Balay if (set) *set = tflg; 70053acd3b1SBarry Smith PetscFunctionReturn(0); 70153acd3b1SBarry Smith } 70253acd3b1SBarry Smith 703d3e47460SLisandro Dalcin /*@C 704d3e47460SLisandro Dalcin PetscOptionsEnumArray - Gets an array of enum values for a particular 705d3e47460SLisandro Dalcin option in the database. 706d3e47460SLisandro Dalcin 707d3e47460SLisandro Dalcin Logically Collective on the communicator passed in PetscOptionsBegin() 708d3e47460SLisandro Dalcin 709d3e47460SLisandro Dalcin Input Parameters: 710d3e47460SLisandro Dalcin + opt - the option one is seeking 711d3e47460SLisandro Dalcin . text - short string describing option 712d3e47460SLisandro Dalcin . man - manual page for option 713d3e47460SLisandro Dalcin - n - maximum number of values 714d3e47460SLisandro Dalcin 715d3e47460SLisandro Dalcin Output Parameter: 716d3e47460SLisandro Dalcin + value - location to copy values 717d3e47460SLisandro Dalcin . n - actual number of values found 718d3e47460SLisandro Dalcin - set - PETSC_TRUE if found, else PETSC_FALSE 719d3e47460SLisandro Dalcin 720d3e47460SLisandro Dalcin Level: beginner 721d3e47460SLisandro Dalcin 722d3e47460SLisandro Dalcin Notes: 723d3e47460SLisandro Dalcin The array must be passed as a comma separated list. 724d3e47460SLisandro Dalcin 725d3e47460SLisandro Dalcin There must be no intervening spaces between the values. 726d3e47460SLisandro Dalcin 727d3e47460SLisandro Dalcin Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 728d3e47460SLisandro Dalcin 729d3e47460SLisandro Dalcin Concepts: options database^array of enums 730d3e47460SLisandro Dalcin 731d3e47460SLisandro Dalcin .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 732d3e47460SLisandro Dalcin PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 733d3e47460SLisandro Dalcin PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 734d3e47460SLisandro Dalcin PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 735d3e47460SLisandro Dalcin PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 736d3e47460SLisandro Dalcin PetscOptionsFList(), PetscOptionsEList(), PetscOptionsRealArray() 737d3e47460SLisandro Dalcin @*/ 7384416b707SBarry Smith PetscErrorCode PetscOptionsEnumArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],const char *const *list,PetscEnum value[],PetscInt *n,PetscBool *set) 739d3e47460SLisandro Dalcin { 740d3e47460SLisandro Dalcin PetscInt i,nlist = 0; 7414416b707SBarry Smith PetscOptionItem amsopt; 742d3e47460SLisandro Dalcin PetscErrorCode ierr; 743d3e47460SLisandro Dalcin 744d3e47460SLisandro Dalcin PetscFunctionBegin; 745d3e47460SLisandro Dalcin while (list[nlist++]) if (nlist > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 746d3e47460SLisandro Dalcin if (nlist < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 747d3e47460SLisandro Dalcin nlist -= 3; /* drop enum name, prefix, and null termination */ 748d3e47460SLisandro Dalcin if (0 && !PetscOptionsObject->count) { /* XXX Requires additional support */ 749d3e47460SLisandro Dalcin PetscEnum *vals; 7504416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_INT_ARRAY/*XXX OPTION_ENUM_ARRAY*/,&amsopt);CHKERRQ(ierr); 751d3e47460SLisandro Dalcin ierr = PetscStrNArrayallocpy(nlist,list,(char***)&amsopt->list);CHKERRQ(ierr); 752d3e47460SLisandro Dalcin amsopt->nlist = nlist; 753d3e47460SLisandro Dalcin ierr = PetscMalloc1(*n,(PetscEnum**)&amsopt->data);CHKERRQ(ierr); 754d3e47460SLisandro Dalcin amsopt->arraylength = *n; 755d3e47460SLisandro Dalcin vals = (PetscEnum*)amsopt->data; 756d3e47460SLisandro Dalcin for (i=0; i<*n; i++) vals[i] = value[i]; 757d3e47460SLisandro Dalcin } 758c5929fdfSBarry Smith ierr = PetscOptionsGetEnumArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,list,value,n,set);CHKERRQ(ierr); 759d3e47460SLisandro Dalcin if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 760d3e47460SLisandro Dalcin ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%s",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,list[value[0]]);CHKERRQ(ierr); 761d3e47460SLisandro Dalcin for (i=1; i<*n; i++) {ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%s",list[value[i]]);CHKERRQ(ierr);} 762d3e47460SLisandro Dalcin ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (choose from)",text);CHKERRQ(ierr); 763d3e47460SLisandro Dalcin for (i=0; i<nlist; i++) {ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," %s",list[i]);CHKERRQ(ierr);} 764d3e47460SLisandro Dalcin ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," (%s)\n",ManSection(man));CHKERRQ(ierr); 765d3e47460SLisandro Dalcin } 766d3e47460SLisandro Dalcin PetscFunctionReturn(0); 767d3e47460SLisandro Dalcin } 768d3e47460SLisandro Dalcin 76953acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/ 77053acd3b1SBarry Smith /*@C 77153acd3b1SBarry Smith PetscOptionsInt - Gets the integer value for a particular option in the database. 77253acd3b1SBarry Smith 7733f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 77453acd3b1SBarry Smith 77553acd3b1SBarry Smith Input Parameters: 77653acd3b1SBarry Smith + opt - option name 77753acd3b1SBarry Smith . text - short string that describes the option 77853acd3b1SBarry Smith . man - manual page with additional information on option 7790fdccdaeSBarry Smith - currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either 7800fdccdaeSBarry Smith $ PetscOptionsInt(..., obj->value,&object->value,...) or 7810fdccdaeSBarry Smith $ value = defaultvalue 7820fdccdaeSBarry Smith $ PetscOptionsInt(..., value,&value,&flg); 7830fdccdaeSBarry Smith $ if (flg) { 78453acd3b1SBarry Smith 78553acd3b1SBarry Smith Output Parameter: 78653acd3b1SBarry Smith + value - the integer value to return 78753acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 78853acd3b1SBarry Smith 78995452b02SPatrick Sanan Notes: 79095452b02SPatrick Sanan If the user does not supply the option at all value is NOT changed. Thus 7912efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 7922efd9cb1SBarry Smith 793989712b9SBarry Smith The default/currentvalue passed into this routine does not get transferred to the output value variable automatically. 794989712b9SBarry Smith 79553acd3b1SBarry Smith Level: beginner 79653acd3b1SBarry Smith 79753acd3b1SBarry Smith Concepts: options database^has int 79853acd3b1SBarry Smith 79995452b02SPatrick Sanan Notes: 80095452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 80153acd3b1SBarry Smith 80253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 803acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 804acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 80553acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 80653acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 807acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 808a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 80953acd3b1SBarry Smith @*/ 8104416b707SBarry Smith PetscErrorCode PetscOptionsInt_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscInt currentvalue,PetscInt *value,PetscBool *set) 81153acd3b1SBarry Smith { 81253acd3b1SBarry Smith PetscErrorCode ierr; 8134416b707SBarry Smith PetscOptionItem amsopt; 81412655325SBarry Smith PetscBool wasset; 81553acd3b1SBarry Smith 81653acd3b1SBarry Smith PetscFunctionBegin; 817e55864a3SBarry Smith if (!PetscOptionsObject->count) { 8184416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 8196356e834SBarry Smith ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 82012655325SBarry Smith *(PetscInt*)amsopt->data = currentvalue; 8213e211508SBarry Smith 822c5929fdfSBarry Smith ierr = PetscOptionsGetInt(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,¤tvalue,&wasset);CHKERRQ(ierr); 8233e211508SBarry Smith if (wasset) { 82412655325SBarry Smith *(PetscInt*)amsopt->data = currentvalue; 8253e211508SBarry Smith } 826af6d86caSBarry Smith } 827*89a13869SBarry Smith ierr = PetscOptionsGetInt(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,set);CHKERRQ(ierr); 828e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 8291a1499c8SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,currentvalue,text,ManSection(man));CHKERRQ(ierr); 83053acd3b1SBarry Smith } 83153acd3b1SBarry Smith PetscFunctionReturn(0); 83253acd3b1SBarry Smith } 83353acd3b1SBarry Smith 83453acd3b1SBarry Smith /*@C 83553acd3b1SBarry Smith PetscOptionsString - Gets the string value for a particular option in the database. 83653acd3b1SBarry Smith 8373f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 83853acd3b1SBarry Smith 83953acd3b1SBarry Smith Input Parameters: 84053acd3b1SBarry Smith + opt - option name 84153acd3b1SBarry Smith . text - short string that describes the option 84253acd3b1SBarry Smith . man - manual page with additional information on option 8430fdccdaeSBarry Smith . currentvalue - the current value; caller is responsible for setting this value correctly. This is not used to set value 844bcbf2dc5SJed Brown - len - length of the result string including null terminator 84553acd3b1SBarry Smith 84653acd3b1SBarry Smith Output Parameter: 84753acd3b1SBarry Smith + value - the value to return 84853acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 84953acd3b1SBarry Smith 85053acd3b1SBarry Smith Level: beginner 85153acd3b1SBarry Smith 85253acd3b1SBarry Smith Concepts: options database^has int 85353acd3b1SBarry Smith 85495452b02SPatrick Sanan Notes: 85595452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 85653acd3b1SBarry Smith 8577fccdfe4SBarry Smith Even if the user provided no string (for example -optionname -someotheroption) the flag is set to PETSC_TRUE (and the string is fulled with nulls). 8587fccdfe4SBarry Smith 8592efd9cb1SBarry Smith If the user does not supply the option at all value is NOT changed. Thus 8602efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 8612efd9cb1SBarry Smith 862989712b9SBarry Smith The default/currentvalue passed into this routine does not get transferred to the output value variable automatically. 863989712b9SBarry Smith 8642efd9cb1SBarry Smith 865*89a13869SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 866acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 867acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsReal(), PetscOptionsBool(), 86853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 86953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 870acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 871a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 87253acd3b1SBarry Smith @*/ 8734416b707SBarry Smith PetscErrorCode PetscOptionsString_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],const char currentvalue[],char value[],size_t len,PetscBool *set) 87453acd3b1SBarry Smith { 87553acd3b1SBarry Smith PetscErrorCode ierr; 8764416b707SBarry Smith PetscOptionItem amsopt; 87753acd3b1SBarry Smith 87853acd3b1SBarry Smith PetscFunctionBegin; 8791a1499c8SBarry Smith if (!PetscOptionsObject->count) { 8804416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 88164facd6cSBarry Smith /* must use system malloc since SAWs may free this */ 8820fdccdaeSBarry Smith ierr = PetscStrdup(currentvalue ? currentvalue : "",(char**)&amsopt->data);CHKERRQ(ierr); 883af6d86caSBarry Smith } 884c5929fdfSBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,len,set);CHKERRQ(ierr); 885e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 8861a1499c8SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,currentvalue,text,ManSection(man));CHKERRQ(ierr); 88753acd3b1SBarry Smith } 88853acd3b1SBarry Smith PetscFunctionReturn(0); 88953acd3b1SBarry Smith } 89053acd3b1SBarry Smith 89153acd3b1SBarry Smith /*@C 89253acd3b1SBarry Smith PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 89353acd3b1SBarry Smith 8943f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 89553acd3b1SBarry Smith 89653acd3b1SBarry Smith Input Parameters: 89753acd3b1SBarry Smith + opt - option name 89853acd3b1SBarry Smith . text - short string that describes the option 89953acd3b1SBarry Smith . man - manual page with additional information on option 9000fdccdaeSBarry Smith - currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either 9010fdccdaeSBarry Smith $ PetscOptionsReal(..., obj->value,&object->value,...) or 9020fdccdaeSBarry Smith $ value = defaultvalue 9030fdccdaeSBarry Smith $ PetscOptionsReal(..., value,&value,&flg); 9040fdccdaeSBarry Smith $ if (flg) { 90553acd3b1SBarry Smith 90653acd3b1SBarry Smith Output Parameter: 90753acd3b1SBarry Smith + value - the value to return 90853acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 90953acd3b1SBarry Smith 91095452b02SPatrick Sanan Notes: 91195452b02SPatrick Sanan If the user does not supply the option at all value is NOT changed. Thus 9122efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 9132efd9cb1SBarry Smith 914989712b9SBarry Smith The default/currentvalue passed into this routine does not get transferred to the output value variable automatically. 915989712b9SBarry Smith 91653acd3b1SBarry Smith Level: beginner 91753acd3b1SBarry Smith 91853acd3b1SBarry Smith Concepts: options database^has int 91953acd3b1SBarry Smith 92095452b02SPatrick Sanan Notes: 92195452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 92253acd3b1SBarry Smith 923*89a13869SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 924acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 925acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 92653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 92753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 928acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 929a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 93053acd3b1SBarry Smith @*/ 9314416b707SBarry Smith PetscErrorCode PetscOptionsReal_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscReal currentvalue,PetscReal *value,PetscBool *set) 93253acd3b1SBarry Smith { 93353acd3b1SBarry Smith PetscErrorCode ierr; 9344416b707SBarry Smith PetscOptionItem amsopt; 93553acd3b1SBarry Smith 93653acd3b1SBarry Smith PetscFunctionBegin; 937e55864a3SBarry Smith if (!PetscOptionsObject->count) { 9384416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr); 939538aa990SBarry Smith ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 940a297a907SKarl Rupp 9410fdccdaeSBarry Smith *(PetscReal*)amsopt->data = currentvalue; 942538aa990SBarry Smith } 943c5929fdfSBarry Smith ierr = PetscOptionsGetReal(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,set);CHKERRQ(ierr); 9441a1499c8SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 9451a1499c8SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%g>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,(double)currentvalue,text,ManSection(man));CHKERRQ(ierr); 94653acd3b1SBarry Smith } 94753acd3b1SBarry Smith PetscFunctionReturn(0); 94853acd3b1SBarry Smith } 94953acd3b1SBarry Smith 95053acd3b1SBarry Smith /*@C 95153acd3b1SBarry Smith PetscOptionsScalar - Gets the scalar value for a particular option in the database. 95253acd3b1SBarry Smith 9533f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 95453acd3b1SBarry Smith 95553acd3b1SBarry Smith Input Parameters: 95653acd3b1SBarry Smith + opt - option name 95753acd3b1SBarry Smith . text - short string that describes the option 95853acd3b1SBarry Smith . man - manual page with additional information on option 9590fdccdaeSBarry Smith - currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with either 9600fdccdaeSBarry Smith $ PetscOptionsScalar(..., obj->value,&object->value,...) or 9610fdccdaeSBarry Smith $ value = defaultvalue 9620fdccdaeSBarry Smith $ PetscOptionsScalar(..., value,&value,&flg); 9630fdccdaeSBarry Smith $ if (flg) { 9640fdccdaeSBarry Smith 96553acd3b1SBarry Smith 96653acd3b1SBarry Smith Output Parameter: 96753acd3b1SBarry Smith + value - the value to return 96853acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 96953acd3b1SBarry Smith 97095452b02SPatrick Sanan Notes: 97195452b02SPatrick Sanan If the user does not supply the option at all value is NOT changed. Thus 9722efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 9732efd9cb1SBarry Smith 974989712b9SBarry Smith The default/currentvalue passed into this routine does not get transferred to the output value variable automatically. 975989712b9SBarry Smith 97653acd3b1SBarry Smith Level: beginner 97753acd3b1SBarry Smith 97853acd3b1SBarry Smith Concepts: options database^has int 97953acd3b1SBarry Smith 98095452b02SPatrick Sanan Notes: 98195452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 98253acd3b1SBarry Smith 983*89a13869SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 984acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 985acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 98653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 98753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 988acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 989a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 99053acd3b1SBarry Smith @*/ 9914416b707SBarry Smith PetscErrorCode PetscOptionsScalar_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscScalar currentvalue,PetscScalar *value,PetscBool *set) 99253acd3b1SBarry Smith { 99353acd3b1SBarry Smith PetscErrorCode ierr; 99453acd3b1SBarry Smith 99553acd3b1SBarry Smith PetscFunctionBegin; 99653acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX) 9970fdccdaeSBarry Smith ierr = PetscOptionsReal(opt,text,man,currentvalue,value,set);CHKERRQ(ierr); 99853acd3b1SBarry Smith #else 999c5929fdfSBarry Smith ierr = PetscOptionsGetScalar(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,set);CHKERRQ(ierr); 100053acd3b1SBarry Smith #endif 100153acd3b1SBarry Smith PetscFunctionReturn(0); 100253acd3b1SBarry Smith } 100353acd3b1SBarry Smith 100453acd3b1SBarry Smith /*@C 100590d69ab7SBarry Smith PetscOptionsName - Determines if a particular option has been set in the database. This returns true whether the option is a number, string or boolean, even 100690d69ab7SBarry Smith its value is set to false. 100753acd3b1SBarry Smith 10083f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 100953acd3b1SBarry Smith 101053acd3b1SBarry Smith Input Parameters: 101153acd3b1SBarry Smith + opt - option name 101253acd3b1SBarry Smith . text - short string that describes the option 101353acd3b1SBarry Smith - man - manual page with additional information on option 101453acd3b1SBarry Smith 101553acd3b1SBarry Smith Output Parameter: 101653acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 101753acd3b1SBarry Smith 101853acd3b1SBarry Smith Level: beginner 101953acd3b1SBarry Smith 102053acd3b1SBarry Smith Concepts: options database^has int 102153acd3b1SBarry Smith 102295452b02SPatrick Sanan Notes: 102395452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 102453acd3b1SBarry Smith 1025*89a13869SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 1026acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 1027acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 102853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 102953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1030acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1031a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 103253acd3b1SBarry Smith @*/ 10334416b707SBarry Smith PetscErrorCode PetscOptionsName_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool *flg) 103453acd3b1SBarry Smith { 103553acd3b1SBarry Smith PetscErrorCode ierr; 10364416b707SBarry Smith PetscOptionItem amsopt; 103753acd3b1SBarry Smith 103853acd3b1SBarry Smith PetscFunctionBegin; 1039e55864a3SBarry Smith if (!PetscOptionsObject->count) { 10404416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1041ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1042a297a907SKarl Rupp 1043ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 10441ae3d29cSBarry Smith } 1045c5929fdfSBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg);CHKERRQ(ierr); 1046e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1047e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 104853acd3b1SBarry Smith } 104953acd3b1SBarry Smith PetscFunctionReturn(0); 105053acd3b1SBarry Smith } 105153acd3b1SBarry Smith 105253acd3b1SBarry Smith /*@C 1053a264d7a6SBarry Smith PetscOptionsFList - Puts a list of option values that a single one may be selected from 105453acd3b1SBarry Smith 10553f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 105653acd3b1SBarry Smith 105753acd3b1SBarry Smith Input Parameters: 105853acd3b1SBarry Smith + opt - option name 105953acd3b1SBarry Smith . text - short string that describes the option 106053acd3b1SBarry Smith . man - manual page with additional information on option 106153acd3b1SBarry Smith . list - the possible choices 10620fdccdaeSBarry Smith . currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with 10630fdccdaeSBarry Smith $ PetscOptionsFlist(..., obj->value,value,len,&flg); 10640fdccdaeSBarry Smith $ if (flg) { 10653cc1e11dSBarry Smith - len - the length of the character array value 106653acd3b1SBarry Smith 106753acd3b1SBarry Smith Output Parameter: 106853acd3b1SBarry Smith + value - the value to return 106953acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 107053acd3b1SBarry Smith 107153acd3b1SBarry Smith Level: intermediate 107253acd3b1SBarry Smith 107395452b02SPatrick Sanan Notes: 107495452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 107553acd3b1SBarry Smith 10762efd9cb1SBarry Smith If the user does not supply the option at all value is NOT changed. Thus 10772efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 10782efd9cb1SBarry Smith 1079989712b9SBarry Smith The default/currentvalue passed into this routine does not get transferred to the output value variable automatically. 1080989712b9SBarry Smith 108153acd3b1SBarry Smith See PetscOptionsEList() for when the choices are given in a string array 108253acd3b1SBarry Smith 108353acd3b1SBarry Smith To get a listing of all currently specified options, 108488c29154SBarry Smith see PetscOptionsView() or PetscOptionsGetAll() 108553acd3b1SBarry Smith 1086eabe10d7SBarry Smith Developer Note: This cannot check for invalid selection because of things like MATAIJ that are not included in the list 1087eabe10d7SBarry Smith 108853acd3b1SBarry Smith Concepts: options database^list 108953acd3b1SBarry Smith 1090*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1091acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 109253acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 109353acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1094acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1095a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList(), PetscOptionsEnum() 109653acd3b1SBarry Smith @*/ 10974416b707SBarry Smith PetscErrorCode PetscOptionsFList_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char ltext[],const char man[],PetscFunctionList list,const char currentvalue[],char value[],size_t len,PetscBool *set) 109853acd3b1SBarry Smith { 109953acd3b1SBarry Smith PetscErrorCode ierr; 11004416b707SBarry Smith PetscOptionItem amsopt; 110153acd3b1SBarry Smith 110253acd3b1SBarry Smith PetscFunctionBegin; 11031a1499c8SBarry Smith if (!PetscOptionsObject->count) { 11044416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,ltext,man,OPTION_FLIST,&amsopt);CHKERRQ(ierr); 110564facd6cSBarry Smith /* must use system malloc since SAWs may free this */ 11060fdccdaeSBarry Smith ierr = PetscStrdup(currentvalue ? currentvalue : "",(char**)&amsopt->data);CHKERRQ(ierr); 11073cc1e11dSBarry Smith amsopt->flist = list; 11083cc1e11dSBarry Smith } 1109c5929fdfSBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,len,set);CHKERRQ(ierr); 11101a1499c8SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 11111a1499c8SBarry Smith ierr = PetscFunctionListPrintTypes(PetscOptionsObject->comm,stdout,PetscOptionsObject->prefix,opt,ltext,man,list,currentvalue);CHKERRQ(ierr);CHKERRQ(ierr); 111253acd3b1SBarry Smith } 111353acd3b1SBarry Smith PetscFunctionReturn(0); 111453acd3b1SBarry Smith } 111553acd3b1SBarry Smith 111653acd3b1SBarry Smith /*@C 111753acd3b1SBarry Smith PetscOptionsEList - Puts a list of option values that a single one may be selected from 111853acd3b1SBarry Smith 11193f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 112053acd3b1SBarry Smith 112153acd3b1SBarry Smith Input Parameters: 112253acd3b1SBarry Smith + opt - option name 112353acd3b1SBarry Smith . ltext - short string that describes the option 112453acd3b1SBarry Smith . man - manual page with additional information on option 1125a264d7a6SBarry Smith . list - the possible choices (one of these must be selected, anything else is invalid) 112653acd3b1SBarry Smith . ntext - number of choices 11270fdccdaeSBarry Smith - currentvalue - the current value; caller is responsible for setting this value correctly. Normally this is done with 11280fdccdaeSBarry Smith $ PetscOptionsElist(..., obj->value,&value,&flg); 11290fdccdaeSBarry Smith $ if (flg) { 11300fdccdaeSBarry Smith 113153acd3b1SBarry Smith 113253acd3b1SBarry Smith Output Parameter: 113353acd3b1SBarry Smith + value - the index of the value to return 113453acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 113553acd3b1SBarry Smith 113653acd3b1SBarry Smith Level: intermediate 113753acd3b1SBarry Smith 113895452b02SPatrick Sanan Notes: 113995452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 114053acd3b1SBarry Smith 11412efd9cb1SBarry Smith If the user does not supply the option at all value is NOT changed. Thus 11422efd9cb1SBarry Smith you should ALWAYS initialize value if you access it without first checking if the set flag is true. 11432efd9cb1SBarry Smith 1144a264d7a6SBarry Smith See PetscOptionsFList() for when the choices are given in a PetscFunctionList() 114553acd3b1SBarry Smith 114653acd3b1SBarry Smith Concepts: options database^list 114753acd3b1SBarry Smith 1148*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1149acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 115053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 115153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1152acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1153a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEnum() 115453acd3b1SBarry Smith @*/ 11554416b707SBarry Smith PetscErrorCode PetscOptionsEList_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char ltext[],const char man[],const char *const *list,PetscInt ntext,const char currentvalue[],PetscInt *value,PetscBool *set) 115653acd3b1SBarry Smith { 115753acd3b1SBarry Smith PetscErrorCode ierr; 115853acd3b1SBarry Smith PetscInt i; 11594416b707SBarry Smith PetscOptionItem amsopt; 116053acd3b1SBarry Smith 116153acd3b1SBarry Smith PetscFunctionBegin; 11621a1499c8SBarry Smith if (!PetscOptionsObject->count) { 11634416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr); 116464facd6cSBarry Smith /* must use system malloc since SAWs may free this */ 11650fdccdaeSBarry Smith ierr = PetscStrdup(currentvalue ? currentvalue : "",(char**)&amsopt->data);CHKERRQ(ierr); 11666991f827SBarry Smith ierr = PetscStrNArrayallocpy(ntext,list,(char***)&amsopt->list);CHKERRQ(ierr); 11671ae3d29cSBarry Smith amsopt->nlist = ntext; 11681ae3d29cSBarry Smith } 1169c5929fdfSBarry Smith ierr = PetscOptionsGetEList(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 11701a1499c8SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1171e3f729a5SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%s> %s (choose one of)",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,currentvalue,ltext);CHKERRQ(ierr); 117253acd3b1SBarry Smith for (i=0; i<ntext; i++) { 1173e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," %s",list[i]);CHKERRQ(ierr); 117453acd3b1SBarry Smith } 1175e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," (%s)\n",ManSection(man));CHKERRQ(ierr); 117653acd3b1SBarry Smith } 117753acd3b1SBarry Smith PetscFunctionReturn(0); 117853acd3b1SBarry Smith } 117953acd3b1SBarry Smith 118053acd3b1SBarry Smith /*@C 1181acfcf0e5SJed Brown PetscOptionsBoolGroupBegin - First in a series of logical queries on the options database for 1182d5649816SBarry Smith which at most a single value can be true. 118353acd3b1SBarry Smith 11843f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 118553acd3b1SBarry Smith 118653acd3b1SBarry Smith Input Parameters: 118753acd3b1SBarry Smith + opt - option name 118853acd3b1SBarry Smith . text - short string that describes the option 118953acd3b1SBarry Smith - man - manual page with additional information on option 119053acd3b1SBarry Smith 119153acd3b1SBarry Smith Output Parameter: 119253acd3b1SBarry Smith . flg - whether that option was set or not 119353acd3b1SBarry Smith 119453acd3b1SBarry Smith Level: intermediate 119553acd3b1SBarry Smith 119695452b02SPatrick Sanan Notes: 119795452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 119853acd3b1SBarry Smith 1199acfcf0e5SJed Brown Must be followed by 0 or more PetscOptionsBoolGroup()s and PetscOptionsBoolGroupEnd() 120053acd3b1SBarry Smith 120153acd3b1SBarry Smith Concepts: options database^logical group 120253acd3b1SBarry Smith 1203*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1204acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 120553acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 120653acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1207acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1208a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 120953acd3b1SBarry Smith @*/ 12104416b707SBarry Smith PetscErrorCode PetscOptionsBoolGroupBegin_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool *flg) 121153acd3b1SBarry Smith { 121253acd3b1SBarry Smith PetscErrorCode ierr; 12134416b707SBarry Smith PetscOptionItem amsopt; 121453acd3b1SBarry Smith 121553acd3b1SBarry Smith PetscFunctionBegin; 1216e55864a3SBarry Smith if (!PetscOptionsObject->count) { 12174416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1218ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1219a297a907SKarl Rupp 1220ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 12211ae3d29cSBarry Smith } 122268b16fdaSBarry Smith *flg = PETSC_FALSE; 1223c5929fdfSBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,NULL);CHKERRQ(ierr); 1224e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1225e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," Pick at most one of -------------\n");CHKERRQ(ierr); 1226e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 122753acd3b1SBarry Smith } 122853acd3b1SBarry Smith PetscFunctionReturn(0); 122953acd3b1SBarry Smith } 123053acd3b1SBarry Smith 123153acd3b1SBarry Smith /*@C 1232acfcf0e5SJed Brown PetscOptionsBoolGroup - One in a series of logical queries on the options database for 1233d5649816SBarry Smith which at most a single value can be true. 123453acd3b1SBarry Smith 12353f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 123653acd3b1SBarry Smith 123753acd3b1SBarry Smith Input Parameters: 123853acd3b1SBarry Smith + opt - option name 123953acd3b1SBarry Smith . text - short string that describes the option 124053acd3b1SBarry Smith - man - manual page with additional information on option 124153acd3b1SBarry Smith 124253acd3b1SBarry Smith Output Parameter: 124353acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 124453acd3b1SBarry Smith 124553acd3b1SBarry Smith Level: intermediate 124653acd3b1SBarry Smith 124795452b02SPatrick Sanan Notes: 124895452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 124953acd3b1SBarry Smith 1250acfcf0e5SJed Brown Must follow a PetscOptionsBoolGroupBegin() and preceded a PetscOptionsBoolGroupEnd() 125153acd3b1SBarry Smith 125253acd3b1SBarry Smith Concepts: options database^logical group 125353acd3b1SBarry Smith 1254*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1255acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 125653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 125753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1258acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1259a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 126053acd3b1SBarry Smith @*/ 12614416b707SBarry Smith PetscErrorCode PetscOptionsBoolGroup_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool *flg) 126253acd3b1SBarry Smith { 126353acd3b1SBarry Smith PetscErrorCode ierr; 12644416b707SBarry Smith PetscOptionItem amsopt; 126553acd3b1SBarry Smith 126653acd3b1SBarry Smith PetscFunctionBegin; 1267e55864a3SBarry Smith if (!PetscOptionsObject->count) { 12684416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1269ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1270a297a907SKarl Rupp 1271ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 12721ae3d29cSBarry Smith } 127317326d04SJed Brown *flg = PETSC_FALSE; 1274c5929fdfSBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,NULL);CHKERRQ(ierr); 1275e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1276e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 127753acd3b1SBarry Smith } 127853acd3b1SBarry Smith PetscFunctionReturn(0); 127953acd3b1SBarry Smith } 128053acd3b1SBarry Smith 128153acd3b1SBarry Smith /*@C 1282acfcf0e5SJed Brown PetscOptionsBoolGroupEnd - Last in a series of logical queries on the options database for 1283d5649816SBarry Smith which at most a single value can be true. 128453acd3b1SBarry Smith 12853f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 128653acd3b1SBarry Smith 128753acd3b1SBarry Smith Input Parameters: 128853acd3b1SBarry Smith + opt - option name 128953acd3b1SBarry Smith . text - short string that describes the option 129053acd3b1SBarry Smith - man - manual page with additional information on option 129153acd3b1SBarry Smith 129253acd3b1SBarry Smith Output Parameter: 129353acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 129453acd3b1SBarry Smith 129553acd3b1SBarry Smith Level: intermediate 129653acd3b1SBarry Smith 129795452b02SPatrick Sanan Notes: 129895452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 129953acd3b1SBarry Smith 1300acfcf0e5SJed Brown Must follow a PetscOptionsBoolGroupBegin() 130153acd3b1SBarry Smith 130253acd3b1SBarry Smith Concepts: options database^logical group 130353acd3b1SBarry Smith 1304*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1305acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 130653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 130753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1308acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1309a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 131053acd3b1SBarry Smith @*/ 13114416b707SBarry Smith PetscErrorCode PetscOptionsBoolGroupEnd_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool *flg) 131253acd3b1SBarry Smith { 131353acd3b1SBarry Smith PetscErrorCode ierr; 13144416b707SBarry Smith PetscOptionItem amsopt; 131553acd3b1SBarry Smith 131653acd3b1SBarry Smith PetscFunctionBegin; 1317e55864a3SBarry Smith if (!PetscOptionsObject->count) { 13184416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1319ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1320a297a907SKarl Rupp 1321ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 13221ae3d29cSBarry Smith } 132317326d04SJed Brown *flg = PETSC_FALSE; 1324c5929fdfSBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,NULL);CHKERRQ(ierr); 1325e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1326e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 132753acd3b1SBarry Smith } 132853acd3b1SBarry Smith PetscFunctionReturn(0); 132953acd3b1SBarry Smith } 133053acd3b1SBarry Smith 133153acd3b1SBarry Smith /*@C 1332acfcf0e5SJed Brown PetscOptionsBool - Determines if a particular option is in the database with a true or false 133353acd3b1SBarry Smith 13343f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 133553acd3b1SBarry Smith 133653acd3b1SBarry Smith Input Parameters: 133753acd3b1SBarry Smith + opt - option name 133853acd3b1SBarry Smith . text - short string that describes the option 1339868c398cSBarry Smith . man - manual page with additional information on option 134094ae4db5SBarry Smith - currentvalue - the current value 134153acd3b1SBarry Smith 134253acd3b1SBarry Smith Output Parameter: 134353acd3b1SBarry Smith . flg - PETSC_TRUE or PETSC_FALSE 134453acd3b1SBarry Smith . set - PETSC_TRUE if found, else PETSC_FALSE 134553acd3b1SBarry Smith 13462efd9cb1SBarry Smith Notes: 13472efd9cb1SBarry Smith TRUE, true, YES, yes, nostring, and 1 all translate to PETSC_TRUE 13482efd9cb1SBarry Smith FALSE, false, NO, no, and 0 all translate to PETSC_FALSE 13492efd9cb1SBarry Smith 13502efd9cb1SBarry Smith If the option is given, but no value is provided, then flg and set are both given the value PETSC_TRUE. That is -requested_bool 13512efd9cb1SBarry Smith is equivalent to -requested_bool true 13522efd9cb1SBarry Smith 13532efd9cb1SBarry Smith If the user does not supply the option at all flg is NOT changed. Thus 13542efd9cb1SBarry Smith you should ALWAYS initialize the flg if you access it without first checking if the set flag is true. 13552efd9cb1SBarry Smith 135653acd3b1SBarry Smith Level: beginner 135753acd3b1SBarry Smith 135853acd3b1SBarry Smith Concepts: options database^logical 135953acd3b1SBarry Smith 136095452b02SPatrick Sanan Notes: 136195452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 136253acd3b1SBarry Smith 1363*89a13869SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 1364acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 1365acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 136653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 136753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1368acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1369a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 137053acd3b1SBarry Smith @*/ 13714416b707SBarry Smith PetscErrorCode PetscOptionsBool_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool currentvalue,PetscBool *flg,PetscBool *set) 137253acd3b1SBarry Smith { 137353acd3b1SBarry Smith PetscErrorCode ierr; 1374ace3abfcSBarry Smith PetscBool iset; 13754416b707SBarry Smith PetscOptionItem amsopt; 137653acd3b1SBarry Smith 137753acd3b1SBarry Smith PetscFunctionBegin; 1378e55864a3SBarry Smith if (!PetscOptionsObject->count) { 13794416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1380ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1381a297a907SKarl Rupp 138294ae4db5SBarry Smith *(PetscBool*)amsopt->data = currentvalue; 1383af6d86caSBarry Smith } 1384c5929fdfSBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,flg,&iset);CHKERRQ(ierr); 138553acd3b1SBarry Smith if (set) *set = iset; 13861a1499c8SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 138794ae4db5SBarry Smith const char *v = PetscBools[currentvalue]; 13881a1499c8SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,v,text,ManSection(man));CHKERRQ(ierr); 138953acd3b1SBarry Smith } 139053acd3b1SBarry Smith PetscFunctionReturn(0); 139153acd3b1SBarry Smith } 139253acd3b1SBarry Smith 139353acd3b1SBarry Smith /*@C 139453acd3b1SBarry Smith PetscOptionsRealArray - Gets an array of double values for a particular 139553acd3b1SBarry Smith option in the database. The values must be separated with commas with 139653acd3b1SBarry Smith no intervening spaces. 139753acd3b1SBarry Smith 13983f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 139953acd3b1SBarry Smith 140053acd3b1SBarry Smith Input Parameters: 140153acd3b1SBarry Smith + opt - the option one is seeking 140253acd3b1SBarry Smith . text - short string describing option 140353acd3b1SBarry Smith . man - manual page for option 140453acd3b1SBarry Smith - nmax - maximum number of values 140553acd3b1SBarry Smith 140653acd3b1SBarry Smith Output Parameter: 140753acd3b1SBarry Smith + value - location to copy values 140853acd3b1SBarry Smith . nmax - actual number of values found 140953acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 141053acd3b1SBarry Smith 141153acd3b1SBarry Smith Level: beginner 141253acd3b1SBarry Smith 141353acd3b1SBarry Smith Notes: 141453acd3b1SBarry Smith The user should pass in an array of doubles 141553acd3b1SBarry Smith 141653acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 141753acd3b1SBarry Smith 141853acd3b1SBarry Smith Concepts: options database^array of strings 141953acd3b1SBarry Smith 1420*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1421acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 142253acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 142353acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1424acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1425a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 142653acd3b1SBarry Smith @*/ 14274416b707SBarry Smith PetscErrorCode PetscOptionsRealArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscBool *set) 142853acd3b1SBarry Smith { 142953acd3b1SBarry Smith PetscErrorCode ierr; 143053acd3b1SBarry Smith PetscInt i; 14314416b707SBarry Smith PetscOptionItem amsopt; 143253acd3b1SBarry Smith 143353acd3b1SBarry Smith PetscFunctionBegin; 1434e55864a3SBarry Smith if (!PetscOptionsObject->count) { 1435e26ddf31SBarry Smith PetscReal *vals; 1436e26ddf31SBarry Smith 14374416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr); 1438e55864a3SBarry Smith ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 1439e26ddf31SBarry Smith vals = (PetscReal*)amsopt->data; 1440e26ddf31SBarry Smith for (i=0; i<*n; i++) vals[i] = value[i]; 1441e26ddf31SBarry Smith amsopt->arraylength = *n; 1442e26ddf31SBarry Smith } 1443c5929fdfSBarry Smith ierr = PetscOptionsGetRealArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr); 1444e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1445a519f713SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%g",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,(double)value[0]);CHKERRQ(ierr); 144653acd3b1SBarry Smith for (i=1; i<*n; i++) { 1447e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%g",(double)value[i]);CHKERRQ(ierr); 144853acd3b1SBarry Smith } 1449e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 145053acd3b1SBarry Smith } 145153acd3b1SBarry Smith PetscFunctionReturn(0); 145253acd3b1SBarry Smith } 145353acd3b1SBarry Smith 1454050cccc3SHong Zhang /*@C 1455050cccc3SHong Zhang PetscOptionsScalarArray - Gets an array of Scalar values for a particular 1456050cccc3SHong Zhang option in the database. The values must be separated with commas with 1457050cccc3SHong Zhang no intervening spaces. 1458050cccc3SHong Zhang 1459050cccc3SHong Zhang Logically Collective on the communicator passed in PetscOptionsBegin() 1460050cccc3SHong Zhang 1461050cccc3SHong Zhang Input Parameters: 1462050cccc3SHong Zhang + opt - the option one is seeking 1463050cccc3SHong Zhang . text - short string describing option 1464050cccc3SHong Zhang . man - manual page for option 1465050cccc3SHong Zhang - nmax - maximum number of values 1466050cccc3SHong Zhang 1467050cccc3SHong Zhang Output Parameter: 1468050cccc3SHong Zhang + value - location to copy values 1469050cccc3SHong Zhang . nmax - actual number of values found 1470050cccc3SHong Zhang - set - PETSC_TRUE if found, else PETSC_FALSE 1471050cccc3SHong Zhang 1472050cccc3SHong Zhang Level: beginner 1473050cccc3SHong Zhang 1474050cccc3SHong Zhang Notes: 1475050cccc3SHong Zhang The user should pass in an array of doubles 1476050cccc3SHong Zhang 1477050cccc3SHong Zhang Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1478050cccc3SHong Zhang 1479050cccc3SHong Zhang Concepts: options database^array of strings 1480050cccc3SHong Zhang 1481*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1482050cccc3SHong Zhang PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 1483050cccc3SHong Zhang PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1484050cccc3SHong Zhang PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1485050cccc3SHong Zhang PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1486050cccc3SHong Zhang PetscOptionsFList(), PetscOptionsEList() 1487050cccc3SHong Zhang @*/ 14884416b707SBarry Smith PetscErrorCode PetscOptionsScalarArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscScalar value[],PetscInt *n,PetscBool *set) 1489050cccc3SHong Zhang { 1490050cccc3SHong Zhang PetscErrorCode ierr; 1491050cccc3SHong Zhang PetscInt i; 14924416b707SBarry Smith PetscOptionItem amsopt; 1493050cccc3SHong Zhang 1494050cccc3SHong Zhang PetscFunctionBegin; 1495050cccc3SHong Zhang if (!PetscOptionsObject->count) { 1496050cccc3SHong Zhang PetscScalar *vals; 1497050cccc3SHong Zhang 14984416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_SCALAR_ARRAY,&amsopt);CHKERRQ(ierr); 1499050cccc3SHong Zhang ierr = PetscMalloc((*n)*sizeof(PetscScalar),&amsopt->data);CHKERRQ(ierr); 1500050cccc3SHong Zhang vals = (PetscScalar*)amsopt->data; 1501050cccc3SHong Zhang for (i=0; i<*n; i++) vals[i] = value[i]; 1502050cccc3SHong Zhang amsopt->arraylength = *n; 1503050cccc3SHong Zhang } 1504c5929fdfSBarry Smith ierr = PetscOptionsGetScalarArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr); 1505050cccc3SHong Zhang if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 150695f3a755SJose E. Roman ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%g+%gi",PetscOptionsObject->prefix?PetscOptionsObject->prefix:"",opt+1,(double)PetscRealPart(value[0]),(double)PetscImaginaryPart(value[0]));CHKERRQ(ierr); 1507050cccc3SHong Zhang for (i=1; i<*n; i++) { 150895f3a755SJose E. Roman ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%g+%gi",(double)PetscRealPart(value[i]),(double)PetscImaginaryPart(value[i]));CHKERRQ(ierr); 1509050cccc3SHong Zhang } 1510050cccc3SHong Zhang ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 1511050cccc3SHong Zhang } 1512050cccc3SHong Zhang PetscFunctionReturn(0); 1513050cccc3SHong Zhang } 151453acd3b1SBarry Smith 151553acd3b1SBarry Smith /*@C 151653acd3b1SBarry Smith PetscOptionsIntArray - Gets an array of integers for a particular 1517b32a342fSShri Abhyankar option in the database. 151853acd3b1SBarry Smith 15193f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 152053acd3b1SBarry Smith 152153acd3b1SBarry Smith Input Parameters: 152253acd3b1SBarry Smith + opt - the option one is seeking 152353acd3b1SBarry Smith . text - short string describing option 152453acd3b1SBarry Smith . man - manual page for option 1525f8a50e2bSBarry Smith - n - maximum number of values 152653acd3b1SBarry Smith 152753acd3b1SBarry Smith Output Parameter: 152853acd3b1SBarry Smith + value - location to copy values 1529f8a50e2bSBarry Smith . n - actual number of values found 153053acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 153153acd3b1SBarry Smith 153253acd3b1SBarry Smith Level: beginner 153353acd3b1SBarry Smith 153453acd3b1SBarry Smith Notes: 1535b32a342fSShri Abhyankar The array can be passed as 1536bebe2cf6SSatish Balay a comma separated list: 0,1,2,3,4,5,6,7 15370fd488f5SShri Abhyankar a range (start-end+1): 0-8 15380fd488f5SShri Abhyankar a range with given increment (start-end+1:inc): 0-7:2 1539bebe2cf6SSatish Balay a combination of values and ranges separated by commas: 0,1-8,8-15:2 1540b32a342fSShri Abhyankar 1541b32a342fSShri Abhyankar There must be no intervening spaces between the values. 154253acd3b1SBarry Smith 154353acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 154453acd3b1SBarry Smith 1545b32a342fSShri Abhyankar Concepts: options database^array of ints 154653acd3b1SBarry Smith 1547*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1548acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 154953acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 155053acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1551acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1552a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList(), PetscOptionsRealArray() 155353acd3b1SBarry Smith @*/ 15544416b707SBarry Smith PetscErrorCode PetscOptionsIntArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscBool *set) 155553acd3b1SBarry Smith { 155653acd3b1SBarry Smith PetscErrorCode ierr; 155753acd3b1SBarry Smith PetscInt i; 15584416b707SBarry Smith PetscOptionItem amsopt; 155953acd3b1SBarry Smith 156053acd3b1SBarry Smith PetscFunctionBegin; 1561e55864a3SBarry Smith if (!PetscOptionsObject->count) { 1562e26ddf31SBarry Smith PetscInt *vals; 1563e26ddf31SBarry Smith 15644416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr); 1565854ce69bSBarry Smith ierr = PetscMalloc1(*n,(PetscInt**)&amsopt->data);CHKERRQ(ierr); 1566e26ddf31SBarry Smith vals = (PetscInt*)amsopt->data; 1567e26ddf31SBarry Smith for (i=0; i<*n; i++) vals[i] = value[i]; 1568e26ddf31SBarry Smith amsopt->arraylength = *n; 1569e26ddf31SBarry Smith } 1570c5929fdfSBarry Smith ierr = PetscOptionsGetIntArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr); 1571e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1572e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%d",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,value[0]);CHKERRQ(ierr); 157353acd3b1SBarry Smith for (i=1; i<*n; i++) { 1574e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%d",value[i]);CHKERRQ(ierr); 157553acd3b1SBarry Smith } 1576e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 157753acd3b1SBarry Smith } 157853acd3b1SBarry Smith PetscFunctionReturn(0); 157953acd3b1SBarry Smith } 158053acd3b1SBarry Smith 158153acd3b1SBarry Smith /*@C 158253acd3b1SBarry Smith PetscOptionsStringArray - Gets an array of string values for a particular 158353acd3b1SBarry Smith option in the database. The values must be separated with commas with 158453acd3b1SBarry Smith no intervening spaces. 158553acd3b1SBarry Smith 15863f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 158753acd3b1SBarry Smith 158853acd3b1SBarry Smith Input Parameters: 158953acd3b1SBarry Smith + opt - the option one is seeking 159053acd3b1SBarry Smith . text - short string describing option 159153acd3b1SBarry Smith . man - manual page for option 159253acd3b1SBarry Smith - nmax - maximum number of strings 159353acd3b1SBarry Smith 159453acd3b1SBarry Smith Output Parameter: 159553acd3b1SBarry Smith + value - location to copy strings 159653acd3b1SBarry Smith . nmax - actual number of strings found 159753acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 159853acd3b1SBarry Smith 159953acd3b1SBarry Smith Level: beginner 160053acd3b1SBarry Smith 160153acd3b1SBarry Smith Notes: 160253acd3b1SBarry Smith The user should pass in an array of pointers to char, to hold all the 160353acd3b1SBarry Smith strings returned by this function. 160453acd3b1SBarry Smith 160553acd3b1SBarry Smith The user is responsible for deallocating the strings that are 160653acd3b1SBarry Smith returned. The Fortran interface for this routine is not supported. 160753acd3b1SBarry Smith 160853acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 160953acd3b1SBarry Smith 161053acd3b1SBarry Smith Concepts: options database^array of strings 161153acd3b1SBarry Smith 1612*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1613acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 161453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 161553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1616acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1617a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 161853acd3b1SBarry Smith @*/ 16194416b707SBarry Smith PetscErrorCode PetscOptionsStringArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscBool *set) 162053acd3b1SBarry Smith { 162153acd3b1SBarry Smith PetscErrorCode ierr; 16224416b707SBarry Smith PetscOptionItem amsopt; 162353acd3b1SBarry Smith 162453acd3b1SBarry Smith PetscFunctionBegin; 1625e55864a3SBarry Smith if (!PetscOptionsObject->count) { 16264416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr); 1627854ce69bSBarry Smith ierr = PetscMalloc1(*nmax,(char**)&amsopt->data);CHKERRQ(ierr); 1628a297a907SKarl Rupp 16291ae3d29cSBarry Smith amsopt->arraylength = *nmax; 16301ae3d29cSBarry Smith } 1631c5929fdfSBarry Smith ierr = PetscOptionsGetStringArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,nmax,set);CHKERRQ(ierr); 1632e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1633e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 163453acd3b1SBarry Smith } 163553acd3b1SBarry Smith PetscFunctionReturn(0); 163653acd3b1SBarry Smith } 163753acd3b1SBarry Smith 1638e2446a98SMatthew Knepley /*@C 1639acfcf0e5SJed Brown PetscOptionsBoolArray - Gets an array of logical values (true or false) for a particular 1640e2446a98SMatthew Knepley option in the database. The values must be separated with commas with 1641e2446a98SMatthew Knepley no intervening spaces. 1642e2446a98SMatthew Knepley 16433f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 1644e2446a98SMatthew Knepley 1645e2446a98SMatthew Knepley Input Parameters: 1646e2446a98SMatthew Knepley + opt - the option one is seeking 1647e2446a98SMatthew Knepley . text - short string describing option 1648e2446a98SMatthew Knepley . man - manual page for option 1649e2446a98SMatthew Knepley - nmax - maximum number of values 1650e2446a98SMatthew Knepley 1651e2446a98SMatthew Knepley Output Parameter: 1652e2446a98SMatthew Knepley + value - location to copy values 1653e2446a98SMatthew Knepley . nmax - actual number of values found 1654e2446a98SMatthew Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 1655e2446a98SMatthew Knepley 1656e2446a98SMatthew Knepley Level: beginner 1657e2446a98SMatthew Knepley 1658e2446a98SMatthew Knepley Notes: 1659e2446a98SMatthew Knepley The user should pass in an array of doubles 1660e2446a98SMatthew Knepley 1661e2446a98SMatthew Knepley Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1662e2446a98SMatthew Knepley 1663e2446a98SMatthew Knepley Concepts: options database^array of strings 1664e2446a98SMatthew Knepley 1665*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1666acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 1667e2446a98SMatthew Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1668e2446a98SMatthew Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1669acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1670a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 1671e2446a98SMatthew Knepley @*/ 16724416b707SBarry Smith PetscErrorCode PetscOptionsBoolArray_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscBool value[],PetscInt *n,PetscBool *set) 1673e2446a98SMatthew Knepley { 1674e2446a98SMatthew Knepley PetscErrorCode ierr; 1675e2446a98SMatthew Knepley PetscInt i; 16764416b707SBarry Smith PetscOptionItem amsopt; 1677e2446a98SMatthew Knepley 1678e2446a98SMatthew Knepley PetscFunctionBegin; 1679e55864a3SBarry Smith if (!PetscOptionsObject->count) { 1680ace3abfcSBarry Smith PetscBool *vals; 16811ae3d29cSBarry Smith 16824416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_BOOL_ARRAY,&amsopt);CHKERRQ(ierr); 16831a1499c8SBarry Smith ierr = PetscMalloc1(*n,(PetscBool**)&amsopt->data);CHKERRQ(ierr); 1684ace3abfcSBarry Smith vals = (PetscBool*)amsopt->data; 16851ae3d29cSBarry Smith for (i=0; i<*n; i++) vals[i] = value[i]; 16861ae3d29cSBarry Smith amsopt->arraylength = *n; 16871ae3d29cSBarry Smith } 1688c5929fdfSBarry Smith ierr = PetscOptionsGetBoolArray(PetscOptionsObject->options,PetscOptionsObject->prefix,opt,value,n,set);CHKERRQ(ierr); 1689e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1690e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%d",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,value[0]);CHKERRQ(ierr); 1691e2446a98SMatthew Knepley for (i=1; i<*n; i++) { 1692e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,",%d",value[i]);CHKERRQ(ierr); 1693e2446a98SMatthew Knepley } 1694e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 1695e2446a98SMatthew Knepley } 1696e2446a98SMatthew Knepley PetscFunctionReturn(0); 1697e2446a98SMatthew Knepley } 1698e2446a98SMatthew Knepley 16998cc676e6SMatthew G Knepley /*@C 1700d1da0b69SBarry Smith PetscOptionsViewer - Gets a viewer appropriate for the type indicated by the user 17018cc676e6SMatthew G Knepley 17028cc676e6SMatthew G Knepley Logically Collective on the communicator passed in PetscOptionsBegin() 17038cc676e6SMatthew G Knepley 17048cc676e6SMatthew G Knepley Input Parameters: 17058cc676e6SMatthew G Knepley + opt - option name 17068cc676e6SMatthew G Knepley . text - short string that describes the option 17078cc676e6SMatthew G Knepley - man - manual page with additional information on option 17088cc676e6SMatthew G Knepley 17098cc676e6SMatthew G Knepley Output Parameter: 17108cc676e6SMatthew G Knepley + viewer - the viewer 17118cc676e6SMatthew G Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 17128cc676e6SMatthew G Knepley 17138cc676e6SMatthew G Knepley Level: beginner 17148cc676e6SMatthew G Knepley 17158cc676e6SMatthew G Knepley Concepts: options database^has int 17168cc676e6SMatthew G Knepley 171795452b02SPatrick Sanan Notes: 171895452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 17198cc676e6SMatthew G Knepley 17205a7113b9SPatrick Sanan See PetscOptionsGetViewer() for the format of the supplied viewer and its options 17218cc676e6SMatthew G Knepley 1722*89a13869SBarry Smith .seealso: PetscOptionsGetViewer(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 17238cc676e6SMatthew G Knepley PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 17248cc676e6SMatthew G Knepley PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 17258cc676e6SMatthew G Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 17268cc676e6SMatthew G Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 17278cc676e6SMatthew G Knepley PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1728a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 17298cc676e6SMatthew G Knepley @*/ 17304416b707SBarry Smith PetscErrorCode PetscOptionsViewer_Private(PetscOptionItems *PetscOptionsObject,const char opt[],const char text[],const char man[],PetscViewer *viewer,PetscViewerFormat *format,PetscBool *set) 17318cc676e6SMatthew G Knepley { 17328cc676e6SMatthew G Knepley PetscErrorCode ierr; 17334416b707SBarry Smith PetscOptionItem amsopt; 17348cc676e6SMatthew G Knepley 17358cc676e6SMatthew G Knepley PetscFunctionBegin; 17361a1499c8SBarry Smith if (!PetscOptionsObject->count) { 17374416b707SBarry Smith ierr = PetscOptionItemCreate_Private(PetscOptionsObject,opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 173864facd6cSBarry Smith /* must use system malloc since SAWs may free this */ 17395b02f95dSBarry Smith ierr = PetscStrdup("",(char**)&amsopt->data);CHKERRQ(ierr); 17408cc676e6SMatthew G Knepley } 174116413a6aSBarry Smith ierr = PetscOptionsGetViewer(PetscOptionsObject->comm,PetscOptionsObject->options,PetscOptionsObject->prefix,opt,viewer,format,set);CHKERRQ(ierr); 1742e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1743e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject->prefix ? PetscOptionsObject->prefix : "",opt+1,"",text,ManSection(man));CHKERRQ(ierr); 17448cc676e6SMatthew G Knepley } 17458cc676e6SMatthew G Knepley PetscFunctionReturn(0); 17468cc676e6SMatthew G Knepley } 17478cc676e6SMatthew G Knepley 174853acd3b1SBarry Smith 174953acd3b1SBarry Smith /*@C 1750b52f573bSBarry Smith PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 175153acd3b1SBarry Smith in KSPSetFromOptions_GMRES(). 175253acd3b1SBarry Smith 17533f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 175453acd3b1SBarry Smith 175553acd3b1SBarry Smith Input Parameter: 175653acd3b1SBarry Smith . head - the heading text 175753acd3b1SBarry Smith 175853acd3b1SBarry Smith 175953acd3b1SBarry Smith Level: intermediate 176053acd3b1SBarry Smith 176195452b02SPatrick Sanan Notes: 176295452b02SPatrick Sanan Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 176353acd3b1SBarry Smith 1764b52f573bSBarry Smith Can be followed by a call to PetscOptionsTail() in the same function. 176553acd3b1SBarry Smith 176653acd3b1SBarry Smith Concepts: options database^subheading 176753acd3b1SBarry Smith 1768*89a13869SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1769acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 177053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 177153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1772acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1773a264d7a6SBarry Smith PetscOptionsFList(), PetscOptionsEList() 177453acd3b1SBarry Smith @*/ 17754416b707SBarry Smith PetscErrorCode PetscOptionsHead(PetscOptionItems *PetscOptionsObject,const char head[]) 177653acd3b1SBarry Smith { 177753acd3b1SBarry Smith PetscErrorCode ierr; 177853acd3b1SBarry Smith 177953acd3b1SBarry Smith PetscFunctionBegin; 1780e55864a3SBarry Smith if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) { 1781e55864a3SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject->comm," %s\n",head);CHKERRQ(ierr); 178253acd3b1SBarry Smith } 178353acd3b1SBarry Smith PetscFunctionReturn(0); 178453acd3b1SBarry Smith } 178553acd3b1SBarry Smith 178653acd3b1SBarry Smith 178753acd3b1SBarry Smith 178853acd3b1SBarry Smith 178953acd3b1SBarry Smith 179053acd3b1SBarry Smith 1791