<commit_before>#!/bin/bash

_vpath=..
if [ ! -z "$VPATH" ]; then
    _vpath=$VPATH
fi

source $_vpath/default_settings.bash
if [ $? -ne 0 ]; then
    echo "ERROR Could not find: $_vpath/default_settings.bash"
    exit 1
fi
[ -e $_vpath/settings.bash ] && source $_vpath/settings.bash

# The different settings used in this
vars=(a s d c z b h i l)

ptr_declarations ${vars[@]} > var_declarations.inc
{
    _psnl "type :: pta_"
    _psnl " type(pta__), pointer :: p(:) => null()"
    _psnl "end type pta_"
    _psnl "type :: pta__"
    _psnl " character(len=1), pointer :: p => null()"
    _psnl "end type pta__"
    _psnl "type(pta_) :: pa_"
} >> var_declarations.inc
ptr_declarations -count 2 ${vars[@]} > var_declarations2.inc
{
    _psnl "type :: pta_"
    _psnl " type(pta__), pointer :: p(:) => null()"
    _psnl "end type pta_"
    _psnl "type :: pta__"
    _psnl " character(len=1), pointer :: p => null()"
    _psnl "end type pta__"
    _psnl "type(pta_) :: pa__1, pa__2"
} >> var_declarations2.inc

# Print out to the mod file
{
for sub in assign associate associatd ; do
args="get set"
[ "$sub" == "associatd" ] && args="l r"
_psnl "interface $sub"
# Add the character(len=*)
case "$sub" in
    assign)
	# Add the character(len=*)
	modproc $sub a "0_0" get set
	# Add the variable
	modproc $sub var ""
	;;
    associate)
	# Add the variable
	modproc $sub var ""
	;;
esac
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	modproc $sub $v $d $args
    done
done
_psnl "end interface"
_psnl "public :: $sub"
done
if [ 1 -eq 0 ]; then
for sub in eq ne lt gt ge le ; do
_psnl "interface operator(.$sub.)"
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	modproc $sub $v $d l r
    done
done
modproc $sub v 0
_psnl "end interface"
_psnl "public :: operator(.$sub.)"
done
fi
} > var_interface.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if (this%t == '$v$d') then"
	_psnl "  p$v$d = transfer(this%enc,p$v$d)"
	if [[ $v == "V" ]]; then
	    _psnl "  p$v$d%p = ''"
	fi
	_psnl "  deallocate(p$v$d%p)"
	_psnl "end if"
    done
done
} > var_delete.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if ( this%t == '$v$d' ) then"
	_psnl "#define DIM $d"
	_psnl '#include "settings.inc"'
	_psnl "p$v${d}_2 = transfer(rhs%enc,p$v${d}_2)"
	_psnl "ALLOC(p$v${d}_1%p,p$v${d}_2%p)"
	_psnl "#undef DIM"
	[ $d -lt $(var_N $v) ] && _ps "else"
    done
    _psnl "endif"
done
} > var_var_alloc.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if ( this%t == '$v$d' ) then"
	_psnl "p$v${d}_1%p = p$v${d}_2%p"
	_psnl "allocate(this%enc(size(transfer(p$v${d}_1, local_enc_type))))"
	_psnl "this%enc = transfer(p$v${d}_1, local_enc_type)"
	[ $d -lt $(var_N $v) ] && _ps "else"
    done
    _psnl "endif"
done
# In case the variable is a user-type, then we
# copy the encoding, probably this is a bit wearing, but
_psnl "if ( this%t == 'USER' ) then"
_psnl "write(*,'(a)') 'var: Cannot assign a UT, USE call associate(..)'"
_psnl "end if"
} > var_var_set.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if ( this%t == '$v$d' ) then"
	_psnl "p$v${d}_1 = transfer(this%enc,p$v${d}_1)"<commit_msg>bug: final fix for LHS re-allocation<commit_after>#!/bin/bash

_vpath=..
if [ ! -z "$VPATH" ]; then
    _vpath=$VPATH
fi

source $_vpath/default_settings.bash
if [ $? -ne 0 ]; then
    echo "ERROR Could not find: $_vpath/default_settings.bash"
    exit 1
fi
[ -e $_vpath/settings.bash ] && source $_vpath/settings.bash

# The different settings used in this
vars=(a s d c z b h i l)

ptr_declarations ${vars[@]} > var_declarations.inc
{
    _psnl "type :: pta_"
    _psnl " type(pta__), pointer :: p(:) => null()"
    _psnl "end type pta_"
    _psnl "type :: pta__"
    _psnl " character(len=1), pointer :: p => null()"
    _psnl "end type pta__"
    _psnl "type(pta_) :: pa_"
} >> var_declarations.inc
ptr_declarations -count 2 ${vars[@]} > var_declarations2.inc
{
    _psnl "type :: pta_"
    _psnl " type(pta__), pointer :: p(:) => null()"
    _psnl "end type pta_"
    _psnl "type :: pta__"
    _psnl " character(len=1), pointer :: p => null()"
    _psnl "end type pta__"
    _psnl "type(pta_) :: pa__1, pa__2"
} >> var_declarations2.inc

# Print out to the mod file
{
for sub in assign associate associatd ; do
args="get set"
[ "$sub" == "associatd" ] && args="l r"
_psnl "interface $sub"
# Add the character(len=*)
case "$sub" in
    assign)
	# Add the character(len=*)
	modproc $sub a "0_0" get set
	# Add the variable
	modproc $sub var ""
	;;
    associate)
	# Add the variable
	modproc $sub var ""
	;;
esac
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	modproc $sub $v $d $args
    done
done
_psnl "end interface"
_psnl "public :: $sub"
done
if [ 1 -eq 0 ]; then
for sub in eq ne lt gt ge le ; do
_psnl "interface operator(.$sub.)"
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	modproc $sub $v $d l r
    done
done
modproc $sub v 0
_psnl "end interface"
_psnl "public :: operator(.$sub.)"
done
fi
} > var_interface.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if (this%t == '$v$d') then"
	_psnl "  p$v$d = transfer(this%enc,p$v$d)"
	if [[ $v == "V" ]]; then
	    _psnl "  p$v$d%p = ''"
	fi
	_psnl "  deallocate(p$v$d%p)"
	_psnl "end if"
    done
done
} > var_delete.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if ( this%t == '$v$d' ) then"
	_psnl "#define DIM $d"
	_psnl '#include "settings.inc"'
	_psnl "p$v${d}_2 = transfer(rhs%enc,p$v${d}_2)"
	_psnl "ALLOC(p$v${d}_1%p,p$v${d}_2%p)"
	_psnl "#undef DIM"
	[ $d -lt $(var_N $v) ] && _ps "else"
    done
    _psnl "endif"
done
} > var_var_alloc.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if ( this%t == '$v$d' ) then"
	_psnl "p$v${d}_1%p = p$v${d}_2%p"
	_psnl "allocate(this%enc(size(transfer(p$v${d}_1, local_enc_type))))"
	_psnl "this%enc(:) = transfer(p$v${d}_1, local_enc_type)"
	[ $d -lt $(var_N $v) ] && _ps "else"
    done
    _psnl "endif"
done
# In case the variable is a user-type, then we
# copy the encoding, probably this is a bit wearing, but
_psnl "if ( this%t == 'USER' ) then"
_psnl "write(*,'(a)') 'var: Cannot assign a UT, USE call associate(..)'"
_psnl "end if"
} > var_var_set.inc


{
for v in ${vars[@]} ; do
    md=0
    [ $v == 'a' ] && md=1
    for d in `seq $md $(var_N $v)` ; do
	_psnl "if ( this%t == '$v$d' ) then"
	_psnl "p$v${d}_1 = transfer(this%enc,p$v${d}_1)"
{'fraction_non_alphanumeric': 0.19471709006928406, 'fraction_numerical': 0.010392609699769052, 'mean_word_length': 3.117052881758764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1949290', 'n_tokens_mistral': 3103, 'n_tokens_neox': 3034, 'n_words': 884}