<commit_before>
#include "FAST_Library.h"
#include "stdio.h"
#include <string.h>
#include <math.h>
#include <stdlib.h> 
#include <malloc.h>

int checkError(const int ErrStat, const char * ErrMsg);
void setOutputsToFAST(OpFM_InputType_t* OpFM_Input_from_FAST, OpFM_OutputType_t* OpFM_Output_to_FAST);


int 
main(int argc, char *argv[], char *env[])
{
   double dt;
   double TMax;
   float TurbinePos[3];
   int TurbID;
   int ErrStat = 0;
   char ErrMsg[INTERFACE_STRING_LENGTH];        // make sure this is the same size as IntfStrLen in FAST_Library.f90
   char InputFileName[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90
   char CheckpointFileRoot[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90

   OpFM_InputType_t* OpFM_Input_from_FAST = NULL;
   OpFM_OutputType_t* OpFM_Output_to_FAST = NULL;
   
   int n_t_global = -2;
   int i = 0;
   int j = 0;
   int k = 0;
   int n_t_global_start = 0;
   int NumBlades = 0;
   int NumElementsPerBlade = 0;
   int n_checkpoint = 10;
   int NumScOutputs = 0; // 5;  // # outputs from the supercontroller == # inputs to the controller
   int NumScInputs = 0; // 2;   // # inputs to the supercontroller == # outputs from the controller

   OpFM_Input_from_FAST = malloc(sizeof(OpFM_InputType_t));
   OpFM_Output_to_FAST = malloc(sizeof(OpFM_OutputType_t));
   if (OpFM_Input_from_FAST == NULL || OpFM_Output_to_FAST == NULL) {
      fprintf(stderr, "Error allocating space for OpFM interface types.\n");
      return 1;
   }



   if (0){ // restart from checkpoint file

      /* ******************************
      restart
      ********************************* */
      /* note that this will set n_t_global inside the FAST library */
      strcpy(CheckpointFileRoot, "../../../CertTest/Test18.1200");
      FAST_OpFM_Restart(CheckpointFileRoot, &AbortErrLev, &dt, &NumBlades, &NumElementsPerBlade, &n_t_global_start, OpFM_Input_from_FAST, OpFM_Output_to_FAST, &ErrStat, ErrMsg);
      if (checkError(ErrStat, ErrMsg)) return 1;

   }
   else{
      /* ******************************
      initialization
      ********************************* */

      // this calls the Init() routines of each module
      strcpy(InputFileName, "../../../CertTest/Test18.fst");
      TurbID = 1;
      TurbinePos[0] = 0.0;  // x location of turbine
      TurbinePos[1] = 0.0;  // y location of turbine
      TurbinePos[2] = 0.0;  // z location of turbine

      FAST_OpFM_Init(&TMax, InputFileName, &TurbID, &NumScOutputs, &NumScInputs, TurbinePos, &AbortErrLev, &dt, &NumBlades, &NumElementsPerBlade,
                     OpFM_Input_from_FAST, OpFM_Output_to_FAST, &ErrStat, ErrMsg);
      if (checkError(ErrStat, ErrMsg)) return 1;

      // set wind speeds at initial locations
      setOutputsToFAST(OpFM_Input_from_FAST, OpFM_Output_to_FAST);

      FAST_OpFM_Solution0(&ErrStat, ErrMsg);
      if (checkError(ErrStat, ErrMsg)) return 1;

   }

   // determine subcycling number

   /* ******************************
   call FAST once per time step
   ********************************* */

   for (n_t_global = n_t_global_start; n_t_global < 20; n_t_global++){

      /* ******************************
      if you want to create a checkpoint file:
      ********************************* */
      if (n_t_global == n_checkpoint){
         //sprintf(CheckpointFileRoot, "../../CertTest/Test18.%d", n_t_global);
         sprintf(CheckpointFileRoot, " "); // if blank, it will use FAST convention <RootName>.n_t_global<commit_msg>added calculation of number of tower points<commit_after>
#include "FAST_Library.h"
#include "stdio.h"
#include <string.h>
#include <math.h>
#include <stdlib.h> 
#include <malloc.h>

int checkError(const int ErrStat, const char * ErrMsg);
void setOutputsToFAST(OpFM_InputType_t* OpFM_Input_from_FAST, OpFM_OutputType_t* OpFM_Output_to_FAST);


int 
main(int argc, char *argv[], char *env[])
{
   double dt;
   double TMax;
   float TurbinePos[3];
   int TurbID;
   int ErrStat = 0;
   char ErrMsg[INTERFACE_STRING_LENGTH];        // make sure this is the same size as IntfStrLen in FAST_Library.f90
   char InputFileName[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90
   char CheckpointFileRoot[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90

   OpFM_InputType_t* OpFM_Input_from_FAST = NULL;
   OpFM_OutputType_t* OpFM_Output_to_FAST = NULL;
   
   int n_t_global = -2;
   int i = 0;
   int j = 0;
   int k = 0;
   int n_t_global_start = 0;
   int NumBlades = 0;
   int NumElementsPerBlade = 0;
   int NumTwrElements = 0;
   int n_checkpoint = 10;
   int NumScOutputs = 0; // 5;  // # outputs from the supercontroller == # inputs to the controller
   int NumScInputs = 0; // 2;   // # inputs to the supercontroller == # outputs from the controller

   OpFM_Input_from_FAST = malloc(sizeof(OpFM_InputType_t));
   OpFM_Output_to_FAST = malloc(sizeof(OpFM_OutputType_t));
   if (OpFM_Input_from_FAST == NULL || OpFM_Output_to_FAST == NULL) {
      fprintf(stderr, "Error allocating space for OpFM interface types.\n");
      return 1;
   }



   if (0){ // restart from checkpoint file

      /* ******************************
      restart
      ********************************* */
      /* note that this will set n_t_global inside the FAST library */
      strcpy(CheckpointFileRoot, "../../../CertTest/Test18.1200");
      FAST_OpFM_Restart(CheckpointFileRoot, &AbortErrLev, &dt, &NumBlades, &NumElementsPerBlade, &n_t_global_start, OpFM_Input_from_FAST, OpFM_Output_to_FAST, &ErrStat, ErrMsg);
      if (checkError(ErrStat, ErrMsg)) return 1;

   }
   else{
      /* ******************************
      initialization
      ********************************* */

      // this calls the Init() routines of each module
      strcpy(InputFileName, "../../../CertTest/Test18.fst");
      TurbID = 1;
      TurbinePos[0] = 0.0;  // x location of turbine
      TurbinePos[1] = 0.0;  // y location of turbine
      TurbinePos[2] = 0.0;  // z location of turbine

      FAST_OpFM_Init(&TMax, InputFileName, &TurbID, &NumScOutputs, &NumScInputs, TurbinePos, &AbortErrLev, &dt, &NumBlades, &NumElementsPerBlade,
                     OpFM_Input_from_FAST, OpFM_Output_to_FAST, &ErrStat, ErrMsg);
      if (checkError(ErrStat, ErrMsg)) return 1;

      NumTwrElements = OpFM_Output_to_FAST->u_Len - NumBlades*NumElementsPerBlade - 1;

      // set wind speeds at initial locations
      setOutputsToFAST(OpFM_Input_from_FAST, OpFM_Output_to_FAST);

      FAST_OpFM_Solution0(&ErrStat, ErrMsg);
      if (checkError(ErrStat, ErrMsg)) return 1;

   }

   // determine subcycling number

   /* ******************************
   call FAST once per time step
   ********************************* */

   for (n_t_global = n_t_global_start; n_t_global < 20; n_t_global++){

      /* ******************************
      if you want to create a checkpoint file:
      ********************************* */
      if (n_t_global == n_checkpoint){
         //sprintf(CheckpointFileRoot, "../../CertTest/Test18.%d", n_t_global);
         sprintf(CheckpointFileRoot, " "); // if blank, it will use FAST convention <RootName>.n_t_global
{'fraction_non_alphanumeric': 0.16920962199312714, 'fraction_numerical': 0.013745704467353952, 'mean_word_length': 3.48305606900801, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1501807', 'n_tokens_mistral': 2517, 'n_tokens_neox': 2399, 'n_words': 598}