-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlats4d.gs
executable file
·4318 lines (3809 loc) · 148 KB
/
lats4d.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*
* Lats4d is a minimum fuss script for writing NetCDF, HDF-SDS or GRIB
* files from GrADS using the PCMDI (http://www-pcmdi.llnl.gov) LATS
* interface. This script requires GrADS Version 1.7.beta.9 or later.
*
* See usage() for documentation; from GrADS enter "lats4d -h"
*
* This script has been placed in the Public Domain.
*
*...........................................................................
*
* main(args) Main driver checking config, handling error conditions, etc.
*
function main ( args )
_myname = 'lats4d: '
_version = '2.1.5 of 28 June 2010'
* Parse command line
* ------------------
rc = parsecmd(args)
if ( rc != 0 )
say '<RC> 'rc' </RC>'
say '</IPC>'
if ( _quit = 1 )
say _myname 'exiting from GrADS...'
'quit'
endif
return rc
endif
* Check GrADS configuration
* -------------------------
rc = chkcfg()
if ( rc != 0 )
say '<RC> 'rc' </RC>'
say '</IPC>'
if ( _quit = 1 )
say _myname 'exiting from GrADS...'
'quit'
endif
return rc
endif
* Consistency check
* -----------------
if ( _needLATS=0 ); _hasLATS=0; endif
if ( _needLATS=1 & _hasLATS=0 )
rc = 1
say '<RC> 'rc' </RC>'
say '</IPC>'
say 'ERROR: cannot proceed without LATS; try specifying a different -format'
if ( _quit = 1 )
say _myname 'exiting from GrADS...'
'quit'
endif
return rc
endif
* Output file message
* -------------------
_fmsg = 'unknown'
_vmsg = 'creat'
if ( _format = 'stream' | _format = 'sequential' )
_fmsg = _format ' file ' _ofname '.bin'
_fwrite = 1
else
_fwrite = 0
if ( _format = 'coards' | _format = 'netcdf' | _format = 'nc3')
if ( _shave>0 | _gzip>=0 )
_format = 'netcdf4'
else
_fmsg = _format ' file ' _ofname '.nc'
_format = 'netcdf'
endif
endif
if ( _format = 'netcdf4' | _format = 'nc4')
_fmsg = _format ' file ' _ofname '.nc4'
_format = 'netcdf4'
endif
if ( _format = 'hdf' | _format = 'hdf4')
_fmsg = _format ' file ' _ofname '.hdf'
_format = 'hdf4'
endif
if ( _format = 'grib' )
_format = 'grib_only'
endif
if ( _format = 'grib_only' | _format = 'grads_grib' )
_fmsg = _format ' file ' _ofname '.grb'
endif
if ( _format = 'stats' )
_fmsg = 'statistics'
endif
n = lenstr(_format)-2
ext = substr(_format,n,3)
if ( ext='.gs' | ext='.GS' )
_gsfile = _format
_fmsg = 'script ' _gsfile
_vmsg = 'execut'
_format = 'script'
endif
n = lenstr(_format)-3
ext = substr(_format,n,4)
if ( ext='.gsf' )
_gsfile = _format
_fmsg = 'script ' _gsfile
_vmsg = 'call'
_format = 'gsfunc'
rc = gsfallow("on")
'!rm -rf lats4d_user.gsf'
'!ln -s ' _gsfile ' lats4d_user.gsf'
endif
if ( _fmsg = 'unknown' )
say _myname 'invalid format "'_format'", exiting GrADS...'
'quit'
endif
endif
* OK, ready for the real work
* ---------------------------
rc = lats4d ( args )
if ( rc != 0 )
say _myname 'error '_vmsg'ing ' _fmsg
say '<RC> 'rc' </RC>'
say '</IPC>'
else
say _myname '' _vmsg 'ed ' _fmsg
endif
if ( _quit = 1 )
say _myname 'exiting from GrADS...'
'quit'
endif
return rc
*............................................................................
*
* lats4d(args) The main lats4d entry point.
*
function lats4d ( args )
if ( _verb = 1 )
say _myname 'Version ' _version
endif
* Open input file and reset dimension environment if desired...
* Assumes global grid, i.e., longitudinal wrapping
* -------------------------------------------------------------
if ( _ifname != '' )
'reinit'
rc=openf(_ifname,_ftype)
if ( rc != 0 )
say _myname 'cannot open file "'_ifname'"'
return rc
endif
if ( _ctlinfo )
say '<ctlinfo>'
'query ctlinfo'
say result
say '</ctlinfo>'
return 0
endif
rc = xyrange()
'set x ' _xmin ' ' _xmax
'set y ' _ymin ' ' _ymax
endif
* Get file number
* ---------------
'q file'
if ( rc != 0 )
say _myname 'no files open; specify "-i" option or open a file'
return rc
endif
_datf = subwrd(result,2)
* Open alternate input file name; must be conformant with
* main input file name
* -------------------------------------------------------
if ( _afname != '' )
rc=openf(_afname,_ftype)
if ( rc != 0 )
say _myname 'cannot open alternate file "'_afname'"'
return rc
endif
_altf = _datf + 1
endif
* Open dimension environment file if so desired,
* otherwise let dim env file be the same as the current data file
* ---------------------------------------------------------------
rc = setdimf()
if ( rc != 0 )
say _myname 'could not open dimension env file: ' _dimenv
return rc
endif
* File information
* ----------------
if ( _verb = 1 )
'q file ' _datf
say _myname 'Data file is '
say result
if ( _datf != _dimf )
'q file ' _dimf
say _myname 'Dimension environment file is '
say result
else
say _myname 'Dimension environment file same as data file'
endif
if ( _afname != '' )
'q file ' _altf
say _myname 'Alternate Data file is '
say result
endif
endif
* Metadata describing origin of the dataset
*------------------------------------------
rc=LATScmd(_setLATS ' model ' _model)
rc=LATScmd(_setLATS ' center ' _center)
* Parameter table
* ---------------
rc = getvars()
ch = substr(_table,1,1)
* generate parameter table
if ( ch = '@' )
_table = substr(_table,2,256)
rc = mkptab()
if ( rc != 0 ); return 1; endif
endif
* use internal table
if ( ch = '=' )
_table = ''
endif
if ( _table != '' )
rc=LATScmd(_setLATS ' parmtab ' _table)
id = subwrd(_result,5)
if ( id = 0 ); return 1; endif
endif
* LATS comments (Title for GRIB files)
* ------------------------------------
if ( _title = '' )
if ( _func = '' )
comment = 'File created by GrADS using LATS4D available from '
else
comment = 'File created by GrADS using LATS4D '
comment = comment '(-func ' _func ') available from '
endif
url = 'http://opengrads.org/wiki/index.php?title=Lats4D'
rc=LATScmd(_setLATS ' comment ' comment url)
else
rc=LATScmd(_setLATS ' comment ' _title)
endif
* Metadata describing conventions/format
* --------------------------------------
if ( _needLATS )
rc=LATScmd(_setLATS ' convention ' _format)
if ( rc != 0 )
say _myname 'not really, we stop right here'
return 1
endif
endif
* Get (z,t) range on file
* -----------------------
rc = ztrange()
* Metadata describing time frequency of grids
* -------------------------------------------
if ( _freq = '' )
rc = getfreq()
if ( rc != 0 )
say _myname 'could not determine time frequency; specify -freq option'
return rc
endif
endif
rc=LATScmd(_setLATS ' calendar ' _cal)
if ( rc != 0 ); return rc; endif
if (_gzip>=0)
rc=LATScmd(_setLATS ' gzip ' _gzip)
if ( rc != 0 ); return rc; endif
if ( _verb = 1 )
say _myname 'compressing with GZIP level ' _gzip
endif
endif
if (_shave>0)
rc=LATScmd(_setLATS ' shave ' _shave)
if ( rc != 0 ); return rc; endif
if ( _verb = 1 )
say _myname 'shaving ' _shave ' bits from mantissa and compressing'
endif
endif
rc=LATScmd(_setLATS ' frequency ' _freq)
if ( rc != 0 ); return rc; endif
if ( _tinc='' ); _tinc=1; endif
odeltat = _tinc * _deltat
rc=LATScmd(_setLATS ' deltat ' odeltat)
if ( rc != 0 ); return rc; endif
* Redefine time range (_tmin,_tmax) if user wants to
* --------------------------------------------------
rc = gettim()
if ( rc = 1 )
say _myname 'invalid time range ' _time
return
endif
* If -ntimes specified, limit tmax
* --------------------------------
if ( _ntimes > 0 )
_tmax = _tmin + _ntimes - 1
endif
if ( _verb = 1 )
'set t ' _tmin ' ' _tmax
'q time'
t1 = subwrd(result,3)
t2 = subwrd(result,5)
say _myname 'time range: ' t1 ' ' t2 ' by ' _tinc ', delta t: ' _deltat ' ' _freq
'set t ' _tmin
endif
* If -nlevels specified, limit _zmax
* --------------------------------
if ( _nlevels > 0 )
_zmax = _zmin + _nlevels - 1
endif
if ( _verb = 1 )
'set z ' _zmin ' ' _zmax
endif
* Define the vertical dimension
* -----------------------------
if ( _levels = '' )
rc = getlevs()
endif
if ( _verb = 1 )
say _myname 'vertical levels: ' _levels
endif
rc = setlevs()
if ( rc = 1 ); return 1; endif
* Set LATS grid type
* ------------------
rc=LATScmd(_setLATS ' gridtype ' _gridtype)
if ( rc != 0 ); return rc; endif
* Instruct LATS to use the dimension environment to set the LATS time
* -------------------------------------------------------------------
rc=LATScmd(_setLATS ' timeoption dim_env')
if ( rc != 0 ); return rc; endif
* Define the horizontal grid (based on dim env file)
* --------------------------------------------------
'set dfile ' _dimf
rc = setgrid()
if ( rc != 0 ); return rc; endif
if ( _verb = 1 )
say _myname 'latitudinal range: ' _lat
say _myname 'longitudinal range: ' _lon
endif
_gid = getgid()
if ( _gid < 1 ); return 1; endif
'set dfile ' _datf
* Define the output file name
* ---------------------------
if ( _fwrite = 1 )
if ( _format = 'stream' )
'set fwrite ' _endianess ' -st '_ofname'.bin'
else
'set fwrite ' _endianess ' -sq '_ofname'.bin'
endif
else
if ( _needLATS )
rc=LATScmd(_setLATS ' create ' _ofname)
_fid = subwrd(_result,5)
if ( _fid < 1 ); return 1; endif
endif
endif
* Define all the variables to be written to the LATS file
* -------------------------------------------------------
rc = defvars()
if ( rc != 0 )
say _myname 'fatal error defining variables'
return rc
endif
if ( _verb = 1 )
if ( _func !='' ); say _myname 'Function expression: ' _func; endif
if ( _svars !='' ); say _myname 'surface variables: ' _svars ; endif
if ( _uvars !='' ); say _myname 'upper air variables: ' _uvars ; endif
endif
if ( _svars='' & _uvars='' )
say _myname 'All invalid sfc/upper variables: ' _vars
return 1
endif
* Put GrADS in LATS output mode
* -----------------------------
if ( _fwrite = 1 )
'set gxout fwrite'
else
if ( _needLATS )
if ( _udxLATS=0 )
rc=LATScmd('set gxout latsdata')
if ( rc != 0 ); return rc; endif
endif
else
'set gxout stat'
endif
endif
* Now, if user wants time mean then redefine time environment
* -----------------------------------------------------------
if ( _mean = 1 )
_tbeg = _tmin
_tend = _tmax
if ( _tinc = '' ); _tinc = 1; endif
_tmid = ( _tmin + _tmax ) / 2
if ( _tmean != '' ); _tmid = _tmean; endif
_tmin = _tmid
_tmax = _tmid
if ( _verb = 1 )
'set t ' _tmid
'q time'
t1 = subwrd(result,3)
say _myname 'time average grid valid at ' t1
say _myname 'averaging increment: ' _tinc ', delta t: ' _deltat ' ' _freq
endif
endif
* The LATS interface only allows one horizontal slice of data
* to be written at a time (z and t dimensions must be fixed),
* so we setup 2 loops
* --------------------------------------------------------------
if ( _format = 'stats' )
say ''
say '<stats>'
endif
* Check number of time steps
* --------------------------
ntimes = _tmax - _tmin + 1
if ( ntimes>_mxtimes )
say ''
say 'ERROR: number of time steps larger than current maximum ' _mxtimes
say 'ERROR: if you really intended to write out that many timesteps, specify'
say _myname ' -mxtimes ' ntimes
say 'ERROR: or else verify your -time option'
say ''
return 1
endif
* Loop over time...
* -----------------
_t = _tmin
while ( _t <= _tmax )
'set t ' _t
if ( rc != 0 ); return rc; endif
'set z ' _zmin
if ( rc != 0 ); return rc; endif
if ( _verb = 1 & _format != 'stats' )
'q time'
time = subwrd(result,3)
if ( _format = 'script' )
say _myname 'running ' _fmsg ' on ' time
else
if ( _format = 'gsfunc' )
say _myname 'calling ' _fmsg ' on ' time
else
if ( _format != 'stats' )
say _myname 'writing to ' _fmsg ' on ' time
endif
endif
endif
endif
if ( _format = 'stats' )
'q time'
time = subwrd(result,3)
filen = subwrd(_ifname,1)
say '+'
say '+ <> Statistics on ' time ' for "' basename(filen) '"'
if ( _afname != '' )
filen = subwrd(_afname,1)
say '+ <> Secondary input file is "' basename(filen) '"'
if ( _func = '' )
_func = '@[email protected]'
endif
endif
if ( _func != '' )
say ' >>> Applying function "' _func '"'
endif
_pad = '+ '
endif
* Write surface variables
* -----------------------
n = 1
if ( _format = 'stats' & _nsvar>0 ); pstat('HEADER'); endif
while ( n <= _nsvar )
var = subwrd(_svars,n)
name = var
if ( _dimenv != '' )
var = var '.' _datf '(t=' _t ')'
endif
var = subst(var,_func)
if ( _mean = 1 )
var = 'ave('var',t='_tbeg',t='_tend','_tinc')'
endif
vid = subwrd(_svids,n)
if ( _needLATS )
rc=LATScmd(_setLATS ' write ' _fid ' ' vid)
if ( rc != 0 ); return rc; endif
endif
'set dfile ' _dimf
if ( _format = 'stats' )
rc = pstat(name,var,'sfc')
else
if ( _format = 'script' )
'run ' _gsfile ' ' var
else
if ( _format = 'gsfunc' )
rc = lats4d_user(var)
if ( rc='' ); rc=0; endif
else
if ( _udxLATS=1 & _fwrite!=1)
rc=LATScmd('lats_data ' var)
else
'display ' var
endif
endif
endif
endif
if ( rc !=0 ); return rc; endif
'set dfile ' _datf
n = n + 1
endwhile
*
* Loop over upper air variables...
* --------------------------------
n = 1
while ( n <= _nuvar )
var = subwrd(_uvars,n)
name = var
if ( _dimenv != '' )
var = var '.' _datf '(t=' _t ')'
endif
var = subst(var,_func)
if ( _mean = 1 )
var = 'ave('var',t='_tbeg',t='_tend','_tinc')'
endif
vid = subwrd(_uvids,n)
* Loop over levels...
* -------------------
k = 1
_level = subwrd(_levels,k)
if ( _format = 'stats' ); pstat('HEADER'); endif
while ( _level != '' )
_latlevel = subwrd(_latlevels,k)
'set lev ' _level
if ( _needLATS )
rc=LATScmd(_setLATS ' write ' _fid ' ' vid ' ' _latlevel)
if ( rc != 0 ); return rc; endif
endif
'set dfile ' _dimf
if ( _format = 'stats' )
rc = pstat(name,var,_level)
else
if ( _format = 'script' )
'run ' _gsfile ' ' var
else
if ( _format = 'gsfunc' )
rc = lats4d_user(var)
if ( rc = '' ); rc=0; endif
else
if ( _udxLATS=1 & _fwrite!=1)
rc=LATScmd('lats_data ' var)
else
'display ' var
endif
endif
endif
endif
if ( rc != 0 ); return rc; endif
'set dfile ' _datf
k = k + 1
_level = subwrd(_levels,k)
endwhile
if ( _format = 'stats' ); pstat('TOTAL',name); endif
n = n + 1
endwhile
_t = _t + _tinc
endwhile
if ( _format = 'stats' )
say ''
say '</stats>'
endif
rc = restdim()
* Close LATS file
* ---------------
if ( _fwrite = 1 )
'disable fwrite'
else
if ( _needLATS )
rc=LATScmd(_setLATS ' close ' _fid)
if ( rc != 0 ); return rc; endif
endif
endif
* All done
* --------
return 0
*.........................................................................
function usage(flag)
say ''
say 'NAME'
say ''
say ' lats4d - LATS for Dummies (Version ' _version ')'
say ''
say 'SYNOPSIS'
say ''
say ' lats4d [-i fn] [-o fn] [-cal calendar] [-center ctr] [-de fn]'
say ' [-format fmt] [-ftype ctl|sdf|xdf] [-freq ...] '
say ' [-func expr] [-h] [-grid type]'
say ' [-lat y1 y2] [-levs ...] [-lon x1 x2] '
say ' [-model mod] [-mean] [-precision nbits] [-table tab] '
say ' [-time t1 t2 [tincr]] [-title ...]'
say ' [-v] [-vars ...] [-xvars] [-zrev] [-q] '
say ''
if ( flag != 1 )
say ' Enter "lats4d -h" for additional information'
say ''
return
endif
say 'DESCRIPTION'
say ''
say ' A minimum fuss gs script for writing NetCDF, HDF-SDS or '
say ' GRIB files from GrADS using the PCMDI LATS interface '
say ' (http://www-pcmdi.llnl.gov). This script can serve as a'
say ' general purpose file conversion and subsetting utility.'
say ' Any GrADS readable file (GrADS IEEE, GSFC Phoenix, GRIB, '
say ' NetCDF or HDF-SDS) can be subset and converted to GRIB, '
say ' NetCDF, HDF-SDS, flat binary (direct access) or sequential'
say ' (FORTRAN) binary using a single command line. When writing'
say ' binary files, the user can request the files to be little '
say ' or big endian, regardless of the endianess of the hardware.'
say ' '
say ' When invoked without arguments this script will create a'
say ' COARDS compliant NetCDF or HDF-SDS file named '
say ' "grads.lats.nc", with all the contents of the default '
say ' file (all variables, levels, times). The file name and '
say ' several other attributes can be customized at the command'
say ' line, see OPTIONS below.'
say ' '
say ' IN GrADS v1.x, NetCDF files are obtained by running this script under the'
say ' executable "gradsnc". HDF-SDS files can be produced with'
say ' the "gradshdf" executable. Notice that the classic version'
say ' of grads, "gradsc", does not include support for LATS and'
say ' therefore cannot be used with lats4d. This script requires'
say ' GrADS Version 1.7.beta.9 or later.'
say ''
say 'OPTIONS'
say ''
say ' -i fn input file name; it can be any'
say ' of the following:'
say ' - an ASCII control (ctl) file'
say ' used for GRIB, IEEE files, and'
say ' as of GrADS v1.9, for NetCDF/HDF'
say ' files as well.'
say ' - a binary NetCDF file/template'
say ' - a binary HDF-SDS file/template'
say ' - an ASCII data descriptor file (ddf)'
say ' used for non-COARDS compliant'
say ' NetCDF/HDF-SDS files through'
say ' the "xdfopen" command'
say ' If the option "-ftype" is not'
say ' specified lats4d attempts to'
say ' determine the file type using'
say ' a heuristic algorithm.'
say ' NOTE: When the option "-i" is '
say ' specified a GrADS "reinit" is '
say ' issued before the file is opened.'
say ' For NetCDF/HDF-SDS templates in'
say ' GrADS consult the SDFopen home'
say ' page listed under SEE ALSO'
say ''
say ' -j fn secondary input file name with same'
say ' structure as the the primary input'
say ' file (same variables, grid, times).'
say ' This is useful for comparing files.'
say ' You can also specify -func for'
say ' controling how the 2 files are compared.'
say ' By default, -func is set to "@[email protected]"'
say ' for the difference of the 2 files.'
say ' The default is no secondary file.'
say ''
say ' -o fn output (base) file name; default: '
say ' "grads.lats"'
say ''
say ' -be when format is "stream" or "sequential"'
say ' this option forces the file to be'
say ' BIG ENDIAN, regardless of the native'
say ' endianess'
say ''
say ' -cal calendar calendar type: "standard", "noleap", '
say ' "clim", or "climleap"; default: '
say ' "standard"'
say ''
say ' -center ctr center, e.g., PCMDI, GSFC, NCEP, etc'
say ''
say ' -ctlinfo performs a "q ctlinfo" and writes it'
say ' to the screen. '
say ''
say ' -de fn Dimension environment file name;'
say ' defaut: same as "-i" argument.'
say ' This option is useful for using'
say ' lats4d with the regridding, e.g.,'
say ' the re() function. See REGRIDDING below'
say ' for more information.'
say ''
say ' -format fmt LATS file format; fmt can be one of the'
say ' following:'
say ' coards'
say ' netcdf (*)'
say ' netcdf4 (*)'
say ' hdf4 (*)'
say ' grib'
say ' grads_grib'
say ' sequential'
say ' stream'
say ' stats'
say ' $script.gs'
say ' $script.gsf'
say ' where $script is a generic script name. '
say ' Specify "grads_grib" instead of "grib" for'
say ' getting ctl and gribmap files as well.'
say ' See FORMAT OPTIONS below for more information.'
say ' NOTE: Formats netcdf, netcdf4 and hdf4 requires'
say ' GrADS Version v2.0.a7.oga.3 or later.'
say ' In GrADS v1.x, NetCDF/HDF output is'
say ' obtained with format "coards", and the actual'
say ' output format is determined by the name of'
say ' GrADS binary (either gradsnc or gradshdf.)'
say ''
say ' -ftype ctl|sdf|xdf Specifies the input file type:'
say ' ctl standard GrADS control (ctl)'
say ' file used for IEEE and GRIB '
say ' files'
say ' sdf COARDS compliant NetCDF/HDF-SDS'
say ' binary data file'
say ' xdf data descriptor file (ddf)'
say ' used for non-COARDS compliant'
say ' NetCDF/HDF-SDS files through'
say ' the "xdfopen" command'
say ' By default lats4d attempts to '
say ' determine the file type using a'
say ' heuristic algorithm; use this'
say ' option if lats4d fails to properly'
say ' detect the input file type'
say ' '
say ' -freq [n] unit Time frequency of the input file.'
say ' LATS4D usually detects this from'
say ' the GrADS metadata, but sometimes'
say ' it fails with an error message.'
say ' In such cases use this option.'
say ' Example: -freq 6 hourly '
say ' NOTE: unlike GrADS, LATS does not'
say ' support time frequency in minutes'
say ' Default: n=1, e.g., -freq daily'
say ' '
say ' -func expr Evaluates the expression "expr"'
say ' before writing to the output'
say ' file. The character "@" is used'
say ' to denote the variable name in'
say ' "expr". Example:'
say ' '
say ' -func ave(@,t-1,t+1)'
say ' '
say ' will replace "@" with each '
say ' variable name and produce a file'
say ' with running means. Default:'
say ' expr = @'
say ' '
say ' -grid type Grid type: linear, gaussian or'
say ' generic; default: linear'
say ' '
say ' -gzip level Specifies the gzip compression level.'
say ' This option applies to NetCDF4 output.'
say ' The "level" parameter must be in the'
say ' range [0,9], where the higher the level'
say ' the hearder it will work to compress.'
say ' NOTE: This option requires GrADS Version'
say ' v2.0.a7.oga.3 or later.'
say ' '
say ' -h displays this man page'
say ''
say ' -halo left [right] Specify the halo width for the satellite'
say ' mask. This option is ignored unless option -mask'
say ' is specified.'
say ''
say ' -lat y1 y2 latitude range, e.g., "-30 30" for '
say ' 30S thru 30N; default: latitude '
say ' dimension environment'
say ''
say ' -le when format is "stream" or "sequential"'
say ' this option forces the file to be'
say ' LITTLE ENDIAN, regardless of the'
say ' native endianess'
say ''
say ' -levs lev1 ... levN list of levels; default: all levels'
say ''
say ' -lon x1 x2 longitude range, e.g., "-50 20" for '
say ' 50W thru 20E; default: longitude '
say ' dimension environment'
say ''
say ' -mask sat Mask the output variables according to the'
say ' orbits of the satellite "sat". This is '
say ' accomplished with function orb_mask() '
say ' provided by the ORB extension. Currently, '
say ' the following values of "sat" are supported:'
say ''
say ' Sat Swath (km)'
say ' --------------- -------------'
say ' airs 1650'
say ' amsu_a 1650'
say ' amsr_e 1445'
say ' aqua 0'
say ' aster 60'
say ' aura 0'
say ' calipso 0'
say ' cloudsat 0'
say ' hirdls 3000'
say ' hsb 1650'
say ' misr 380'
say ' modis_terra 2330'
say ' modis_terra_day 2330 (day_time only)'
say ' modis_aqua 2330'
say ' modis_aqua_day 2330 (day_time only)'
say ' mopitt 616'
say ' omi 2600'
say ' omi_day 2600 (day time only)'
say ' terra 0'
say ' tes 180'
say ' '
say ' You can slo specify option -halo to '
say ' specify gridpoints around the mask.'
say ' Consult the ORB documentation for more details:'
say ' http://opengrads.org/doc/udxt/orb/'
say ''
say ' -mxtimes n Maximum number of timesteps to be written to file;'
say ' default is 744'
say ''
say ' -mean saves time mean to file; the actual'
say ' averaging period is specified with'
say ' the "-time" option; the "tincr" '
say ' parameter is the time increment'
say ' for the average (see GrADS ave()'
say ' function)'
say ''
say ' -tmean specify output "t" for the time mean;'
say ' default is the mid time of the'
say ' averaging interval. Noice that "t"'
say ' is an integer'
say ''
say ' -model mod model name, e.g., GEOS/DAS'
say ''
say ' -nlevels n Specify number of level steps to be written'
say ' to file'
say ''
say ' -ntimes n Specify number of time steps to be written'
say ' to file; it superseeds the -time option'
say ''
say ' -precision nbits specify the number of bits of'
say ' precision when storing in GRIB.'
say ' This option is only used when'
say ' lats4d automatically generates'
say ' a parameter table file (see option'
say ' -table below), and the output'
say ' format is "grib" or "grads_grib".'
say ' Default: nbits = 16'
say ''
say ' -shave [nbits] Specify number of mantissa bits to shave'
say ' before compression. Default is nbits=12;'
say ' nbits must be in the range [1,23]. '
say ' This feature requires netcdf4 output and'
say ' will automatically trigger gzip level 2'
say ' compression (see -zip option).'
say ' NOTE: This option requires GrADS Version'
say ' v2.0.a7.oga.3 or later.'
say ''
say ' -table tab LATS parameter table file, e.g., '
say ' "dao.lats.table". If the table name'
say ' starts with "@" (e.g., @my.table)'
say ' then lats4d automatically generates'
say ' a LATS parameter table appropriate'
say ' for the current file and saves it '
say ' to a file; the file name in this'
say ' case is the same as "tab" with the'
say ' @ character removed (e.g., my.table).'
say ' Specify tab as "=" for using the'
say ' internal LATS parameter table.'
say ' See below for additional info on'
say ' parameter tables.'
say ' Default: @.grads.lats.table'
say ''
say ''
say ' -time t1 t2 [tincr] time range and time increment in '
say ' units of the "delta t" in the'
say ' input file; "tincr" is optional;'
say ' Example: "0z1dec91 18z31dec91 2"'
say ' to write every other '
say ' time step'
say ' Defaults: (t1,t2) is taken from '
say ' the time dimension environment,'
say ' and tincr=1. Note: enter "= ="'
say ' for keeping the default values'
say ' for (t1,t2) while specifying tincr'
say ''
say ' -title text output dataset TITLE for GRIB files,'
say ' COMMENTS for NetCDF/HDF files'
say ''
say ' -v verbose mode'
say ''
say ' -vars var1 ... varN list of variables; default: all '
say ' variables on the current file will'
say ' be written to the output file'
say ''
say ' -xsfc exclude all surface variables'
say ''
say ' -xvars var1 ... varN list of variables to exclude;'
say ' default: none'
say ''
say ' -xupper exclude all upper air variables'
say ''
say ' -zrev reverse order of vertical levels'
say ''
say ' -q quits GrADS upon return'
say ' '
say 'FORMAT OPTIONS'
say ' '
say ' Although Lats4d was originally designed as a frontend to'
say ' the LATS interface, it has grown to become somewhat of a generic'
say ' "iterator" for GrADS redable files. In fact, some "-format" options'
say ' do not involve LATS at all. In particular,'
say ' '
say ' 1) The options "-format stream" and "-format sequential" create'
say ' binary files using the GrADS command "set gxout fwrite".'
say ' A useful feature not implemented yet is the ability of '
say ' automatically creating a ctl file.'
say ' 2) The option "-format stats" does not write any file. Instead,'
say ' it just prints statistics about the variables on file, for'
say ' each time and level. When used in conjunction with "-j"'