Skip to content

Instantly share code, notes, and snippets.

View drikosev's full-sized avatar

Evangelos Drikos drikosev

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
struct dim {
int lower;
int upper;
};
struct array {
@drikosev
drikosev / Dictionary.txt
Last active February 11, 2022 08:18
BOZ Literal Constants in function "ulen"
This Fortran/C interoperability example implements a static dictionary
containing <numeric key, unicode text> pairs, which are defined in file
"dictionary.c" and a Fortran program ie can print them in a terminal.
To build the project in a Linux, MacOS, or Cygwin terminal you can use
the Makefile. If you have GNU Fortran installed, then just type "make".
In Windows 8.1 ie run dictionary.exe in a blue PowerShell Console.
Sep 16, 2019
Ev. Drikos
The program in this gist demonstrates how one can achieve
default initialization on Fortran derived types, since the
language does not inherently support such a functionality.
In Specific, Fortran allows the instantiation of an object
! Profiled: 23ms (total time varies per optimization level)
! start libdyld.dylib: 12ms (52.1%)
! main program run: 11ms (47.8%)
! findloc: 9.1% of 11ms
! [The above representative percentages vary per run]
! Compiler: GNU Fortran 4.8.5 (github.com/drikosev/pc)
! Profiler: Instruments 9.3
! OS: macOS 10.13
! Computer: MBPR 2013 - 2,4 GHz Intel Core i7
! { dg-do run }
! { dg-options "-fopenmp" }
! By default: -fallow-invalid-boz
! By default: Warn only few known non portable uses
! whereas -Wno-invalid-boz disables all related warnings,
! and -Winvalid-boz enables all related warnings.
program boz_extensions
integer, parameter :: p0 = Z'1234'
real,parameter :: rc = real(z'50CB9F09')
module m_type0
type :: Type0
contains
procedure :: eq => eq0
end type Type0
contains
logical function eq0(this,b)
@drikosev
drikosev / realloc_class_0.f90
Last active January 19, 2021 09:50
Deallocations on Intrinsic Assignment
! { dg-do run }
! { dg-shouldfail "Fortran runtime error: Assignment with unallocated RHS 'w'" }
! { dg-output "Fortran runtime error: Assignment with unallocated RHS 'w'" }
! Catch a Runtime error on intrinsic assignment of
! a class LHS with an unallocated RHS.
module testmode
implicit none
@drikosev
drikosev / m_sys.f90
Last active March 1, 2021 22:14
Hardcode or find at Runtime OS Name and File Separator in Fortran (by m_sys.java).
module m_sys
implicit none
public get_os_name
public get_user_home
public get_arg_prefix
public get_file_sep
character(len=20), save :: os_name = ' '
character(len=255), save :: homedir = ' '
! CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
! 10 - no equal sign required
! 11 - equal sign required
integer :: icep = 302 !ie
integer :: nn
character(2) :: ch
character(1050) :: go
parameter(go = &
!01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 & ! cells col
<sql-implementation> ::=
<direct SQL statement>
<direct SQL statement> ::=
[ <separator> ] <directly executable statement> <semicolon>
<separator> ::=
{ <comment> | <white spaces> } ...
<comment> ::=