WANtaroHP (Miscellany)

toJA

Outline of this page

Contents


Bubble sort and Shell sort

Outline of this program

Source code by f90

FilenameDescription
program for sorting of real numbers


Bubble sort of character string

Outline of this program

Source code by f90

FilenameDescription
program for sorting of character strings


Random numbers

Outline of this program

Source code by f90 and output sample by GMT

FilenameDescription
program for random number generation
Sample figure of uniform random numbers by GMT
Sample figure of normal random numbers by GMT


Get date and time

Outline of this program

Source code by f90

FilenameDescription
Program to get date and time


Get calculation time

Outline of this program

Source code by f90

FilenameDescription
Program to get calculation time


Convert Decimal digits to Hexadecimal digits

Outline of this program

Source code by f90

FilenameDescription
Program to convert Decimal digits to Hexadecimal digits


Create color strip gif images and HTML file to show them

Outline of this program

gfortran -o f90_COL_HTML.exe f90_COL_HTML.f90

f90_COL_HTML n c:\WANtaroHP_COL\col_inp_GPL.txt c:\WANtaroHP_COL\zesubGPLcol.html
f90_COL_HTML n c:\WANtaroHP_COL\col_inp_GMT.txt c:\WANtaroHP_COL\zesubGMTcol.html
f90_COL_HTML n c:\WANtaroHP_COL\col_inp_IMK.txt c:\WANtaroHP_COL\zesubIMKcol.html

In above commands, argument n is flag for making gif image. In this case, gif images of color strip are not created by ImageMagick. If y is inputted, ImageMagick makes many gif images of color strip.

Source code by f90

FilenameDescription
Program to create gif image and show them by HTML
Input data for GMT color
Input data for gnuplot color
Input data for ImageMagick color

Awk script for HTML color

For HTML color, following awk script and data are used. Commands for execution of awk script is shown below.

gawk -f awk_html_col.awk dat_html_col.txt > zesubHTMLcol.html
FilenameDescription
Awk script to show color strips by HTML
Input data for HTML color


Create font strip gif images and HTML file to show them

Outline of this program

gfortran -o f90_IMFONT.exe f90_IMFONT.f90

f90_IMFONT n c:\WANtaroHP_Font\inp_fname.txt c:\WANtaroHP_Font\zesubIMKfont.html

In above commands, argument n is flag for making gif image. In this case, gif images of font strip are not created by ImageMagick. If y is inputted, ImageMagick makes many gif images of font strip.

Source code by f90

FilenameDescription
Batch file for making input data file (including awk script)
Program to create gif image and show them by HTML
Input data of font name


Get the distance between 2 points with longitudes and latitudes

Outline of this program

Commandline input/output

Sample batch file for execution of F90 program and result

Batch file
gfortran -o f90_DIST.exe f90_DIST.f90

rem distance from Kuala Lumpur to Tokyo
f90_DIST 101.55 3.117 139.76 35.69

rem distance from Kuala Lumpur to Jakarta
f90_DIST 101.55 3.117 106.833 -6.183

rem distance from Kuala Lumpur to Bangkok
f90_DIST 101.55 3.117 100.567 13.733

rem distance from Kuala Lumpur to Vientiane
f90_DIST 101.55 3.117 102.567 17.95

rem distance from Kuala Lumpur to Ha Noi
f90_DIST 101.55 3.117 105.800 21.017

rem distance from Kuala Lumpur to Seoul
f90_DIST 101.55 3.117 126.967 37.567

rem distance from Kuala Lumpur to Beijing
f90_DIST 101.55 3.117 116.283 39.933
Result
Location     Lon(deg) Lat(deg) GSI(km)   L-A(km)   Hubeny(km)
Kuala Lumpur 101.550   3.117   ---       ---       ---
Tokyo        139.760  35.690   5332.871  5332.837  5395.254
Jakarta      106.833  -6.183   1184.251  1184.231  1184.532
Bangkok      100.567  13.733   1179.183  1179.106  1179.090
Vientiane    102.567  17.950   1644.567  1644.533  1644.471
Ha Noi       105.800  21.017   2033.151  2033.150  2033.494
Seoul        126.967  37.567   4612.771  4612.781  4646.478
Beijing      116.283  39.933   4339.904  4339.820  4352.810
  • GSI: Geospatial Information Authority of Japan
    • http://vldb.gsi.go.jp/sokuchi/surveycalc/bl2stf.html
  • L-A: Lambert-Andyer's formula
  • Hubeny: Hubeny's formula

Source code by f90

FilenameDescription
Program to calculate the distance between 2 points

File input and output of distance matrix

Sample batch file for execution of F90 program

gfortran -o f90_DIST1.exe f90_DIST1.f90

f90_DIST1 inp_city.txt out_city.csv

Source code by f90

FilenameDescription
Program to calculate the distance between 2 points (Lambert-Andyer's formula)
Input data sample
Output data sample


Create Calender by html document

Outline of this program

Batch file for execution

01 | rem **************************
02 | rem Required files
03 | rem   inp_2013_2nd_half.txt
04 | rem   f90_CALDAT.f90
05 | rem   f90_CALENDER.f90
06 | rem   f90_CALSMALL.f90
07 | rem **************************
08 |
09 | gfortran -o f90_CALDAT.exe f90_CALDAT.f90
10 | f90_CALDAT 240 60 192 64 255 192
11 | rem f90_CALDAT 240 60 255 255 255 255
12 |
13 | gfortran -o f90_CALENDER.exe f90_CALENDER.f90
14 | f90_CALENDER 20130125 inp_2013_2nd_half.txt cal_201301.html
15 | f90_CALENDER 20130225 inp_2013_2nd_half.txt cal_201302.html
16 | f90_CALENDER 20130325 inp_2013_2nd_half.txt cal_201303.html
17 | f90_CALENDER 20130425 inp_2013_2nd_half.txt cal_201304.html
18 | f90_CALENDER 20130525 inp_2013_2nd_half.txt cal_201305.html
19 | f90_CALENDER 20130625 inp_2013_2nd_half.txt cal_201306.html
20 | f90_CALENDER 20130725 inp_2013_2nd_half.txt cal_201307.html
21 | f90_CALENDER 20130825 inp_2013_2nd_half.txt cal_201308.html
22 | f90_CALENDER 20130925 inp_2013_2nd_half.txt cal_201309.html
23 | f90_CALENDER 20131025 inp_2013_2nd_half.txt cal_201310.html
24 | f90_CALENDER 20131125 inp_2013_2nd_half.txt cal_201311.html
25 | f90_CALENDER 20131225 inp_2013_2nd_half.txt cal_201312.html
26 |
27 | gfortran -o f90_CALSMALL.exe f90_CALSMALL.f90
28 | f90_CALSMALL 2011 cal_all_2011.html
29 | f90_CALSMALL 2012 cal_all_2012.html
30 | f90_CALSMALL 2013 cal_all_2013.html
31 | f90_CALSMALL 2014 cal_all_2014.html
32 |
33 | del img1.png
34 | del img2.png
35 | del imgm.png
36 | del temp1.png
37 | del temp2.png
38 | del tempi.png
01-07
Comments
09-10
Compile and execute the program of f90_CALDAT
13-25
Compile and execute the program of f90_CALENDER
27-31
Compile and execute the program of f90_CALSMALL
33-38
Delete work files for making image

Arguments in command line for f90_CALDAT

This program can define the color of calender and create the top page for showing calender.

f90_CALDAT Hmax Hmin Smax Smin Vmax Vmin
f90_CALDATexecuted program name
Hmax, HminMaximim and minimum value of H in HSV color model
Smax, SminMaximim and minimum value of S in HSV color model
Vmax, VminMaximim and minimum value of V in HSV color model

In the sample baych file shown above, monthly average temperatures in Maebashi are related using following manner.

Temperature Min. ⇐ Middle ⇒ Max.
Hue Max. ⇐ Middle ⇒ Min.
Saturation Min. ⇐ Middle ⇒ Max.
Value Min. ⇐ Middle ⇒ Max.

Average temperatures in Maebashi which is used as input data are defined as following code in the program of f90_CALDAT.f90.

real(4)::Te(1:12)=(/3.3,3.6,6.9,12.9,17.7,21.2,24.7,26.1,21.9,16.1,10.5,5.8/)

Arguments in command line for f90_CALENDER

This program can create a calender for specified one month.

f90_CALENDER yyyymmdd fnameR fnameW
f90_CALENDERexecuted program name
yyyymmdd specified date (yyyy: year, mm: month, dd: day)
fnameR Input file name for comments (it shall be text file)
fnameW Output file name (it shall be html file)

Arguments in command line for f90_CALSMALL

This program can create all days calender for specified one year.

f90_CALSMALL yyyy fnameW
f90_CALSMALLexecuted program name
yyyy specified year
fnameW Output file name (it shall be html file)

Source code by f90 and related documents

FilenameDescription
F90 program source
F90 program source (one month calender)
F90 program source (one year calender)
Input file for comments
Top page for showing calender


Create Color circle based on HSV color model by GMT

Outline of this program

Difinition of Hue
Range of angleRGBColoe name
0/60 max min->maxmin Red->Yellow
60/120 max->minmax min Yellow->Lime
120/180min max min->maxGreen->Cyan
180/240min max->minmax Cyan->Blue
240/300min->maxmin max Blue->Magenta
300/360max min max->minMagenta->Red
Range of variables
R G B H S V
Max.255 255 255 359 255 255
Min.0 0 0 0 0 0
Kindintegerintegerintegerintegerintegerinteger
R: red, G: green, B: blue
H: hue, S: saturation, V: value
colcurc0 colcurc1 colcurc2
colcurc3 colcurc4 colcurc5

Batch file for execution

gfortran -o f90_COLCIRC.exe f90_COLCIRC.f90

f90_COLCIRC 1 255 255 > bat_gmt_exe.bat
set fig=fig_gmt_colcirc1.eps
call bat_gmt_colcirc

f90_COLCIRC 1 128 255 > bat_gmt_exe.bat
set fig=fig_gmt_colcirc2.eps
call bat_gmt_colcirc

f90_COLCIRC 1 255 192 > bat_gmt_exe.bat
set fig=fig_gmt_colcirc3.eps
call bat_gmt_colcirc

f90_COLCIRC 1 128 192 > bat_gmt_exe.bat
set fig=fig_gmt_colcirc4.eps
call bat_gmt_colcirc

f90_COLCIRC 60 255 255 > bat_gmt_exe.bat
set fig=fig_gmt_colcirc0.eps
call bat_gmt_colcirc

del _*

Program name executed is f90_COLCIRC. Command line arguments are 'Increment of H-value', 'S-value', 'V-value' in HSV-color system and 'Output file name'. In the output file, the parts of commands for GMT are written, and another control file is required to execute GMT.

Source code by f90 and related documents

FilenameDescription
Program to create a part of GMT commands
Batch file for GMT execution (control)
Sample of GMT commands created by Fortran program


Create Color strips based on HSV color model by ImageMagick

Outline of this program

H S=255S=128S= 64S= 64S= 32S= 16
(deg)V=255V=255V=255V=192V=192V=192
0 LM LM LM LM LM LM
30 LM LM LM LM LM LM
60 LM LM LM LM LM LM
90 LM LM LM LM LM LM
120 LM LM LM LM LM LM
150 LM LM LM LM LM LM
180 LM LM LM LM LM LM
210 LM LM LM LM LM LM
240 LM LM LM LM LM LM
270 LM LM LM LM LM LM
300 LM LM LM LM LM LM
330 LM LM LM LM LM LM

Batch file for execution

gfortran -o f90_HSVrgbHEX.exe f90_HSVrgbHEX.f90

f90_HSVrgbHEX

Source code by f90 and related documents

FilenameDescription
Program to create a part of GMT commands
Batch file for ImageMagick by F90 program (control)
ImageMagick commands


Point inclusion test for plane polygon

Outline of this program

Sample input data

2                         Number of domain
8                         Number of coordinates for the first domain
 0.7  0.0                 (x,y) coordinates for the first domain
 0.1  0.1
 0.0  0.7
-0.1  0.1                  (Definition of the blue area in the sample drawing)
-0.7  0.0
-0.1 -0.1
 0.0 -0.7
 0.1 -0.1
8                         Number of coordinates for the second domain
 0.50  0.50               (x,y) coordinates for the second domain
 0.05  0.00
 0.50 -0.50
 0.00 -0.05                (Definition of the green area in the sample drawing)
-0.50 -0.50
-0.05  0.00
-0.50  0.50
 0.00  0.05
200000                    Number of coordinates for the inclusion test
-0.524425 -0.417869       (x,y) coordinates for the testing
0.691628 -0.695583        Total number of inputted coordinates is 200,000.
0.171075 -0.613049        The ranges of coordinates are (x,y)=(-1 / 1, -1 / 1).
・・・・・

Sample batch file for execution

gfortran -o f90_DOMAIN.exe f90_DOMAIN.f90

f90_DOMAIN inp_dom2.txt

rem *** GMT commands for drawing ***
set range=-1/1/-1/1
set paper=10/10
set inp0=_mat_00.txt
set inp1=_mat_01.txt
set inp2=_mat_02.txt
set fig=fig_gmt_dom2.eps
psxy %inp1% -R%range% -JX%paper% -SC0.01 -G0/0/255 -P -K > %fig%
psxy %inp2% -R -J -SC0.01 -G0/255/0 -O -K >> %fig%
psxy %inp0% -R -J -SC0.01 -G255/0/0 -O >> %fig%

Sample drawing

Sample drawing is made based on following rules.

LM

Source code by f90 and related documents

FilenameDescription
f90 program code

toJA
inserted by FC2 system