Skip to content

contour_colored: Error with default assignment of levels variable and non-symmetric contour plots #1418

@WaveHello

Description

@WaveHello

Hello,

I was playing around with the

default_gaussian_example

and ran into two errors.

  1. Required to be fixed first: The levels is allocated to zero size and not assigned a value. This trickle dows and eventually leads the plots levels to be set to null.
  2. For non-origin symmetric contour plots, colored contour lines are plotted but there is no fill between the lines.

Minimal working example is here: wave_gaussian_example.txt. The file extension needs to be changed back to .f90.

Stack and Suggested Change

The problems starts from w_levels being allocated to a zero size array in

subroutine convert_contour_arrays(..)

w_levels (as levels) eventually makes it to

subroutine add_colored_contour_plot_data(plots, plot_count, max_plots, &
                                            x_grid, y_grid, z_grid, levels, &
                                            colormap, show_colorbar, label)
     ...

! NOTE: Suggested change, include size check on levels        
         if (present(levels)) then 
            allocate(plots(plot_count)%contour_levels(size(levels)))
            plots(plot_count)%contour_levels = levels
        else
            call generate_default_contour_levels(plots(plot_count))
        end if

and since it's present and allocated (even though it doesn't have a value) it makes it through

if (present(levels)) then 

and

 plots(plot_count)%contour_levels = levels

ends up being set to nothing.

The minimal change to get it working is to change the if statement to

if (present(levels) .and. size(levels) .gt. 0) then

General Note

I would have made a pull request but I can't figure out how square domains generate levels.

Change Locations

The change to the if statement needs to be made in four subroutines:
1)
subroutine add_contour_plot_data(plots, plot_count, max_plots, colors, x_grid, y_grid, z_grid, levels, label)

subroutine add_colored_contour_plot_data(plots, plot_count, max_plots, x_grid, y_grid, z_grid, levels, colormap, show_colorbar, label)

subroutine add_contour_plot_data(self, x_grid, y_grid, z_grid, levels, label)

 subroutine add_colored_contour_plot_data(self, x_grid, y_grid, z_grid, levels, colormap, show_colorbar, label)

General question

It seems like the oop interface could wrap the functional one, instead of re-implementing the same procedures. Was duplicating the implementation a purposeful design choice or was claude being an overachiever?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions