Prototype and Summary of Library Subprograms 'libgm'
(for C Language)

Japanese

  All subprograms included in this Library 'libgm' are coded in C language.
  The prototypes and outlines of all entry names are described very short bellow. For FORTRAN callable routines and their equivalents, further detail description is available in manual page HTMLs, which can be accessed through the index page libfE.html.

[Library Archive File]  path :  /home/SHARE/lib/libgm.a
[Useful Setting]    alias  cc   'gcc \!* -L/home/SHARE/lib -lgm -lm'
                    alias  f77  'g77 \!* -L/home/SHARE/lib -lgm'

PSPLOT (LINE Graphics PostScript Output)

int  psopn(char *pfile, char *sheet);
void psopn_(char *pfile, char *sheet);
  Select sheet size, and open PostScript output filename.

int  plots(double xo, double yo);
void plots_(float *xo, float *yo);
  Define start of page, and initial origin.

int  plote(void);
void plote_(void);
  Define end of page.

int  pscls(void);
void pscls_(void);
  Close PostScript output file.

int  epsbox(double obbx, double obby, double sbbx, double sbby);
void epsbox_(float *obbx, float *obby, float *sbbx, float *sbby);
  Define values of BoundingBox with its origin coordinates (obbx,obby) and
  its width and height (sbbx,sbby), before calling psopn(psopn_).

int  plot(double xp, double yp, int md);
void plot_(float *xp, float *yp, int *md);
  Move pen according to mode.

int clspath(int join);
  Draw to the first point of continuous pen-down drawing to close polygon,
  with corner joining parameter (Miter join if join=0, Bevel join if join=2,
  and Round join otherwise).  

int  scisor(double xlm, double ylm, double wlm, double hlm);
void scisor_(float *xlm, float *ylm, float *wlm, float *hlm);
  Scisor out the outside of rectangle range.

int  factor(double fac);
void factor_(float *fac);
  Set scale factor.

int  penatr(int jpen, int icol, int ityp, double thick);
void penatr_(int *jpen, int *icol, int *ityp, float *thick);
  Setup pen attributes.

int  newpen(int npen);
void newpen_(int *npen);
  Select new pen number.

int  qpatr(int mpen, int *lcol, int *ltyp, double *wthick);
  Get the pen attributes, i.e., color (lcol), line type (ltyp), and line width
  (wthick), of current pen, and its pen number is returned as function value.

int  qpsfp(FILE **fps);
  Get file pointer (fps) of PS output file.
int  qapos(int *ixp, int *iyp);
  Get current absolute pen position (ixp,iyp).

int  where(double *wx, double *wy, double *wfac);
void where_(float *wx, float *wy, float *wfac);
  Get current pen coordinates and scale factor.

int  wrect(double xl, double yl, double wide, double high);
void wrect_(float *xl, float *yl, float *wide, float *high);
  Draw a rectangle.

void wpolyg_(float *xm, float *ym, int *npt, int *inc);
  Draw a polygon.

int  wcirc(double xc, double yc, double radius, double ang1, double ang2);
void wcirc_(float *xc, float *yc, float *radius, float *ang1, float *ang2);
  Draw a circle.

PSPAINT (Surface Graphics PostScript Output)

int dftone(int nlevel, int mtone[], int ktnlo, int ktnhi, int ktnvd);
void dftone_(int *nlevel, int mtone[], int *ktnlo, int *ktnhi, int *ktnvd);
  Define and assign monochromatic gray-scale grading for 2D surface
  representation 'paintm'.

int dfrgbt(int nclev, int mrgb[], int kclo, int kchi, int kcnv);
void dfrgbt_(int *nclev, int mrgb[], int *kclo, int *kchi, int *kcnv);
  Define and assign color grading for 2D surface representation 'paintm'.

int dfcols(int nclev, double fh, double fd, int kcnv);
void dfcols_(int *nclev, float *fh, float *fd, int *kcnv);
  Auto-generate and assign color grading for 2D surface representation
  'paintm', and also auto-generate shaded color grading for dual 2D surface
  representation 'paintw'.

int dfc40s(void);
void dfc40s_(void);
  Define and assign color with standard 40 grades for 2D surface
  representation 'paintm'.

int dresol(int nras);
void dresol_(int *nras);
  Modify resolution of 'paintm'/'paintw' representation.

int dframe(double xo, double yo, double wd, double hi, int imax, int jmax);
void dframe_(float *xo, float *yo, float *wd, float *hi, int *imax, int *jmax);
  Define frame of 'paintm'/'paintw' representation.

int dframo(double x0, double y0, double x1, double y1, double x2, double y2,
           int imax, int jmax);
void dframo_(float *x0, float *y0, float *x1, float *y1, float *x2, float *y2,
             int *imax, int *jmax);
  Define oblique framework for perspective representation by 'paintm'/'paintw'.

int paintm(float *v, float vlo, float vhi, float vnvd);
void paintm_(float *v, float *vlo, float *vhi, float *vnvd);
  Repesent 2D surface with gray-scale or color grading.

int paintw(float *v, float vlo, float vhi, float vnvd, float *u);
void paintw_(float *v, float *vlo, float *vhi, float *vnvd, float *u);
  Repesent dual 2D surface with shaded color grading.

int dfpcol(int key, int mcol);
void dfpcol_(int *key, int *mcol);
  Assign color to paint object by 'paintc'/'paintr'/'paintp'.

int paintc(double xc, double yc, double radius);
void paintc_(float *xc, float *yc, float *radius);
  Paint a circle.

int paintr(double xorg, double yorg, double wide, double high);
void paintr_(float *xorg, float *yorg, float *wide, float *high);
  Paint a rectangle.

int paintp(float xa[], float ya[], int npt, int inc);
void paintp_(float xa[], float ya[], int *npt, int *inc);
  Paint a polygon.

PTEXT (Font TEXT and Center-Symbol Graphics)

int lstyle(char *fnt, double high, double ang, int tcol, int bcol);
void lstyle_(char fnt[3], float *high, float *ang, int *tcol, int *bcol);
  Select font style.

int ptext(char *text, int ltxt, double xp, double yp, int kp);
void ptext_(char *text, int *ltxt, float *xp, float *yp, int *kp);
  Draw text string by the font style defined by 'lstyle'.

int pcstr(double xp, double yp, double chi, char *text, double ang, int ns);
void pcstr_(float *xp, float *yp, float *chi, char *text, float *ang, int *ns);
  Draw text string by Courier font.

int pmark(int mark, double xc, double yc, double size, double thick, int mcol);
void pmark_(int *mark, float *xc, float *yc, float *sz, float *th, int *mcol);
  Draw a centered symbol mark.

CONT (Drawing Line Contour Map)

int conts(double xorg, double yorg, double wide, double high,
          int imax, int jmax, double csize);
void conts_(float *xorg, float *yorg, float *wide, float *high,
            int *imax, int *jmax, float *csize);
  Specify the framework of 2D contouring 'contx'.

int contso(double x0, double y0, double x1, double y1, double x2, double y2,
           int imax, int jmax);
void contso_(float *x0, float *y0, float *x1, float *y1, float *x2, float *y2,
             int *imax, int *jmax);
  Specify oblique framework for perspective view of contour map by 'contx'.

int contx(float *v, float undef, int istep, int lcapt,
          int lml, int lmh, int kln);
void contx_(float *v, float *undef, int *istep, int *lcapt,
            int *lml, int *lmh, int *kln);
int contr(float *v, float undef, float step, int lcapt,
          float vlml, float vlmh, int kln)
void contr_(float *v, float *undef, float *step, int *lcapt,
            float *vlml, float *vlmh, int *kln)
  Execute contour map drawing.

WSHORE (Drawing Coastlines etc.)

void rshore(int m, int is, int in, int kw, int ke);
void rshore_(int *m, int *is, int *in, int *kw, int *ke);
  Define the range to draw coastlines etc. by 'pshore'.

void pshore(double xorg, double yorg, int mpen, double scl,
            void (*conv)(float *alat, float *alon, float *xe, float *yn));
void pshore_(float *xorg, float *yorg, int *mpen, float *scl,
            void (*conv)(float *alat, float *alon, float *xe, float *yn));
  Draw coastlins, lakes, rivers, prefecture boundaries with larger scale.

void wshore(double xorg, double yorg, int mpen, double scl,
            void (*conv)(float *alat, float *alon, float *xe, float *yn));
void wshore_(float *xorg, float *yorg, int *mpen, float *scl,
            void (*conv)(float *alat, float *alon, float *xe, float *yn));
  Draw coastlines, lakes and rivers with smaller scale.

AXIS (Drawing character/mark/axis etc. using stroke table)

Following routines are obsolete, and still remain only for compatibility purposes.
int chtype(double ang, double slope, double high, double ratio);
void chtype_(float *ang, float *slope, float *high, float *ratio);
  Define character type.

int p1char(char c);
int pchars(char *bcd);
void pchar_(char *s, int *nc, float *xs, float *ys, int *kk);
void gsymbl_(float *xs, float *ys, float *high, char *s, float *ang, int *nc);
  Draw 1 character or character string.

int psmset(int ksms);
void pnorm_(void);
void psubsc_(void);
void psupsc_(void);
  Select normal/subscript/superscript mode.
int pscdef(char csb, char csp);
void pshift_(char cs[2]);
  Specify shift-code characters.

int pcsymb(int ics, double size, double ang);
void csymbl_(float *xs, float *ys, float *sz, int *ics, float *ang, int *mp);
  Draw a centered symbol.

int symbol(double xp, double yp, double high, char *text, double ang, int nc);
void symbol_(float *xp, float *yp, float *high, char *text,
             float *ang, int *nc);
  Draw a text string.

int number(double xp, double yp, double high, double fv, double ang, int ndec);
void number_(float *xp, float *yp, float *high, float *fv,
             float *ang, int *ndec);
  Draw a number.

int scale(float va[], double axlen, int npt, int inc);
void scale_(float va[], float *axlen, int *npt, int *inc);
  Prepare for scaling.

int line(float xa[], float ya[], int npt, int inc, int ltype, int mark);
void line_(float xa[], float ya[], int *npt, int *inc, int *ltype, int *mark);
  Draw a line graph of array data.

int axis(double xp, double yp, char *text, int ltx,
         double axlen, double angle, double firstv, double deltav);
void axis_(float *xp, float *yp, char *text, int *ltx,
           float *axlen, float *angle, float *firstv, float *deltav);
  Draw a axis.

XYCONV (Conversion for Map Projection)

int cvinit(int nca, double gi, double gk, double sp1, double sp2);
void cvinit_(int *nca, float *gi, float *gk, float *sp1, float *sp2);
void cvdinit_(int *nca, double *gi, double *gk, double *sp1, double *sp2);
  Specify projection method.

int cviken(double fi, double fk, double *ye, double *xn);
void cviken_(float *fi, float *fk, float *ye, float *xn);
void cvdiken_(double *fi, double *fk, double *ye, double *xn);
  Convert Lat./Lon. into plane rectangular coordinates.

int cvenik(double ye, double xn, double *fi, double *fk);
void cvenik_(float *ye, float *xn, float *fi, float *fk);
void cvdenik_(double *ye, double *xn, double *fi, double *fk);
  Convert plane rectangular coordinates into lat./lon.

void xyconv_(float *gi, float *gk, float *fi, float *fk, float *x, float *y);
void nxycnv_(float *gi, float *gk, float *fi, float *fk, float *x, float *y);
  Convert Lat./Lon. into Japanes Transverse Mercator X/Y.
void utm_(int *nz, float *fi, float *fk, float *x, float *y);
  Convert Lat./Lon. into Universal Transverse Mercator X/Y.
void ikconv_(float *gi, float *gk, float *x, float *y, float *fi, float *fk);
void nikcnv_(float *gi, float *gk, float *x, float *y, float *fi, float *fk);
  Convert Japanes Transverse Mercator X/Y into Lat./Lon.
void utmik_(int *nz, float *x, float *y, float *fi, float *fk);
  Convert Universal Transverse Mercator X/Y into Lat./Lon.

XW84T (Geodetic Coordinates Conversion)

void xw84t(double wlat, double wlon, double walt,
             double *tlat, double *tlon, double *talt);
void xw84t_(float *wlat, float *wlon, float *walt,
             float *tlat, float *tlon, float *talt);
void xw84td_(double *wlat, double *wlon, double *walt,
             double *tlat, double *tlon, double *talt);
  Convert WGS84 Lat./Lon./Alt. into Old-Tokyo datum.

void xtw84(double tlat, double tlon, double talt,
            double *wlat, double *wlon, double *walt);
void xtw84_(float *tlat, float *tlon, float *talt,
             float *wlat, float *wlon, float *walt);
void xtw84d_(double *tlat, double *tlon, double *talt,
             double *wlat, double *wlon, double *walt);
  Convert Old-Tokyo datum Lat./Lon./Alt. into WGS84 coordinates.

IGRF (International Geomagnetic Reference Field Calculation)

void field(double are, double aflat, double ara, int maxoda);
  Give equatorial radius (are) and reciprocal flattening (aflat) of Earth
  ellipsoid, and radius of reference sphere (ara) and maximum order/degree
  (maxoda) of IGRF calculation.

void tcoef(double agh[MxOD+1][MxOD+1], double aght[MxOD+1][MxOD+1],
            double atzero, int kexta, double aext[3]);
  Give Gauss coeficients (agh) and their time variations (aght), base year
  (atzero), external source flag (kexta), and coefficients of external (aext).

void tyear(double ayear);
  Give time epoch (ayear) of calculation.

void mfldg(double alat, double alon, double ahi,
            double *ax, double *ay, double *az, double *af);
  Calculate geocentric 3 components (ax,ay,az) and total intensity (af) of IGRF
  model, from geographic latitude (alat), longitude (alon), and altitude (ahi).

void mfldc(double athe, double alon, double ar,
            double *ax, double *ay, double *az, double *af);
  Calculate geocentric 3 components (ax,ay,az) and total intensity (af) of IGRF
  model, from geocentric colatitude (athe), longitude (alon), and geocentric
  distance (ar).

void gcomp(double *axg, double *ayg, double *azg);
  Get geopgraphic 3 component (axg,ayg,azg) of IGRF model for the point last
  specified by 'mfldg' or 'mfldc'.

void gigrf(int gen, double *year);
void gigrf_(int *gen, float *year);
  Select IGRF model by generation number (gen), and specify the time epoch
  (year) of IGRF calculation.

void igrfc(double fido, double fkeido, double high, double *tf);
void igrfc_(float *fi, float *fk, float *h, float *f);
  Specify position and get total force IGRF value.

void igrfm(double fm[6]);
void igrfm_(float fm[6]);
  Get full components of IGRF vector.

void sigrf(double year);
void sigrf_(float *year);
void sdgrf(double year);
void sdgrf_(float *year);
void spgrf(double year);
void spgrf_(float *year);
  Select IGRF model (Tentative IGRF/DGRF/PGFR), and specify time epoch (year)
  of IGRF calculation.  Generation of model is selected automatically from the
  value of time epoch (year).

CALMA (Synthetic Magnetic Anomaly Calculation for Simple Model)

void magafd(double the, double phi, double dip, double dec);
void magafd_(float *the, float *phi, float *dip, float *dec);
  Give inclination (the) and declination (phi) of source magnetization, and
  inclination (dip) and declination (dec) of Earth's magnetic filed. 

void mpoint(double am, double xc, double yc, double zc, double vol);
void mpoint_(float *am, float *xc, float *yc, float *zc, float *vol);
  Select point source model, and set source parameters.
void mvline(double am, double xc, double yc, double za, double w, double area);
void mvline_(float *am, float *xc, float *yc, float *za, float *w,
             float *area);
  Select line source model, and set source parameters.
void mhrect(double am, double cx, double rx, double cy, double ry,
            double zc, double h);
void mhrect_(float *am, float *cx, float *rx, float *cy, float *ry,
             float *zc, float *h);
  Select rectangle sheet source model, and set source parameters.
void mprism(double am, double cx, double rx, double cy, double ry,
            double za, double w);
void mprism_(float *am, float *cx, float *rx, float *cy, float *ry,
             float *za, float *w);
  Select block source model, and set source parameters.

double calma(double xp, double yp, double zp);
float calma_(float *xp, float *yp, float *zp);
  Calculate magnetic anomaly for specified position (xp,yp,zp).

SML (Regression Analysis)

int sm1opn(int nvar, int nsrc);
void sm1opn_(int *nvar, int *nsrc);
  Initialize n-parameters linear regression.
int sm1ex(double var[], double src[]);
void sm1ex_(float fv[], float fs[]);
  Process n-parameters linear regression.
int sm1cls(double *coef);
void sm1cls_(float *fc, int *mc, int *nc);
  Get regression coefficients of n-parameters linear regression.
int sm1rv(double vr[], double sr[]);
void sm1rv_(float fvr[], float fsr[]);
  Calculate linear regression formula value for specified n-parameters.

int sm2opn(int ndg2, int nsrc);
void sm2opn_(int *ndg2, int *nsrc);
  Initialize 2-parameters n-th order regression.
int sm2ex(double u, double v, double src[]);
void sm2ex_(float *fu, float *fv, float fs[]);
  Process 2-parameters n-th order regression.
int sm2cls(double *coef);
void sm2cls_(float *fc, int *mc, int *nc);
  Get regression coefficients of 2-parameters n-th order regression.
int sm2rv(double ur, double vr, double sr[]);
void sm2rv_(float *fur, float *fvr, float fsr[]);
  Calculate n-th order regression formula value for specified 2-parameters.

int sm3opn(int ndg3, int nsrc);
void sm3opn_(int *ndg3, int *nsrc);
  Initialize 3-parameters n-th order regression.
int sm3ex(double x, double y, double z, double src[]);
void sm3ex_(float *fx, float *fy, float *fz, float fs[]);
  Process 3-parameters n-th order regression.
int sm3cls(double *coef);
void sm3cls_(float *fc, int *mc, int *nc);
  Get regression coefficients of 3-parameters n-th order regression.
int sm3rv(double xr, double yr, double zr, double sr[]);
void sm3rv_(float *fxr, float *fyr, float *fzr, float fsr[]);
  Calculate n-th order regression formula value for specified 3-parameters.

RAND (Random Number Generation)

double rand1(void);
float rand1_(void);
  Generate uniform random number within the range of [-1, +1].

double randg(void);
float randg_(void);
  Generate Gaussian random number with zero mean and dispersion 1.

LWKDIR (Assistance to Show the progress of loop operation,
to Set-up Working Directory Path,
and to Read-in Process Parameters)

int prompt(char *str);
void prompt_(char *str, size_t ls);
  Output message str to screen (stderr).
int premsg(char *str);
void premsg_(char *str, size_t ls);
  Output message str and a NewLine code to screen (stderr).

int dpcini(char *str);
void dpcini_(char *str, size_t ls);
  Initialize progress display with output of heading string.
int dpcent(int m, int n);
void dpcent_(int *m, int *n);
  Display the progress of loop operation.

char *strdtm()
void strdtm_(char *sdt, size_t ls)
  Acquire Date-Time string.
int lrtrim_(char name[], size_t len);
  Get character length of a string trimmed off right spaces.

void abend_(int *ecd);
  Error exit with showing error code number.
void abendm_(char *ems, size_t len);
  Error exit with showing error message.

void opnpinc(int argc, char *argv[])
void opnpin_(void);
  Provide a chance to select predefined data file as a data source for reading
  process parameters.
  opnpinc() must be called after setting up '*argv[]' and 'argc' with the array
  of command and parameter strings and its number at the start of main program.
void clspin(void);
void clspin_(void);
  Close 'opnpin' mechanism.

int get_wkdir(char *dnm, size_t len);
int lwkdir_(int *len, char *dnm);
  Establish the Working Directory Path.

int parmin(int lbuf, char *buf);
  Read preocess parameter(s) as a raw string.
void parmin_(char *str, int lbuf, char *buf, size_t ls);
  Output prompt message and read process parameter(s) as a raw string.

void gparma(char *str, int lnam, char *nam);
void gparma_(char *str, int *lnam, char *nam, size_t ls);
  Output prompt message and read process parameter as a string.
void gparmi(char *str, int *iv);
void gparmi_(char *str, int *iv, size_t ls);
  Output prompt message and read process parameter as a integer value.
void gparmf(char *str, float *fv);
void gparmf_(char *str, float *fv, size_t ls);
  Output prompt message and read process parameter as a floating value.
void gparmd(char *str, double *dv);
void gparmd_(char *str, double *dv, size_t ls);
  Output prompt message and read process parameter as a double-float value.
void gparmif(char *str, int *iv, float *fv);
void gparmif_(char *str, int *iv, float *fv, size_t ls);
  Output prompt message and read process parameter as two values of integer and
  floating.
void gparmid(char *str, int *iv, double *dv);
void gparmid_(char *str, int *iv, double *dv, size_t ls);
  Output prompt message and read process parameter as two values of integer and
  double-float.
void gparmi2(char *str, int *iv1, int *iv2);
void gparmi2_(char *str, int *iv1, int *iv2, size_t ls);
  Output prompt message and read process parameter as two integer values.
void gparmf2(char *str, float *fv1, float *fv2);
void gparmf2_(char *str, float *fv1, float *fv2, size_t ls);
  Output prompt message and read process parameter as two floating values.
void gparmd2(char *str, double *dv1, double *dv2);
void gparmd2_(char *str, double *dv1, double *dv2, size_t ls);
  Output prompt message and read process parameter as two double-float values.

void getargs_(int *max, char args[][], int *argc, size_t ls);
  getargs_() receives the command and parameters (array of strings 'args')
  and its number ('argc') at the start of main program.  The array 'args' is
  of fixed length 'ls' with maximum elements 'max'.