111111111111 fonds do.xnwntair*...

23
Fonds Do.xnwntair* ClRsrOM 111111111111 010017287

Upload: others

Post on 27-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

Fonds Do.xnwntair* ClRsrOM

111111111111 010017287

Page 2: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté
Page 3: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

TABLEDESMATIERES 3

INTRODUCTION

UTILISATION 1. GRILLEASCIIAVECEN-TETE 2. GRILLEAKIISANSEN-TETE

ANNEXES

ANNEXE 1: INSTALLATION l.GMT-THEGENERICMAPPINC TOOL 2. PREPARATION 3. INSTALLATIONDE ASCIUGRD 4. MAKEFILE

ANNEXE~:MAN

ANNEXE 3: ASCII~GRD.C

ANNEXE 4: BIBLIOGRAPHIE 27

5

7 8

11

13

15

ASCII2GRD(Février 1996)-Notice d'utilisatioo Laboratoire de Géophysique - Orstom Bondy

Page 4: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

INTRODUCTION 5

ASCII2GRD est un programme permettant de transformer une grille ascii en grille binaire « GMT » (format netCDF). Il est écrit en Langage C et il utilise les ressources du produit GMT (Generic Mapping Tool) et les librairies netCDF. Se reporter à l’annexe I pour l’installation de ascii2grdi et de son manuel en ligne.

L’affichage du man (man ascii2grd) donne une description compléte sur la fonction et l’utilisation de cette commande (Annexe 2), mais un rapide résumé peut être obtenu en éxécutant le programme sans arguments (ascii2grd). Les deux cas distinct d’utilisation de la commande selon que la grille ascii à transformer a ou n’a pas d’en- tête sont développées plus longement dans la partie UTILISATION.

Pour obtenir de plus amples renseignements sur le format des fichiers « grd » il est conseillé de se reporter au document Technical Reference and Cookbook - Appendix B dont les références sont citées en annexe 4.

Pour toute supgestion ou renseignement complémentaire Germinal GABALDA Orstom - Laboratoire de Géophysique 32, av. Henri Varagnat - 93143 - BONDY CEDEX FRAhTE Email: [email protected]

ASClI2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 5: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

UTILISATION 7

1. GIULLEASCIIAVECEN-TETE

Si le fichier ascii contient en plus de la grille de données un en- tête de 11 lignes correctement renseigné alors la syntaxe de la commande est trés simple:

ascii2grd ( gridfile 1 -GgrdNe -H

Ascii2grd lie l’entrée standard ou le fichier gridfile si celui-ci est spécifié dans la commande est crée le fichier binaire grdfile,

Dans l’en-tête présenté ci-dessous les valeurs indispensables à une bonne lecturekriture de grille sont en gras, les champs soulimés peuvent être omis et les commentaires sont en italiques.

Tide : Enaisseur Elastiaue Command : grd2ascii Te.resu.grd -Cl 1 -N9999 -R10/20/-Y5 Remark : grille de test Normal - mode d’enregistrement dès noeuds 0 I format gr@le (pas utilisé) 10 20 0.5 degre 21 : x min, x-ma,x x inc, unité, nx -5 5 0.5 degre 21 : y:min, y-max, y:inc, unité, ny 0103km : z min, z max, unité 1 0 9999 : facteur d’éhelle et oHset pour Z, non valeur

- 10 20 : sens de lecture pour les longitudes 5-5 : sens de lecture pour les latitudes

IMPORTANT:

- La ligne 1 doit commencer par la chame «Titie :» (9 caractéres) - La ligne 2 doit commencer par la chaîîe Kommand :» (9 caractéres) - La ligne 3 doit commencer par la chaîne &emark :» (9 caractéres) - le champ de la ligne 4 peut prendre les valeurs Normal ou Pixel - Le champ non-valeur (ligne 9) peut être numérique ou prendre la valeur NaN - La ligne 11 fixe le sens de lecture de la grille (idem option -r)

ASCII2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Boody

Page 6: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

UTILISATION 8

2. GRILLE ASCII SANS EN-TETE

La commande doit contenir toutes les informations nécessaires à une lecture correcte de la grille ascii, elle est donc plus complexe:

ascii2grd [ gridfile ] -Ggrdfile -I~[mlc) [/dy[mlc) -Rouest/esthdhord [ -F ] ---- [ -r ] [ -Nnodata ) [ -Dxunithunitlarnitlscale/offsetltitle/remark ] ---m

gridfile. Fichier ASCII contenant la grille. En l’absence de fichier, la commande lie l’entrée standard

-G grdflle est le nom du fichier binaire au format gmt (netCDF).

-1 @ [et optionnellement ~JJ est le pas de la grille. Accolez m pour indiquer des minutes, ou c pour des secondes.

-R ouest/est/sudhord permet de défti les limites géographiques --m- de la grille. Ces limites peuvent être indiquées en degrés et minutes [et secondes] avec le format dd:mm[:ss].

OPTIONS:

-F

-r

-N

-D

force le mode d’enregistrement à Pixel mormal par défaut].

indique que la grille en entree est rangée par latitudes croissantes, soit à partir du Sud Word par défaut].

nodata. Les valeurs numériques nodata (ou la chaîne NaN) seront remplacés par la valeur machine ‘Not a Number’ dans -- la grille binaire [nodata = NaN par défaut].

permet de donner une valeur à xuuit, yunit, zuuit, scale, offset, title et remark Pour laisser une valeur inchangée (valeur par défaut), tapez le signe ‘égale’ (=) comme valeur.

Valeurs par défiut: xunit = user x unit, yunit = uwr- y-unit, zunit = user z unit, -- -- seale = 1 et offset = 0.

ASCII2GRD (Février 1996) - Notice d’utilisatioo Laboratoire de Géophysique - Orstom Boody

Page 7: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

UTILISATION 9

Par conséquent pour simuler l’en-tête présenté dans la partie précédente il faut lancer la commande suivante:

ascii2grd test.asc -Gtest.grd -10.5 -Rl0/20/-5/5 -N9999 -Ddegre/degre/km/l/O/‘Epaisseur EIastique’/6griile de test’

IMPORTANT:

Dans le fichier binaire « gmt », la grille est toujours stockée de l’Ouest (xmin) vers l’Est (xmax) en commençant par le nord (ymax), la grille ascii est donc lue dans cette ordre. L’option -r permet de lire une grille dont la première ligne correspond au Sud. La conversion d ‘une grille rangée par longitudes décroissantes n ‘est pas possible.

Les deux dessins ci-dessous illustrent la différence entre les modes normal et pixel. l Dans le mode normal, les noeuds sont centrés aux intersections de

la grille et chaque valeur représente une moyenne dans la cellule de dimensions dx * dy centrée sur le noeud.

l Dans le mode pixel, les noeuds sont aux centres des cellules délimitées par les intersections de la grille et chaque valeur représente une moyenne dans cette cellule.

Mode Normal Mode Pixel

ASCIILGRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 8: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 1: INSTALLATION 11

1. GMT - The Generic Mappine Tool

GMT est un ensemble d’outils Unix qui permettent de manipuler des données et de produire des dessins postscripts. GMT peut être obtenu gratuitement sur intemet ainsi que les librairies netCDF qui sont utilisées par plusieurs fonctions de GMT. - ftp anonyme à partir de la machine kiawe.soest.hawaii.edu

( 128.17 1.15 1.16) sous le répertoire pub/gmt - www à l’adresse http://www.soest.hawaii.edu/soest/gmt.html.

2. Préparation

- Créez un répertoire sous le répertoire contenant les sources GMT

- Copiez les fichiers ascii2grd.c, ascii2grd.man et makefile dans ce répertoire

- Editez le makefïle et adaptez à votre site les variables PRODUC, NETCDF, LIBDIR, BINDIR et MANDIR

PRODUC = ascii2grd NETCDF = Chemin pour atteindre netCDF LIBDIR = Chemin pour atteindre les librairies GMT BINDIR = Répertoire d’installation du binaire ascii2grd MANDIR = Répertoire d’installation du man

3. Installation de ASCII2GRD

- Pour générer et installer le programme, installer le manuel en ligne et nettoyer le répertoire, tapez make a11

- Pour générer le programme, tapez make bin - Pour installer le programme, tapez make install - Pour installer le manuel en ligne, tapez make man - Pour nettoyer le répertoire, tapez make clean

Si BINDIR et MANDIR ne sont pas des répertoires standards alors pensez à modifier les variables PATI3 et MANPATH.

ASCLUGRD (Février 1996) - Notice d’utilisatioo Laboratoire de Gophysique - Orstom Bondy

Page 9: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 1: INSTALLATION 12

4. Makefile # FOLIO~ the inshwtioas in this mak&le to customize your setup. # TO compiIJlinwinstaU the progmm,instaU mur pages and clean, try “make rll”. # TO compil4iak the program. try “make bin”. # TO install tbe progam. txy “make install”. # TO install man pqs, by “make mari”“” # TO clean out diraztory with “make cieao”. # # Atior: GermîMl Gabalda # oRsroh4 - Geupbysique # Bondy-93143-FRANCE # i)rte: l-AUG 1995 # # Set PRODUCJFiTCDF, BINDD?, LEBDDt, ad MANDIR behre a* m! # # PRODUC ->‘Ibe-OftIWppIl # NEXDF -~Whuetohdwcdf~cslibmdinclude # BINDIR ->w-baetoaauexeaableoode # LXBDIR ->wlmecMrqQortdat8lïiesue~ued. -Ihispotb # mustkhni.i.r.statiDg~mot/ ru MANDIR ->ukeGmmmmlpgcBrins@lbd 1 PRODUC =uw

- Ias~cDF-23.2 l mDIR - ImsdGMT-3.Ubh LIBDIR - /usrdGMT-3.UDb MANDIR = /urJGMT-i.Umdmaml t -?b NEKDFLIB =W=T’CDW% NEIXDFINC =s(NErcDFymchlde # !SHELL=hiddl cc =Cc SI = -DsI INsrALL = instau -s CFLAGS = -0 -1. -I$(NEKDFINC) -DLIBDlR~“~D~)\” s(Sr) CDF = -LS(NJXCDFLIB) -htcdf PS = -lpsl GMT = -lgut y---- -- SUFHXES: aU: bin install mari clean

# BM-y m= v---m-------------- bin: S(T’RODUC)

S(PRODUC): S(PRODUC).c 4

S(CC) S(CFLAGS) S? -L.. -Igmt S(CDF) -lm -0 s@

# pJn.iuL --------- ---w-w- J

insuil: S(BlNDIRy SfJ’RODUC)

S(BINDIRy YpRODUC): S(PRODUC) s(INSTALL) S? s(BINDIR) d

# MS lqL= _Ia--mmm----m ----------

llWl: S(MANDIR)/ $(PRODUC). 1

M $(MAND~)//.$??ODUC). 1: S(PRODUC). mari

# (-LJ=JQJ ________-_--_____--____ - -m--m--- ---- 4 clull:

rm -f *.o S(PRODUC)

ASCIUGRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 10: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 2: MAN

ASCIIZGRD(I) MISC REFERENCE MANUAL PAGES ASCIIZGRDqI)

NAME

ascii2grd - Converting an ASCII grid-file to grd file format

SYNOPSIS

asciilgrd [ gridfile 1 -G&U -H

ascii2grd [ grid6le ] -GpdiXe -b &[mlc][& inc[mlc]] -Rws&a&outnorth [ -F ] [ -r ] [ -NnocIata 1 [-Dxunit/vunit/zuni&calebffbet/titl~remark ]

DESCRIPTION

ascii2grd reads and ASCII me and creates a binary grue.

gtidfile. An ASCII grid file with/without header.

-G

-H

-R

-1

OFITONS

-D

-F

-1

-N

grdfiie is the name of the binary output grtile.

Input file has header record (Sec example below).

Title : Elastïc thickness Command : grd2aacii -R-4/4/0/10 Topo.grd Remark : Normal : node registration 0 : grdfile format (net used) -4 4 0.5 degle 17 : x-min x-max x-inc units nx 0 10 0.5 degre 21 : y-min y-max y-inc units ny 0 103 km : z-min z-max utlits 10 NaN : scale-f%ztor add-ol%et no-data -4 4 : longitude range 10 0 : latitude range

wst, east. south and & specify the region of interest. TO specify boundaries in &grees and minutes [and seconds], use the ddmm[:ss] format.

+ [and OptionalIy m is the gridding interval. Append m to indicate minutes, or c to indicate seconds.

Give values for xunit. vunit, munit. scale, ofbet title, and remark TO leave some of these values untouched, speci@ = as the value.

Force pixel registration mf&ult is grid reg.istration].

First row in the input file has yvalue = south (ymi@ [Default is notth].

No&ta TO specify the nan-value Ft is NaN].

Sun Release 4.1 Last change: 23 February 1996 1

ASCII2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géopbysique - Orstom Boody

Page 11: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 2: MAN 14

ASCIIZGRD(I) MISC. REFERENCE MANUAL PAGES ASCII2GRD(l)

EXAMPLES

TO create a grdfile fiom the AsCIl data in hatiifl.asc, try

ascü2grd h.asc -Ddegre&degr~mGaUlI”Hawaiian Gravity”/“GRS-IlO Ellipsaid used” -Ghawaü_grv_new.grd -R198/208/18/25 -15m

SEE ALSO

REFERENCES

W-l, P., aad W. H F. Smith, 1995, The Generic Mapping Tools (GMT) version 3.0 Te&nical Rekence & Cookbu& SOEST/NOAA. Weasel, P., and W. H. F. Smith, 1991, Free sdhvare helps map ad display data, EOS Trans. AGU, 72,441.

AUI’HOR

Germinal GabaIda ([email protected]) Geophysic Laboratory ORSTOM - (F - 93 143 Bondy Cedex)

Based on xyz2grdc (version 2.0) cif Paul Wessel

Sun Release 4.1 Last change: 23 Februaty 1996 2

A.CfYl2CRD UVvricr 19961- Notice d’utilisation Laboratoire de Géoobysiaue - Orstom Bondy .------ \--.-- -- --- ., . ..~~. _- _

Page 12: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

-xl? 3: kSCII2GRD.C 15

* ascii2grd rends a ascii grid file from standard input and creates * the corresponding grd-file. nx and oy are computed as: * nx = rint((east-west)/dx) + 1, ay = riot((oorth-southYdy) + 1 * * Author: Germinal Gabalda - Orstom (Geophysic Laboratory) l Email: gabalda@$ravi.boody.orstom.fr * Author: Germinal Gabalda * Date: 22-FEB-1996 l History: Based on syz2grd.c (version 2.0) of Paul Vesse1 * Versioo: 1.0 “1

#include “gmt. h”

main 63.w argv) iot argc; char **argx {

int emr = FALSE, got-input = FALSE, pixel = FALSE, reverse = FALSE, header = FALSE; iot Nnan = FALSE;

iot ij. ij, x, y, z, nm, one-or-zero, dummy[4]; int n-filled = 0, n_empty = 0, eatry, nx, ny,

doublew,e,s,n,clx=O.O,dy=O.O,no_data,vaI; double lonr~l,lonr~2, Iatr-1, Iatr-2;

char *grctfile, line[BUFSIZJ, input[512], *ptc

FILE *@i = NULL;

struct GRD-HEADER grd;

grd6Ie = CNULL; input[O] = 0; w=e=s=n=O.O; -y[01 = dummyjl] = dummy[2] = dummy[3] = 0;

argc = gmt-tegin (aw, argv);

no-data = gmt-NaN;

for (i = 1; i < argc; i*) { if (iqv[i][O] = ‘-‘) {

sd& Mw~Wl> { /* Common parameters l /

case ‘\(Y: gmt-quick = TRUE; break;

case ‘I-r: header = l-RUE; break

ASCII2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géopbysique - Orstom Bondy

Page 13: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

kiNNl%E 3: ASCII2GRD.C 16

case ‘R’: em += pt--R (arp[i]. Btw, &e. &s. &n); break;

case ‘D’: strcpy (inpuc &argv[i][2]k got-input = TRUE: break;

case ‘F: pixel = TRUE; bnak;

case ‘G: @le = &argv(i][2]; brrak;

CaseW: if(!argvfi][2l) {

fprintf(stderr, “aacii2@ GMT SYNTAXERROR-N optioa Must speci@value or NaMn”);

-; 1 else {

no-data = (!strcmp (&argv[i][2], “NaN”)) ? gmt-NaN : af (BiargvIil PI);

Nnan =TRUE; ) break;

errer = TRUE; tW-def=ltt_eno bw[ilI11); break;

1 1 else if((fpi = fopen (mi], Y)) = NULL) {

fpWf(suien, “tii2gd Canna Gnd ascii grid %sW, argy[i]);

d

exit (- 1); > J

1

if (argc = 1 11 gmt-quick) { fprintf (stderr, “asci@rd O/&s - Converting an ASCII grid-file to a netCDF gpSle\n\n”,

GMT VERSION); fprintf (stderr,=usage:w); fprintf(stdfm, ” - gridfïle with heahr : ascii2grd [<gridfile>] -G<grdfïle> -H~I”); fprintf (stderr, ” - gridtle without header: ascii2grd [<gridEle>] -G<grdfile>

-R-+zst/east/~rtorthRst/east/south/north>\n”); fprintf (stden, ” -I<dx[m~c]>[Kdy[m(c]>][-F] [-r] [-N<nodata+P); fprintf (stden, ” [-D<xunit/yunit/zuni~~~~~ti~~re~>]~~);

ASCIIZGRD (Février 1996) - Notice d’utilisation Laboratoire de Gophysique - Orstom Bondy

Page 14: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

&-N-E= 3: &CII2GRD.C 17

if (gmt-quick) exit (- 1):

fprintf (stderr. ” gridfile is an ascii g,rid file [or standard tnput] with or without header\n”). fprintf (stderr. ” -G to name the output grdf3e.W): fptintf (stderr. ” -H Input file has header\n”); fprintf (stderr. ” -R west, est. south and north specie the region of interest. TO speci@\n”); fptintf (stderr. ” boundaries in degrees and minutes [and seconds],use dd~rnm[:ss]

format.w’); fprintf (stderr. ” -1 specifies grid s&(s). Append m [or c] to <dx andlor <dy> for mtnutes

[or Seconds]~“); Qwintf(stderr, “ùi\tOlTIONS:\n”); @rintf (stderr. ” -F Will force pixel registration Il)efault is grid registration]\n”); f@intf (stderr, ” -r to read latitude frorn south [default north].\n”); @ri& (stderr, ” -N to specify the nan3nvalue [Default is NaN]\n”); fprintf (stderr, ” -D to enter information. Specify ‘=’ to get detàult ValtAn”); exit (- 1);

>

if (! header déâ: !project inforegion-supplied) { Qrintf (stderr,%cii2grd: GMT SYNTAX ERROR Must specify -R options”); errer++;

1 if (header && project~info.region~supplied) {

@ri.ntf (S&T, Wcii2gr& GMT SYNTAX ERRER: -H and -R not compatible\n”); eKor++;

1

if(!header && (dx <= 0.0 11 dy <= 0.0)) { fptbtf(ti~, “ascii2grd: GMT SYNTAX ERROR -1 option. Must specify positive

increment(s)W); errer*;

t if (header && (dx > 0.0 11 dy > 0.0)) {

f@tid(stde~, “ascii2grd: GMT SYNTAX ERROR -H and -1 not compatibleù1”); errer++;

)

if (header && got-input) ( fprintf (stderr, “ascii2grd: GMT SYNTAX ERROR -H and -D not compatible\n”); errer++;

1

tf(header 4% Nnan) { $rrintf (stderr, “ascii2grd: GMT SYNTAX ERROR -H and -N not compatible\n”); errer++;

1

if (header && pixel) { Qrintf (stderr, “ascii2grd: GMT SYNTAX ERROR -H and -F not compatible\n”): errer++;

>

if (header && reverse) { fprintf(st&rr, “ascii2grd GMT SYNTAX ERROR -H and -r not compatible\n”); errer++;

1

ASCII2GRD (Février 196) - Notice d’utilisatioo Laboratoire de Géophysique - Orstom Bondy

Page 15: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 3: fiSCII2GRD.C 18 3

d(!grdfïle) i fprintftstderr. “ascii2grd: GMT SYNTAX ERROR option -G: Must specify output fileb-0: u error++;

1

if (errer) exit (- 1);

if(fpi = Nuu) fpi = stdin; 4

grd-init (&grd, argc. argv, FUSE);

rDecabheaderinformatm*/ if(header) (

error = FALSC ~!=~y (lioe, SO, @i); P Title line */

fprintf (stderr, “a&cülgtd: Canaa read Title line, abortsb”); err0t-W

1 elst {

if (strstr(lioe,Title :“)) { ptr=strtdr(tine.@w; far(i=l;iClO;i++,ptr++~ =PY(grdtitlc,pbk

1 else {

@rintf (stderr, “ascX!gd Cannet fmd Title Line, aborkh”); errer++;

1 1

ptr = fgets (line, 80, fpi); /* Command line */ i.f(!Pw {

fplintf(stderr, kcii2gr& caMot rexl comman d line, aborth”); errer++;

1 J

p=Fyte (line. 80, @i); /* Remark line */

@lintIf (stc&?rr, “ascii2 grd Cannet read Remark line, aborth”); errer++;

1 else {

if (strstr(line,“Remark : “)) { ptr = strtok (line, “b”); for (i = 1; i < 10; i*, pirtt); strcpy (grd. remark, pu);

1 else {

d

J

fprintf (stderr, “ascii2grd: Cannet find Remark Iine, aborth”); errer++; ti

1 1

ptr = fgets (line, 80, fpi); /* Registration lïne */ if(W {

J

fptintf (stderr, “asc” u2grd: Cannet read Registration line, abotth”); errer++; d

1

ASCIUGRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 16: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 3: ASCII2GRD.C 19

ptr = strtok (line. ” \t.“); if (!strcmp (ptr. “Pixel”) 11 !strcmp cptr. “pirel”)) pixel =TRIE;

1

ptr = fgets (line. 80, fpi): /* Format line l / d (!ptr) {

fprintf (stderr. “ascii2grd: Cannot read Format line. aborts\n”); errai++;

j

ptr = fgets @ne, 80, fpi); /* x-min, x-max. x-inc. units and nx line */ if(W) 1

fprintf (stderr, “ascii2grd: Cannot read x line, aborts\n”); errer++;

1 else {

pcr=sMOk(lh?,“~); entry = 0; whde @tr) 1

switch (entry) { case 0:

grdx-min = ddmmss~to~degree (ptr); break;

case 1: grdx-max = dchnmss-to-degree @tr); break;

case 2: grdx-inc = atof(ptr); break;

case 3: strcpy (grdx-uni& ptr): breaki

case 4: grdnx =atof@tr); break;

defaldt: break;

1 ptr = strtok (CNULL, ” k”); entrp+;

1 1

ptr = fgets (line, 80, fpi); /* y-min, y-max, y-inc. units and ny line */ if(W {

fprintf (stderr, “ascii2gd Cannet rezui y line, aborts\n”); errer++;

1 else {

ptr = strtok (line, ” \t,“); entry = 0, Me@tr){

switch (entry) { case 0:

d-y-- = --to-degree @tr); break;

ASCU2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 17: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 3: ASCII~GRD.C 20

case 1: grd.y-max = ddmmss-to-degree (pu): - break;

cas 2: grd.y-inc = atof (pu); 1111 brrak;

case 3: stq.y (grdyuds, pu); haki 4

case 4:

E=“@“‘: &sault:

4

pa = stmk (CNULL, ” k”); enw+;

1 1

case 1: grdz-max = atof (ptr); bteak;

ptr = stltok (CNULL, ” k”); enq++;

1 1

ptr = fgets (line, 80, fpi); P scale-fàctor, ti-off& and no-data line */ if(W) 1

fprhtf (stderr, “ascii2grd: Cànnot read z(2) line, abortsh”); efror++;

1

ASCLUGRD (Février 1996) - Notice d’utilisation hboratoire de Géophysique - Orstom Bondy

Page 18: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

fiNN-E?‘iE3: hKII2GRD.C 21

else { ptr = strtok (line, ” \t,“). entry = 0; tile (ptr) {

switch (entry) { case 0:

grdz-sale-factor = atof (ptr): break:

case 1: grd.z-add-offset = atof (ptr); break

case 2: no-data = (! strcmp (Pr, ‘INaN”)) 7 gmt-NaN : atof (ptr); break;

default: break

1 pu = strtok (CNULL, ” k”); em++;

1 1

ptr = @?ts @ne, 80, fpi); /* loar~l, lonr-2 (longitude range) */ a(w) {

@id (stderr, “ascii2grd: Canot read longitude range line, abortsù1”); eNoH+;

1 else {

ptr = shtok (Line, ” \c”); entry = 0; while (ptr) {

switch (entry) { case 0:

lonr-1 = ddmms~to_degree (ptr,; break;

case 1: lonr-2 = ddmmss to - - degree (ptr); break;

defwt: break

1 ptr = strtok (CNULL, ” \t,“); entry++;

1 1

ptr = fm @ne, 80, fpi); /* latr- 1, km-2 (latitude range) */ if(W) 1

fprintf(stdeK, ‘23SCii2~d Catl.not read latitude range line, &orts~“); errer++;

1 else {

ptr = strtok (line, ” \t,“); entry = 0; eik @tr> {

switch (entry) { case 0:

latr-1 = ddmmss-to-degree (pH>; break,

ASCII2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - 0-m Bondy

Page 19: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

LiNNE= 3: kiSCII2GRD.C 22 * u

case 1: latr-2 = cklmmss~to~degree (ptr ); d break;

default: break;

1 d

ptr = strtok (CNULL. * k,“); entrp+;

1 L

/+DSUkgtdiOfOXllUtiOagi~n,ifiUly*/

ifo {

fbf (i = 0; input[i]; i++) if (input[i) = ‘-‘) input[i] = ’ ‘; l$== y (inprf “n

~&H switch (entxy) {

case 0: if(ptr[O] != 9 strcgy (grdx--h Pw;

case 1:

case 2:

if (pa[O] != ‘=‘) grdz~scale~ktor = atuf Qxr); bfeak;

case 4: if QU[O] != -> grd.z-add-ofkt = atof (pu); break;

case 5: if @tr[O] != “> strcpy (grdtitle, ptr); brrak;

case 6: if @.r[O] != Id) strcpy (grd remark ptr); break;

detàult: break;

1 ptr = strtok (CNULL, “P); enW++;

1 1

if(pixel) { grdnode-uffset = 1; one-or-zfxo = 0,

1 else {

grdnock~offset = 0; one-or-zero = 1;

)

A!KLl2GRD (Février 1996) - Notice d’utilisatioo Laboratoire de Géophysique - Orstom Bondy

Page 20: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

LI

L

L

ANNEXE 3: ASCII~GRD.~ 23

if(!header) { grdnx = rint ((e-w)/dx) + one-or-zero; grd.ny = rint ((n-s)/dy) + one-or-zero; grd.x-min = w, grd.x-max = e; grd.y-min = s; g.rd.y-max = n; grd.x-inc = dx; grd.y-inc = dy; fprintf (stderr, “ascii2grd: nx = %d ny = %d\n”, grdnx, grd.ny);

> else {

project-info.region-supplied = TRUE; errot=O; if ((grd.x-min >= grd.x max) 11 (grd.y_min >= grd.y-max)) {

fprintf (stderr, “ascii2grd: HEADER ERROR (REGION: xmin>=xmax or ymin+ymax)ù1”);

errer++; > nx = rint ((grd.x-max-grd.x-min)/g,rd.x inc) + one-or-zero; ny = rint ((grd.y-max-grd.y-min)/grd.yjnc) + one-or-zero; if((nx != grd.nx) 11 (ny != grd.ny)) {

fprintf (stderr, “ascii2grd: HJSADER ERROR (NX and/or NY)ùI”); errer++;

if ((grd.x-inc <= 0.0 II grd.y-inc <= 0.0)) { fprintf (stderr, “ascii2grd: HEADER ERROR (INCREMENT: dx or dy negative)\n”); errer++;

1 if (grd.z-min > grd.z-max) {

fprintf (stderr, “ascii2grd: HEADER WARNING (zmin > zmax)b”); 1

if (lonr-4 > lonr-2) { fprintf (stderr, “ascii2grd: rows going from %Ig to %Ig (NOT IMPLEMENTED

SORRY!)\n”, lonr-1, lonr-2); errer++;

> if ((lonr-1 != grd.x-min) )I (lonr-2 != grd.x-max)) {

fprintf(stderr, “ascii2grd: HEADER WARNING (longitude min and xmin differs)b”);

1

if ((latr-1 = grd.y-min) && (latr-2 = grd.y-max)) { fprinlf (stderr, “ascii2grd: first rows in ascii grid has south (ymin)\n”); reverse = TRI-JE;

> else if ((latr-1 = grd.y-max) && (latr-2 = grd.y-min)) {

fprintf (stderr, “ascii2grd: first rows in ascii grid has north (yma.x)\n”); 1 else {

fprintf (stderr, “ascii2grd: HEADER ERROR (latitude range and x limites differs)\n”);

errer++; 1

if (error) exit (- 1); >

mn = grdnx * grd.ny;

ASCIUGRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 21: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

a = (float *> memory (CNULL, nm, sizeof (float), “ascii2grd”);

ij = 0;

for (i = ij = 0; j < grd.ny; j++) {

if(reverse) ij = mn - ((J+l)*grd.nx); i = 0; while (i < g,rd.nx) {

ptr = fgets (line, BUFSIZ, fpi); if (!ptr) {

fprintf (stderr, “ascii2grd: Cannot read line %d, aborts\n”, j); exit (- 1);

1 ptr = strtok(line, ” \t,“); while (ptr && *ptr != ‘b’ && i < grd.nx) {

a[ij] = (sscanf (ptr, “%If’, &val) = 1) ? val : gmt-NaN; if (val = no-data) a[ij] = gmt-NaN;

ptr = strtok(CNULL, ” \t,“); i++; ij++;

if (I$i != Min) fclose (fpi);

for (ij = 0; ij < nm; ij++) { if (bad-float (a[ij]))

n empty++; else * -

n-filled++; 1

/* Check if all nodes got one value only */

fprintf (stderr, “ascii2grd: n-used: %d n-filled: %d n-empty: %d set to NaNIn”, nm, n-filled, n-empty);

if (writesd (grdfïle, &grd, a, 0.0, 0.0, 0.0, 0.0, dummy, FALSE)) { fprintf (stderr, “ascii2grd: Error writing file %An”, grdtïle); exit (- 1);

>

free ((char *)a);

gmt-end (argc, argv);

ASCII2GRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 22: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE 3: kk3CtiGRD.C 25

if (writesd (grdfile, &grd, a, 0.0, 0.0, 0.0, 0.0, dummy, FALSE)) { fjxintf (stderr, “ascii2grd: Errer writing file %S~I”, grclf3e); exit (- 1);

1

free ((char *)a);

int get-a%R (item, w, e, s, a) char *item- double *w,‘*e, *s, *n; {

char *text, stria 1001;

/* get-ar&R interprete la ligne de commande pour l’option -R */

int i, errer = 0; dode *P[41, ~to-c&we 0;

switch (item[ 11) { case ‘R:

PM = w P[U = e; PM = s; P[~I = n;

project_info.regim~supplied = TRUE; i = 0; strcpy (string &item[2]); .text = strtok (dring, “I”); while (text) {

*P[i] = ddmms-tc-degree (text); i++; text = strtok (CNULL, “Y);

ACi < 4) II (*P[~I * *P[~I) II (*WI = *pi311 1 { errer++;

fjnintf(stderr, “ascii2grd GMT SYNTAX ERROR -R option. Correct syntax: in”);

ok\n”);

1

fprinlf (stderr, “\t-R<xmin>/<xmax>/<ymin>/<ymax>, dd: mm format

1 break;

return (errer); >

A!XXDGRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy

Page 23: 111111111111 Fonds Do.xnwntair* ClRsrOMhorizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_6/... · UTILISATION 9 Par conséquent pour simuler l’en-tête présenté

ANNEXE~:BIBLIOGRAPHIE 27

l Gabalda G., GMT, GRD2ASCII, Programme de conversion de grilles binaires (netCDF) en grilles ascii, (Version 3.0 - Février 1996), Orstom, Laboratoire de Géophysique, Bondy, Notice d’utilisation, 17 p.

l Wessel, P., and W. H. F. Smith, New version of the Generic Mapping Tools released, EOS Trans. Amer. Geophys. U., vol. 76, pp. 329, 1995.

l Wessel, P., and W. H. F. Smith, 1995, The Generic Mapping Tools mm version 3.0 Technical Reference & Cookbook, SOEST/NOAA.

l Wessel, P., and W. H. F. Smith, New version of the Generic Mapping Tools released., EOS Trans. Amer. Geophys. U. electronic suppzement, http://www. agu.org/eos-elec9-i 154e. html, 1995.

l Wessel, P., and W. H. F. Smith, Free software helps map and display data, EOS Trans. Amer. Geophys. U., vol. 72, pp. 441, 445-446, 199 1.

ASCIDGRD (Février 1996) - Notice d’utilisation Laboratoire de Géophysique - Orstom Bondy