CMI Example Component Execution

From CSDMS

Component Execution

Go

C

    int bocca_status = 0;
    struct edu_csdms_models_Sedflux3D__data *pd =
      edu_csdms_models_Sedflux3D__get_data (self);

    pd->is_driver = TRUE;

    edu_csdms_models_Sedflux3D_CMI_initialize (self, NULL, _ex);

    edu_csdms_models_Sedflux3D_CMI_run (self, -1, _ex);

    edu_csdms_models_Sedflux3D_CMI_finalize (self, _ex);
EXIT:
    bocca_status = 2;
    edu_csdms_models_Sedflux3D_CMI_finalize (self, _ex);
    return bocca_status;

C++

  int bocca_status = 0;

  this->log.info ("Go");
  this->is_driver = TRUE;

  this->CMI_initialize (NULL);
  this->CMI_run (-1);
  this->CMI_finalize ();

  return bocca_status;

Fortran

  type(edu_csdms_tools_TemplateFiles_t) :: template
  type(edu_csdms_models_LTRANS_wrap) :: dp
  character (len=2048) :: input_dir
  character (len=2048) :: isStandalone
  integer :: ng, seconds, stepT

  double precision :: days_dbl, time_interval

  ! As the execution is in the go method this component is the Driver
  dp%d_private_data%isDriver = .TRUE.
  print *, "LTRANS_CMI> LTRANS status: Driver"
  call flush()
  call edu_csdms_models_LTRANS__get_data_m(self, dp)

  call getString (dp%d_private_data%userinput, "/LTRANS/Input/Dir", ".", input_dir, exception)
  call getInt (dp%d_private_data%userinput, "/LTRANS/Input/Var/dt", 1, dt, exception)
  call getString (dp%d_private_data%userinput, "/LTRANS/Input/Var/isStandalone", "", isStandalone, exception)

  !TODO: For some reason getDouble not working, changing to getInteger (For testing)
  call getDouble (dp%d_private_data%userinput, "/LTRANS/Input/Var/days", 1.0D0, days_dbl, exception)
  !call getInt (dp%d_private_data%userinput, "/LTRANS/Input/Var/days", 1, days, exception)
  days = days_dbl
  print *, "LTRANS_CMI> dt: ", dt, " days: ", days
  call flush()

  if (input_dir=="GUI") then
    print *, "LTRANS_CMI> Input from User Input"
    call new (template, exception)
    print *, "LTRANS_CMI> Creating output file"
    ! If ltrans is coupled use a different input file template
    if(isStandalone == 'FALSE') then
        print *, 'Is project runing in standalone mode: ', isStandalone
        call add_file (template, "LTRANS_coupled.data.in", "LTRANS.data", exception)
        !call add_file (template, "LTRANS_grid.data.in", "GRID.data", exception)
        call substitute (template, dp%d_private_data%userinput, "/LTRANS/Input/Var/", ".", exception);
    else
        call add_file (template, "LTRANS.data.in", "LTRANS.data", exception)
        !call add_file (template, "LTRANS_grid.data.in", "GRID.data", exception)
        call substitute (template, dp%d_private_data%userinput, "/LTRANS/Input/Var/", ".", exception);
    end if
  else
    print *, "LTRANS_CMI> Input from File"
    print *, 'LTRANS_CMI> Copying input file to working directory: ', input_dir
    call system("cp " // input_dir // " .")
  end if

  if(trim(isStandalone) == 'FALSE') then
    print *, 'LTRANS_CMI> Getting the component ready, running as a coupled component'
    call LTR_CMI_initializev31n7eesph_mi(self, "NULL", retval, exception)

    !days*24*60*60 = total number of seconds to run the model
    !divide that by dt to get the number of external time steps
    seconds = days*DBLE(24)*DBLE(60)*DBLE(60) !Total seconds to run model
    stepT   = int(seconds/dt)                 !number of external time steps
    print *, 'LTRANS_CMI> Total seconds to run model: ', seconds
    print *, 'LTRANS_CMI> Number of external time step: ', stepT
    print *, 'Time step: '
    print *, real(p)
    do p=1,stepT
        time_interval=real(p)
        call LTRANS_CMI_run4nqryolxalh_xn_mi(self, time_interval, retval, exception)
    enddo
    call flush()
    print *, "LTRANS_cmi> Run finished. Finalizing model..."
    call LTRAN_CMI_finalizehz7pezx1ae_mi(self, retval, exception)
  else
    print *, 'ltrans cmi> Running as a standalone component'
    call run_LTRANS()
  end if
  print *, 'LTRANS_CMI> Done.'

Initialize

C

    struct edu_csdms_models_Sedflux3D__data *this =
             edu_csdms_models_Sedflux3D__get_data (self);

    edu_csdms_tools_Verbose_info (this->log, "Initializing.", _ex);
    if (this->status >= CMI_STATUS_INITIALIZING)
      return TRUE;
    else
      this->status = CMI_STATUS_INITIALIZING;

    edu_csdms_tools_Verbose_info (this->log, "Create port queue.", _ex);
    { // Create port queue.
      edu_csdms_ports_CMIPort port = edu_csdms_ports_CMIPort__cast (self, _ex);
      struct sidl_string__array* ports =
        edu_csdms_tools_CMIConfigFile_get_array (this->cfg_file,
            "CMI_PORT_NAMES", _ex);
      this->ports = edu_csdms_tools_CMIPortQueue__create (_ex);

      edu_csdms_tools_Verbose_info (this->log, "Initialize port queue.", _ex);
      edu_csdms_tools_CMIPortQueue_initialize (this->ports,
          this->d_services, port, _ex);

      edu_csdms_tools_Verbose_info (this->log, "Add ports to queue.", _ex);
      edu_csdms_tools_CMIPortQueue_add_ports (this->ports, CMI_PORT_NAMES,
          _ex);

      edu_csdms_tools_Verbose_info (this->log, "Connect ports.", _ex);
      edu_csdms_tools_CMIPortQueue_connect_ports (this->ports, _ex);
    }
    edu_csdms_tools_Verbose_info (this->log, "Created port queue.", _ex);

    edu_csdms_tools_Verbose_info (this->log, "Read parameters.", _ex);
    { /* Read parameters from the config dialog. */
      edu_csdms_tools_TemplateFiles template;
      char **src;
      char **dest;
      const char *src_files = CMI_TEMPLATE_SOURCE_FILES;
      const char *dest_files = CMI_TEMPLATE_DEST_FILES;
      char * val;
      //struct sidl_string__array* src_files =
      //  gov_cca_TypeMap_getStringArray (this->cmi_data,
      //      "CMI_TEMPLATE_SOURCE_FILES", NULL, _ex);
      //sidl_string__array dst_files = gov_cca_TypeMap_getStringArray (
      //    this->cmi_data, "CMI_TEMPLATE_DEST_FILES", NULL, _ex);

      template = edu_csdms_tools_TemplateFiles__create (_ex);
      edu_csdms_tools_TemplateFiles_add_files (template, src_files,
          dest_files, _ex);

      val = gov_cca_TypeMap_getString (this->userinput,
          "/Sedflux3D/Input/Var/InputDir", "GUI", _ex);
      if (g_ascii_strcasecmp (val, "GUI")==0)
        gov_cca_TypeMap_putString (this->userinput,
            "/Sedflux3D/Input/Var/InputDir", ".", _ex);

      val = gov_cca_TypeMap_getString (this->userinput,
          "/Sedflux3D/Input/Var/InitializationFile", "GUI", _ex);
      if (g_ascii_strcasecmp (val, "GUI")==0)
        gov_cca_TypeMap_putString (this->userinput,
            "/Sedflux3D/Input/Var/InitializationFile",
            "${SimulationName}_init.kvf", _ex);

      val = gov_cca_TypeMap_getString (this->userinput,
          "/Sedflux3D/Input/Var/RiverFile", "GUI", _ex);
      if (g_ascii_strcasecmp (val, "GUI")==0)
        gov_cca_TypeMap_putString (this->userinput,
            "/Sedflux3D/Input/Var/RiverFile",
            "${SimulationName}_river.kvf", _ex);

      val = gov_cca_TypeMap_getString (this->userinput,
          "/Sedflux3D/Input/Var/SedimentFile", "GUI", _ex);
      if (g_ascii_strcasecmp (val, "GUI")==0)
        gov_cca_TypeMap_putString (this->userinput,
            "/Sedflux3D/Input/Var/SedimentFile",
            "${SimulationName}_sediment.kvf", _ex);

      gov_cca_TypeMap_putString (this->userinput,
          "/Sedflux3D/Input/Var/ProcessFile",
          "${SimulationName}_process.kvf", _ex);

      edu_csdms_tools_TemplateFiles_substitute (template,
          this->userinput, "/"CMI_COMPONENT_NAME"/Input/Var/", ".",
          _ex);

      val = gov_cca_TypeMap_getString (this->userinput,
          "/Sedflux3D/Input/Var/SimulationName", CMI_COMPONENT_NAME, _ex);
      gov_cca_TypeMap_putString (this->userinput,
          "/Sedflux3D/SimulationName", val, _ex);
    }

    edu_csdms_tools_Verbose_info (this->log, "BMI initialize.", _ex);
    this->state = BMI_Initialize (CMI_COMPONENT_NAME"_command_line.txt");

    edu_csdms_tools_Verbose_info (this->log, "Create print queue.", _ex);
    {
      edu_csdms_ports_CMIPort port = edu_csdms_ports_CMIPort__cast (self, _ex);
      this->print_queue = edu_csdms_tools_PrintQueue__create (_ex);

      edu_csdms_tools_Verbose_info (this->log, "Initialize print queue.", _ex);
      edu_csdms_tools_PrintQueue_initialize (this->print_queue,
          this->userinput, "/"CMI_COMPONENT_NAME, port, _ex);

      edu_csdms_tools_Verbose_info (this->log, "Add file to print queue.", _ex);
      edu_csdms_tools_PrintQueue_add_files_from_list (this->print_queue,
          CMI_OUTPUT_FILE_NS, _ex);
    }
    edu_csdms_tools_Verbose_info (this->log, "Created print queue.", _ex);

    edu_csdms_tools_Verbose_info (this->log, "Initialize uses ports.", _ex);
    edu_csdms_tools_CMIPortQueue_initialize_ports (this->ports, NULL, _ex);

#if CMI_TURN_OFF_MAPPING
    edu_csdms_tools_Verbose_warning (this->log, "Forgetting mappers.", _ex);
#else
    edu_csdms_tools_Verbose_info (this->log, "Set up mappers.", _ex);
    edu_csdms_tools_CMIPortQueue_add_mappers (this->ports, CMI_MAPPERS, _ex);
#endif

    edu_csdms_tools_Verbose_info (this->log, "Initialized.", _ex);
    this->status = CMI_STATUS_INITIALIZED;
    return TRUE;

C++

  this->log.info ("Initializing");
  if (this->status >= CMI_STATUS_INITIALIZING)
    return TRUE;
  else
    this->status = CMI_STATUS_INITIALIZING;

  this->log.info (this->CMI_get_status ());

  this->log.info ("Create port queue.");
  { // Create port queue.
    ::edu::csdms::ports::CMIPort port =
      ::babel_cast<edu::csdms::ports::CMIPort>(*this);

    this->ports = ::edu::csdms::tools::CMIPortQueue::_create ();

    this->ports.initialize (this->d_services, port);

    this->ports.add_ports (CMI_PORT_NAMES);

    this->ports.connect_ports ();
  }
  this->log.info ("Created port queue.");

  this->log.info ("Parse config file.");
  { // Read parameters from the config dialog.
    ::edu::csdms::tools::TemplateFiles tmpls;
    const char *src_files = CMI_TEMPLATE_SOURCE_FILES;
    const char *dest_files = CMI_TEMPLATE_DEST_FILES;
    string val;

    tmpls = ::edu::csdms::tools::TemplateFiles::_create ();
    tmpls.add_files (CMI_TEMPLATE_SOURCE_FILES, CMI_TEMPLATE_DEST_FILES);
    tmpls.substitute (this->userinput, "/"CMI_COMPONENT_NAME"/Input/Var/",
        ".");

    val = this->userinput.getString (
        "/"CMI_COMPONENT_NAME"/Input/Var/SimulationName",
        CMI_COMPONENT_NAME);
    this->userinput.putString (
        "/"CMI_COMPONENT_NAME"/SimulationName",
        val);
  }
  this->log.info ("Parsed config file.");

  /* The contents of this file will be something like,
   * Child Child.in
   * */
  this->state.initialize ("Child_command_line.txt");

  this->log.info ("Create print queue.");
  { // Set up the print queue.
    ::edu::csdms::ports::CMIPort port =
      ::babel_cast<edu::csdms::ports::CMIPort>(*this);
    this->print_q = ::edu::csdms::tools::PrintQueue::_create ();

    this->print_q.initialize (this->userinput, "/"CMI_COMPONENT_NAME,
        port);
    this->print_q.add_files_from_list (CMI_OUTPUT_FILE_NS);
  }
  this->log.info ("Created print queue.");

#if CMI_TURN_OFF_PORTS
  this->log.warning ("Forgetting ports for now.");
#else
  this->log.info ("Initialize ports.");
  this->ports.initialize_ports (0);
#endif

#if CMI_TURN_OFF_MAPPING
  this->log.warning ("Mapping is turned off.");
#else
  this->log.info ("Initialize mappers.");
  this->ports.add_mappers (CMI_MAPPERS);

  this->log.info ("Map initial values.");
  this->ports.run_mappers ();
#endif

  this->status = CMI_STATUS_INITIALIZED;

  this->log.info ("Initialized.");
  this->log.info (this->CMI_get_status ());
  return TRUE;

Fortran

! Insert-Code-Here {edu.csdms.models.LTRANS.CMI_initialize} (CMI_initialize method)

! This method has not been implemented
!
  type(edu_csdms_models_LTRANS_wrap) :: dp
  type(edu_csdms_tools_IRFPortQueue_t) :: port_queue
  type(edu_csdms_ports_CMIPort_t) :: cmi_port
!  type(sidl_string_1d) :: properties
  type(edu_csdms_ports_CMIPort_t) :: ocean_port
  type(sidl__array) :: return_sidl_array
  integer :: long_var_names_array_size
  integer :: i


  call edu_csdms_models_LTRANS__get_data_m(self, dp)

  print *, "LTRANS_CMI> Initializing LTRANS component"
  dp%d_private_data%cmi_status = 'I'

  !call get_port("Ocean", ocean_port)

  call cast(self, cmi_port, exception)

  ! This will initialize the IRFPortQueue
  print *, "LTRANS_CMI> Initialize port queue"
  call new(port_queue, exception)
  call initialize_cmi(port_queue, dp%d_private_data%d_services, cmi_port, exception)

  ! Add ports to the IRFPortQueue
  print *, "LTRANS_CMI> Adding ports to IRFPortQueue"
  print *, "LTRANS_CMI> Added Ports: ", trim(dp%d_private_data%CMI_PORT_NAMES)
  call add_ports(port_queue, dp%d_private_data%CMI_PORT_NAMES, exception)

  print *, "LTRANS_CMI> Connecting uses ports in queue and Initialize uses ports"
  call connect_cmi_ports(port_queue, exception)

  ! Initializing the uses ports
  ! print *, "LTRANS_CMI> Initialize uses ports"
  ! Commenting 'initialize_ports' of irfportqueu. The properties arguement is causing a segmentation fault.
  ! call initialize_ports(port_queue, properties, exception)

  print *, "LTRANS_CMI> Getting the uses port Ocean"
  call get_cmi_port(port_queue, "Ocean", ocean_port, exception)

  !print *, "LTRANS_CMI> Get values of ROMS Grid"
  !dp%d_private_data%long_var_names(5) = "angle_between_xi_axis_and_east"
  !dp%d_private_data%long_var_names(6) = "bathymetry_at_rho_points"
  !dp%d_private_data%long_var_names(7) = "latitude_of_rho_points"
  !dp%d_private_data%long_var_names(8) = "latitude_of_u_points"
  !dp%d_private_data%long_var_names(9) = "latitude_of_v_points"
  !dp%d_private_data%long_var_names(10) = "longitude_of_rho_points"
  !dp%d_private_data%long_var_names(11) = "longitude_of_u_points"
  !dp%d_private_data%long_var_names(12) = "longitude_of_v_points"
  !dp%d_private_data%long_var_names(13) = "mask_on_rho_points"
  !dp%d_private_data%long_var_names(14) = "mask_on_u_points"
  !dp%d_private_data%long_var_names(15) = "mask_on_v_points"

  dp%d_private_data%long_var_names(1) = "free_surface"
  dp%d_private_data%long_var_names(2) = "u_momentum_component"
  dp%d_private_data%long_var_names(3) = "v_momentum_component"
  dp%d_private_data%long_var_names(4) = "vertical_momentum_component"
  dp%d_private_data%long_var_names(5) = "salinity_vertical_diffusion_coefficient"
  dp%d_private_data%long_var_names(6) = "salinity"
  dp%d_private_data%long_var_names(7) = "potential_temperature"
  ! Grid initialization values, for now this is been read from file
  dp%d_private_data%long_var_names(8) = "s_coordinate_stretching_curves_at_rho_points"
  dp%d_private_data%long_var_names(9) = "s_coordinate_stretching_curves_at_w_points"
  dp%d_private_data%long_var_names(10) = "s_coordinate_independent_variable_at_vertical_rho_points"
  dp%d_private_data%long_var_names(11) = "s_coordinate_independent_variable_at_vertical_w_points"

  ! Call get values of ROMS component
  !long_var_names_array_size = SIZE(dp%d_private_data%long_var_names)
  ! do i = 8, long_var_names_array_size
  !   call flush()
  !   print *, "LTRANS_CMI> Getting Value for ", trim(dp%d_private_data%long_var_names(i))
  !   call CMI_get_values(ocean_port, TRIM(dp%d_private_data%long_var_names(i)), return_sidl_array, exception)
  !   call flush()
  !   print *, "LTRANS_CMI> Setting Value for ", trim(dp%d_private_data%long_var_names(i))
  !   call LTR_CMI_set_valuespoyw79p49f_mi(self, TRIM(dp%d_private_data%long_var_names(i)), return_sidl_array, exception)
  ! end do

  ! Initializing LTRANS
  print *, "LTRANS_CMI> Calling LTRANS initialize"
  call ltrans_initialize(config_file)
  dp%d_private_data%cmi_status = 'I'
  print *, "LTRANS_CMI> Initialization Done."

  ! Setting IRFPortQueue to the global vriable
  dp%d_private_data%irf_port_queue = port_queue

Run

C

    struct edu_csdms_models_Sedflux3D__data *this =
             edu_csdms_models_Sedflux3D__get_data (self);

    edu_csdms_tools_Verbose_info (this->log,
        edu_csdms_models_Sedflux3D_CMI_get_status (self, _ex), _ex);

    if (this->status == CMI_STATUS_UPDATING)
      return TRUE;
    else
      this->status = CMI_STATUS_UPDATING;

    if (time_interval<0)
      time_interval = BMI_Get_end_time (this->state);

    edu_csdms_tools_Verbose_info (this->log, "Updating", _ex);
    {
      double print_time = edu_csdms_tools_PrintQueue_next_print_time (
          this->print_queue, _ex);
      while (print_time>0 && print_time<time_interval)
      {
        this->status = CMI_STATUS_UPDATED;

        edu_csdms_tools_Verbose_info (this->log, "Running until next print time.", _ex);
        edu_csdms_models_Sedflux3D_CMI_run (self, print_time, _ex);

        edu_csdms_tools_PrintQueue_print_all (this->print_queue, print_time, _ex);
        print_time = edu_csdms_tools_PrintQueue_next_print_time (
            this->print_queue, _ex);
      }
    }

    {
      double now = BMI_Get_current_time (this->state);
      const double port_queue_dt = CMI_PORT_QUEUE_DT;
      double t = now + port_queue_dt;

      for (; t<time_interval; t+=port_queue_dt)
      {
        edu_csdms_tools_Verbose_info (this->log, "Updating ports.", _ex);
        edu_csdms_tools_CMIPortQueue_run_ports (this->ports, now, _ex);

#if CMI_TURN_OFF_MAPPING
        edu_csdms_tools_Verbose_warning (this->log, "Forgetting mappers.", _ex);
#else
        edu_csdms_tools_Verbose_info (this->log, "Running mappers.", _ex);
        edu_csdms_tools_CMIPortQueue_run_mappers (this->ports, _ex);
#endif

        edu_csdms_tools_Verbose_info (this->log, "Updating myself.", _ex);
        BMI_Update_until (this->state, t);
        now = BMI_Get_current_time (this->state);
      }

      if (t>time_interval)
      {
        edu_csdms_tools_Verbose_info (this->log, "Updating ports.", _ex);
        edu_csdms_tools_CMIPortQueue_run_ports (this->ports, now, _ex);

#if CMI_TURN_OFF_MAPPING
        edu_csdms_tools_Verbose_warning (this->log, "Forgetting mappers.", _ex);
#else
        edu_csdms_tools_Verbose_info (this->log, "Running mappers.", _ex);
        edu_csdms_tools_CMIPortQueue_run_mappers (this->ports, _ex);
#endif

        BMI_Update_until (this->state, time_interval);
      }
    }

    edu_csdms_tools_Verbose_info (this->log, "Updated.", _ex);
    this->status = CMI_STATUS_UPDATED;

    return TRUE;

C++

  this->log.info ("Updating.");
  this->log.info (this->CMI_get_status ());

  if (this->status == CMI_STATUS_UPDATING)
    return TRUE;
  else
    this->status = CMI_STATUS_UPDATING;

  {
    double print_time = this->print_q.next_print_time ();
    while (print_time>0 && print_time<time_interval)
    {
      this->status = CMI_STATUS_UPDATED;

      this->log.info ("Running until next print time.");
      this->CMI_run (print_time);

      this->print_q.print_all (print_time);
      print_time = this->print_q.next_print_time ();
    }
  }

  { // Run model until the stop time
    double now = this->state.get_current_time ();
    double port_queue_dt = CMI_PORT_QUEUE_DT;
    double t = now + port_queue_dt;
    for (; t<time_interval; t+=port_queue_dt)
    {
#if CMI_TURN_OFF_PORTS
      this->log.warning ("Forgetting ports for now.");
#else
      this->log.info ("Updating ports.");
      this->ports.run_ports (now);
#endif

#if CMI_TURN_OFF_MAPPING
      this->log.warning ("Not mapping values.");
#else
      this->log.info ("Mapping values.");
      this->ports.run_mappers ();
#endif

      this->log.info ("Updating myself.");
      this->state.update_until (t);

      now = this->state.get_current_time ();
    }

    if (t>time_interval)
    { // The last partial time step (if necessary).
#if CMI_TURN_OFF_PORTS
      this->log.warning ("Forgetting ports for now.");
#else
      this->log.info ("Updating ports.");
      this->ports.run_ports (now);
#endif

#if CMI_TURN_OFF_MAPPING
      this->log.warning ("Not mapping values.");
#else
      this->log.info ("Mapping values.");
      this->ports.run_mappers ();
#endif

      this->log.info ("Updating myself.");
      this->state.update_until (time_interval);
    }
  }

  this->status = CMI_STATUS_UPDATED;
  ::std::cerr << CMI_COMPONENT_NAME ": Status is "
              << this->CMI_get_status () << ::std::endl;

  this->log.info ("Updated.");
  this->log.info (this->CMI_get_status ());
  return TRUE;

Fortran

! Insert-Code-Here {edu.csdms.models.LTRANS.CMI_run} (CMI_run method)

  type(edu_csdms_ports_CMIPort_t) :: ocean_port
  type(edu_csdms_tools_IRFPortQueue_t) :: port_queue
  type(edu_csdms_models_LTRANS_wrap) :: dp
  type(sidl__array) :: return_sidl_array
  type(sidl__array) :: return_sidl_array2
  integer :: long_var_names_array_size
  integer :: i
  logical :: isfirstTimeStep=.true.

  call edu_csdms_models_LTRANS__get_data_m(self, dp)

  dp%d_private_data%cmi_status = 'U'
  port_queue = dp%d_private_data%irf_port_queue

  print *, "LTRANS_CMI> Run all the connected ports for current timestep: ", time_interval
  call run_ports(port_queue, time_interval, exception)

  call get_cmi_port(port_queue, "Ocean", ocean_port, exception)

  ! Call get values of ROMS component
  print *, "LTRANS_CMI> Get values of ROMS for timestep ", time_interval
  long_var_names_array_size = SIZE(dp%d_private_data%long_var_names)
   do i = 1, 7
     call flush()
     print *, "LTRANS_CMI> Getting Value for ", trim(dp%d_private_data%long_var_names(i)), ", value for timestep ", time_interval
     call CMI_get_values(ocean_port, TRIM(dp%d_private_data%long_var_names(i)), return_sidl_array, exception)
     call flush()
     print *, "LTRANS_CMI> Setting Value for ", trim(dp%d_private_data%long_var_names(i)), ", value for timestep ", time_interval
     call LTR_CMI_set_valuespoyw79p49f_mi(self, TRIM(dp%d_private_data%long_var_names(i)), return_sidl_array, exception)
   end do

   if(isfirstTimeStep)then
        print *, 'ltrans bmi> Getting values to get the node depth'
        do i = 8, long_var_names_array_size
            call flush()
            print *, "LTRANS_CMI> Getting Value for ", trim(dp%d_private_data%long_var_names(i)), ", value for timestep ", time_interval
            call CMI_get_values(ocean_port, TRIM(dp%d_private_data%long_var_names(i)), return_sidl_array, exception)
            call flush()
            print *, "LTRANS_CMI> Setting Value for ", trim(dp%d_private_data%long_var_names(i)), ", value for timestep ", time_interval
            call LTR_CMI_set_valuespoyw79p49f_mi(self, TRIM(dp%d_private_data%long_var_names(i)), return_sidl_array, exception)
        end do
        isfirstTimeStep=.false.
    end if
  !
  call ltrans_update(time_interval)

Finalize

C

    struct edu_csdms_models_Sedflux3D__data *this =
             edu_csdms_models_Sedflux3D__get_data (self);

    this->status = CMI_STATUS_FINALIZING;

    {
      BMI_Finalize (this->state);

      this->is_driver = FALSE;
      this->state = NULL;

      edu_csdms_tools_PrintQueue_close (this->print_queue, _ex);
    }

    this->status = CMI_STATUS_FINALIZED;

    return TRUE;

C++

  this->status = CMI_STATUS_FINALIZING;

  this->state.finalize ();

  this->is_driver = FALSE;
  //this->state = NULL;

  this->print_q.close ();
  this->ports.finalize_ports ();
  this->ports.disconnect_ports ();

  this->status = CMI_STATUS_FINALIZED;

  return TRUE;

Fortran

! Insert-Code-Here {edu.csdms.models.LTRANS.CMI_finalize} (CMI_finalize method)
!
! This method has not been implemented
!
  type(edu_csdms_ports_CMIPort_t) :: ocean_port
  type(edu_csdms_tools_IRFPortQueue_t) :: port_queue
  type(edu_csdms_models_LTRANS_wrap) :: dp

  call edu_csdms_models_LTRANS__get_data_m(self, dp)

  dp%d_private_data%cmi_status = 'F'
  port_queue = dp%d_private_data%irf_port_queue

  call get_cmi_port(port_queue, "Ocean", ocean_port, exception)

  print *, 'Ltrans_cmi> Finalizing ocean port'
  call finalize_ports(port_queue, exception)

  print *, "LTRANS_CMI> Finalize LTRANS"
  call ltran_finalize()