17d0a6c19SBarry Smith 253acd3b1SBarry Smith /* 33fc1eb6aSBarry Smith Implements the higher-level options database querying methods. These are self-documenting and can attach at runtime to 43fc1eb6aSBarry Smith GUI code to display the options and get values from the users. 553acd3b1SBarry Smith 653acd3b1SBarry Smith */ 753acd3b1SBarry Smith 8afcb2eb5SJed Brown #include <petsc-private/petscimpl.h> /*I "petscsys.h" I*/ 9665c2dedSJed Brown #include <petscviewer.h> 1053acd3b1SBarry Smith 112aa6d131SJed Brown #define ManSection(str) ((str) ? (str) : "None") 122aa6d131SJed Brown 1353acd3b1SBarry Smith /* 1453acd3b1SBarry Smith Keep a linked list of options that have been posted and we are waiting for 153fc1eb6aSBarry Smith user selection. See the manual page for PetscOptionsBegin() 1653acd3b1SBarry Smith 1753acd3b1SBarry Smith Eventually we'll attach this beast to a MPI_Comm 1853acd3b1SBarry Smith */ 19f8d0b74dSMatthew Knepley PetscOptionsObjectType PetscOptionsObject; 2053acd3b1SBarry Smith PetscInt PetscOptionsPublishCount = 0; 2153acd3b1SBarry Smith 2253acd3b1SBarry Smith #undef __FUNCT__ 2353acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsBegin_Private" 2453acd3b1SBarry Smith /* 2553acd3b1SBarry Smith Handles setting up the data structure in a call to PetscOptionsBegin() 2653acd3b1SBarry Smith */ 2753acd3b1SBarry Smith PetscErrorCode PetscOptionsBegin_Private(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 2853acd3b1SBarry Smith { 2953acd3b1SBarry Smith PetscErrorCode ierr; 3053acd3b1SBarry Smith 3153acd3b1SBarry Smith PetscFunctionBegin; 3253acd3b1SBarry Smith PetscOptionsObject.next = 0; 3353acd3b1SBarry Smith PetscOptionsObject.comm = comm; 346356e834SBarry Smith PetscOptionsObject.changedmethod = PETSC_FALSE; 35a297a907SKarl Rupp 36c31cb41cSBarry Smith ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); 3753acd3b1SBarry Smith ierr = PetscStrallocpy(prefix,&PetscOptionsObject.prefix);CHKERRQ(ierr); 38c31cb41cSBarry Smith ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); 3953acd3b1SBarry Smith ierr = PetscStrallocpy(title,&PetscOptionsObject.title);CHKERRQ(ierr); 4053acd3b1SBarry Smith 410298fd71SBarry Smith ierr = PetscOptionsHasName(NULL,"-help",&PetscOptionsObject.printhelp);CHKERRQ(ierr); 4253acd3b1SBarry Smith if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1) { 4361b37b28SSatish Balay if (!PetscOptionsObject.alreadyprinted) { 4453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(comm,"%s -------------------------------------------------\n",title);CHKERRQ(ierr); 4553acd3b1SBarry Smith } 4661b37b28SSatish Balay } 4753acd3b1SBarry Smith PetscFunctionReturn(0); 4853acd3b1SBarry Smith } 4953acd3b1SBarry Smith 503194b578SJed Brown #undef __FUNCT__ 513194b578SJed Brown #define __FUNCT__ "PetscObjectOptionsBegin_Private" 523194b578SJed Brown /* 533194b578SJed Brown Handles setting up the data structure in a call to PetscObjectOptionsBegin() 543194b578SJed Brown */ 553194b578SJed Brown PetscErrorCode PetscObjectOptionsBegin_Private(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); 633194b578SJed Brown PetscOptionsObject.object = obj; 643194b578SJed Brown 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 } 723194b578SJed Brown ierr = PetscOptionsBegin_Private(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 */ 7953acd3b1SBarry Smith #undef __FUNCT__ 8053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsCreate_Private" 81e3ed6ec8SBarry Smith static int PetscOptionsCreate_Private(const char opt[],const char text[],const char man[],PetscOptionType t,PetscOptions *amsopt) 8253acd3b1SBarry Smith { 8353acd3b1SBarry Smith int ierr; 8453acd3b1SBarry Smith PetscOptions next; 853be6e4c3SJed Brown PetscBool valid; 8653acd3b1SBarry Smith 8753acd3b1SBarry Smith PetscFunctionBegin; 883be6e4c3SJed Brown ierr = PetscOptionsValidKey(opt,&valid);CHKERRQ(ierr); 893be6e4c3SJed Brown if (!valid) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_ARG_INCOMP,"The option '%s' is not a valid key",opt); 903be6e4c3SJed Brown 916e655a9bSJed Brown ierr = PetscNew(struct _n_PetscOptions,amsopt);CHKERRQ(ierr); 9253acd3b1SBarry Smith (*amsopt)->next = 0; 9353acd3b1SBarry Smith (*amsopt)->set = PETSC_FALSE; 946356e834SBarry Smith (*amsopt)->type = t; 9553acd3b1SBarry Smith (*amsopt)->data = 0; 9661b37b28SSatish Balay 9753acd3b1SBarry Smith ierr = PetscStrallocpy(text,&(*amsopt)->text);CHKERRQ(ierr); 9853acd3b1SBarry Smith ierr = PetscStrallocpy(opt,&(*amsopt)->option);CHKERRQ(ierr); 996356e834SBarry Smith ierr = PetscStrallocpy(man,&(*amsopt)->man);CHKERRQ(ierr); 10053acd3b1SBarry Smith 101a297a907SKarl Rupp if (!PetscOptionsObject.next) PetscOptionsObject.next = *amsopt; 102a297a907SKarl Rupp else { 10353acd3b1SBarry Smith next = PetscOptionsObject.next; 10453acd3b1SBarry Smith while (next->next) next = next->next; 10553acd3b1SBarry Smith next->next = *amsopt; 10653acd3b1SBarry Smith } 10753acd3b1SBarry Smith PetscFunctionReturn(0); 10853acd3b1SBarry Smith } 10953acd3b1SBarry Smith 11053acd3b1SBarry Smith #undef __FUNCT__ 111aee2cecaSBarry Smith #define __FUNCT__ "PetscScanString" 112aee2cecaSBarry Smith /* 1133fc1eb6aSBarry Smith PetscScanString - Gets user input via stdin from process and broadcasts to all processes 1143fc1eb6aSBarry Smith 1153fc1eb6aSBarry Smith Collective on MPI_Comm 1163fc1eb6aSBarry Smith 1173fc1eb6aSBarry Smith Input Parameters: 1183fc1eb6aSBarry Smith + commm - communicator for the broadcast, must be PETSC_COMM_WORLD 1193fc1eb6aSBarry Smith . n - length of the string, must be the same on all processes 1203fc1eb6aSBarry Smith - str - location to store input 121aee2cecaSBarry Smith 122aee2cecaSBarry Smith Bugs: 123aee2cecaSBarry Smith . Assumes process 0 of the given communicator has access to stdin 124aee2cecaSBarry Smith 125aee2cecaSBarry Smith */ 1263fc1eb6aSBarry Smith static PetscErrorCode PetscScanString(MPI_Comm comm,size_t n,char str[]) 127aee2cecaSBarry Smith { 128330cf3c9SBarry Smith size_t i; 129aee2cecaSBarry Smith char c; 1303fc1eb6aSBarry Smith PetscMPIInt rank,nm; 131aee2cecaSBarry Smith PetscErrorCode ierr; 132aee2cecaSBarry Smith 133aee2cecaSBarry Smith PetscFunctionBegin; 134aee2cecaSBarry Smith ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 135aee2cecaSBarry Smith if (!rank) { 136aee2cecaSBarry Smith c = (char) getchar(); 137aee2cecaSBarry Smith i = 0; 138aee2cecaSBarry Smith while (c != '\n' && i < n-1) { 139aee2cecaSBarry Smith str[i++] = c; 140aee2cecaSBarry Smith c = (char)getchar(); 141aee2cecaSBarry Smith } 142aee2cecaSBarry Smith str[i] = 0; 143aee2cecaSBarry Smith } 1444dc2109aSBarry Smith ierr = PetscMPIIntCast(n,&nm);CHKERRQ(ierr); 1453fc1eb6aSBarry Smith ierr = MPI_Bcast(str,nm,MPI_CHAR,0,comm);CHKERRQ(ierr); 146aee2cecaSBarry Smith PetscFunctionReturn(0); 147aee2cecaSBarry Smith } 148aee2cecaSBarry Smith 149aee2cecaSBarry Smith #undef __FUNCT__ 150aee2cecaSBarry Smith #define __FUNCT__ "PetscOptionsGetFromTextInput" 151aee2cecaSBarry Smith /* 1523cc1e11dSBarry Smith PetscOptionsGetFromTextInput - Presents all the PETSc Options processed by the program so the user may change them at runtime 153aee2cecaSBarry Smith 154aee2cecaSBarry Smith Notes: this isn't really practical, it is just to demonstrate the principle 155aee2cecaSBarry Smith 156*7781c08eSBarry Smith A carriage return indicates no change from the default; but this like -ksp_monitor <stdout> the default is actually not stdout the default 157*7781c08eSBarry Smith is to do nothing so to get it to use stdout you need to type stdout. This is kind of bug? 158*7781c08eSBarry Smith 159aee2cecaSBarry Smith Bugs: 160*7781c08eSBarry Smith + All processes must traverse through the exact same set of option queries due to the call to PetscScanString() 1613cc1e11dSBarry Smith . Internal strings have arbitrary length and string copies are not checked that they fit into string space 162aee2cecaSBarry Smith - Only works for PetscInt == int, PetscReal == double etc 163aee2cecaSBarry Smith 1643cc1e11dSBarry Smith Developer Notes: Normally the GUI that presents the options the user and retrieves the values would be running in a different 1653cc1e11dSBarry Smith address space and communicating with the PETSc program 1663cc1e11dSBarry Smith 167aee2cecaSBarry Smith */ 168aee2cecaSBarry Smith PetscErrorCode PetscOptionsGetFromTextInput() 1696356e834SBarry Smith { 1706356e834SBarry Smith PetscErrorCode ierr; 1716356e834SBarry Smith PetscOptions next = PetscOptionsObject.next; 1726356e834SBarry Smith char str[512]; 173a4404d99SBarry Smith PetscInt id; 174*7781c08eSBarry Smith PetscBool bid; 175a4404d99SBarry Smith PetscReal ir,*valr; 176330cf3c9SBarry Smith PetscInt *vald; 177330cf3c9SBarry Smith size_t i; 1786356e834SBarry Smith 179e26ddf31SBarry Smith ierr = (*PetscPrintf)(PETSC_COMM_WORLD,"%s -------------------------------------------------\n",PetscOptionsObject.title);CHKERRQ(ierr); 1806356e834SBarry Smith while (next) { 1816356e834SBarry Smith switch (next->type) { 1826356e834SBarry Smith case OPTION_HEAD: 1836356e834SBarry Smith break; 184e26ddf31SBarry Smith case OPTION_INT_ARRAY: 185e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1);CHKERRQ(ierr); 186e26ddf31SBarry Smith vald = (PetscInt*) next->data; 187e26ddf31SBarry Smith for (i=0; i<next->arraylength; i++) { 188e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"%d",vald[i]);CHKERRQ(ierr); 189e26ddf31SBarry Smith if (i < next->arraylength-1) { 190e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr); 191e26ddf31SBarry Smith } 192e26ddf31SBarry Smith } 193e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s) ",next->text,next->man);CHKERRQ(ierr); 194e26ddf31SBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 195e26ddf31SBarry Smith if (str[0]) { 196e26ddf31SBarry Smith PetscToken token; 197e26ddf31SBarry Smith PetscInt n=0,nmax = next->arraylength,*dvalue = (PetscInt*)next->data,start,end; 198e26ddf31SBarry Smith size_t len; 199e26ddf31SBarry Smith char *value; 200ace3abfcSBarry Smith PetscBool foundrange; 201e26ddf31SBarry Smith 202e26ddf31SBarry Smith next->set = PETSC_TRUE; 203e26ddf31SBarry Smith value = str; 204e26ddf31SBarry Smith ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr); 205e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 206e26ddf31SBarry Smith while (n < nmax) { 207e26ddf31SBarry Smith if (!value) break; 208e26ddf31SBarry Smith 209e26ddf31SBarry Smith /* look for form d-D where d and D are integers */ 210e26ddf31SBarry Smith foundrange = PETSC_FALSE; 211e26ddf31SBarry Smith ierr = PetscStrlen(value,&len);CHKERRQ(ierr); 212e26ddf31SBarry Smith if (value[0] == '-') i=2; 213e26ddf31SBarry Smith else i=1; 214330cf3c9SBarry Smith for (;i<len; i++) { 215e26ddf31SBarry Smith if (value[i] == '-') { 216e32f2f54SBarry Smith if (i == len-1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_USER,"Error in %D-th array entry %s\n",n,value); 217e26ddf31SBarry Smith value[i] = 0; 218cfbddea1SSatish Balay ierr = PetscOptionsStringToInt(value,&start);CHKERRQ(ierr); 219cfbddea1SSatish Balay ierr = PetscOptionsStringToInt(value+i+1,&end);CHKERRQ(ierr); 220e32f2f54SBarry 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); 221e32f2f54SBarry 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); 222e26ddf31SBarry Smith for (; start<end; start++) { 223e26ddf31SBarry Smith *dvalue = start; dvalue++;n++; 224e26ddf31SBarry Smith } 225e26ddf31SBarry Smith foundrange = PETSC_TRUE; 226e26ddf31SBarry Smith break; 227e26ddf31SBarry Smith } 228e26ddf31SBarry Smith } 229e26ddf31SBarry Smith if (!foundrange) { 230cfbddea1SSatish Balay ierr = PetscOptionsStringToInt(value,dvalue);CHKERRQ(ierr); 231e26ddf31SBarry Smith dvalue++; 232e26ddf31SBarry Smith n++; 233e26ddf31SBarry Smith } 234e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 235e26ddf31SBarry Smith } 2368c74ee41SBarry Smith ierr = PetscTokenDestroy(&token);CHKERRQ(ierr); 237e26ddf31SBarry Smith } 238e26ddf31SBarry Smith break; 239e26ddf31SBarry Smith case OPTION_REAL_ARRAY: 240e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"-%s%s <",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",next->option+1);CHKERRQ(ierr); 241e26ddf31SBarry Smith valr = (PetscReal*) next->data; 242e26ddf31SBarry Smith for (i=0; i<next->arraylength; i++) { 243e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,"%g",valr[i]);CHKERRQ(ierr); 244e26ddf31SBarry Smith if (i < next->arraylength-1) { 245e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,",");CHKERRQ(ierr); 246e26ddf31SBarry Smith } 247e26ddf31SBarry Smith } 248e26ddf31SBarry Smith ierr = PetscPrintf(PETSC_COMM_WORLD,">: %s (%s) ",next->text,next->man);CHKERRQ(ierr); 249e26ddf31SBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 250e26ddf31SBarry Smith if (str[0]) { 251e26ddf31SBarry Smith PetscToken token; 252e26ddf31SBarry Smith PetscInt n = 0,nmax = next->arraylength; 253e26ddf31SBarry Smith PetscReal *dvalue = (PetscReal*)next->data; 254e26ddf31SBarry Smith char *value; 255e26ddf31SBarry Smith 256e26ddf31SBarry Smith next->set = PETSC_TRUE; 257e26ddf31SBarry Smith value = str; 258e26ddf31SBarry Smith ierr = PetscTokenCreate(value,',',&token);CHKERRQ(ierr); 259e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 260e26ddf31SBarry Smith while (n < nmax) { 261e26ddf31SBarry Smith if (!value) break; 262cfbddea1SSatish Balay ierr = PetscOptionsStringToReal(value,dvalue);CHKERRQ(ierr); 263e26ddf31SBarry Smith dvalue++; 264e26ddf31SBarry Smith n++; 265e26ddf31SBarry Smith ierr = PetscTokenFind(token,&value);CHKERRQ(ierr); 266e26ddf31SBarry Smith } 2678c74ee41SBarry Smith ierr = PetscTokenDestroy(&token);CHKERRQ(ierr); 268e26ddf31SBarry Smith } 269e26ddf31SBarry Smith break; 2706356e834SBarry Smith case OPTION_INT: 271e26ddf31SBarry 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); 2723fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 2733fc1eb6aSBarry Smith if (str[0]) { 274c272547aSJed Brown #if defined(PETSC_USE_64BIT_INDICES) 275c272547aSJed Brown sscanf(str,"%lld",&id); 276c272547aSJed Brown #else 277aee2cecaSBarry Smith sscanf(str,"%d",&id); 278c272547aSJed Brown #endif 279aee2cecaSBarry Smith next->set = PETSC_TRUE; 280a297a907SKarl Rupp 281aee2cecaSBarry Smith *((PetscInt*)next->data) = id; 282aee2cecaSBarry Smith } 283aee2cecaSBarry Smith break; 284aee2cecaSBarry Smith case OPTION_REAL: 285e26ddf31SBarry 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); 2863fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 2873fc1eb6aSBarry Smith if (str[0]) { 288ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE) 289a4404d99SBarry Smith sscanf(str,"%e",&ir); 290ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE) 291aee2cecaSBarry Smith sscanf(str,"%le",&ir); 292ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128) 293d9822059SBarry Smith ir = strtoflt128(str,0); 294d9822059SBarry Smith #else 295513dbe71SLisandro Dalcin SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Unknown scalar type"); 296a4404d99SBarry Smith #endif 297aee2cecaSBarry Smith next->set = PETSC_TRUE; 298aee2cecaSBarry Smith *((PetscReal*)next->data) = ir; 299aee2cecaSBarry Smith } 300aee2cecaSBarry Smith break; 301*7781c08eSBarry Smith case OPTION_BOOL: 302*7781c08eSBarry 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); 303*7781c08eSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 304*7781c08eSBarry Smith if (str[0]) { 305*7781c08eSBarry Smith ierr = PetscOptionsStringToBool(str,&bid);CHKERRQ(ierr); 306*7781c08eSBarry Smith next->set = PETSC_TRUE; 307*7781c08eSBarry Smith *((PetscBool*)next->data) = bid; 308*7781c08eSBarry Smith } 309*7781c08eSBarry Smith break; 310aee2cecaSBarry Smith case OPTION_STRING: 311e26ddf31SBarry 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); 3123fc1eb6aSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 3133fc1eb6aSBarry Smith if (str[0]) { 314aee2cecaSBarry Smith next->set = PETSC_TRUE; 315*7781c08eSBarry Smith next->data = (void*)strdup(str); 3166356e834SBarry Smith } 3176356e834SBarry Smith break; 3183cc1e11dSBarry Smith case OPTION_LIST: 319140e18c1SBarry Smith ierr = PetscFunctionListPrintTypes(PETSC_COMM_WORLD,stdout,PetscOptionsObject.prefix,next->option,next->text,next->man,next->flist,(char*)next->data);CHKERRQ(ierr); 3203cc1e11dSBarry Smith ierr = PetscScanString(PETSC_COMM_WORLD,512,str);CHKERRQ(ierr); 3213cc1e11dSBarry Smith if (str[0]) { 3223cc1e11dSBarry Smith PetscOptionsObject.changedmethod = PETSC_TRUE; 3233cc1e11dSBarry Smith next->set = PETSC_TRUE; 324*7781c08eSBarry Smith next->data = (void*)strdup(str); 3253cc1e11dSBarry Smith } 3263cc1e11dSBarry Smith break; 327b432afdaSMatthew Knepley default: 328b432afdaSMatthew Knepley break; 3296356e834SBarry Smith } 3306356e834SBarry Smith next = next->next; 3316356e834SBarry Smith } 3326356e834SBarry Smith PetscFunctionReturn(0); 3336356e834SBarry Smith } 3346356e834SBarry Smith 335e04113cfSBarry Smith #if defined(PETSC_HAVE_SAWS) 336e04113cfSBarry Smith #include <petscviewersaws.h> 337d5649816SBarry Smith 338d5649816SBarry Smith static int count = 0; 339d5649816SBarry Smith 340b3506946SBarry Smith #undef __FUNCT__ 341e04113cfSBarry Smith #define __FUNCT__ "PetscOptionsSAWsDestroy" 342e04113cfSBarry Smith PetscErrorCode PetscOptionsSAWsDestroy(void) 343d5649816SBarry Smith { 3442657e9d9SBarry Smith PetscFunctionBegin; 345d5649816SBarry Smith PetscFunctionReturn(0); 346d5649816SBarry Smith } 347d5649816SBarry Smith 348d5649816SBarry Smith #undef __FUNCT__ 349*7781c08eSBarry Smith #define __FUNCT__ "PetscOptionsSAWsInput" 350b3506946SBarry Smith /* 351*7781c08eSBarry Smith PetscOptionsSAWsInput - Presents all the PETSc Options processed by the program so the user may change them at runtime using the SAWs 352b3506946SBarry Smith 353b3506946SBarry Smith Bugs: 354b3506946SBarry Smith + All processes must traverse through the exact same set of option queries do to the call to PetscScanString() 355b3506946SBarry Smith . Internal strings have arbitrary length and string copies are not checked that they fit into string space 356b3506946SBarry Smith - Only works for PetscInt == int, PetscReal == double etc 357b3506946SBarry Smith 358b3506946SBarry Smith 359b3506946SBarry Smith */ 360475446a1SBarry Smith PetscErrorCode PetscOptionsSAWsInput() 361b3506946SBarry Smith { 362b3506946SBarry Smith PetscErrorCode ierr; 363b3506946SBarry Smith PetscOptions next = PetscOptionsObject.next; 364d5649816SBarry Smith static int mancount = 0; 365b3506946SBarry Smith char options[16]; 366*7781c08eSBarry Smith PetscBool changedmethod = PETSC_FALSE, locked = PETSC_TRUE; 367*7781c08eSBarry Smith char manname[16],setname[16],textname[16]; 3682657e9d9SBarry Smith char dir[1024]; 369b3506946SBarry Smith 370b3506946SBarry Smith /* the next line is a bug, this will only work if all processors are here, the comm passed in is ignored!!! */ 371b3506946SBarry Smith sprintf(options,"Options_%d",count++); 372a297a907SKarl Rupp 373e04113cfSBarry Smith PetscOptionsObject.pprefix = PetscOptionsObject.prefix; /* SAWs will change this, so cannot pass prefix directly */ 3741bc75a8dSBarry Smith 375*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s","title");CHKERRQ(ierr); 376*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject.title,1,SAWs_READ,SAWs_STRING)); 377*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s","prefix");CHKERRQ(ierr); 3782657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&PetscOptionsObject.pprefix,1,SAWs_READ,SAWs_STRING)); 3792657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/ChangedMethod",&changedmethod,1,SAWs_WRITE,SAWs_BOOLEAN)); 380*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,("/PETSc/Options/Locked",&locked,1,SAWs_WRITE,SAWs_BOOLEAN)); 381b3506946SBarry Smith 382b3506946SBarry Smith while (next) { 383*7781c08eSBarry Smith sprintf(setname,"set_%d",mancount); 384*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",setname);CHKERRQ(ierr); 3852657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->set,1,SAWs_WRITE,SAWs_INT)); 386*7781c08eSBarry Smith sprintf(manname,"man_%d",mancount); 3872657e9d9SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",manname);CHKERRQ(ierr); 388*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->man,1,SAWs_READ,SAWs_STRING)); 389*7781c08eSBarry Smith sprintf(textname,"text_%d",mancount++); 390*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",textname);CHKERRQ(ierr); 391*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->text,1,SAWs_READ,SAWs_STRING)); 3929f32e415SBarry Smith 393b3506946SBarry Smith switch (next->type) { 394b3506946SBarry Smith case OPTION_HEAD: 395b3506946SBarry Smith break; 396b3506946SBarry Smith case OPTION_INT_ARRAY: 397*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 3982657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_INT)); 399b3506946SBarry Smith break; 400b3506946SBarry Smith case OPTION_REAL_ARRAY: 401*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4022657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_DOUBLE)); 403b3506946SBarry Smith break; 404b3506946SBarry Smith case OPTION_INT: 405*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4062657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_INT)); 407b3506946SBarry Smith break; 408b3506946SBarry Smith case OPTION_REAL: 409*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4102657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_DOUBLE)); 411b3506946SBarry Smith break; 412*7781c08eSBarry Smith case OPTION_BOOL: 413*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4142657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,1,SAWs_WRITE,SAWs_BOOLEAN)); 4151ae3d29cSBarry Smith break; 416*7781c08eSBarry Smith case OPTION_BOOL_ARRAY: 417*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4182657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_BOOLEAN)); 41971f08665SBarry Smith break; 420b3506946SBarry Smith case OPTION_STRING: 421*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 422*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING)); 4231ae3d29cSBarry Smith break; 4241ae3d29cSBarry Smith case OPTION_STRING_ARRAY: 425*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 4262657e9d9SBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->data,next->arraylength,SAWs_WRITE,SAWs_STRING)); 427b3506946SBarry Smith break; 428b3506946SBarry Smith case OPTION_LIST: 429*7781c08eSBarry Smith {/*PetscInt ntext;*/ 430*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 431*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING)); 432*7781c08eSBarry Smith /*ierr = PetscFunctionListGet(next->flist,(const char***)&next->edata,&ntext);CHKERRQ(ierr); 433*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 434*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->edata,ntext-1,SAWs_READ,SAWs_STRING));*/ 4351ae3d29cSBarry Smith break;} 4361ae3d29cSBarry Smith case OPTION_ELIST: 437*7781c08eSBarry Smith {/*PetscInt ntext = next->nlist; */ 438*7781c08eSBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->option);CHKERRQ(ierr); 439*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,&next->data,1,SAWs_WRITE,SAWs_STRING)); 440*7781c08eSBarry Smith /*ierr = PetscMalloc((ntext+1)*sizeof(char**),&next->edata);CHKERRQ(ierr); 4411ae3d29cSBarry Smith ierr = PetscMemcpy(next->edata,next->list,ntext*sizeof(char*));CHKERRQ(ierr); 4422657e9d9SBarry Smith ierr = PetscSNPrintf(dir,1024,"/PETSc/Options/%s",next->text);CHKERRQ(ierr); 443*7781c08eSBarry Smith PetscStackCallSAWs(SAWs_Register,(dir,next->edata,ntext,SAWs_READ,SAWs_STRING));*/ 44471f08665SBarry Smith break;} 445b3506946SBarry Smith default: 446b3506946SBarry Smith break; 447b3506946SBarry Smith } 448b3506946SBarry Smith next = next->next; 449b3506946SBarry Smith } 450b3506946SBarry Smith 451b3506946SBarry Smith /* wait until accessor has unlocked the memory */ 452*7781c08eSBarry Smith SAWs_Lock(); 453*7781c08eSBarry Smith while (locked) { 454*7781c08eSBarry Smith SAWs_Unlock(); 455*7781c08eSBarry Smith ierr = PetscSleep(2);CHKERRQ(ierr); 456*7781c08eSBarry Smith SAWs_Lock(); 457*7781c08eSBarry Smith } 458*7781c08eSBarry Smith SAWs_Unlock(); 459b3506946SBarry Smith 460b3506946SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 461b3506946SBarry Smith if (changedmethod) PetscOptionsPublishCount = -2; 462b3506946SBarry Smith 4639a492a5cSBarry Smith PetscStackCallSAWs(SAWs_Unlock,()); 4649a492a5cSBarry Smith PetscStackCallSAWs(SAWs_Delete,("/PETSc/Options")); 465b3506946SBarry Smith PetscFunctionReturn(0); 466b3506946SBarry Smith } 467b3506946SBarry Smith #endif 468b3506946SBarry Smith 4696356e834SBarry Smith #undef __FUNCT__ 47053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnd_Private" 47153acd3b1SBarry Smith PetscErrorCode PetscOptionsEnd_Private(void) 47253acd3b1SBarry Smith { 47353acd3b1SBarry Smith PetscErrorCode ierr; 4746356e834SBarry Smith PetscOptions last; 4756356e834SBarry Smith char option[256],value[1024],tmp[32]; 476330cf3c9SBarry Smith size_t j; 47753acd3b1SBarry Smith 47853acd3b1SBarry Smith PetscFunctionBegin; 479aee2cecaSBarry Smith if (PetscOptionsObject.next) { 480b3506946SBarry Smith if (!PetscOptionsPublishCount) { 481*7781c08eSBarry Smith #if defined(PETSC_HAVE_SAWS) 482475446a1SBarry Smith ierr = PetscOptionsSAWsInput();CHKERRQ(ierr); 483b3506946SBarry Smith #else 48471f08665SBarry Smith ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr); 485b3506946SBarry Smith #endif 486aee2cecaSBarry Smith } 487aee2cecaSBarry Smith } 4886356e834SBarry Smith 489c31cb41cSBarry Smith ierr = PetscFree(PetscOptionsObject.title);CHKERRQ(ierr); 490c31cb41cSBarry Smith ierr = PetscFree(PetscOptionsObject.prefix);CHKERRQ(ierr); 4916356e834SBarry Smith 4926356e834SBarry Smith /* reset counter to -2; this updates the screen with the new options for the selected method */ 4936356e834SBarry Smith if (PetscOptionsObject.changedmethod) PetscOptionsPublishCount = -2; 49461b37b28SSatish Balay /* reset alreadyprinted flag */ 49561b37b28SSatish Balay PetscOptionsObject.alreadyprinted = PETSC_FALSE; 4963194b578SJed Brown if (PetscOptionsObject.object) PetscOptionsObject.object->optionsprinted = PETSC_TRUE; 4970298fd71SBarry Smith PetscOptionsObject.object = NULL; 4986356e834SBarry Smith 4996356e834SBarry Smith while (PetscOptionsObject.next) { 5006356e834SBarry Smith if (PetscOptionsObject.next->set) { 5016356e834SBarry Smith if (PetscOptionsObject.prefix) { 5026356e834SBarry Smith ierr = PetscStrcpy(option,"-");CHKERRQ(ierr); 5036356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.prefix);CHKERRQ(ierr); 5046356e834SBarry Smith ierr = PetscStrcat(option,PetscOptionsObject.next->option+1);CHKERRQ(ierr); 5056356e834SBarry Smith } else { 5066356e834SBarry Smith ierr = PetscStrcpy(option,PetscOptionsObject.next->option);CHKERRQ(ierr); 5076356e834SBarry Smith } 5086356e834SBarry Smith 5096356e834SBarry Smith switch (PetscOptionsObject.next->type) { 5106356e834SBarry Smith case OPTION_HEAD: 5116356e834SBarry Smith break; 512e26ddf31SBarry Smith case OPTION_INT_ARRAY: 513e26ddf31SBarry Smith sprintf(value,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[0]); 514e26ddf31SBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 515e26ddf31SBarry Smith sprintf(tmp,"%d",(int)((PetscInt*)PetscOptionsObject.next->data)[j]); 516e26ddf31SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 517e26ddf31SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 518e26ddf31SBarry Smith } 519e26ddf31SBarry Smith break; 5206356e834SBarry Smith case OPTION_INT: 5217a72a596SBarry Smith sprintf(value,"%d",(int) *(PetscInt*)PetscOptionsObject.next->data); 5226356e834SBarry Smith break; 5236356e834SBarry Smith case OPTION_REAL: 5247a72a596SBarry Smith sprintf(value,"%g",(double) *(PetscReal*)PetscOptionsObject.next->data); 5256356e834SBarry Smith break; 5266356e834SBarry Smith case OPTION_REAL_ARRAY: 5277a72a596SBarry Smith sprintf(value,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[0]); 5286356e834SBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 5297a72a596SBarry Smith sprintf(tmp,"%g",(double)((PetscReal*)PetscOptionsObject.next->data)[j]); 5306356e834SBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 5316356e834SBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 5326356e834SBarry Smith } 5336356e834SBarry Smith break; 534*7781c08eSBarry Smith case OPTION_BOOL: 53571f08665SBarry Smith sprintf(value,"%d",*(int*)PetscOptionsObject.next->data); 5366356e834SBarry Smith break; 537*7781c08eSBarry Smith case OPTION_BOOL_ARRAY: 538ace3abfcSBarry Smith sprintf(value,"%d",(int)((PetscBool*)PetscOptionsObject.next->data)[0]); 5391ae3d29cSBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 540ace3abfcSBarry Smith sprintf(tmp,"%d",(int)((PetscBool*)PetscOptionsObject.next->data)[j]); 5411ae3d29cSBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 5421ae3d29cSBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 5431ae3d29cSBarry Smith } 5441ae3d29cSBarry Smith break; 5456356e834SBarry Smith case OPTION_LIST: 5461ae3d29cSBarry Smith case OPTION_ELIST: 547*7781c08eSBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 5486356e834SBarry Smith break; 5491ae3d29cSBarry Smith case OPTION_STRING: 550475446a1SBarry Smith ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr); 5511ae3d29cSBarry Smith case OPTION_STRING_ARRAY: 5521ae3d29cSBarry Smith sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]); 5531ae3d29cSBarry Smith for (j=1; j<PetscOptionsObject.next->arraylength; j++) { 5541ae3d29cSBarry Smith sprintf(tmp,"%s",((char**)PetscOptionsObject.next->data)[j]); 5551ae3d29cSBarry Smith ierr = PetscStrcat(value,",");CHKERRQ(ierr); 5561ae3d29cSBarry Smith ierr = PetscStrcat(value,tmp);CHKERRQ(ierr); 5571ae3d29cSBarry Smith } 5586356e834SBarry Smith break; 5596356e834SBarry Smith } 5606356e834SBarry Smith ierr = PetscOptionsSetValue(option,value);CHKERRQ(ierr); 5616356e834SBarry Smith } 562503cfb0cSBarry Smith ierr = PetscFree(PetscOptionsObject.next->text);CHKERRQ(ierr); 563503cfb0cSBarry Smith ierr = PetscFree(PetscOptionsObject.next->option);CHKERRQ(ierr); 5646356e834SBarry Smith ierr = PetscFree(PetscOptionsObject.next->man);CHKERRQ(ierr); 56571f08665SBarry Smith ierr = PetscFree(PetscOptionsObject.next->edata);CHKERRQ(ierr); 566a297a907SKarl Rupp 567*7781c08eSBarry Smith if ((PetscOptionsObject.next->type == OPTION_STRING) || (PetscOptionsObject.next->type == OPTION_LIST) || (PetscOptionsObject.next->type == OPTION_ELIST)){ 568*7781c08eSBarry Smith free(PetscOptionsObject.next->data); 569*7781c08eSBarry Smith } else { 570*7781c08eSBarry Smith ierr = PetscFree(PetscOptionsObject.next->data);CHKERRQ(ierr); 571*7781c08eSBarry Smith } 572*7781c08eSBarry Smith 5736356e834SBarry Smith last = PetscOptionsObject.next; 5746356e834SBarry Smith PetscOptionsObject.next = PetscOptionsObject.next->next; 5756356e834SBarry Smith ierr = PetscFree(last);CHKERRQ(ierr); 5766356e834SBarry Smith } 5776356e834SBarry Smith PetscOptionsObject.next = 0; 57853acd3b1SBarry Smith PetscFunctionReturn(0); 57953acd3b1SBarry Smith } 58053acd3b1SBarry Smith 58153acd3b1SBarry Smith #undef __FUNCT__ 58253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEnum" 58353acd3b1SBarry Smith /*@C 58453acd3b1SBarry Smith PetscOptionsEnum - Gets the enum value for a particular option in the database. 58553acd3b1SBarry Smith 5863f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 58753acd3b1SBarry Smith 58853acd3b1SBarry Smith Input Parameters: 58953acd3b1SBarry Smith + opt - option name 59053acd3b1SBarry Smith . text - short string that describes the option 59153acd3b1SBarry Smith . man - manual page with additional information on option 59253acd3b1SBarry Smith . list - array containing the list of choices, followed by the enum name, followed by the enum prefix, followed by a null 59353acd3b1SBarry Smith - defaultv - the default (current) value 59453acd3b1SBarry Smith 59553acd3b1SBarry Smith Output Parameter: 59653acd3b1SBarry Smith + value - the value to return 597b32e0204SMatthew G Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 59853acd3b1SBarry Smith 59953acd3b1SBarry Smith Level: beginner 60053acd3b1SBarry Smith 60153acd3b1SBarry Smith Concepts: options database 60253acd3b1SBarry Smith 60353acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 60453acd3b1SBarry Smith 60553acd3b1SBarry Smith list is usually something like PCASMTypes or some other predefined list of enum names 60653acd3b1SBarry Smith 60753acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 608acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 609acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 61053acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 61153acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 612acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 61353acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 61453acd3b1SBarry Smith @*/ 6157087cfbeSBarry Smith PetscErrorCode PetscOptionsEnum(const char opt[],const char text[],const char man[],const char *const *list,PetscEnum defaultv,PetscEnum *value,PetscBool *set) 61653acd3b1SBarry Smith { 61753acd3b1SBarry Smith PetscErrorCode ierr; 61853acd3b1SBarry Smith PetscInt ntext = 0; 619aa5bb8c0SSatish Balay PetscInt tval; 620ace3abfcSBarry Smith PetscBool tflg; 62153acd3b1SBarry Smith 62253acd3b1SBarry Smith PetscFunctionBegin; 62353acd3b1SBarry Smith while (list[ntext++]) { 624e32f2f54SBarry Smith if (ntext > 50) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument appears to be wrong or have more than 50 entries"); 62553acd3b1SBarry Smith } 626e32f2f54SBarry Smith if (ntext < 3) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"List argument must have at least two entries: typename and type prefix"); 62753acd3b1SBarry Smith ntext -= 3; 628aa5bb8c0SSatish Balay ierr = PetscOptionsEList(opt,text,man,list,ntext,list[defaultv],&tval,&tflg);CHKERRQ(ierr); 629aa5bb8c0SSatish Balay /* with PETSC_USE_64BIT_INDICES sizeof(PetscInt) != sizeof(PetscEnum) */ 630aa5bb8c0SSatish Balay if (tflg) *value = (PetscEnum)tval; 631aa5bb8c0SSatish Balay if (set) *set = tflg; 63253acd3b1SBarry Smith PetscFunctionReturn(0); 63353acd3b1SBarry Smith } 63453acd3b1SBarry Smith 63553acd3b1SBarry Smith /* -------------------------------------------------------------------------------------------------------------*/ 63653acd3b1SBarry Smith #undef __FUNCT__ 63753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsInt" 63853acd3b1SBarry Smith /*@C 63953acd3b1SBarry Smith PetscOptionsInt - Gets the integer value for a particular option in the database. 64053acd3b1SBarry Smith 6413f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 64253acd3b1SBarry Smith 64353acd3b1SBarry Smith Input Parameters: 64453acd3b1SBarry Smith + opt - option name 64553acd3b1SBarry Smith . text - short string that describes the option 64653acd3b1SBarry Smith . man - manual page with additional information on option 64753acd3b1SBarry Smith - defaultv - the default (current) value 64853acd3b1SBarry Smith 64953acd3b1SBarry Smith Output Parameter: 65053acd3b1SBarry Smith + value - the integer value to return 65153acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 65253acd3b1SBarry Smith 65353acd3b1SBarry Smith Level: beginner 65453acd3b1SBarry Smith 65553acd3b1SBarry Smith Concepts: options database^has int 65653acd3b1SBarry Smith 65753acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 65853acd3b1SBarry Smith 65953acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 660acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 661acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 66253acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 66353acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 664acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 66553acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 66653acd3b1SBarry Smith @*/ 6677087cfbeSBarry Smith PetscErrorCode PetscOptionsInt(const char opt[],const char text[],const char man[],PetscInt defaultv,PetscInt *value,PetscBool *set) 66853acd3b1SBarry Smith { 66953acd3b1SBarry Smith PetscErrorCode ierr; 6706356e834SBarry Smith PetscOptions amsopt; 67153acd3b1SBarry Smith 67253acd3b1SBarry Smith PetscFunctionBegin; 673b3506946SBarry Smith if (!PetscOptionsPublishCount) { 6746356e834SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT,&amsopt);CHKERRQ(ierr); 6756356e834SBarry Smith ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 676a297a907SKarl Rupp 6776356e834SBarry Smith *(PetscInt*)amsopt->data = defaultv; 678af6d86caSBarry Smith } 67953acd3b1SBarry Smith ierr = PetscOptionsGetInt(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 68061b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 6812aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr); 68253acd3b1SBarry Smith } 68353acd3b1SBarry Smith PetscFunctionReturn(0); 68453acd3b1SBarry Smith } 68553acd3b1SBarry Smith 68653acd3b1SBarry Smith #undef __FUNCT__ 68753acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsString" 68853acd3b1SBarry Smith /*@C 68953acd3b1SBarry Smith PetscOptionsString - Gets the string value for a particular option in the database. 69053acd3b1SBarry Smith 6913f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 69253acd3b1SBarry Smith 69353acd3b1SBarry Smith Input Parameters: 69453acd3b1SBarry Smith + opt - option name 69553acd3b1SBarry Smith . text - short string that describes the option 69653acd3b1SBarry Smith . man - manual page with additional information on option 697bcbf2dc5SJed Brown . defaultv - the default (current) value 698bcbf2dc5SJed Brown - len - length of the result string including null terminator 69953acd3b1SBarry Smith 70053acd3b1SBarry Smith Output Parameter: 70153acd3b1SBarry Smith + value - the value to return 70253acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 70353acd3b1SBarry Smith 70453acd3b1SBarry Smith Level: beginner 70553acd3b1SBarry Smith 70653acd3b1SBarry Smith Concepts: options database^has int 70753acd3b1SBarry Smith 70853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 70953acd3b1SBarry Smith 7107fccdfe4SBarry 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). 7117fccdfe4SBarry Smith 71253acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 713acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 714acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsReal(), PetscOptionsBool(), 71553acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 71653acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 717acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 71853acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 71953acd3b1SBarry Smith @*/ 7207087cfbeSBarry Smith PetscErrorCode PetscOptionsString(const char opt[],const char text[],const char man[],const char defaultv[],char value[],size_t len,PetscBool *set) 72153acd3b1SBarry Smith { 72253acd3b1SBarry Smith PetscErrorCode ierr; 723aee2cecaSBarry Smith PetscOptions amsopt; 72453acd3b1SBarry Smith 72553acd3b1SBarry Smith PetscFunctionBegin; 726b3506946SBarry Smith if (!PetscOptionsPublishCount) { 727aee2cecaSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 728*7781c08eSBarry Smith amsopt->data = (void*)strdup(defaultv ? defaultv : ""); 729af6d86caSBarry Smith } 73053acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 73161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 7322aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr); 73353acd3b1SBarry Smith } 73453acd3b1SBarry Smith PetscFunctionReturn(0); 73553acd3b1SBarry Smith } 73653acd3b1SBarry Smith 73753acd3b1SBarry Smith #undef __FUNCT__ 73853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsReal" 73953acd3b1SBarry Smith /*@C 74053acd3b1SBarry Smith PetscOptionsReal - Gets the PetscReal value for a particular option in the database. 74153acd3b1SBarry Smith 7423f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 74353acd3b1SBarry Smith 74453acd3b1SBarry Smith Input Parameters: 74553acd3b1SBarry Smith + opt - option name 74653acd3b1SBarry Smith . text - short string that describes the option 74753acd3b1SBarry Smith . man - manual page with additional information on option 74853acd3b1SBarry Smith - defaultv - the default (current) value 74953acd3b1SBarry Smith 75053acd3b1SBarry Smith Output Parameter: 75153acd3b1SBarry Smith + value - the value to return 75253acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 75353acd3b1SBarry Smith 75453acd3b1SBarry Smith Level: beginner 75553acd3b1SBarry Smith 75653acd3b1SBarry Smith Concepts: options database^has int 75753acd3b1SBarry Smith 75853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 75953acd3b1SBarry Smith 76053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 761acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 762acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 76353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 76453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 765acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 76653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 76753acd3b1SBarry Smith @*/ 7687087cfbeSBarry Smith PetscErrorCode PetscOptionsReal(const char opt[],const char text[],const char man[],PetscReal defaultv,PetscReal *value,PetscBool *set) 76953acd3b1SBarry Smith { 77053acd3b1SBarry Smith PetscErrorCode ierr; 771538aa990SBarry Smith PetscOptions amsopt; 77253acd3b1SBarry Smith 77353acd3b1SBarry Smith PetscFunctionBegin; 774b3506946SBarry Smith if (!PetscOptionsPublishCount) { 775538aa990SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL,&amsopt);CHKERRQ(ierr); 776538aa990SBarry Smith ierr = PetscMalloc(sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 777a297a907SKarl Rupp 778538aa990SBarry Smith *(PetscReal*)amsopt->data = defaultv; 779538aa990SBarry Smith } 78053acd3b1SBarry Smith ierr = PetscOptionsGetReal(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 78161b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 7822aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,defaultv,text,ManSection(man));CHKERRQ(ierr); 78353acd3b1SBarry Smith } 78453acd3b1SBarry Smith PetscFunctionReturn(0); 78553acd3b1SBarry Smith } 78653acd3b1SBarry Smith 78753acd3b1SBarry Smith #undef __FUNCT__ 78853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsScalar" 78953acd3b1SBarry Smith /*@C 79053acd3b1SBarry Smith PetscOptionsScalar - Gets the scalar value for a particular option in the database. 79153acd3b1SBarry Smith 7923f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 79353acd3b1SBarry Smith 79453acd3b1SBarry Smith Input Parameters: 79553acd3b1SBarry Smith + opt - option name 79653acd3b1SBarry Smith . text - short string that describes the option 79753acd3b1SBarry Smith . man - manual page with additional information on option 79853acd3b1SBarry Smith - defaultv - the default (current) value 79953acd3b1SBarry Smith 80053acd3b1SBarry Smith Output Parameter: 80153acd3b1SBarry Smith + value - the value to return 80253acd3b1SBarry Smith - flg - PETSC_TRUE if found, else PETSC_FALSE 80353acd3b1SBarry Smith 80453acd3b1SBarry Smith Level: beginner 80553acd3b1SBarry Smith 80653acd3b1SBarry Smith Concepts: options database^has int 80753acd3b1SBarry Smith 80853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 80953acd3b1SBarry Smith 81053acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 811acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 812acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 81353acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 81453acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 815acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 81653acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 81753acd3b1SBarry Smith @*/ 8187087cfbeSBarry Smith PetscErrorCode PetscOptionsScalar(const char opt[],const char text[],const char man[],PetscScalar defaultv,PetscScalar *value,PetscBool *set) 81953acd3b1SBarry Smith { 82053acd3b1SBarry Smith PetscErrorCode ierr; 82153acd3b1SBarry Smith 82253acd3b1SBarry Smith PetscFunctionBegin; 82353acd3b1SBarry Smith #if !defined(PETSC_USE_COMPLEX) 82453acd3b1SBarry Smith ierr = PetscOptionsReal(opt,text,man,defaultv,value,set);CHKERRQ(ierr); 82553acd3b1SBarry Smith #else 82653acd3b1SBarry Smith ierr = PetscOptionsGetScalar(PetscOptionsObject.prefix,opt,value,set);CHKERRQ(ierr); 82753acd3b1SBarry Smith #endif 82853acd3b1SBarry Smith PetscFunctionReturn(0); 82953acd3b1SBarry Smith } 83053acd3b1SBarry Smith 83153acd3b1SBarry Smith #undef __FUNCT__ 83253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsName" 83353acd3b1SBarry Smith /*@C 83490d69ab7SBarry 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 83590d69ab7SBarry Smith its value is set to false. 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 84353acd3b1SBarry Smith 84453acd3b1SBarry Smith Output Parameter: 84553acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 84653acd3b1SBarry Smith 84753acd3b1SBarry Smith Level: beginner 84853acd3b1SBarry Smith 84953acd3b1SBarry Smith Concepts: options database^has int 85053acd3b1SBarry Smith 85153acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 85253acd3b1SBarry Smith 85353acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 854acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 855acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 85653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 85753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 858acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 85953acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 86053acd3b1SBarry Smith @*/ 8617087cfbeSBarry Smith PetscErrorCode PetscOptionsName(const char opt[],const char text[],const char man[],PetscBool *flg) 86253acd3b1SBarry Smith { 86353acd3b1SBarry Smith PetscErrorCode ierr; 8641ae3d29cSBarry Smith PetscOptions amsopt; 86553acd3b1SBarry Smith 86653acd3b1SBarry Smith PetscFunctionBegin; 8671ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 868*7781c08eSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 869ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 870a297a907SKarl Rupp 871ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 8721ae3d29cSBarry Smith } 87353acd3b1SBarry Smith ierr = PetscOptionsHasName(PetscOptionsObject.prefix,opt,flg);CHKERRQ(ierr); 87461b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 8752aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 87653acd3b1SBarry Smith } 87753acd3b1SBarry Smith PetscFunctionReturn(0); 87853acd3b1SBarry Smith } 87953acd3b1SBarry Smith 88053acd3b1SBarry Smith #undef __FUNCT__ 88153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsList" 88253acd3b1SBarry Smith /*@C 88353acd3b1SBarry Smith PetscOptionsList - Puts a list of option values that a single one may be selected from 88453acd3b1SBarry Smith 8853f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 88653acd3b1SBarry Smith 88753acd3b1SBarry Smith Input Parameters: 88853acd3b1SBarry Smith + opt - option name 88953acd3b1SBarry Smith . text - short string that describes the option 89053acd3b1SBarry Smith . man - manual page with additional information on option 89153acd3b1SBarry Smith . list - the possible choices 8923cc1e11dSBarry Smith . defaultv - the default (current) value 8933cc1e11dSBarry Smith - len - the length of the character array value 89453acd3b1SBarry Smith 89553acd3b1SBarry Smith Output Parameter: 89653acd3b1SBarry Smith + value - the value to return 89753acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 89853acd3b1SBarry Smith 89953acd3b1SBarry Smith Level: intermediate 90053acd3b1SBarry Smith 90153acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 90253acd3b1SBarry Smith 90353acd3b1SBarry Smith See PetscOptionsEList() for when the choices are given in a string array 90453acd3b1SBarry Smith 90553acd3b1SBarry Smith To get a listing of all currently specified options, 90688c29154SBarry Smith see PetscOptionsView() or PetscOptionsGetAll() 90753acd3b1SBarry Smith 90853acd3b1SBarry Smith Concepts: options database^list 90953acd3b1SBarry Smith 91053acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 911acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 91253acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 91353acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 914acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 915171400e9SBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum() 91653acd3b1SBarry Smith @*/ 917140e18c1SBarry Smith PetscErrorCode PetscOptionsList(const char opt[],const char ltext[],const char man[],PetscFunctionList list,const char defaultv[],char value[],size_t len,PetscBool *set) 91853acd3b1SBarry Smith { 91953acd3b1SBarry Smith PetscErrorCode ierr; 9203cc1e11dSBarry Smith PetscOptions amsopt; 92153acd3b1SBarry Smith 92253acd3b1SBarry Smith PetscFunctionBegin; 923b3506946SBarry Smith if (!PetscOptionsPublishCount) { 9243cc1e11dSBarry Smith ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr); 925*7781c08eSBarry Smith amsopt->data = (void*)strdup(defaultv ? defaultv : ""); 9263cc1e11dSBarry Smith amsopt->flist = list; 9273cc1e11dSBarry Smith } 92853acd3b1SBarry Smith ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr); 929*7781c08eSBarry Smith if (*set) { 930*7781c08eSBarry Smith PetscVoidFunction fptr; 931*7781c08eSBarry Smith ierr = PetscFunctionListFind(list,value,&fptr);CHKERRQ(ierr); 932*7781c08eSBarry Smith if (!fptr) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Unknown value %s for %s",value,opt); 933*7781c08eSBarry Smith } 93461b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 935140e18c1SBarry Smith ierr = PetscFunctionListPrintTypes(PetscOptionsObject.comm,stdout,PetscOptionsObject.prefix,opt,ltext,man,list,defaultv);CHKERRQ(ierr);CHKERRQ(ierr); 93653acd3b1SBarry Smith } 93753acd3b1SBarry Smith PetscFunctionReturn(0); 93853acd3b1SBarry Smith } 93953acd3b1SBarry Smith 94053acd3b1SBarry Smith #undef __FUNCT__ 94153acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsEList" 94253acd3b1SBarry Smith /*@C 94353acd3b1SBarry Smith PetscOptionsEList - Puts a list of option values that a single one may be selected from 94453acd3b1SBarry Smith 9453f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 94653acd3b1SBarry Smith 94753acd3b1SBarry Smith Input Parameters: 94853acd3b1SBarry Smith + opt - option name 94953acd3b1SBarry Smith . ltext - short string that describes the option 95053acd3b1SBarry Smith . man - manual page with additional information on option 95153acd3b1SBarry Smith . list - the possible choices 95253acd3b1SBarry Smith . ntext - number of choices 95353acd3b1SBarry Smith - defaultv - the default (current) value 95453acd3b1SBarry Smith 95553acd3b1SBarry Smith Output Parameter: 95653acd3b1SBarry Smith + value - the index of the value to return 95753acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 95853acd3b1SBarry Smith 95953acd3b1SBarry Smith Level: intermediate 96053acd3b1SBarry Smith 96153acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 96253acd3b1SBarry Smith 963140e18c1SBarry Smith See PetscOptionsList() for when the choices are given in a PetscFunctionList() 96453acd3b1SBarry Smith 96553acd3b1SBarry Smith Concepts: options database^list 96653acd3b1SBarry Smith 96753acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 968acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 96953acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 97053acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 971acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 972171400e9SBarry Smith PetscOptionsList(), PetscOptionsEnum() 97353acd3b1SBarry Smith @*/ 9747087cfbeSBarry Smith PetscErrorCode PetscOptionsEList(const char opt[],const char ltext[],const char man[],const char *const *list,PetscInt ntext,const char defaultv[],PetscInt *value,PetscBool *set) 97553acd3b1SBarry Smith { 97653acd3b1SBarry Smith PetscErrorCode ierr; 97753acd3b1SBarry Smith PetscInt i; 9781ae3d29cSBarry Smith PetscOptions amsopt; 97953acd3b1SBarry Smith 98053acd3b1SBarry Smith PetscFunctionBegin; 9811ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 982d5649816SBarry Smith ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr); 983*7781c08eSBarry Smith amsopt->data = (void*)strdup(defaultv ? defaultv : ""); 9841ae3d29cSBarry Smith amsopt->list = list; 9851ae3d29cSBarry Smith amsopt->nlist = ntext; 9861ae3d29cSBarry Smith } 98753acd3b1SBarry Smith ierr = PetscOptionsGetEList(PetscOptionsObject.prefix,opt,list,ntext,value,set);CHKERRQ(ierr); 98861b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 98953acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s> (choose one of)",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,defaultv);CHKERRQ(ierr); 99053acd3b1SBarry Smith for (i=0; i<ntext; i++) { 99153acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s",list[i]);CHKERRQ(ierr); 99253acd3b1SBarry Smith } 9932aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," (%s)\n",ManSection(man));CHKERRQ(ierr); 99453acd3b1SBarry Smith } 99553acd3b1SBarry Smith PetscFunctionReturn(0); 99653acd3b1SBarry Smith } 99753acd3b1SBarry Smith 99853acd3b1SBarry Smith #undef __FUNCT__ 999acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroupBegin" 100053acd3b1SBarry Smith /*@C 1001acfcf0e5SJed Brown PetscOptionsBoolGroupBegin - First in a series of logical queries on the options database for 1002d5649816SBarry Smith which at most a single value can be true. 100353acd3b1SBarry Smith 10043f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 100553acd3b1SBarry Smith 100653acd3b1SBarry Smith Input Parameters: 100753acd3b1SBarry Smith + opt - option name 100853acd3b1SBarry Smith . text - short string that describes the option 100953acd3b1SBarry Smith - man - manual page with additional information on option 101053acd3b1SBarry Smith 101153acd3b1SBarry Smith Output Parameter: 101253acd3b1SBarry Smith . flg - whether that option was set or not 101353acd3b1SBarry Smith 101453acd3b1SBarry Smith Level: intermediate 101553acd3b1SBarry Smith 101653acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 101753acd3b1SBarry Smith 1018acfcf0e5SJed Brown Must be followed by 0 or more PetscOptionsBoolGroup()s and PetscOptionsBoolGroupEnd() 101953acd3b1SBarry Smith 102053acd3b1SBarry Smith Concepts: options database^logical group 102153acd3b1SBarry Smith 102253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1023acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 102453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 102553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1026acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 102753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 102853acd3b1SBarry Smith @*/ 10297087cfbeSBarry Smith PetscErrorCode PetscOptionsBoolGroupBegin(const char opt[],const char text[],const char man[],PetscBool *flg) 103053acd3b1SBarry Smith { 103153acd3b1SBarry Smith PetscErrorCode ierr; 10321ae3d29cSBarry Smith PetscOptions amsopt; 103353acd3b1SBarry Smith 103453acd3b1SBarry Smith PetscFunctionBegin; 10351ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 1036*7781c08eSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1037ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1038a297a907SKarl Rupp 1039ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 10401ae3d29cSBarry Smith } 104168b16fdaSBarry Smith *flg = PETSC_FALSE; 10420298fd71SBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,NULL);CHKERRQ(ierr); 104361b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 104453acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," Pick at most one of -------------\n");CHKERRQ(ierr); 10452aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 104653acd3b1SBarry Smith } 104753acd3b1SBarry Smith PetscFunctionReturn(0); 104853acd3b1SBarry Smith } 104953acd3b1SBarry Smith 105053acd3b1SBarry Smith #undef __FUNCT__ 1051acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroup" 105253acd3b1SBarry Smith /*@C 1053acfcf0e5SJed Brown PetscOptionsBoolGroup - One in a series of logical queries on the options database for 1054d5649816SBarry Smith which at most a single value can be true. 105553acd3b1SBarry Smith 10563f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 105753acd3b1SBarry Smith 105853acd3b1SBarry Smith Input Parameters: 105953acd3b1SBarry Smith + opt - option name 106053acd3b1SBarry Smith . text - short string that describes the option 106153acd3b1SBarry Smith - man - manual page with additional information on option 106253acd3b1SBarry Smith 106353acd3b1SBarry Smith Output Parameter: 106453acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 106553acd3b1SBarry Smith 106653acd3b1SBarry Smith Level: intermediate 106753acd3b1SBarry Smith 106853acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 106953acd3b1SBarry Smith 1070acfcf0e5SJed Brown Must follow a PetscOptionsBoolGroupBegin() and preceded a PetscOptionsBoolGroupEnd() 107153acd3b1SBarry Smith 107253acd3b1SBarry Smith Concepts: options database^logical group 107353acd3b1SBarry Smith 107453acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1075acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 107653acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 107753acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1078acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 107953acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 108053acd3b1SBarry Smith @*/ 10817087cfbeSBarry Smith PetscErrorCode PetscOptionsBoolGroup(const char opt[],const char text[],const char man[],PetscBool *flg) 108253acd3b1SBarry Smith { 108353acd3b1SBarry Smith PetscErrorCode ierr; 10841ae3d29cSBarry Smith PetscOptions amsopt; 108553acd3b1SBarry Smith 108653acd3b1SBarry Smith PetscFunctionBegin; 10871ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 1088*7781c08eSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1089ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1090a297a907SKarl Rupp 1091ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 10921ae3d29cSBarry Smith } 109317326d04SJed Brown *flg = PETSC_FALSE; 10940298fd71SBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,NULL);CHKERRQ(ierr); 109561b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 10962aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 109753acd3b1SBarry Smith } 109853acd3b1SBarry Smith PetscFunctionReturn(0); 109953acd3b1SBarry Smith } 110053acd3b1SBarry Smith 110153acd3b1SBarry Smith #undef __FUNCT__ 1102acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolGroupEnd" 110353acd3b1SBarry Smith /*@C 1104acfcf0e5SJed Brown PetscOptionsBoolGroupEnd - Last in a series of logical queries on the options database for 1105d5649816SBarry Smith which at most a single value can be true. 110653acd3b1SBarry Smith 11073f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 110853acd3b1SBarry Smith 110953acd3b1SBarry Smith Input Parameters: 111053acd3b1SBarry Smith + opt - option name 111153acd3b1SBarry Smith . text - short string that describes the option 111253acd3b1SBarry Smith - man - manual page with additional information on option 111353acd3b1SBarry Smith 111453acd3b1SBarry Smith Output Parameter: 111553acd3b1SBarry Smith . flg - PETSC_TRUE if found, else PETSC_FALSE 111653acd3b1SBarry Smith 111753acd3b1SBarry Smith Level: intermediate 111853acd3b1SBarry Smith 111953acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 112053acd3b1SBarry Smith 1121acfcf0e5SJed Brown Must follow a PetscOptionsBoolGroupBegin() 112253acd3b1SBarry Smith 112353acd3b1SBarry Smith Concepts: options database^logical group 112453acd3b1SBarry Smith 112553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1126acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 112753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 112853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1129acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 113053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 113153acd3b1SBarry Smith @*/ 11327087cfbeSBarry Smith PetscErrorCode PetscOptionsBoolGroupEnd(const char opt[],const char text[],const char man[],PetscBool *flg) 113353acd3b1SBarry Smith { 113453acd3b1SBarry Smith PetscErrorCode ierr; 11351ae3d29cSBarry Smith PetscOptions amsopt; 113653acd3b1SBarry Smith 113753acd3b1SBarry Smith PetscFunctionBegin; 11381ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 1139*7781c08eSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1140ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1141a297a907SKarl Rupp 1142ace3abfcSBarry Smith *(PetscBool*)amsopt->data = PETSC_FALSE; 11431ae3d29cSBarry Smith } 114417326d04SJed Brown *flg = PETSC_FALSE; 11450298fd71SBarry Smith ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,NULL);CHKERRQ(ierr); 114661b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 11472aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 114853acd3b1SBarry Smith } 114953acd3b1SBarry Smith PetscFunctionReturn(0); 115053acd3b1SBarry Smith } 115153acd3b1SBarry Smith 115253acd3b1SBarry Smith #undef __FUNCT__ 1153acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBool" 115453acd3b1SBarry Smith /*@C 1155acfcf0e5SJed Brown PetscOptionsBool - Determines if a particular option is in the database with a true or false 115653acd3b1SBarry Smith 11573f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 115853acd3b1SBarry Smith 115953acd3b1SBarry Smith Input Parameters: 116053acd3b1SBarry Smith + opt - option name 116153acd3b1SBarry Smith . text - short string that describes the option 116253acd3b1SBarry Smith - man - manual page with additional information on option 116353acd3b1SBarry Smith 116453acd3b1SBarry Smith Output Parameter: 116553acd3b1SBarry Smith . flg - PETSC_TRUE or PETSC_FALSE 116653acd3b1SBarry Smith . set - PETSC_TRUE if found, else PETSC_FALSE 116753acd3b1SBarry Smith 116853acd3b1SBarry Smith Level: beginner 116953acd3b1SBarry Smith 117053acd3b1SBarry Smith Concepts: options database^logical 117153acd3b1SBarry Smith 117253acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 117353acd3b1SBarry Smith 117453acd3b1SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 1175acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 1176acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 117753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 117853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1179acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 118053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 118153acd3b1SBarry Smith @*/ 11827087cfbeSBarry Smith PetscErrorCode PetscOptionsBool(const char opt[],const char text[],const char man[],PetscBool deflt,PetscBool *flg,PetscBool *set) 118353acd3b1SBarry Smith { 118453acd3b1SBarry Smith PetscErrorCode ierr; 1185ace3abfcSBarry Smith PetscBool iset; 1186aee2cecaSBarry Smith PetscOptions amsopt; 118753acd3b1SBarry Smith 118853acd3b1SBarry Smith PetscFunctionBegin; 1189b3506946SBarry Smith if (!PetscOptionsPublishCount) { 1190*7781c08eSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_BOOL,&amsopt);CHKERRQ(ierr); 1191ace3abfcSBarry Smith ierr = PetscMalloc(sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1192a297a907SKarl Rupp 1193ace3abfcSBarry Smith *(PetscBool*)amsopt->data = deflt; 1194af6d86caSBarry Smith } 1195acfcf0e5SJed Brown ierr = PetscOptionsGetBool(PetscOptionsObject.prefix,opt,flg,&iset);CHKERRQ(ierr); 119653acd3b1SBarry Smith if (!iset) { 119753acd3b1SBarry Smith if (flg) *flg = deflt; 119853acd3b1SBarry Smith } 119953acd3b1SBarry Smith if (set) *set = iset; 120061b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1201ace3abfcSBarry Smith const char *v = PetscBools[deflt]; 12022aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s: <%s> %s (%s)\n",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,v,text,ManSection(man));CHKERRQ(ierr); 120353acd3b1SBarry Smith } 120453acd3b1SBarry Smith PetscFunctionReturn(0); 120553acd3b1SBarry Smith } 120653acd3b1SBarry Smith 120753acd3b1SBarry Smith #undef __FUNCT__ 120853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsRealArray" 120953acd3b1SBarry Smith /*@C 121053acd3b1SBarry Smith PetscOptionsRealArray - Gets an array of double values for a particular 121153acd3b1SBarry Smith option in the database. The values must be separated with commas with 121253acd3b1SBarry Smith no intervening spaces. 121353acd3b1SBarry Smith 12143f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 121553acd3b1SBarry Smith 121653acd3b1SBarry Smith Input Parameters: 121753acd3b1SBarry Smith + opt - the option one is seeking 121853acd3b1SBarry Smith . text - short string describing option 121953acd3b1SBarry Smith . man - manual page for option 122053acd3b1SBarry Smith - nmax - maximum number of values 122153acd3b1SBarry Smith 122253acd3b1SBarry Smith Output Parameter: 122353acd3b1SBarry Smith + value - location to copy values 122453acd3b1SBarry Smith . nmax - actual number of values found 122553acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 122653acd3b1SBarry Smith 122753acd3b1SBarry Smith Level: beginner 122853acd3b1SBarry Smith 122953acd3b1SBarry Smith Notes: 123053acd3b1SBarry Smith The user should pass in an array of doubles 123153acd3b1SBarry Smith 123253acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 123353acd3b1SBarry Smith 123453acd3b1SBarry Smith Concepts: options database^array of strings 123553acd3b1SBarry Smith 123653acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1237acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 123853acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 123953acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1240acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 124153acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 124253acd3b1SBarry Smith @*/ 12437087cfbeSBarry Smith PetscErrorCode PetscOptionsRealArray(const char opt[],const char text[],const char man[],PetscReal value[],PetscInt *n,PetscBool *set) 124453acd3b1SBarry Smith { 124553acd3b1SBarry Smith PetscErrorCode ierr; 124653acd3b1SBarry Smith PetscInt i; 1247e26ddf31SBarry Smith PetscOptions amsopt; 124853acd3b1SBarry Smith 124953acd3b1SBarry Smith PetscFunctionBegin; 1250b3506946SBarry Smith if (!PetscOptionsPublishCount) { 1251e26ddf31SBarry Smith PetscReal *vals; 1252e26ddf31SBarry Smith 1253e26ddf31SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_REAL_ARRAY,&amsopt);CHKERRQ(ierr); 1254e26ddf31SBarry Smith ierr = PetscMalloc((*n)*sizeof(PetscReal),&amsopt->data);CHKERRQ(ierr); 1255e26ddf31SBarry Smith vals = (PetscReal*)amsopt->data; 1256e26ddf31SBarry Smith for (i=0; i<*n; i++) vals[i] = value[i]; 1257e26ddf31SBarry Smith amsopt->arraylength = *n; 1258e26ddf31SBarry Smith } 125953acd3b1SBarry Smith ierr = PetscOptionsGetRealArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 126061b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1261a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%G",PetscOptionsObject.prefix?PetscOptionsObject.prefix:"",opt+1,value[0]);CHKERRQ(ierr); 126253acd3b1SBarry Smith for (i=1; i<*n; i++) { 1263a83599f4SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%G",value[i]);CHKERRQ(ierr); 126453acd3b1SBarry Smith } 12652aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 126653acd3b1SBarry Smith } 126753acd3b1SBarry Smith PetscFunctionReturn(0); 126853acd3b1SBarry Smith } 126953acd3b1SBarry Smith 127053acd3b1SBarry Smith 127153acd3b1SBarry Smith #undef __FUNCT__ 127253acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsIntArray" 127353acd3b1SBarry Smith /*@C 127453acd3b1SBarry Smith PetscOptionsIntArray - Gets an array of integers for a particular 1275b32a342fSShri Abhyankar option in the database. 127653acd3b1SBarry Smith 12773f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 127853acd3b1SBarry Smith 127953acd3b1SBarry Smith Input Parameters: 128053acd3b1SBarry Smith + opt - the option one is seeking 128153acd3b1SBarry Smith . text - short string describing option 128253acd3b1SBarry Smith . man - manual page for option 1283f8a50e2bSBarry Smith - n - maximum number of values 128453acd3b1SBarry Smith 128553acd3b1SBarry Smith Output Parameter: 128653acd3b1SBarry Smith + value - location to copy values 1287f8a50e2bSBarry Smith . n - actual number of values found 128853acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 128953acd3b1SBarry Smith 129053acd3b1SBarry Smith Level: beginner 129153acd3b1SBarry Smith 129253acd3b1SBarry Smith Notes: 1293b32a342fSShri Abhyankar The array can be passed as 1294b32a342fSShri Abhyankar a comma seperated list: 0,1,2,3,4,5,6,7 12950fd488f5SShri Abhyankar a range (start-end+1): 0-8 12960fd488f5SShri Abhyankar a range with given increment (start-end+1:inc): 0-7:2 12970fd488f5SShri Abhyankar a combination of values and ranges seperated by commas: 0,1-8,8-15:2 1298b32a342fSShri Abhyankar 1299b32a342fSShri Abhyankar There must be no intervening spaces between the values. 130053acd3b1SBarry Smith 130153acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 130253acd3b1SBarry Smith 1303b32a342fSShri Abhyankar Concepts: options database^array of ints 130453acd3b1SBarry Smith 130553acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1306acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 130753acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 130853acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1309acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 131053acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsRealArray() 131153acd3b1SBarry Smith @*/ 13127087cfbeSBarry Smith PetscErrorCode PetscOptionsIntArray(const char opt[],const char text[],const char man[],PetscInt value[],PetscInt *n,PetscBool *set) 131353acd3b1SBarry Smith { 131453acd3b1SBarry Smith PetscErrorCode ierr; 131553acd3b1SBarry Smith PetscInt i; 1316e26ddf31SBarry Smith PetscOptions amsopt; 131753acd3b1SBarry Smith 131853acd3b1SBarry Smith PetscFunctionBegin; 1319b3506946SBarry Smith if (!PetscOptionsPublishCount) { 1320e26ddf31SBarry Smith PetscInt *vals; 1321e26ddf31SBarry Smith 1322e26ddf31SBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_INT_ARRAY,&amsopt);CHKERRQ(ierr); 1323e26ddf31SBarry Smith ierr = PetscMalloc((*n)*sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr); 1324e26ddf31SBarry Smith vals = (PetscInt*)amsopt->data; 1325e26ddf31SBarry Smith for (i=0; i<*n; i++) vals[i] = value[i]; 1326e26ddf31SBarry Smith amsopt->arraylength = *n; 1327e26ddf31SBarry Smith } 132853acd3b1SBarry Smith ierr = PetscOptionsGetIntArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 132961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 133053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,value[0]);CHKERRQ(ierr); 133153acd3b1SBarry Smith for (i=1; i<*n; i++) { 133253acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 133353acd3b1SBarry Smith } 13342aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 133553acd3b1SBarry Smith } 133653acd3b1SBarry Smith PetscFunctionReturn(0); 133753acd3b1SBarry Smith } 133853acd3b1SBarry Smith 133953acd3b1SBarry Smith #undef __FUNCT__ 134053acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsStringArray" 134153acd3b1SBarry Smith /*@C 134253acd3b1SBarry Smith PetscOptionsStringArray - Gets an array of string values for a particular 134353acd3b1SBarry Smith option in the database. The values must be separated with commas with 134453acd3b1SBarry Smith no intervening spaces. 134553acd3b1SBarry Smith 13463f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 134753acd3b1SBarry Smith 134853acd3b1SBarry Smith Input Parameters: 134953acd3b1SBarry Smith + opt - the option one is seeking 135053acd3b1SBarry Smith . text - short string describing option 135153acd3b1SBarry Smith . man - manual page for option 135253acd3b1SBarry Smith - nmax - maximum number of strings 135353acd3b1SBarry Smith 135453acd3b1SBarry Smith Output Parameter: 135553acd3b1SBarry Smith + value - location to copy strings 135653acd3b1SBarry Smith . nmax - actual number of strings found 135753acd3b1SBarry Smith - set - PETSC_TRUE if found, else PETSC_FALSE 135853acd3b1SBarry Smith 135953acd3b1SBarry Smith Level: beginner 136053acd3b1SBarry Smith 136153acd3b1SBarry Smith Notes: 136253acd3b1SBarry Smith The user should pass in an array of pointers to char, to hold all the 136353acd3b1SBarry Smith strings returned by this function. 136453acd3b1SBarry Smith 136553acd3b1SBarry Smith The user is responsible for deallocating the strings that are 136653acd3b1SBarry Smith returned. The Fortran interface for this routine is not supported. 136753acd3b1SBarry Smith 136853acd3b1SBarry Smith Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 136953acd3b1SBarry Smith 137053acd3b1SBarry Smith Concepts: options database^array of strings 137153acd3b1SBarry Smith 137253acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1373acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 137453acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 137553acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1376acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 137753acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 137853acd3b1SBarry Smith @*/ 13797087cfbeSBarry Smith PetscErrorCode PetscOptionsStringArray(const char opt[],const char text[],const char man[],char *value[],PetscInt *nmax,PetscBool *set) 138053acd3b1SBarry Smith { 138153acd3b1SBarry Smith PetscErrorCode ierr; 13821ae3d29cSBarry Smith PetscOptions amsopt; 138353acd3b1SBarry Smith 138453acd3b1SBarry Smith PetscFunctionBegin; 13851ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 13861ae3d29cSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING_ARRAY,&amsopt);CHKERRQ(ierr); 13871ae3d29cSBarry Smith ierr = PetscMalloc((*nmax)*sizeof(char*),&amsopt->data);CHKERRQ(ierr); 1388a297a907SKarl Rupp 13891ae3d29cSBarry Smith amsopt->arraylength = *nmax; 13901ae3d29cSBarry Smith } 139153acd3b1SBarry Smith ierr = PetscOptionsGetStringArray(PetscOptionsObject.prefix,opt,value,nmax,set);CHKERRQ(ierr); 139261b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 13932aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <string1,string2,...>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,text,ManSection(man));CHKERRQ(ierr); 139453acd3b1SBarry Smith } 139553acd3b1SBarry Smith PetscFunctionReturn(0); 139653acd3b1SBarry Smith } 139753acd3b1SBarry Smith 1398e2446a98SMatthew Knepley #undef __FUNCT__ 1399acfcf0e5SJed Brown #define __FUNCT__ "PetscOptionsBoolArray" 1400e2446a98SMatthew Knepley /*@C 1401acfcf0e5SJed Brown PetscOptionsBoolArray - Gets an array of logical values (true or false) for a particular 1402e2446a98SMatthew Knepley option in the database. The values must be separated with commas with 1403e2446a98SMatthew Knepley no intervening spaces. 1404e2446a98SMatthew Knepley 14053f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 1406e2446a98SMatthew Knepley 1407e2446a98SMatthew Knepley Input Parameters: 1408e2446a98SMatthew Knepley + opt - the option one is seeking 1409e2446a98SMatthew Knepley . text - short string describing option 1410e2446a98SMatthew Knepley . man - manual page for option 1411e2446a98SMatthew Knepley - nmax - maximum number of values 1412e2446a98SMatthew Knepley 1413e2446a98SMatthew Knepley Output Parameter: 1414e2446a98SMatthew Knepley + value - location to copy values 1415e2446a98SMatthew Knepley . nmax - actual number of values found 1416e2446a98SMatthew Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 1417e2446a98SMatthew Knepley 1418e2446a98SMatthew Knepley Level: beginner 1419e2446a98SMatthew Knepley 1420e2446a98SMatthew Knepley Notes: 1421e2446a98SMatthew Knepley The user should pass in an array of doubles 1422e2446a98SMatthew Knepley 1423e2446a98SMatthew Knepley Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 1424e2446a98SMatthew Knepley 1425e2446a98SMatthew Knepley Concepts: options database^array of strings 1426e2446a98SMatthew Knepley 1427e2446a98SMatthew Knepley .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1428acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 1429e2446a98SMatthew Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 1430e2446a98SMatthew Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1431acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1432e2446a98SMatthew Knepley PetscOptionsList(), PetscOptionsEList() 1433e2446a98SMatthew Knepley @*/ 14347087cfbeSBarry Smith PetscErrorCode PetscOptionsBoolArray(const char opt[],const char text[],const char man[],PetscBool value[],PetscInt *n,PetscBool *set) 1435e2446a98SMatthew Knepley { 1436e2446a98SMatthew Knepley PetscErrorCode ierr; 1437e2446a98SMatthew Knepley PetscInt i; 14381ae3d29cSBarry Smith PetscOptions amsopt; 1439e2446a98SMatthew Knepley 1440e2446a98SMatthew Knepley PetscFunctionBegin; 14411ae3d29cSBarry Smith if (!PetscOptionsPublishCount) { 1442ace3abfcSBarry Smith PetscBool *vals; 14431ae3d29cSBarry Smith 1444*7781c08eSBarry Smith ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_BOOL_ARRAY,&amsopt);CHKERRQ(ierr); 1445ace3abfcSBarry Smith ierr = PetscMalloc((*n)*sizeof(PetscBool),&amsopt->data);CHKERRQ(ierr); 1446ace3abfcSBarry Smith vals = (PetscBool*)amsopt->data; 14471ae3d29cSBarry Smith for (i=0; i<*n; i++) vals[i] = value[i]; 14481ae3d29cSBarry Smith amsopt->arraylength = *n; 14491ae3d29cSBarry Smith } 1450acfcf0e5SJed Brown ierr = PetscOptionsGetBoolArray(PetscOptionsObject.prefix,opt,value,n,set);CHKERRQ(ierr); 1451e2446a98SMatthew Knepley if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 1452e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%d",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,value[0]);CHKERRQ(ierr); 1453e2446a98SMatthew Knepley for (i=1; i<*n; i++) { 1454e2446a98SMatthew Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,",%d",value[i]);CHKERRQ(ierr); 1455e2446a98SMatthew Knepley } 14562aa6d131SJed Brown ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm,">: %s (%s)\n",text,ManSection(man));CHKERRQ(ierr); 1457e2446a98SMatthew Knepley } 1458e2446a98SMatthew Knepley PetscFunctionReturn(0); 1459e2446a98SMatthew Knepley } 1460e2446a98SMatthew Knepley 14618cc676e6SMatthew G Knepley #undef __FUNCT__ 14628cc676e6SMatthew G Knepley #define __FUNCT__ "PetscOptionsViewer" 14638cc676e6SMatthew G Knepley /*@C 14648cc676e6SMatthew G Knepley PetscOptionsInt - Gets a viewer appropriate for the type indicated by the user 14658cc676e6SMatthew G Knepley 14668cc676e6SMatthew G Knepley Logically Collective on the communicator passed in PetscOptionsBegin() 14678cc676e6SMatthew G Knepley 14688cc676e6SMatthew G Knepley Input Parameters: 14698cc676e6SMatthew G Knepley + opt - option name 14708cc676e6SMatthew G Knepley . text - short string that describes the option 14718cc676e6SMatthew G Knepley - man - manual page with additional information on option 14728cc676e6SMatthew G Knepley 14738cc676e6SMatthew G Knepley Output Parameter: 14748cc676e6SMatthew G Knepley + viewer - the viewer 14758cc676e6SMatthew G Knepley - set - PETSC_TRUE if found, else PETSC_FALSE 14768cc676e6SMatthew G Knepley 14778cc676e6SMatthew G Knepley Level: beginner 14788cc676e6SMatthew G Knepley 14798cc676e6SMatthew G Knepley Concepts: options database^has int 14808cc676e6SMatthew G Knepley 14818cc676e6SMatthew G Knepley Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 14828cc676e6SMatthew G Knepley If no value is provided ascii:stdout is used 14838cc676e6SMatthew G Knepley $ ascii[:[filename][:format]] defaults to stdout - format can be one of info, info_detailed, or matlab, for example ascii::info prints just the info 14848cc676e6SMatthew G Knepley $ about the object to standard out 14858cc676e6SMatthew G Knepley $ binary[:filename] defaults to binaryoutput 14868cc676e6SMatthew G Knepley $ draw 14878cc676e6SMatthew G Knepley $ socket[:port] defaults to the standard output port 14888cc676e6SMatthew G Knepley 1489cffb1e40SBarry Smith Use PetscRestoreViewerDestroy() after using the viewer, otherwise a memory leak will occur 14908cc676e6SMatthew G Knepley 14918cc676e6SMatthew G Knepley .seealso: PetscOptionsGetViewer(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 14928cc676e6SMatthew G Knepley PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 14938cc676e6SMatthew G Knepley PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 14948cc676e6SMatthew G Knepley PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 14958cc676e6SMatthew G Knepley PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 14968cc676e6SMatthew G Knepley PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 14978cc676e6SMatthew G Knepley PetscOptionsList(), PetscOptionsEList() 14988cc676e6SMatthew G Knepley @*/ 1499cffb1e40SBarry Smith PetscErrorCode PetscOptionsViewer(const char opt[],const char text[],const char man[],PetscViewer *viewer,PetscViewerFormat *format,PetscBool *set) 15008cc676e6SMatthew G Knepley { 15018cc676e6SMatthew G Knepley PetscErrorCode ierr; 15028cc676e6SMatthew G Knepley PetscOptions amsopt; 15038cc676e6SMatthew G Knepley 15048cc676e6SMatthew G Knepley PetscFunctionBegin; 15058cc676e6SMatthew G Knepley if (!PetscOptionsPublishCount) { 15068cc676e6SMatthew G Knepley ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr); 1507*7781c08eSBarry Smith amsopt->data = (void*)strdup(""); 15088cc676e6SMatthew G Knepley } 1509cffb1e40SBarry Smith ierr = PetscOptionsGetViewer(PetscOptionsObject.comm,PetscOptionsObject.prefix,opt,viewer,format,set);CHKERRQ(ierr); 15108cc676e6SMatthew G Knepley if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 15118cc676e6SMatthew G Knepley ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," -%s%s <%s>: %s (%s)\n",PetscOptionsObject.prefix ? PetscOptionsObject.prefix : "",opt+1,"",text,ManSection(man));CHKERRQ(ierr); 15128cc676e6SMatthew G Knepley } 15138cc676e6SMatthew G Knepley PetscFunctionReturn(0); 15148cc676e6SMatthew G Knepley } 15158cc676e6SMatthew G Knepley 151653acd3b1SBarry Smith 151753acd3b1SBarry Smith #undef __FUNCT__ 151853acd3b1SBarry Smith #define __FUNCT__ "PetscOptionsHead" 151953acd3b1SBarry Smith /*@C 1520b52f573bSBarry Smith PetscOptionsHead - Puts a heading before listing any more published options. Used, for example, 152153acd3b1SBarry Smith in KSPSetFromOptions_GMRES(). 152253acd3b1SBarry Smith 15233f9fe445SBarry Smith Logically Collective on the communicator passed in PetscOptionsBegin() 152453acd3b1SBarry Smith 152553acd3b1SBarry Smith Input Parameter: 152653acd3b1SBarry Smith . head - the heading text 152753acd3b1SBarry Smith 152853acd3b1SBarry Smith 152953acd3b1SBarry Smith Level: intermediate 153053acd3b1SBarry Smith 153153acd3b1SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 153253acd3b1SBarry Smith 1533b52f573bSBarry Smith Can be followed by a call to PetscOptionsTail() in the same function. 153453acd3b1SBarry Smith 153553acd3b1SBarry Smith Concepts: options database^subheading 153653acd3b1SBarry Smith 153753acd3b1SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 1538acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 153953acd3b1SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 154053acd3b1SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 1541acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 154253acd3b1SBarry Smith PetscOptionsList(), PetscOptionsEList() 154353acd3b1SBarry Smith @*/ 15447087cfbeSBarry Smith PetscErrorCode PetscOptionsHead(const char head[]) 154553acd3b1SBarry Smith { 154653acd3b1SBarry Smith PetscErrorCode ierr; 154753acd3b1SBarry Smith 154853acd3b1SBarry Smith PetscFunctionBegin; 154961b37b28SSatish Balay if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) { 155053acd3b1SBarry Smith ierr = (*PetscHelpPrintf)(PetscOptionsObject.comm," %s\n",head);CHKERRQ(ierr); 155153acd3b1SBarry Smith } 155253acd3b1SBarry Smith PetscFunctionReturn(0); 155353acd3b1SBarry Smith } 155453acd3b1SBarry Smith 155553acd3b1SBarry Smith 155653acd3b1SBarry Smith 155753acd3b1SBarry Smith 155853acd3b1SBarry Smith 155953acd3b1SBarry Smith 1560