/[ascend]/trunk/base/generic/solver/slv.c
ViewVC logotype

Diff of /trunk/base/generic/solver/slv.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 302 by johnpye, Fri Jan 27 14:55:43 2006 UTC revision 303 by johnpye, Tue Feb 21 02:38:13 2006 UTC
# Line 325  int slv_register_client(SlvRegistration Line 325  int slv_register_client(SlvRegistration
325      NORC++;      NORC++;
326    } else {    } else {
327      *new_client_id = -2;      *new_client_id = -2;
328      ERROR_REPORTER_NOLINE(ASC_PROG_ERR,"Client %d registration failure (%d)!\n",NORC,status);      ERROR_REPORTER_NOLINE(ASC_PROG_ERR,"Client %d registration failure (%d)!",NORC,status);
329    }    }
330    return status;    return status;
331  }  }
# Line 678  const mtx_block_t *slv_get_solvers_log_b Line 678  const mtx_block_t *slv_get_solvers_log_b
678  void slv_set_solvers_blocks(slv_system_t sys,int len, mtx_region_t *data)  void slv_set_solvers_blocks(slv_system_t sys,int len, mtx_region_t *data)
679  {  {
680    if (sys == NULL || len < 0) {    if (sys == NULL || len < 0) {
681      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_blocks called with NULL system or bad len.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_blocks called with NULL system or bad len.");
682    } else {    } else {
683      if (len && data==NULL) {      if (len && data==NULL) {
684        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_blocks called with bad data.\n");        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_blocks called with bad data.");
685      } else {      } else {
686        if (sys->dof.blocks.nblocks && sys->dof.blocks.block != NULL) {        if (sys->dof.blocks.nblocks && sys->dof.blocks.block != NULL) {
687          ascfree(sys->dof.blocks.block);          ascfree(sys->dof.blocks.block);
# Line 695  void slv_set_solvers_blocks(slv_system_t Line 695  void slv_set_solvers_blocks(slv_system_t
695  void slv_set_solvers_log_blocks(slv_system_t sys,int len, mtx_region_t *data)  void slv_set_solvers_log_blocks(slv_system_t sys,int len, mtx_region_t *data)
696  {  {
697    if (sys == NULL || len < 0) {    if (sys == NULL || len < 0) {
698      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_log_blocks called with NULL system or bad len\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_log_blocks called with NULL system or bad len.");
699    } else {    } else {
700      if (len && data==NULL) {      if (len && data==NULL) {
701        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_log_blocks called with bad data.\n");        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solvers_log_blocks called with bad data.");
702      } else {      } else {
703        if (sys->logdof.blocks.nblocks && sys->logdof.blocks.block != NULL) {        if (sys->logdof.blocks.nblocks && sys->logdof.blocks.block != NULL) {
704          ascfree(sys->logdof.blocks.block);          ascfree(sys->logdof.blocks.block);
# Line 752  void slv_bnd_initialization(slv_system_t Line 752  void slv_bnd_initialization(slv_system_t
752  struct gl_list_t *slv_get_symbol_list(slv_system_t sys)  struct gl_list_t *slv_get_symbol_list(slv_system_t sys)
753  {  {
754    if (sys==NULL) {    if (sys==NULL) {
755      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_symbol_list called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_symbol_list called with NULL system.");
756      return NULL;      return NULL;
757    }    }
758    return sys->symbollist;    return sys->symbollist;
# Line 816  DEFINE_GETSET_LIST_METHODS(DEFINE_GET_SO Line 816  DEFINE_GETSET_LIST_METHODS(DEFINE_GET_SO
816  #define DEFINE_GET_MASTER_LIST_METHOD(NAME,PROP,TYPE) \  #define DEFINE_GET_MASTER_LIST_METHOD(NAME,PROP,TYPE) \
817      struct TYPE **slv_get_master_##NAME##_list(slv_system_t sys){ \      struct TYPE **slv_get_master_##NAME##_list(slv_system_t sys){ \
818          if (sys->PROP.master == NULL) { \          if (sys->PROP.master == NULL) { \
819              ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_master_" #NAME "_list returning NULL?\n"); \              ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_master_" #NAME "_list returning NULL (?)."); \
820          } \          } \
821          return sys->PROP.master; \          return sys->PROP.master; \
822      }      }
# Line 869  DEFINE_SLV_METHODS(DEFINE_MASTER_GET_NUM Line 869  DEFINE_SLV_METHODS(DEFINE_MASTER_GET_NUM
869  void slv_set_obj_relation(slv_system_t sys,struct rel_relation *obj)  void slv_set_obj_relation(slv_system_t sys,struct rel_relation *obj)
870  {  {
871    if (sys==NULL) {    if (sys==NULL) {
872      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_obj_relation called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_obj_relation called with NULL system (?).");
873      return;      return;
874    }    }
875    sys->obj = obj;    sys->obj = obj;
# Line 878  void slv_set_obj_relation(slv_system_t s Line 878  void slv_set_obj_relation(slv_system_t s
878  struct rel_relation *slv_get_obj_relation(slv_system_t sys)  struct rel_relation *slv_get_obj_relation(slv_system_t sys)
879  {  {
880    if (sys==NULL) {    if (sys==NULL) {
881      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_obj_relation called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_obj_relation called with NULL system (?)");
882      return NULL;      return NULL;
883    }    }
884    return sys->obj;    return sys->obj;
# Line 888  void slv_set_obj_variable(slv_system_t s Line 888  void slv_set_obj_variable(slv_system_t s
888                            unsigned maximize)                            unsigned maximize)
889  {  {
890    if (sys==NULL) {    if (sys==NULL) {
891      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_obj_variable called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_obj_variable called with NULL system.");
892      return;      return;
893    }    }
894    sys->objvar = objvar;    sys->objvar = objvar;
# Line 906  void slv_set_obj_variable(slv_system_t s Line 906  void slv_set_obj_variable(slv_system_t s
906  struct var_variable *slv_get_obj_variable(slv_system_t sys)  struct var_variable *slv_get_obj_variable(slv_system_t sys)
907  {  {
908    if (sys==NULL) {    if (sys==NULL) {
909      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_obj_variable called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_obj_variable called with NULL system.");
910      return NULL;      return NULL;
911    }    }
912    return sys->objvar;    return sys->objvar;
# Line 915  struct var_variable *slv_get_obj_variabl Line 915  struct var_variable *slv_get_obj_variabl
915  real64 slv_get_obj_variable_gradient(slv_system_t sys)  real64 slv_get_obj_variable_gradient(slv_system_t sys)
916  {  {
917    if (sys==NULL) {    if (sys==NULL) {
918      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_obj_variable_gradient called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_obj_variable_gradient called with NULL system.");
919      return 0.0;      return 0.0;
920    }    }
921    return sys->objvargrad;    return sys->objvargrad;
# Line 925  real64 slv_get_obj_variable_gradient(slv Line 925  real64 slv_get_obj_variable_gradient(slv
925  void slv_set_need_consistency(slv_system_t sys, int32 need_consistency)  void slv_set_need_consistency(slv_system_t sys, int32 need_consistency)
926  {  {
927    if (sys==NULL) {    if (sys==NULL) {
928      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_need_consistency called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_need_consistency called with NULL system.");
929      return;      return;
930    }    }
931    
# Line 936  void slv_set_need_consistency(slv_system Line 936  void slv_set_need_consistency(slv_system
936  int32 slv_need_consistency(slv_system_t sys)  int32 slv_need_consistency(slv_system_t sys)
937  {  {
938    if (sys==NULL) {    if (sys==NULL) {
939      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_need_consistency called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_need_consistency called with NULL system.");
940      return 0;      return 0;
941    }    }
942    return sys->need_consistency;    return sys->need_consistency;
# Line 1033  static void printinfo(slv_system_t sys, Line 1033  static void printinfo(slv_system_t sys,
1033  {  {
1034    if (CF(sys,name) == NULL ) {    if (CF(sys,name) == NULL ) {
1035      ERROR_REPORTER_NOLINE(ASC_PROG_NOTE,      ERROR_REPORTER_NOLINE(ASC_PROG_NOTE,
1036        "Client %s does not support function %s\n",        "Client %s does not support function '%s'.",
1037        slv_solver_name(sys->solver),rname);        slv_solver_name(sys->solver),rname);
1038    }    }
1039  }  }
# Line 1053  int slv_select_solver(slv_system_t sys,i Line 1053  int slv_select_solver(slv_system_t sys,i
1053    SlvClientDestroyF *destroy;    SlvClientDestroyF *destroy;
1054    
1055    if (sys ==NULL) {    if (sys ==NULL) {
1056      ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_select_solver called with NULL system\n");      ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_select_solver called with NULL system.");
1057      return -1;      return -1;
1058    }    }
1059    if ( solver >= 0 && solver < NORC ) {    if ( solver >= 0 && solver < NORC ) {
# Line 1077  int slv_select_solver(slv_system_t sys,i Line 1077  int slv_select_solver(slv_system_t sys,i
1077      if ( CF(sys,ccreate) != NULL) {      if ( CF(sys,ccreate) != NULL) {
1078        sys->ct = SF(sys,ccreate)(sys,&status_index);        sys->ct = SF(sys,ccreate)(sys,&status_index);
1079      } else {      } else {
1080        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_select_solver create failed due to bad client %s\n",        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_select_solver create failed due to bad client '%s'.",
1081          slv_solver_name(sys->solver));          slv_solver_name(sys->solver));
1082        return sys->solver;        return sys->solver;
1083      }      }
1084      if (sys->ct==NULL) {      if (sys->ct==NULL) {
1085        ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"SlvClientCreate failed in slv_select_solver\n");        ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"SlvClientCreate failed in slv_select_solver.");
1086        sys->solver = -1;        sys->solver = -1;
1087      } else {      } else {
1088        if (status_index) {        if (status_index) {
1089          ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"SlvClientCreate succeeded with warning %d %s\n",          ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"SlvClientCreate succeeded with warning %d %s.",
1090            status_index," in slv_select_solver");            status_index," in slv_select_solver");
1091        }        }
1092        /* we could do a better job explaining the client warnings... */        /* we could do a better job explaining the client warnings... */
# Line 1106  int slv_switch_solver(slv_system_t sys,i Line 1106  int slv_switch_solver(slv_system_t sys,i
1106    int status_index;    int status_index;
1107    
1108    if (sys ==NULL) {    if (sys ==NULL) {
1109      ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_switch_solver called with NULL system\n");      ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_switch_solver called with NULL system.");
1110      return -1;      return -1;
1111    }    }
1112    if( solver >= 0 && solver < g_SlvNumberOfRegisteredClients ){    if( solver >= 0 && solver < g_SlvNumberOfRegisteredClients ){
# Line 1115  int slv_switch_solver(slv_system_t sys,i Line 1115  int slv_switch_solver(slv_system_t sys,i
1115      if ( CF(sys,ccreate) != NULL) {      if ( CF(sys,ccreate) != NULL) {
1116        sys->ct = SF(sys,ccreate)(sys,&status_index);        sys->ct = SF(sys,ccreate)(sys,&status_index);
1117      } else {      } else {
1118        ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_switch_solver create failed due to bad client %s\n",        ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_switch_solver create failed due to bad client '%s'.",
1119           slv_solver_name(sys->solver));           slv_solver_name(sys->solver));
1120        return sys->solver;        return sys->solver;
1121      }      }
1122      if (sys->ct==NULL) {      if (sys->ct==NULL) {
1123        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"SlvClientCreate failed in slv_switch_solver\n");        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"SlvClientCreate failed in slv_switch_solver.");
1124        sys->solver = -1;        sys->solver = -1;
1125      } else {      } else {
1126        if (status_index) {        if (status_index) {
1127          ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"SlvClientCreate succeeded with warning %d %s\n",          ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"SlvClientCreate succeeded with warning %d %s.",
1128             status_index," in slv_switch_solver");             status_index," in slv_switch_solver");
1129        }        }
1130        sys->solver = solver;        sys->solver = solver;
1131      }      }
1132    } else {    } else {
1133      ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_switch_solver called with unknown client (%d)\n",solver);      ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"slv_switch_solver called with unknown client '%d'.",solver);
1134      return -1;      return -1;
1135    }    }
1136    return sys->solver;    return sys->solver;
# Line 1165  void slv_destroy_parms(slv_parameters_t Line 1165  void slv_destroy_parms(slv_parameters_t
1165        ascfree(p->parms[i].description);        ascfree(p->parms[i].description);
1166        break;        break;
1167      default:      default:
1168        ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"Unrecognized parameter type in slv_destroy_parms\n");        ERROR_REPORTER_NOLINE(ASC_PROG_WARNING,"Unrecognized parameter type in slv_destroy_parms.");
1169      }      }
1170    }    }
1171    if (p->parms && p->dynamic_parms) {    if (p->parms && p->dynamic_parms) {
# Line 1266  int32 slv_get_default_parameters(int ind Line 1266  int32 slv_get_default_parameters(int ind
1266  {  {
1267    if (index >= 0 && index < NORC) {    if (index >= 0 && index < NORC) {
1268      if ( SlvClientsData[index].getdefparam == NULL ) {      if ( SlvClientsData[index].getdefparam == NULL ) {
1269        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_default_parameters called with parameterless index\n");        ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_default_parameters called with parameterless index.");
1270        return 0;        return 0;
1271      } else {      } else {
1272        /* send NULL system when setting up interface */        /* send NULL system when setting up interface */
# Line 1274  int32 slv_get_default_parameters(int ind Line 1274  int32 slv_get_default_parameters(int ind
1274        return 1;        return 1;
1275      }      }
1276    } else {    } else {
1277      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_default_parameters called with unregistered index\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_get_default_parameters called with unregistered index.");
1278      return 0;      return 0;
1279    }    }
1280  }  }
# Line 1350  DEFINE_SLV_PROXY_METHOD_VOID(solve); Line 1350  DEFINE_SLV_PROXY_METHOD_VOID(solve);
1350  SlvClientToken slv_get_client_token(slv_system_t sys)  SlvClientToken slv_get_client_token(slv_system_t sys)
1351  {  {
1352    if (sys==NULL) {    if (sys==NULL) {
1353      FPRINTF(stderr,"slv_get_client_token called with NULL system.\n");      FPRINTF(stderr,"slv_get_client_token called with NULL system.");
1354      return NULL;      return NULL;
1355    }    }
1356    return sys->ct;    return sys->ct;
# Line 1360  SlvClientToken slv_get_client_token(slv_ Line 1360  SlvClientToken slv_get_client_token(slv_
1360  void slv_set_client_token(slv_system_t sys, SlvClientToken ct)  void slv_set_client_token(slv_system_t sys, SlvClientToken ct)
1361  {  {
1362    if (sys==NULL) {    if (sys==NULL) {
1363      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_client_token called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_client_token called with NULL system.");
1364      return;      return;
1365    }    }
1366    sys->ct = ct;    sys->ct = ct;
# Line 1369  void slv_set_client_token(slv_system_t s Line 1369  void slv_set_client_token(slv_system_t s
1369  void slv_set_solver_index(slv_system_t sys, int solver)  void slv_set_solver_index(slv_system_t sys, int solver)
1370  {  {
1371    if (sys==NULL) {    if (sys==NULL) {
1372      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solver_index called with NULL system.\n");      ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"slv_set_solver_index called with NULL system.");
1373      return;      return;
1374    }    }
1375    sys->solver = solver;    sys->solver = solver;

Legend:
Removed from v.302  
changed lines
  Added in v.303

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22