Library libohymos

2000/09/03 22:52 update

[ Keywords | Classes | Data | Functions ]

Quick Index

OVERVIEW
HIERARCHY
DEFINE MACROS



Classes

Adder
Data
Template class of Datapack. Derived from Data_pack and Port_type< T>.
Data_pack
abstract class for treating a pair of data time and data value which we call datapack
Delay
Time delay element model
Element
abstract class for element models
I_file
I_file< T> is a class of input port which reads in Data< T> from an input file and sends them.
Input_file
Class of port models of input files
Input_port
abstract class for input ports
JointBl
Joint multiple inputs and output the sum of them
List
OHyMosString
string class
O_file
Object
Base class of all ohymos classes
OhymosOption
OhymosOption treats specification of general options for simulation.
Output_file
Output_port
Base class for creating output ports
Port
Abstract class for creating ports
Port_type
Template class for creating a class which gives data_pack_type
Receive
ReceiveNointp
ReceiveNointp< T> is a class of ports which receive Data< T>
Receive_port
Class for models of receive ports.
Relay
Relay< T> is a class of port which relays Data< T>.
Relay_port
ScfSubSystem
Sub system class confugured from a "structure configuration file"
ScfTotalSystem
total system class confugured from a "structure configuration file"
Send
Send_port
Abstract class for creating send ports.
Sender_port
Abstract class of Sender ports
Sub_system
Total_system
Vary
Template class for treating a variable size array

Back to the top of libohymos


Data

const char Mysdir[] = "OHYMOSSDIR";
typedef int Boolean;
const int DATA2STR_BUFFSIZE = 256;
typedef void (*Clear_function)(void* obj);

Back to the top of libohymos


Global Functions

void Print_comments( FILE* fp_out, char* src_file, int src_line, char* head );
void Eprint( char* src_file, int src_line, char* title, Boolean src_comments );
void Eprint(char* src_file, int src_line, Boolean src_comments ) ;
void Wprint(char* src_file, int src_line, char* title, Boolean src_comments );
void Wprint(char* src_file, int src_line, Boolean src_comments ) ;
void Eprint_memory( char* src_file, int src_line, char* array_typ, int array_len, Boolean src_comments );
void Eprint_memory(char* src_file, int src_line, char* array_typ, Boolean src_comments) ;
void Eprint_memory(char* src_file, int src_line, Boolean src_comments) ;
void Eprint_fopen( char* src_file, int src_line, char* fname, char* mode, Boolean src_comments );
char pick_char(istream& s);
void skip_white_and_char(istream& s, char c);
void str2dstr( char* str, char* dstr, int dstrSize );
void ignore(FILE* fp, char c);
void data2file( float f, FILE* fp );
void data2ofile( float f, FILE* fo );
void data2file(double a, FILE* fp);
void data2ofile(double a, FILE* fo);
void data2file(int k, FILE* fp);
void data2ofile(int k, FILE* fo);
void data2file(long k, FILE* fp);
void data2ofile(long k, FILE* fo);
void dstr2data(char*& data_string, double& a);
void dstr2data(char*& data_string, float& f);
void dstr2data(char*& data_string, int& k);
void dstr2data(char*& data_string, long& k);
void Clf_dp(void* dp) ;
FILE* dataFileOpen(char* fname);
Element_for_test* NewElement() ;
Boolean Init(char* o_name, int o_num, char* p_str ) ;
Element_for_test(char* o_name, int o_num, char* p_str ) ;
Element_for_test(void) ;
~Element_for_test(void) ;
void Pass_whites_and_comments( FILE*& fp, char& current, char comment );
int Get_line_number( FILE*& fp );
Boolean Make_data_string( char* f_name, FILE*& fp, char& current, char*& d_str, int& d_strlen, char head, char tail, char comment, char control );
Boolean Get_string(FILE*& fp, char& current, char*& str, char control);
int Get_strings(FILE*& fp, char& current, char**& str_array, int num_of_strs, char comment, char control);
int khmkdir( char* dir, mode_t mode );

Back to the top of libohymos


const char Mysdir[] = "OHYMOSSDIR";

#include "common.h"

The name of the directorys which contain the source files

Example:

% setenv OHYMOSSDIR "/work;/home/shiiba/Hymos/newhymos"

const char Mysdir[] = "OHYMOSSDIR";

Back to the top of libohymos


typedef int Boolean;

#include "common.h"

Definition of type Boolean

#define NO 0
#define YES 1

typedef int Boolean;

Back to the top of libohymos


void Print_comments( FILE* fp_out, char* src_file, int src_line, char* head );

#include "common.h"

Prints the comments written in the source file 'src_file' to the file to which the file pointer 'fp_out' points. The comment which appears first below the line with line number 'src_line' and subsequent consecutive comments are printed.

void Print_comments(
  FILE* fp_out,   // the comments are printed into 'fp_out'
  char* src_file, // the comments in 'src_file' are processed
  int src_line,   // the comments appears below line number 'src_line'
                  // are processed.
  char* head = "   " // 'head' is printed at the top of each line
);

Back to the top of libohymos


void Eprint( char* src_file, int src_line, char* title, Boolean src_comments );

#include "common.h"

Executes

fprintf(stderr, "E : %s : %d : %s \n", src_file, src_line, title);
and, if 'src_comments' is YES, then executes also
Print_comments(stderr, src_file, src_line);
'exit' is NOT executed in this function.

void Eprint(
  char* src_file, // the name of the source file
  int src_line,   // refer the comments in Print_comments
  char* title,    // string which shows the content of error briefly
  Boolean src_comments = YES
  );

Back to the top of libohymos


void Eprint(char* src_file, int src_line, Boolean src_comments ) ;

#include "common.h"

Executes

fprintf(stderr, "E : %s : %d : %s \n", src_file, src_line, "");
Print_comments(stderr, src_file, src_line);
'exit' is NOT executed in this function.

inline void Eprint(char* src_file, int src_line,
  Boolean src_comments = YES)
                                                   
;

Function is currently defined inline.


Back to the top of libohymos


void Wprint(char* src_file, int src_line, char* title, Boolean src_comments );

#include "common.h"

Executes

fprintf(stderr, "W : %s : %d : %s \n", src_file, src_line, title);
and, if 'src_comments' is YES then executes
Print_comments(stderr, src_file, src_line);

void Wprint(char* src_file, int src_line,
	        char* title, Boolean src_comments = YES);

Back to the top of libohymos


void Wprint(char* src_file, int src_line, Boolean src_comments ) ;

#include "common.h"

Executes

fprintf(stderr, "W : %s : %d : %s \n", src_file, src_line, "");
Print_comments(stderr, src_file, src_line);

inline void Wprint(char* src_file, int src_line,
				   Boolean src_comments = YES)
	                                                 
;

Function is currently defined inline.


Back to the top of libohymos


void Eprint_memory( char* src_file, int src_line, char* array_typ, int array_len, Boolean src_comments );

#include "common.h"

Prints error message showing the occurence of memory shortage and if src_comments is YES then execute

Print_comments(stderr, src_file, src_line);

void Eprint_memory(
  char* src_file,       // the name of the source file in which error
                        // occured
  int src_line,         // the line number where error occured
  char* array_typ,      // the type name of the memory which the user
                        // tried to acquire. ex. "int"
  int array_len,        // the array size
  Boolean src_comments  // whether print the comments in the source file
                        // or not
    // Example
    //  if ((string = new char[16]) == NULL) &(
    //    Eprint_memory(__FILE__, __LINE__, "char", 16, YES);
    //    exit(1);
    //    // memory allocation error
    //  &)
);

Back to the top of libohymos


void Eprint_memory(char* src_file, int src_line, char* array_typ, Boolean src_comments) ;

#include "common.h"

Prints error message showing the occurence of memory shortage. Executes

Eprint_memory(src_file, src_line, array_typ, 0, src_comments)

inline void Eprint_memory(char* src_file, int src_line,
						  char* array_typ,
						  Boolean src_comments)
	                                                                  
;

Function is currently defined inline.


Back to the top of libohymos


void Eprint_memory(char* src_file, int src_line, Boolean src_comments) ;

#include "common.h"

Prints error message showing the occurence of memory shortage. Executes

Eprint_memory(src_file, src_line, "", 0, src_comments)

inline void Eprint_memory(char* src_file, int src_line,
						  Boolean src_comments)
	                                                           
;

Function is currently defined inline.


Back to the top of libohymos


void Eprint_fopen( char* src_file, int src_line, char* fname, char* mode, Boolean src_comments );

#include "common.h"

Print a error message telling that a file cannnot be opened. If src_comments is YES, then execute

Print_comments(stderr, src_file, src_line);

void Eprint_fopen(
  char* src_file, // the name of the source program file where the error
                  // occured.
  int src_line,   // the line number where the error occured.
  char* fname,    // the name of the file which cannot be opened.
  char* mode,     // the file open mode
  Boolean src_comments = YES
  //
  // Example
  //   FILE *fp = fopen("abc.dat", "r");
  //   if (fp == NULL) &(
  //      Eprint_fopen(__FILE__, __LINE__, "abc.dat", "r", YES);
  //      // Cannot open the file.
  //   &)
  //
  );

Back to the top of libohymos


char pick_char(istream& s);

#include "common.h"

Checks the status of istream 's'.

If the status is in such an error state from which it is impossible to recover, then prints error message and exits.

If the status is 'fail' state, then reset the error state to normal state, and reads in the character which caused the error state, and returns the character.

If the status is normal, returns '\0'

istream s の状態を調べ,回復不能のエラー状態にあれば,そのような エラーメッセージを標準エラー出力に書き出して,exit します。fail 状態にあれば,エラー状態を解消し,そのエラーの元になったと思われ る1文字を読みだし,その文字を返します。s の状態が正常であれば, '\0' を返します。

char pick_char(istream& s);

Back to the top of libohymos


void skip_white_and_char(istream& s, char c);

#include "common.h"

Reads in characters from istream 's'. Skips whites spaces and charater 'c'. Character c is skipped only once and when character c is encountered in the second time, character c is pushed back to the stream 's', and exits from the function.

Example

skip_white_and_char(cin, '\"');

void skip_white_and_char(istream& s, char c);

Back to the top of libohymos


const int DATA2STR_BUFFSIZE = 256;

#include "common.h"

DATA2STR_BUFFSIZE

データを文字列に変換する時の文字列のサイズ

const int DATA2STR_BUFFSIZE = 256;

Back to the top of libohymos


void str2dstr( char* str, char* dstr, int dstrSize );

#include "common.h"

Transform string "str" written in "simple data format for input and output" into a data string "dstr". The area for creating the data string "dstr" must be prepared in the unit which calls this function before this function is called. "dstrSize" is the size of the prepared area "dstr".

void str2dstr(
  char* str,
  char* dstr,
  int dstrSize
  );

Back to the top of libohymos


void ignore(FILE* fp, char c);

#include "common.h"

Read character sequence untill it reads the character c. The character sequence including c will be thrown away.

void ignore(FILE* fp, char c);

Back to the top of libohymos


void data2file( float f, FILE* fp );

#include "data2str.h"

Prints a float-type datum into a file in the data format for internal work

void data2file(
  float f,        // float-type datum
  FILE* fp        // file pointer to the file
  );

Back to the top of libohymos


void data2ofile( float f, FILE* fo );

#include "data2str.h"

Prints a float-type datum into a file in the simple data format.

void data2ofile(
  float f,        // float-type datum
  FILE* fo        // file pointer to the file
  );

Back to the top of libohymos


void data2file(double a, FILE* fp);

#include "data2str.h"

Prints a double-type datum into a file in the data format for internal work

void data2file(double a, FILE* fp);

Back to the top of libohymos


void data2ofile(double a, FILE* fo);

#include "data2str.h"

Prints a double-type datum into a file in the simple data format.

void data2ofile(double a, FILE* fo);

Back to the top of libohymos


void data2file(int k, FILE* fp);

#include "data2str.h"

Prints an int-type datum into a file in the data format for internal work

void data2file(int k, FILE* fp);

Back to the top of libohymos


void data2ofile(int k, FILE* fo);

#include "data2str.h"

Prints an int-type datum into a file in the simple data format.

void data2ofile(int k, FILE* fo);

Back to the top of libohymos


void data2file(long k, FILE* fp);

#include "data2str.h"

Prints a long-type datum into a file in the data format for internal work

void data2file(long k, FILE* fp);

Back to the top of libohymos


void data2ofile(long k, FILE* fo);

#include "data2str.h"

Prints a long-type datum into a file in the simple data format.

void data2ofile(long k, FILE* fo);

Back to the top of libohymos


void dstr2data(char*& data_string, double& a);

#include "data2str.h"

Read a double datum from the string starting at data_string and put the pointer data_string further to the next reading point.

データ文字列を double に. データ読み込みのポインタを先へ進めます。

void dstr2data(char*& data_string, double& a);

Back to the top of libohymos


void dstr2data(char*& data_string, float& f);

#include "data2str.h"

Read a float datum from the string starting at data_string and put the pointer data_string further to the next reading point.

データ文字列を float に. データ読み込みのポインタを先へ進めます。

void dstr2data(char*& data_string, float& f);

Back to the top of libohymos


void dstr2data(char*& data_string, int& k);

#include "data2str.h"

Read an int datum from the string starting at data_string and put the pointer data_string further to the next reading point.

データ文字列を int に. データ読み込みのポインタを先へ進めます。

void dstr2data(char*& data_string, int& k);

Back to the top of libohymos


void dstr2data(char*& data_string, long& k);

#include "data2str.h"

Read a long datum from the string starting at data_string and put the pointer data_string further to the next reading point.

データ文字列を long に. データ読み込みのポインタを先へ進めます。

void dstr2data(char*& data_string, long& k);

Back to the top of libohymos


void Clf_dp(void* dp) ;

#include "datapack.h"

Definition of function Clf_dp which is used for deleting list-type object which stores datapack. This function is used in send.cc

inline void Clf_dp(void* dp)                              
;

Function is currently defined inline.


Back to the top of libohymos


FILE* dataFileOpen(char* fname);

#include "dfopen.h"

Creates a temporary data file from the file "fname" and returns the file pointer to that data file. The temporary data file is created by copying the original file "fname" but by removing comment strings that start with "#".

ファイル名 fname を持つファイルから、一時的作業用のデータファ イルを作成し、その一時的作業用のデータファイルへのファイルポ インタを返します。一時的作業用のデータファイルは、元のファイ ル fname を複写し、# で始まるコメント文字列を削除して作成され ます。

When the user executes fclose with the file pointer as the argument, that temporary data file will be automatically deleted.

ユーザが、dataFileOpen が返したファイルポインタを引数として、 関数 fclose を実行すると、その一時的ファイルは自動的に消去さ れます。

Example
FILE* pf = dataFileOpen("datafile.dat");
...
fclose(pf);

FILE* dataFileOpen(char* fname);

Back to the top of libohymos


Element_for_test* NewElement() ;

#include "elm_t.h"

Returns a pointer to a new Element

  virtual Element_for_test* NewElement()                                       
;

Function is currently defined inline.


Back to the top of libohymos


Boolean Init(char* o_name, int o_num, char* p_str ) ;

#include "elm_t.h"

  Boolean Init(char* o_name, int o_num, char* p_str = NULL)
                   ;

Function is currently defined inline.


Back to the top of libohymos


Element_for_test(char* o_name, int o_num, char* p_str ) ;

#include "elm_t.h"

  Element_for_test(char* o_name, int o_num, char* p_str = NULL)
		;

Function is currently defined inline.


Back to the top of libohymos


Element_for_test(void) ;

#include "elm_t.h"

  Element_for_test(void)
		;

Function is currently defined inline.


Back to the top of libohymos


~Element_for_test(void) ;

#include "elm_t.h"

  ~Element_for_test(void)                                                
;

Function is currently defined inline.


Back to the top of libohymos


void Pass_whites_and_comments( FILE*& fp, char& current, char comment );

#include "f_look.h"

Move forward the file pointer "fp" untill a non-white character is encountered. Comment strings are also skipped.

ホワイトスペース, 空行, コメント文を送り, fp を進めます. comment は、コメント文字列開始の文字です。通常は、'#' を指定 してください。comment が NULL のときは、空白文字だけをスキッ プします。

Example
current = fgetc(fp); Pass_whites_and_comments(fp, current, '#');

void Pass_whites_and_comments(
  FILE*& fp,        // file pointer
  char& current,    // input. the character to which the current
                    // "fp" points
                    // output. encountered non-white character
  char comment      // comment character
  );

Back to the top of libohymos


int Get_line_number( FILE*& fp );

#include "f_look.h"

fp が指すファイル位置の行番号を取得します.

int Get_line_number(
  FILE*& fp     // 行番号を調べるファイルのポインタ
  );

Back to the top of libohymos


Boolean Make_data_string( char* f_name, FILE*& fp, char& current, char*& d_str, int& d_strlen, char head, char tail, char comment, char control );

#include "f_look.h"

ファイル f_name の fp 以降で, head, tail に囲まれた 部分をヒープに確保した文字列 d_str にコピーし, データ文字列を 作成します.

Boolean Make_data_string(
  char* f_name,     // ファイル名
  FILE*& fp,        // ファイルポインタ
  char& current,    // fp が指している文字
  char*& d_str,     // output. データ文字列
  int& d_strlen,    // データ文字列の長さ
  char head,        // '('
  char tail,        // ')'
  char comment,     // '#'
  char control      // 行末連続処理文字コード '\'
  );

Back to the top of libohymos


Boolean Get_string(FILE*& fp, char& current, char*& str, char control);

#include "f_look.h"

Boolean Get_string(FILE*& fp, char& current, char*& str, char control);

Back to the top of libohymos


int Get_strings(FILE*& fp, char& current, char**& str_array, int num_of_strs, char comment, char control);

#include "f_look.h"

int Get_strings(FILE*& fp, char& current,
				char**& str_array, int num_of_strs,
				char comment, char control);

Back to the top of libohymos


int khmkdir( char* dir, mode_t mode );

#include "khmkdir.h"

int khmkdir(	  //; make a directory
  char* dir,	  //; the directory to be made. Ex. foo/bar
  mode_t mode	  //; mode
  //
  // If the parent directory has not yet created, it will be also
  // created.  For example, dir is foo/bar and directory foo
  // does not exist, then foo is also created by this function.
);

Back to the top of libohymos


OVERVIEW

2000-09-01 update

Library "libohymos" provides classes for treating rainfall-runoff programs.

OHyMoS は, 京都大学大学院工学研究科土木システム工学専攻水文・水資源 工学研究室ならびに 京都大学防災研究所水災害研究部門洪水災害分野 で開 発・保守されている水文モデル構築システムです。

OHyMoS は、水文モデルを「構造的モデル化法」によって作成するためのシ ス テムで、オブジェクト指向言語 C++ を使って実現されています。

「構造的モデル化法」とは、各水文モデルに共通な構造を抽出して、あらか じめ モデル化しておき、個々の水文要素モデルは、この共通構造を継承し て作成して 行こうとする方法です。

現在のところ、個々の水文モデルもオブジェクト指向言語 C++ を使って記 述さ れなければなりません。

OHyMoS は次のような特徴を持っています。

この文書は、Ohymos-current (ohymos-2.4d.tgz の後で、椎葉が編集中のも のです。) の解説です。ohymos-2.4d.tgz にほぼ対応しています。

OHyMoS のユーザの間で情報を交換するためのメイリングリストohymos-ML が運営されています。

OHyMoS のソースは、 http://hywr.kuciv.kyoto-u.ac.jp/ohymos.html から取得できます。

documents

Back to the top of libohymos


HIERARCHY

    class hierarchy from Object to I_file<T>, O_file<T>

        Object <-- Port <-- Sender_port <--+
                                           |
     +-------------------------------------+
     |
     +---   Send_port <-- Input_port <-- Input_file   <--+-- I_file<T>
                                                         |
                                         Port_type<T> <--+

        Object <-- Port <--+
                           |
     +---------------------+
     |
     +--- Receive_port <-- Output_port <-- Output_file  <--+-- O_file<T>
                                                           |
                                           Port_type<T> <--+

    --------------------------------------------------------------------
    class hierarchy from Object to Send<T>, Receive<T>, Relay<T>

    Object <-- Port <-- Sender_port <-- Send_port <--+-- Send<T>
                                                     |
                                     Port_type<T> <--+

    Object <-- Port <-- Sender_port <-- Relay_port <--+-- Relay<T>
                                                      |
                                      Port_type<T> <--+

    Object <-- Port <-- Receive_port <--+-- Receive<T>
                                        |
                        Port_type<T> <--+

    Object <-- Port <-- Receive_port <--+-- ReceiveNointp<T>
                                        |
                        Port_type<T> <--+

    --------------------------------------------------------------------
    class hierarchy from Object to Total_system

    Object <-- Element <-- Sub_system <-- Total_system

    --------------------------------------------------------------------
    class hierachy to Data

    Data_pack    <--+-- Data<T>
                    |
    Port_type<T> <--+

    --------------------------------------------------------------------

    OHyMosString

    Vary

Back to the top of libohymos


DEFINE MACROS

The following macros are defined in common.h.

NEWCHECK(foo)
If foo is NULL, prints error message and exit.
YES
#define YES 1
NO
#define NO 0

--------------------------------------------------------------------

つぎのマクロが common.h で定義されています。

NEWCHECK(foo)
foo が NULL なら、エラーメッセージ、ファイル名、行数を表示 してイグジッ トします。
YES
#define YES 1
NO
#define NO 0

Back to the top of libohymos


typedef void (*Clear_function)(void* obj);

#include "list.h"

クラス List の収録オブジェクト消去用関数の型 Clear_function の定義

ヒープに確保した Node を delete する時, Node::object が指す先の実体 を消去するために定義します. (List::List 参照)

typedef void (*Clear_function)(void* obj);

Back to the top of libohymos


Generated from source by the Cocoon utilities on Sun Sep 3 22:51:59 2000 .

Report problems to jkotula@stratasys.com