Ice Sheet System Model  4.18
Code documentation
Data Structures | Macros | Functions
Parameters.h File Reference
#include <stdio.h>
#include "../../shared/shared.h"

Go to the source code of this file.

Data Structures

class  Parameters
 Declaration of Parameters class.
More...
 

Macros

#define NUMPARAMS   ParametersENDEnum - ParametersSTARTEnum -1
 

Functions

char * OptionsFromAnalysis (char **ptoolkit, Parameters *parameters, int analysis_type)
 
void ToolkitsOptionsFromAnalysis (Parameters *parameters, int analysis_type)
 

Macro Definition Documentation

◆ NUMPARAMS

#define NUMPARAMS   ParametersENDEnum - ParametersSTARTEnum -1

Definition at line 12 of file Parameters.h.

Function Documentation

◆ OptionsFromAnalysis()

char* OptionsFromAnalysis ( char **  ptoolkit,
Parameters parameters,
int  analysis_type 
)

Definition at line 595 of file Parameters.cpp.

595  { /*{{{*/
596 
597  /* figure out ISSM options for current analysis, return a string. */
598 
599  /*output: */
600  char *outstring = NULL;
601  char *outtoolkit = NULL;
602 
603  /*intermediary: */
604  int dummy;
605  int *analyses = NULL;
606  char **strings = NULL;
607  char *string = NULL;
608  char **toolkits = NULL;
609  char *toolkit = NULL;
610  int numanalyses;
611  int found = -1;
612  int i;
613 
614  parameters->FindParam(&strings,&numanalyses,ToolkitsOptionsStringsEnum);
615  parameters->FindParam(&toolkits,&dummy,ToolkitsTypesEnum); _assert_(dummy==numanalyses);
616  parameters->FindParam(&analyses,&dummy,ToolkitsOptionsAnalysesEnum); _assert_(dummy==numanalyses);
617 
618  if(numanalyses==0)return NULL; //we did not find petsc options, don't bother.
619 
620  /*ok, go through analyses and figure out if it corresponds to our analysis_type: */
621  for(i=0;i<numanalyses;i++){
622  if(analyses[i]==analysis_type){
623  found=i;
624  break;
625  }
626  }
627  if(found==-1){
628  /*still haven't found a list of petsc options, go find the default one, for analysis type DefaultAnalysisEnum: */
629  for(i=0;i<numanalyses;i++){
630  if(analyses[i]==DefaultAnalysisEnum){
631  found=i;
632  break;
633  }
634  }
635  }
636  if(found==-1){
637  _error_("could find neither a default analysis nor analysis " << EnumToStringx(analysis_type));
638  }
639 
640  /*1. Grab the option toolkit: */
641  outtoolkit=xNew<char>(strlen(toolkits[found])+1);
642  strcpy(outtoolkit,toolkits[found]);
643  *pouttoolkit = outtoolkit;
644 
645  /*2. Grab the option string: */
646  outstring=xNew<char>(strlen(strings[found])+1);
647  strcpy(outstring,strings[found]);
648 
649  /*Free ressources*/
650  for(i=0;i<numanalyses;i++){
651  xDelete<char>(toolkits[i]);
652  xDelete<char>(strings[i]);
653  }
654  xDelete<char*>(toolkits);
655  xDelete<char*>(strings);
656  xDelete<int>(analyses);
657  return outstring;
658 }

◆ ToolkitsOptionsFromAnalysis()

void ToolkitsOptionsFromAnalysis ( Parameters parameters,
int  analysis_type 
)
ToolkitsTypesEnum
@ ToolkitsTypesEnum
Definition: EnumDefinitions.h:441
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
DefaultAnalysisEnum
@ DefaultAnalysisEnum
Definition: EnumDefinitions.h:1032
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
ToolkitsOptionsAnalysesEnum
@ ToolkitsOptionsAnalysesEnum
Definition: EnumDefinitions.h:439
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
Parameters::FindParam
void FindParam(bool *pinteger, int enum_type)
Definition: Parameters.cpp:262
ToolkitsOptionsStringsEnum
@ ToolkitsOptionsStringsEnum
Definition: EnumDefinitions.h:440