Tuesday, December 25, 2007

Notes Matlab

Notes Matlab
============

Contents
=========
Help
MEX - C


MEX - C
========

A list of mx-MEX functions is found in:
Help -> MATLAB -> C and Fortran Functions

Mex interface in C code:
******************
void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
/* more C code ... */
******************



Help:
=====
>matlab -help

Setup Matlab's path - save the following into startup.m
*********************
% Add my test directory as the first entry
% on MATLAB's search path

path('/import/george/Applied/chee/programs/RKohn/SallyW',path)
*********************

To Run Matlab m-file, just type the name WITHOUT the ".m"
eg to run Hello.m, type "Hello"


Running Matlab:
1. GUI environment: /usr/local/matlab/bin/matlab
2. NO GUI: /usr/local/matlab/bin/matlabl -nojvm



*********************
RESHAPE

>> crshp(:,:,1)=[1,2,3,4;5,6,7,8;9,10,11,12]
>> crshp(:,:,2)=[13,14,15,16;17,18,19,20;21,22,23,24]
crshp(:,:,1) =
1 2 3 4
5 6 7 8
9 10 11 12
crshp(:,:,2) =
13 14 15 16
17 18 19 20
21 22 23 24

>> reshape(crshp(:,:,1), 12, 1)
ans =
1
5
9
2
6
10
3
7
11
4
8
12

Monday, November 26, 2007

Notes Joomla

Notes Joomla
================

HowTos
Install on Localhost
Transfer from localhost
Errors


HowTos
========
How to hide Details of Author, Category, Published, Hits for articles?
- Ensure each article set to global
- Go to Component - Articles, then select Show/Hide for each of Author, Category, Published, Hits

How to display template?
After selecting templates, go to Extension -> Discover

How to create a banner
- From Components - Banner
-- create a New client
-- create a New category
-- create a New banner, choose the created client and category
- From Extensions - Modules
-- create Banner (Module Type), and assign the previously created banner.



Install on Localhost
========================
https://sourceforge.net/projects/xampp/
Download XAMPP first (Windows/Linux) - which has got all necessary server components for Joomla.
Eg Apache, MySQL, PhP, etc

On Windows, DO NOT install from *.exe, instead use the 7z version of installer and unpack to c:\xampp

On Windows7, it may complain about:
"The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem"
Solution:
Download from 'official' Microsoft site only, the update for Universal C Runtime:
https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows
Choose: "All supported x64-based versions of Windows 7" or similar.

You may also need to install the " Microsoft Visual C++ Redistributable for Visual Studio 2017" from:
https://support.microsoft.com/en-au/help/2977003/the-latest-supported-visual-c-downloads

To run XAMPP (on Win7):
- go to c:\xampp
- run: xampp-control.exe
- start these: Apache, MySQL
- Check Apache by using a browser and go to: http://localhost
- Check MySQL by  using a browser and go to: http://localhost/phpmyadmin

Now ready to install Joomla
- Download the package, eg Joomla_3.9.1-Stable-Full_Package.zip
- Configure Joomla for FIRST TIME, by going to: http://localhost
-- Page1, enter Site: eg blah.com   email: pck..@gmail  user:pck...   pass: usual web
-- Page2 DB questions:  local MySQLi: user/pwd:root/blank  DBname: joomla391  Prefix: jstg3_
- Installed webpages are:
Joomla: http://localhost
Joomla admin page: http://localthost/administrator



Transfer from localhost
========================
Three step process.

1. Zip and transfer the Joomla public directory
- use 7zip to zip up public_html directory or similar.
- upload zip file to destination Joomla folder.
- while in CPanel or similar, click Extract on the zip file.
- put the contents in public_html in destination

2. Export the MySQL DB from localhost, and then import while on the destination's DB.
- login to phpAdmin and connect to source Joomla's DB
- Export the DB (use custom option)
- login to phpMyAdmin and connect to destination Joomla's DB
- manually create the same DB, eg joomla391, with same name as original DB.
- Import the DB file.

3. Modify the config.php file
$dbtype
$host
$user
$password
$db
$dbprefix
$log_path - eg 'public_html/blah/joomla/logs'
$tmp_path - eg 'public_html/blah/joomla/tmp'




Errors

=======

Message: "Error on page" at the bottom left corner of browser

Cause: ...

Solution: Check the entry in public_html\configuration.php for the value of $mosConfig_sitename. If the value is "mydomain.org" instead of "www.mydomain.org", then need to go into administrator as http://mydomain.org/administrator, i.e. without "www"

Tuesday, October 30, 2007

Notes CSS

NotesCSS
=========



Contents
=========
References
Basic Syntax
Examples
Class Selectors
Inserting Stylesheet
Margins


References
===========
1. http://www.htmlhelp.com/reference/css/structure.html#pseudo
2. http://www.w3schools.com/css/css_syntax.asp


Basic Syntax
=============

General Syntax:
<Selector> { <Property> : <Value> ; [<Property> : <Value>] }

Selector is HTML tag, eg:
body, p, etc......
Property is HTML attribute eg:
color, font-family
Value is value of the HTML attributes


Examples
==========
body {color: black} -> simple example
p {font-family: "sans serif"} -> multiple worded Value
p {text-align:center;color:red} -> multiple Property

p -> alternative layout syntax
{
text-align: center;
color: black;
font-family: arial
}

h1,h2,h3,h4,h5,h6 -> multiple selector with same property
{
color: green
}

p.right {text-align: right} -> <p class="right"> This paragraph will be right-aligned.</p>

p.right {text-align: right} -> <p class="right centre"> This paragraph will be right-aligned.</p>
p.center {text-align: center}

.center {text-align: center} -> applies to ALL selector with class "center"

#green {color: green} -> applies to ALL id="green" selector, eg <p id="green"> .....

p#para1 -> applies to p selector with id="para1", eg <p id="para1"> .....
{
text-align: center;
color: red
}

input[type="text"] {background-color: blue} -> apply to selectors with certain elements, eg input-type

/* this is a comment */ -> comments

Class Selectors
================
<div class="sidenav">
<h2> Site navigation</h2>
</div>

div.sidenav { blah } /* styles overall div */
div.sidenav h2 { blah } /* styles h2 within the div */

ID Selectors
=============
#navigation { width: 12em; color: #333; }
div#navigation { width: 12em; color: #333; }



The major difference is that IDs can only be applied once per page,
while classes can be used as many times on a page as needed.

Classes can be used as many times as needed within a document.
IDs can only be applied once within a document.
So, if you need to use the same specific selector more than once, classes are a better choice.



Inserting Stylesheet
=======================

Cascading Order from least to most important:
- Browser default
- External style sheet
- Internal style sheet (inside the <head> tag)
- Inline style (inside an HTML element)


External style sheet
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css" />
</head>


Internal style sheet (inside the <head> tag)
<head>
<style type="text/css">
hr {color: sienna}
p {margin-left: 20px}
body {background-image: url("images/back40.gif")}
</style>
</head>


Inline style (inside an HTML element)
<p style="color: sienna; margin-left: 20px">
This is a paragraph
</p>


Multiple Sytlesheets
- in external CSS:
h3 {color: red;text-align: left;font-size: 8pt}
- in internal CSS:
h3 {text-align: right; font-size: 20pt}

Then the result will be:
color: red; text-align: right; font-size: 20pt


Margins
========

BODY { margin: 5em } /* all margins 5em */
P { margin: 2em 4em } /* top and bottom margins 2em,
left and right margins 4em */
DIV { margin: 1em 2em 3em 4em } /* top margin 1em,
right margin 2em,
bottom margin 3em,
left margin 4em */

Wednesday, October 24, 2007

Notes Windows Power Shell

Notes Windows Power Shell
=======================


Contents
=========
Commands
Scripting
Printing
Digital Signing and Certificates
Search





Commands
=========
get-alias list the real name of old command
get-content list contents of file
get-help get-service help on get-service command
get-command *-service list commands that manipulate services
get-member list the members of the object
get-service list the services running
| Out-Host -Paging prints one page at a time, user scrolling


Scripting
============
1. Extension *.ps1 (p-s-One)
2. To run script
/file.ps1 absolute path
./file.ps1 relative path
3. Line continuation '
4. Execution policy to run on local machine,
Set-ExecutionPolicy remoteSigned
5. Comments starts with #


Printing
==========
To print to a printer:
...blah... | Out-Printer -name "\\iaunsw024.au.cbainet.com\SYD48MP-L8-LXOP"

Search
=======
- Select-String
- findstr

Thursday, August 02, 2007

Notes Fortran

NotesFortran

Contents
=========

FORTRAN95 features
!DEC$ - compiler Directives
Keyword - SEQUENCE
Keyword - PURE
Initialize Data with slash /
Subroutines passed as argument of another subroutine
Allocatable Pointers / Array of Pointers
Using pointers in procedures
Dynamic Memory Allocation with Pointers
Declaration Statements for Arrays
Derived Data Types - with pointer components and being used as dummy pointer arguments
OpenMP
Static, Stack, Heap
Converting Integer to Character OR Writing to variable
Handling Character Strings between C# and Fortran
OpenMP programming warnings
Fortran Editors
String Manipulation



FORTRAN95 features
===================
List of F95 features implemented in Intel Fortran

1. FORALL -
2. PURE - for safety - ensure only INTENT(OUT,INOUT) arguments are changed.
3. ELEMENTAL - a type of PURE routine. Allow operation of arrays on element level.
4. CPU_TIME -
5. NULL intrinsic function - allow allocatable arrays to be pointed to this.


!DEC$ - compiler Directives
============================
Compaq (Digital) Visual Fortran (http://www.canaimasoft.com/f90vb/onlinemanuals/usermanual/TH_60.htm)


Compaq's Visual Fortran compiler (CVF) offers a great deal of flexibility to
create DLLs callable from C and/or Visual Basic. The compiler has a good set of
options to modify name-mangling, calling conventions and the method used to pass
arguments. Most of these options can be indicated through the use of compiler
directives (or pragmas) embedded in the source code. CVF compiler directives are
defined as comment lines, starting with DEC$.


To indicate that a subroutine should conform to the standard calling convention,
you add the DEC$ATTRIBUTE STDCALL compiler directive to the declaration of the
subroutine. For example:


subroutine MySub(argument1, argument2)  
   !DEC$ATTRIBUTES STDCALL:: GenDNASequence

In Compaq Visual Fortran, adding the STDCALL attribute also changes the default
method used to pass arguments, so you need to tell the compiler that arguments to
subroutine MySub are passed by reference. You can do this with the
DEC$ATTRIBUTE REFERENCE directive:

subroutine MySub(argument1, argument2)
!DEC$ATTRIBUTES STDCALL:: MySub
!DEC$ATTRIBUTES REFERENCE:: argument1, argument2


Also, when a procedure is declared with the standard calling convention (STDCALL),
Compaq Visual Fortran mangles its name. The name-mangling performed by CVF converts
the name of the procedure to all uppercase, adds an underscore as a prefix to the name,
and appends an at symbol (@) followed by the size of the stack (in bytes) at the end of
the name. The size of the stack is equal to 4 times the number of arguments in the
subroutine. MySub has 2 arguments, so the mangled name will be:


_MYSUB@8


Having to use this name to call our DLL procedure would be awful in most languages,
and illegal in Visual Basic. You can use another DEC$ATTRIBUTES compiler directive to
indicate an alias for the mangled name of the exported subroutine:



!DEC$ATTRIBUTES ALIAS: 'MySub'::MySub



The first argument is the alias (i.e. the name by which the subroutine would be available
to external programs using the DLL), the second argument is the Fortran name of the subroutine.



Finally, to indicate that the subroutine must be exported to the DLL as a public procedure,
you add the DEC$ATTRIBUTES DLLEXPORT compiler directive to the body of the subroutine:

!DEC$ATTRIBUTES DLLEXPORT:: MySub

So the full declaration of MySub would look like this:

subroutine MySub(argument1, argument2)
!DEC$ATTRIBUTES STDCALL:: MySub
!DEC$ATTRIBUTES DLLEXPORT:: MySub
!DEC$ATTRIBUTES ALIAS: 'MySub'::MySub
!DEC$ATTRIBUTES REFERENCE:: argument1, argument2



To create a DLL, you compile and link using the /dll switch. The following command-line
would compile and link MySub.f90 (containing subroutine MySub) into MySub.dll:


f90 MySub.f90 /dll /out:MySub.dll


Keyword - SEQUENCE
===================
SEQUENCE cause the components of the derived type to be stored in the same sequence they are
listed in the type definition. If SEQUENCE is specified, all derived types specified in component
definitions must be sequence types.


Keyword - PURE
===================
Pure Procedures
A pure procedure is a user-defined procedure that is specified by using the prefix PURE (or
ELEMENTAL) in a FUNCTION or SUBROUTINE statement. Pure procedures are a feature of
Fortran 95.
A pure procedure has no side effects. It has no effect on the state of the program, except for the
following:    
• For functions: It returns a value.
• For subroutines: It modifies INTENT(OUT) and INTENT(INOUT) parameters.
The following intrinsic procedures are implicitly pure:    
• All intrinsic functions  
• The elemental intrinsic subroutine MVBITS
• The intrinsic subroutine MOVE_ALLOC
A statement function is pure only if all functions that it references are pure.



Initialize Data with slash /
==============================
Variables are not auto-initialized. To initialize a variable as you declare it,
put the initial value between two slashes. This kind of initialization is done once
when the unit is first loaded, and hence, it should not be used in a subprogram that
gets invoked repeatedly (use an assignment instead). For symbolic constants,
initialization is achieved via the parameter statement.

    character title*20 / 'York' /
    integer*2 count / 0 /
    real*4 amount / 1.0 /
    !---------------------------------------------------
    ! Note that title will have 20 characters even though
    ! we stored only 4 (they will be padded by blanks).


Subroutines passed as argument of another subroutine
======================================================
subroutine subA( subB )

The subroutine named subB needs to be declared EXTERNAL and hence not be in a module.
If a function needs to be in the same module then can be done as follows:

module test
  contains
     subroutine subA(subB)
external subB
     .....
     subroutine subC()
end module
subroutine subB()
   use test
   call subC()
end subroutine


Allocatable Pointers / Array of Pointers
=========================================
REF: Fortran 90/95 for Scientists and Engineers, Stephen J Chapman
1. It is illegal to have array pointers of native data types in Fortran:
   REAL, DIMENSION(:), POINTER :: PTR
   - the dimension attribute refers to the pointer's target, not of the pointer.
   - the dimension must be deffered shape and the size is the size of the target, not
     the pointer.
2. It is legal to have array pointers by using derived data types:
  TYPE :: ptr
     REAL, DIMENSION(:), POINTER :: P
  END TYPE
  TYPE(ptr), DIMENSION(3) :: P1

REF: Intel Fortran Language Reference
1. In contrast to allocatable arrays, a pointer can be allocated a new target even if it is currently associated with target. The previous association is broken and the pointer is then associated with the new target.
2. If the previous target was created by allocation, it becomes inaccessible unless it can still be referred to by other pointers that are currently associated with it.


Using pointers in procedures
===============================
Pointers may be used as dummy arguments in procedures and may be passed as actual arguments to procedures.
1. If a procedure has dummy arguments with either POINTER or TARGET attributes, then the procedure must have an explicit interface.
2. if a dummy argument is a pointer, then the actual argument passed to the procedure must be a pointer of the same type, kind and rank.
3. a pointer dummy argument must not have the intent attribute
4. a dummy argument cannot appear in an ELEMENTAL procedure in Fortran95.


Dynamic Memory Allocation with Pointers
========================================
REF: Fortran 90/95 for Scientists and Engineers, Stephen J Chapman

REAL, DIMENSION(:), POINTER :: ptr1
ALLOCATE (ptr1(1:10))

This statement creates an unnamed data object of the specified size and the pointer's type and sets the pointer to point to the object. Because the new data object is unnamed, it can only be accessed by using the pointer. After the statement is executed, the association status of the pointer becomes associated. If the pointer was associated with another data object before the ALLOCATE statement is executed, then that association is lost.

The data object created by using the pointer ALLOCATE statement is unnamed and so can only be accessed by the pointer. If all pointers to that memory are either nullified or reassociated, with other targets, then the data object is no longer accessible by the program. The object is still present in memory, but it is no longer possible to use it => MEMORY LEAK.

If a piece of allicated memory is deallocated, then all pointers to that memory should be nullified or reassigned. One of them is automatically nullified by the DEALLOCATE statement, and any others should be nullified in NULLIFY statements.

Declaration Statements for Arrays
===================================
SUBROUTINE SUB(N,C,D,Z)
   REAL, DIMENSION(N,15) :: IARRY        !explicit shape array
   REAL, C(:), D(0:)                     !assumed shape array
   REAL, POINTER :: B(:,:)               !deferred shape array pointer
   REAL, ALLOCATABLE, DIMENSION(:) :: K  !deferred shape allocatable array
   REAL :: Z(N,*)                        !assumed size array

Automatic Arrays - local array in a function, whose size is one of the arguments
Adjustable Arrays - array which is an argument, whose size is also one of the arguments.

To use arrays efficiently, see Optimizing Applications -> Programming Guidelines -> Using Arrays Efficiently.
When passing arrays as arguments, either the starting (base) address of the array or the address of an
array descriptor is passed:
When using explicit-shape (or assumed-size) arrays to receive an array,
the starting address of the array is passed.

When using deferred-shape or assumed-shape arrays to receive an array,
the address of the array descriptor is passed (the compiler creates the array descriptor).

Automatic vs Save
Automatic variables can reduce memory use because only the variables currently being used are allocated to memory.

By default, the compiler allocates local variables of non-recursive subprograms, except for
allocatable arrays, in the static storage area. The compiler may choose to allocate a variable in
temporary (stack or register) storage if it notices that the variable is always defined before
use. Appropriate use of the SAVE attribute can prevent compiler warnings if a variable is used
before it is defined.




Derived Data Types - with pointer components and being used as dummy pointer arguments
========================================================================================
Given a derived data type with pointer arguments:
   type varDDT
      type(BigDDT), pointer :: rComp
   end type
Given that it is used as a dummy pointer argument
   subroutine foo(aDDT)
      type(varDDT), pointer :: aDDT
 ....
    end subroutine

Then, in another function which uses "foo", the DDT can be used as:
program
  type(varDDT), pointer :: aDDT_p
  type(varDDT) :: vDDT

  call testFoo(vDDT)   ! vDDT contains the data found in testFoo
  nullify(aDDT_p)
    end program

    subroutine testFoo(vDDT_local)
  type(varDDT) :: vDDT_local
       aDDT_p => vDDT_local

  call foo(aDDT_p)
       ! vDDT_local will be able to pass to outside routine safely.
    end subroutine


Note that this method is not required if the DDT concerned does not contain components
which are also DDT.


OpenMP
=======

Prerequisite:
Before inserting any OpenMP parallel directives, verify that your code is safe for parallel execution by doing the following:

Place local variables on the stack. This is the default behavior of the Intel Fortran Compiler when -openmp is used.

Use -automatic (or -auto_scalar) to make the locals automatic. This is the default behavior of the Intel Fortran Compiler when -openmp is used. Avoid using the -save option, which inhibits stack allocation of local variables. By default, automatic local scalar variables become shared across threads, so you may need to add synchronization code to ensure proper access by threads.

Static, Stack, Heap
====================
Heap area stores dynamic arrays
Static storage area store variables that are available for the life time of the program.
In C, local variables are stored in the stack.

In Fortran,
"By default, the compiler allocates local scalar variables on the stack. Other, non-allocatable variables of non-recursive subprograms are allocated in static storage by default. This default can be changed through compiler options. Appropriate use of the SAVE attribute may be required if your program assumes that local variables retain their definition across subprogram calls."

For openMP, local variables in Fortran will become automatic and thus stored in the stack. Note that
OpenMP threading model is based on threads and each has its own stack.



"static" as a descriptive term refers to the lifetime of C++ memory or storage locations. There are several types of storage:
        - static
        - dynamic (heap)
        - auto (stack)
A typical storage layout scheme will have the following arrangement, from lowest to highest virtual memory address:
        text (program code)
        static (initialized and uninitialized data)
        heap
        (large virtual address space gap)
        stack
with the heap and stack growing toward each other. The C++ draft standard does not mandate this arrangement, and this example is only an illustration of one way of doing it.


heap-array in Intel Fortran - This option puts automatic arrays and arrays created for temporary computations on the heap instead of the stack.
on Windows:
    /heap-arrays-        = no heap arrays (default)
    /heap-arrays[:size]  = where arrays of size (in kb) or larger are put on the heap.
on Linux:
    -no-heap-arrays        = no heap arrays (default)
    -heap-arrays [size]    = where arrays of size (in kb) or larger are put on the heap.
Example:
    In Fortran, an automatic array gets it size from a run-time expression. For example:
RECURSIVE SUBROUTINE F( N )
INTEGER :: N
REAL :: X ( N )     ! an automatic array
REAL :: Y ( 1000 )  ! an explicit-shape local array on the stack Array X in the example above
                    ! is affected by the heap-array option. Array Y is not.





Converting Integer to Character OR Writing to variable
========================================================
Example:
   CHARACTER(LEN=15), ALLOCATABLE  :: cPctile(:)
   ALLOCATE( cPctile(nPctile) )
   write(cPctile(jj), '(F15.7)') pctile(jj)

The number in pctile(jj) is being written into a CHARACTER variable called cPctile. Note the character has length of
15 which is enough to write 15 characters specified by the Format F15.7.



Handling Character Strings between C# and FortranSubmit New Article
Last Modified On :   December 6, 2009 6:09 PM PST
Rate Please login to rate! Current Score: 0 out of 0 usersPlease login to rate! Current Score: 0 out of 0 usersPlease login to rate! Current Score: 0 out of 0 usersPlease login to rate! Current Score: 0 out of 0 usersPlease login to rate! Current Score: 0 out of 0 users






Handling Character Strings between C# and Fortran
=================================================================

Passing Character Strings as In parameters from C# to Fortran

C# provides built-in reference type "string" representing a string of Unicode characters. It is an alias for String in the .NET Framework. When passing "string" type by value from C# to Fortran function or subroutine platform invoke service copies string parameters, converting them from the .NET Framework format (Unicode) to the unmanaged format (ANSI), if needed. The unmanaged format is null-terminated so the C# method prototype of Fortran function or subroutine must account for the length argument passed along with the string address.


Passing Strings as In/Out parameters from C# to Fortran

Managed strings are immutable, platform invoke does not copy them back from unmanaged memory to managed memory when the function returns. If the Fortran function or subroutine wants In/Out parameters you need use StringBuilder Class in C#. StringBuilder Class represents a string-like object whose value is a mutable sequence of characters.

Fortran subroutine
subroutine FPassStringSub (Int_Arg, Str_In, Str_Out)
!DEC$ ATTRIBUTES DLLEXPORT :: FPassStringSub
integer, intent(in) :: Int_Arg
character*(*), intent(in) :: Str_In
character*(*), intent(out) :: Str_Out
end subroutine



C# method prototype
        [DllImport("FDLL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern void FPASSSTRINGSUB(ref int Int_Arg, string Str_In, StringBuilder Str_Out, int Str_In_Len, int Str_Out_Len);
STR_IN_LEN, int STR_OUT_LEN);



Returning Character Data Types from Fortran to C#

Similar to how C language handles Fortran function returning character data type the corresponding C# method prototype must add two additional arguments to the beginning of the argument list:
-  The first argument is a StringBuilder object where the called function should store the result.
-  The second argument is an int value showing the maximum number of characters that must be returned, padded with blank spaces if necessary.


Fortran function

function FRetString(Int_Arg)
!DEC$ ATTRIBUTES DLLEXPORT :: FRetString
character(*) :: FRetString
integer, intent(in) :: Int_Arg
end function


C# method prototype
        [DllImport("FDLL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern void FRETSTRING(StringBuilder Str_Result, int Res_Len, ref int Int_Arg);



How to avoid Race Conditions in OpenMP programming
===================================================
This section aims to cover a few points to watch for when doing parallel programming using OpenMP in Fortran.
The tips here could also apply to different languages with OpenMP such as C/C++.
1. First danger sign of parallel programming bug is inconsistent behaviour.
2. When a program stalls or hangs indefinitely sometimes, but other times run to completion.
3. When a program crashes sometimes, but other times run to completion.
4. When OpenMP is applied to a higher level function that calls many small low level functions, check  whether module variables have SAVE attribute.
5. If module variables have save attributes, then check if those variables can be declared PRIVATE too so that no outside functions can use them.
6. When the SAVE module variables are being altered in a function in the module, check to see if the function can be encapsulated in a OMP parallel region.
7. When checking for race conditions using tools like Intel Thread Checker, ensure that the number of threads specified is not greater than the number of processors / cores.


Fortran Editors
=================

The following list are GUI based Fortran editors development environment.

Force
http://force.lepsch.com/

Plato - for Silverforst FTN95
http://www.silverfrost.com/16/ftn95/plato.aspx

Photran - on Eclipse IDE
http://www.eclipse.org/photran/

Geany - GTK based
http://www.geany.org/Main/AllFiletypes


There are many other general purpose editors that can edit Fortran including: Vi, Emacs, EditPlus.

String Manipulation
====================
There is a misconception that the string manipulating and handling capabilities are limited. However, it may not be as limited as initially thought. Here are a few useful string handling features from poplular languages that also exist in Fortran.

Comparing Substring:
   INDEX( string, substring) -> returns integer representing the first position of occurance of the substring in string.
   Converting Integer to String
write(charWord, '(I5)') ii-1
where ii is an integer which is written to the character variable 'charWord'.

Thursday, July 26, 2007

Notes Video Capture

Notes Video Capture
===================

See also NotesDVD

Contents
=========
Abstract
Capture Video via Virtual Dub
Experiment with Virtual Dub - Video Compression
Compress AVI (video and audio uncompressed) using Virtual DUB.
VirtualDub with DivX

VirtualDub filters plugins
VirtualDub MPEG2 codecs
How to Improve Video Capture Quality


Abstract
==========
These instructions uses
- Virtual Dub
- DivX codec
- mp3 codec
- video capture / tv tuner card

Video capture is done from miniDV camcorder into *.avi file using Virtual Dub.
The second stage compresses the *.avi file into another *.avi file.
Note between the two *.avi processes, an intermediate process is required to extract the sound from the first avi file into a separate wav file.


Capture Video via Virtual Dub
================================
1. Connect AV cable on Canon to COMPOSITE on TV card, yellow-video, red/white-audio

Do NOT
2. Switch on TV View program.
3. Select Video Source on TView program (select until display on PC screen)


DO:
2. Open Virtual Dub
3. File -> Capture AVI (to go to capture mode)
3.5 Video -> Video source -> Video Composite
4. Device -> Conexant Capture
5. File -> Set Capture File (give a filename)
6. Video -> Compression
Cinepak Codec = 6.6:1
Indeo Video 5.1 = 10:1
(Experiment with Virtual Dub - Video Compression)



Experiment with Virtual Dub - Video Compression
=================================================
Set the following:
- Capture - "Hidden display while capture", 29.97 fps
- Video - "Noise reduction enable", "Enable RGB filtering"
- Audio - MP3, 48kBit, 22kHz
- Record Duration about 20s

Uncompressed RGB YUV = 95.977MB
Cinepak Codec = 1.842MB
Indeo 5.1 = 2.734MB
Indeo 3.2 = 7.197MB
Indeo 4.5 = 2.591MB
Intel YUV = 55.044MB
MS Video1 = 41.639MB

MSVideo - Smoothest picture with smallest filesize

Audio better is using:
1) Raw (no compression)
2) Windows Recording Line Volume = 38%, better than higher volume.

Video - choose either
1) Intel YUV (better compression with DivX)
2) MS Video1


Compress AVI (video and audio uncompressed) using Virtual DUB.
===============================================================
1. Exit the capture mode from previous process
2. Open and select the *.avi file which contain the video and uncompressed audio from previous video capture process.
3. Audio - Source Audio, Full processing mode, Compression (mp3, 48kBit, 22kHz)
4. File -> "Save WAV ..." as MP3 - this process strips the sound from the previous *.avi file into a separate *.wav file.
5. Audio -> Audio From Other File - Select the file that was saved.
6. Video -> Full Processing Mode - Compression (DivX, High Quality)
for Good quality DivX, try
6.5 Audio -> Interleaving - adjust by testing if video out of sync with audio
7.File -> Save as AVI -> this will combine the video from the previous *avi and the newly saved *.wav file to produce a compressed DivX, MP3 *.avi file.
In terms of size, continuing from the experiment, the now compressed files have the following sizes:
IntelYUV_mp3 55.044MB -> 2.046MB
IntelYUV_raw audio 38%Vol 55.416MB -> 1.867MB
MSVideo1 raw audio 40.452MB -> 1.879MB
MSVideo1 raw audio 38%Vol 44.390MB -> 5.443MB


VirtualDub with DivX
======================
1. From the main Menu -> Video -> Compression -> DivX Codex -> Configure
2. In the DivX Codec Properties -> Main -> Profile = "High Definiion Profile" -> Rate Control = "1 Pass" -> Bitrate = 1500 kbps
Fairly good quality vs size -> Profile = "1080HD Profile" -> Encoding Presets = 8 -> Rate Control = "1 Pass" -> Bitrate = 3000 kbps



VirtualDub with DivX
======================
1. From the main Menu -> Video -> Compression -> DivX Codex -> Configure
2. In the DivX Codec Properties -> Main -> Profile = "High Definiion Profile" -> Rate Control = "1 Pass" -> Bitrate = 1500 kbps
      Fairly good quality vs size       -> Profile = "1080HD Profile" -> Encoding Presets = 8 -> Rate Control = "1 Pass" -> Bitrate = 3000 kbps


VirtualDub filters plugins
============================
Filter pack from Dee Mon:
http://www.infognition.com/VDFilterPack/
Jim Leonard's White Balance filter
http://neuron2.net/whitebalance/whitebalance.html

flaXen filter
http://neuron2.net/flaxen/flaxen.html


To use this filter, install Virtual Dub, then install these plugins into the VirtualDub's plugins folder.


VirtualDub MPEG2 codecs
========================
To use the Virtual Dub and encode with the MPEG2, the following codes need to be installed.
Panasonic VfW DV codec
http://www.free-codecs.com/download/panasonic_dv_codec.htm
 Adaptec VfW DV codec
http://www.free-codecs.com/download/adaptec_dvsoft_codec.htm


How to Improve Video Capture Quality
======================================
This step may require additional filters for VirtualDub. See the previous section for filters available for VirtualDub.

White Balance Filter - Jim Leonard
- to correct for white balance problems.
- Example: when the video in general looks orange, blue or too dark.
- may occur when white balance is on automatic mode, so different types of light having different temperatures causes this problem
- this filter can also be used to adjust Hue, Saturation, Intensity, Brightness, Contrast

Deinterlacing filter
- used to remove the effect of interlacing, ie. when not all frames are processed.
- fast motion causes edges of objects to look jagged.
- the filter will also make the video look far sharper

Sharpening Filter
- used when video seem to have soft edges or lack detail.

Dynamic Noise Reduction
- used when video is grainy

Chroma Noise Reduction Filter
- used when there is chroma noise; ie where rainbow effects shimmer across the screen.

VHS filter - flaXen
- used when video has timing issues and skips a bit
- try using the Stabilize section of this filter only

NotesDVD

NotesDVD
=========
(see also NotesDVD)

Contents
=========
PAL/NTSC Aspect Ratio
DVD to DivX



PAL/NTSC Aspect Ratio
======================
Resolutions that video streams can use, are:

720x480 (NTSC, only with MPEG-2)
720x576 (PAL, only with MPEG-2)
704x480 (NTSC, only with MPEG-2)
704x576 (PAL, only with MPEG-2)
352x480 (NTSC, MPEG-2 & MPEG-1)
352x576 (PAL, MPEG-2 & MPEG-1)
352x240 (NTSC, MPEG-2 & MPEG-1)
352x288 (PAL, MPEG-2 & MPEG-1)


PAL/NTSC 720 x 576 / 720 x 480
Size Ratio
720 x 544 1.32:1
640 x 480 1.33:1
592 x 448 1.32:1
544 x 416 1.30:1
512 x 384 1.33:1
448 x 336 1.33:1
400 x 304 1.32:1
384 x 288 1.33:1
336 x 256 1:31:1
320 x 240 1.33:1


PAL/NTSC 720 x 576 / 720 x 480
Size Ratio
720 x 384 1.87:1
640 x 336 1.87:1
576 x 304 1.89:1
512 x 272 1.88:1
480 x 256 1.87:1
448 x 240 1.86:1



DVD to DivX
===========

Summary
1. Rip DVD VOB files from DVD to Hard Drive
2. Convert VOB into AVI
3. Convert VOB into WAV
4. Combine AVI and WAV into another AVI file

Method A: Using mpeg2avi, ac3decode, VirtualDub, Danii's GUI
Step 1 - assuming this is done .....
Step 2 - using mpeg2avi with Danii's GUI
Step 3 - using ac3decode with Danii's GUI
Step 4 - using VirtualDub

Convert VOB into AVI
- open Danii's GUI v0.20
- click MPEG2AVI
- fill in location of:
i) mpeg2avi program
ii) VOB file for single VOB file or
*.lst file for multiple VOB files (containing a list of all VOB files to be combined)
iii) output folder
- click on "DivX Auto"
i) Low motion
ii) 10 Keyframes
iii) 70% compression control
iv) 600 kbps (varies)
v) click Save
- fps = 25 (for PAL)
- q0 High quality
- r1 32bit MMX iDCT
- Output = o8 AVI-YV12 for DivX
- PAL - 4:3
- Crop and Resize (see Resolutions data above)
- Click Create My AVI

Convert VOB into WAV
- open Danii's GUI v0.20
- click AC3DEC
- fill in location of:
i) ac3dec program
ii) VOB file
iii) output folder
- Global Output Gain = 300
- Check - "Span over multiple VOBS automatically"
- Click Create My WAV

Combine AVI and WAV into another AVI file
- open Virtual Dub
- File -> Open video file (output from step 2)
- Video -> Direct Stream Copy (because already compressed to DivX/AVI)
- Audio -> WAV Audio
- Audio -> Full processing mode
- Audio -> Compression - MP3
- Audio -> Interleaving - adjust by testing if video out of sync with audio
- File -> Save As AVI

Saturday, July 21, 2007

Building own PC

Case:
Thermaltake Wing RS100
- $59 http://www.skycomp.com.au/ sydney

Windows Vista Readiness
- check out readiness from
http://www.microsoft.com/windows/products/windowsvista/buyorupgrade/upgradeadvisor.mspx

Thursday, June 14, 2007

NotesWeb

Registering your website
Resources


Resources
==========
https://fontawesome.com/?from=io
http://glyphicons.com/


Registering your website
============================
1. www.google.com/addurl
2. search.yahoo.com/info/submit.html
3. search.msn.com/docs/submit.aspx
4. www.dmoz.org

To analyse your website to see how spiders or bots rate your site:
Submit Express


Search Engine Optimization and SEO Tools



Web Hosting - free ones can be found in:
1. [free-webhosts](http://www.free-webhosts.com/)
2. [Best free web hosting of 2018](https://www.techradar.com/au/news/best-free-web-hosting-sites-of-2018)
- [Infinityfree](https://infinityfree.net/)
- [Freehostia](https://www.freehostia.com/)
- [5GBfree](https://www.5gbfree.com/hosting-plans/)
- [FreeHosting.com](https://www.freehosting.com/client/cart.php)
- [Byethost](https://byet.host/free-hosting)
- [x10hosting](https://x10hosting.com/free-web-hosting)

A few things to consider when choosing Free Webhosting.
1. When they say unlimited or infinite - that cannot be really true. Just remember this.
2. Check if they let you bring your own domain name, if you have already registered elsewhere.
3. If you would like to have multiple sub-websites, eg using multiple technologies like some using Joomla, some using Wordpress, etc, you may need to look for
i) how many databases do they offer?
ii) do they allow subdomains? For example your main site is www.main.com where you use Wordpress. Then you install Joomla on subA subdirectory, then the ability to make subA website to appears as subA.main.com is the subdomain.

For low-cost Webhosting sites - see:
https://www.hostingadvice.com/reviews/cheap/


Wednesday, May 16, 2007

NotesAudio

NotesAudio
===========


Filtering -> Remove Noise from Tape Recording




Filtering -> Remove Noise from Tape Recording
================================================
Using Goldwave Software.

Consider the following files:
SndOrig.wav -> original sound from tape recording with noise
SndNoise.wav -> Sample of white noise from SndOrig.wav
SngGood.wav -> the final improved sound file

1. Open Goldwave software and open the SndOrig.wav file.

2. Copy a section of from SndOrig.wav which is mostly noise (with no music)
and save to SndNoise.wav.

3. Copy the music part that we want from SndOrig.wav to SndGood.wav.
Select (highlight) and copy (Ctrl C) from waveform of SndOrig.wav.
Create a new file (File -> New) at 16bit, mono, 22050Hz (assuming original source is tape recording)
Paste (Ctrl V)

4. Open SndGood.wav and apply lowpass filtering by:
Effect -> Filter -> Lowpass/Highpass
Set initial cutoff freq to 2560Hz
Set to Lowpass
Set to Static
Click OK

5. On the SndGood.wav, increase volume by:
Effect -> Volume -> Change
Increase the volume to over 80% total

6. Open SndNoise.wav and "Select All" and "Copy". The noise wav is now in the clipboard.

7. Open SndGood.wav and reduce noise using the noise profile from clipboard by:
Effect -> Filter -> NoiseReduction
Select "Use Clipboard"
Click OK