external_train_map Subroutine

public subroutine external_train_map(x, nvar, npat, som_type, nx1, ny1, nepoch1, alpha1, grid_type1, distance_type1, neigh_type1, toroidal1, nx2, nepoch2, alpha2, grid_type2, prot, distortion, u_matrix, coords, number_patterns, node_index) bind(C, name="train_2lsom")

Uses

  • proc~~external_train_map~2~~UsesGraph proc~external_train_map~2 two_level_self_organizing_map%external_train_map iso_c_binding iso_c_binding proc~external_train_map~2->iso_c_binding

Subroutine to connect the two_level_self_organizing_map module to R o C Use iso_c_binding module

Type Bound

two_level_self_organizing_map

Arguments

Type IntentOptional Attributes Name
real(kind=c_double), intent(in) :: x(npat,nvar)

Real variables

integer(kind=c_int), intent(in) :: nvar

Integere variables

integer(kind=c_int), intent(in) :: npat

Integere variables

integer(kind=c_int), intent(in) :: som_type

Integere variables

integer(kind=c_int), intent(in) :: nx1

Integere variables

integer(kind=c_int), intent(in) :: ny1

Integere variables

integer(kind=c_int), intent(in) :: nepoch1

Integere variables

real(kind=c_double), intent(in) :: alpha1

Real variables

integer(kind=c_int), intent(in) :: grid_type1

Integer variables

integer(kind=c_int), intent(in) :: distance_type1

Integer variables

integer(kind=c_int), intent(in) :: neigh_type1

Integer variables

integer(kind=c_int), intent(in) :: toroidal1

Integere variables

integer(kind=c_int), intent(in) :: nx2

Integer variables

integer(kind=c_int), intent(in) :: nepoch2

Integer variables

real(kind=c_double), intent(in) :: alpha2

Real variables

integer(kind=c_int), intent(in) :: grid_type2

Integer variables

real(kind=c_double), intent(out) :: prot(nx1*ny1,nvar)

Real variables

real(kind=c_double), intent(out) :: distortion(nepoch1)

Real variables

real(kind=c_double), intent(out) :: u_matrix(2*nx1-1,2*ny1-1)

Real variables

real(kind=c_double), intent(out) :: coords(nx1*ny1,3)

Real variables

integer(kind=c_int), intent(out) :: number_patterns(nx1,ny1)

Integer variables

integer(kind=c_int), intent(out) :: node_index(npat,3)

Integer variables


Variables

Type Visibility Attributes Name Initial
real(kind=wp), public, parameter :: version = 0.1_wp

Subroutine Version

character(len=*), public, parameter :: program_name = "2lsom_train"

Subroutine name

type(two_level_self_organizing_map), public :: my_som
type(kohonen_layer_parameters), public, dimension(1) :: parameters
real(kind=wp), public, dimension(nvar,1) :: var
integer, public :: i
integer, public :: j
integer, public :: k
integer, public :: ierr
integer, public :: pos
integer, public :: ihit
integer, public :: jhit
integer, public :: khit
integer, public :: nx1a
integer, public :: ny1a
type(kohonen_pattern), public, allocatable :: input_patterns(:)
real(kind=wp), public, dimension(nx1*ny1,nvar) :: prototypes
real(kind=wp), public, dimension(nvar,1) :: temp

Source Code

   subroutine external_train_map(x,nvar,npat,som_type,nx1,ny1,nepoch1,alpha1,grid_type1,&
               distance_type1,neigh_type1,toroidal1,nx2,nepoch2,alpha2,grid_type2,&
               prot,distortion,u_matrix,coords,number_patterns,&
               node_index) bind(C, name="train_2lsom")
   !========================================================================================
!!    Subroutine to connect the two_level_self_organizing_map module to R o C
   use, intrinsic :: iso_c_binding, only : c_double, c_int, c_char
!! Use iso_c_binding module
   real(kind=wp),parameter :: version=0.1_wp
!! Subroutine Version
   character(len=*),parameter :: program_name="2lsom_train"
!! Subroutine name
   integer(c_int), intent(in) :: nvar,npat,som_type,nx1,ny1,nepoch1,toroidal1
!! Integere variables
   real(c_double),intent(out) :: prot(nx1*ny1,nvar),distortion(nepoch1)
!! Real variables
   real(c_double),intent(out) :: u_matrix(2*nx1-1,2*ny1-1),coords(nx1*ny1,3)
!! Real variables
   integer(c_int),intent(out) :: number_patterns(nx1,ny1),node_index(npat,3)
!! Integer variables
   real(c_double),intent(in) :: x(npat,nvar)
!! Real variables
   real(c_double),intent(in) :: alpha1,alpha2
!! Real variables
   integer(c_int),intent(in) :: grid_type1,distance_type1,neigh_type1
!! Integer variables
   integer(c_int),intent(in) :: nx2,grid_type2,nepoch2 !,distance_type1,neigh_type2
!! Integer variables
   type(two_level_self_organizing_map) :: my_som
   type(kohonen_layer_parameters),dimension(1) :: parameters
   real(kind=wp),dimension(nvar,1) :: var
   integer :: i,j,k,ierr,pos,ihit,jhit,khit,nx1a,ny1a
   type(kohonen_pattern),allocatable :: input_patterns(:)
   real(kind=wp),dimension(nx1*ny1,nvar) :: prototypes
   real(kind=wp),dimension(nvar,1) :: temp
   !
   parameters(1)%train_option=3;
   parameters(1)%number_nodes_nx=nx1;
   parameters(1)%number_nodes_ny=ny1;
   parameters(1)%number_nodes_nz=1;
   parameters(1)%number_variables1=nvar;
   parameters(1)%number_variables2=1;
   parameters(1)%number_variables=nvar;
   parameters(1)%number_patterns=npat;
   parameters(1)%number_epochs=nepoch1;
   parameters(1)%learning_rate=alpha1;
   parameters(1)%random_seed_=12345;
   !
   select case(grid_type1)
      case(0)
      parameters(1)%node_type="rectangular";
      case(1)
      parameters(1)%node_type="hexagonal"; 
   end select
   !  
   parameters(1)%debug_level=0;
   parameters(1)%debug_file="NOFILE";
   parameters(1)%pattern_file="NOFILE";
   parameters(1)%output_file="NOFILE";
   parameters(1)%distance_type="euclidean"; !"euclidean" !euclidean, manhattan, correlation, correlation2
   !
   select case(neigh_type1)
      case(0)
      parameters(1)%neighborhood_type="bubble";
      case(1)
      parameters(1)%neighborhood_type="gaussian";
   end select  
   !
   select case(som_type)
      case(0)
      parameters(1)%som_type="normal_som";!,visom, robust_som
      case(1)
      parameters(1)%som_type="visom";
      case(2)
      parameters(1)%som_type="robust_som";
   end select
   !      
   if(toroidal1 == 1) then
      parameters(1)%toroidal_grid=.TRUE.;
   else
      parameters(1)%toroidal_grid=.FALSE.;
   endif
   ! 
   end subroutine external_train_map