RUN

From ASCEND

Jump to: navigation, search

The RUN statement in ASCEND is used within METHODS to call other methods within the same MODEL, as well as methods defined in any sub-models of the present model.

REQUIRE "atoms.a4l";
REQUIRE "submodels.a4c";
MODEL mymodel;
    x IS_A temperature;
    sub IS_A submodel_type_1;
METHODS
    METHOD on_load;
        RUN sub.on_load; (* run a method in the submodel *)
        FIX x;
        RUN values; (* run another method within the present model *)
    END on_load;
    METHOD values;
        x := 500 {K};
        sub.p := 1 {bar};
    END values;
END mymodel;

To run a method defined in a base model, you can use the RUN typename::methodname syntax. In this way, methods may be defined incrementally. For example:

REQUIRE "atoms.a4l";
REQUIRE "submodels.a4c";
MODEL mymodel;
    x IS_A temperature;
    sub IS_A submodel_type_1;
METHODS
    METHOD on_load;
        RUN sub.on_load; (* run a method in the submodel *)
        FIX x;
        RUN values; (* run another method within the present model *)
    METHOD values;
        x := 500 {K};
        sub.p := 1 {bar};
    END values;
END mymodel;