11/8/2022 0 Comments Simply fortran aplot manual![]() ![]() contains ! Here go all the procedures declared in this module function spatial_distance_3d ( this, other ) result ( distance_euclidean ) class ( SPATIAL_POINT ), intent ( in ) :: this real ( SRP ) :: distance_euclidean class ( SPATIAL_POINT ), intent ( in ) :: other distance_euclidean = dist (, & ) end function spatial_distance_3d subroutine spatial_init ( this ) class ( SPATIAL_POINT ), intent ( inout ) :: this. procedure, public :: init => spatial_moving_init procedure, public :: go_up => spatial_moving_go_up procedure, public :: go_down => spatial_moving_go_down. type, public, extends ( SPATIAL_POINT ) :: SPATIAL_MOVING ! The following component adds an array of history of the object ! movements: type ( SPATIAL_POINT ), dimension ( HISTORY_SIZE_SPATIAL ) :: history. contains procedure, public :: init => spatial_init procedure, public :: distance => spatial_distance_3d. Module SPATIAL_OBJECTS ! Declarations of objects: type, public :: SPATIAL_POINT real ( SRP ) :: x, y, depth character ( len = LABEL_LENGTH ) :: label. ![]() character ( len =* ), parameter, public :: MODEL_NAME = "HEDG2_01" character ( len =* ), parameter, private :: MODNAME = "COMMONDATA" !> This is the target string, only for the prototype test character ( len =* ), parameter, public :: GA_TARGET = "This is a test of genetic algorithm." !> Model name for tags, file names etc. !! Each procedure should also have a similar private constant PROCNAME. Note that in the debug mode (if IS_DEBUG=TRUE) !! LOGGER should normally produce additional messages that are helpful for !! debuging and locating possible sources of errors. !> MODNAME always refers to the name of the current module for use by !! the LOGGER function LOG_DBG. !! `COMMONDATA` may also include subroutines/functions that have !! general scope and used by many other modules of the model. ![]() !! It is also safe to include public keyword to declarations. !! Everything that has global scope and should be passed to many !! subroutines/functions, should be defined in `COMMONDATA`. !- !> Module **COMMONDATA** is used for definine various global !! parameters like model name, tags, population size etc. as F print *, AB ! F F T end program LOOP_FREE AB = all ( A > B, dim = 2 ) ! Here we output values. end where ! Here is the result of this array operation: print *, "-" print ( fmt_str_r ), A (:, 1 ) ! 1.1 2.1 100.0 print ( fmt_str_r ), A (:, 2 ) ! 1.2 2.2 100.0 print ( fmt_str_r ), A (:, 3 ) ! 1.3 2.3 100.0 print ( fmt_str_r ), A (:, 4 ) ! 1.4 2.4 100.0 print *, "-" print ( fmt_str_i ), B (:, 1 ) ! 10 10 0 print ( fmt_str_i ), B (:, 2 ) ! 10 10 0 print ( fmt_str_i ), B (:, 3 ) ! 10 10 0 print ( fmt_str_i ), B (:, 4 ) ! 10 10 0 ! *** Example 2: Calculate sums of elements for the second (= cols) dimension of A S = sum ( A, dim = 2 ) print *, "-" print ( fmt_str_i ), S ! 5 9 400 ! *** Example 3: Find if the condition holds, for all values over the second (rows) ! dimension, similar function 'any' evaluates for any of these values. #Simply fortran aplot manual code#! more concise code than two nested loops, elsewhere ! it is also easier for the compiler to optimise B = 10 ! and therefore result in faster machine code. ) ! 'where' clearly produces much simpler and A = 10 0. !- program LOOP_FREE ! Declare arrays and variables we need implicit none character ( len =* ), parameter :: fmt_str_r = "(3F8.1)" ! these are just for character ( len =* ), parameter :: fmt_str_i = "(3I8)" ! output formatting ! Assign 2-D array values from a 1-D vector using 'reshape' real, dimension ( 3, 4 ) :: A = reshape (, ) integer, dimension ( 3, 4 ) :: B = 0 integer, dimension ( 3 ) :: S = 0 logical, dimension ( 3 ) :: AB = F ! logical, can be either. ! Note that the order of indices here is: (column, row). !- ! This program illustrates some loop-free Fortran constructions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |