set_output_json_filename Subroutine

public subroutine set_output_json_filename(input_filename)

Set the JSON output filename based on input filename Example: “water.mqc” -> “output_water.json”

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: input_filename

Called by

proc~~set_output_json_filename~~CalledByGraph proc~set_output_json_filename set_output_json_filename program~main main program~main->proc~set_output_json_filename

Variables

Type Visibility Attributes Name Initial
character(len=256), private :: basename
integer, private :: dot_pos
integer, private :: slash_pos

Source Code

   subroutine set_output_json_filename(input_filename)
      !! Set the JSON output filename based on input filename
      !! Example: "water.mqc" -> "output_water.json"
      character(len=*), intent(in) :: input_filename
      integer :: dot_pos, slash_pos
      character(len=256) :: basename

      ! Find last slash (if any) to extract basename
      slash_pos = index(input_filename, '/', back=.true.)
      if (slash_pos > 0) then
         basename = input_filename(slash_pos + 1:)
      else
         basename = input_filename
      end if

      ! Find last dot to remove extension
      dot_pos = index(basename, '.', back=.true.)
      if (dot_pos > 0) then
         basename = basename(1:dot_pos - 1)
      end if

      ! Store basename for later use
      current_basename = trim(basename)

      ! Construct output filename: output_<basename>.json
      output_json_filename = "output_"//trim(basename)//".json"

   end subroutine set_output_json_filename