forked from altMITgcm/MITgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.F
1434 lines (1376 loc) · 47 KB
/
print.F
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
C $Header: /u/gcmpack/MITgcm/eesupp/src/print.F,v 1.19 2001/09/21 14:31:12 adcroft Exp $
C $Name: $
#include "CPP_EEOPTIONS.h"
C-- File printf.F: Routines for performing formatted textual I/O
C-- in the MITgcm UV implementation environment.
C-- Contents
C-- o print_error Does IO with **ERROR** highlighted header
C-- o print_list_i Prints one-deimensional list of INTEGER
C-- numbers.
C-- o print_list_l Prints one-deimensional list of LOGICAL
C-- variables.
C-- o print_list_r8 Prints one-deimensional list of Real*8
C-- numbers.
C-- o print_mapr4 Formats ABCD... contour map of a Real*4 field
C-- Uses print_message for writing
C-- o print_mapr8 Formats ABCD... contour map of a Real*8 field
C-- Uses print_message for writing
C-- o print_message Does IO with unhighlighted header
CBOP
C !ROUTINE: PRINT_ERROR
C !INTERFACE:
SUBROUTINE PRINT_ERROR( message , myThid )
IMPLICIT NONE
C !DESCRIPTION:
C *============================================================*
C | SUBROUTINE PRINT_ERROR
C | o Write out error message using "standard" format.
C *============================================================*
C | Notes
C | =====
C | o Some system I/O is not "thread-safe". For this reason
C | without the FMTFTN_IO_THREAD_SAFE directive set a
C | critical region is defined around the write here. In some
C | cases BEGIN_CRIT() is approximated by only doing writes
C | for thread number 1 - writes for other threads are
C | ignored!
C | o In a non-parallel form these routines are still used
C | to produce pretty printed output. The process and thread
C | id prefix is omitted in this case.
C *============================================================*
C !USES:
C == Global data ==
#include "SIZE.h"
#include "EEPARAMS.h"
#include "EESUPPORT.h"
INTEGER IFNBLNK
EXTERNAL IFNBLNK
INTEGER ILNBLNK
EXTERNAL ILNBLNK
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C message :: Text string to print
C myThid :: Thread number of this instance
CHARACTER*(*) message
INTEGER myThid
C !LOCAL VARIABLES:
C == Local variables ==
C iStart, iEnd :: Temps. for string indexing
C idString :: Temp. for building message prefix
INTEGER iStart
INTEGER iEnd
CHARACTER*9 idString
CEOP
C-- Find beginning and end of message
iStart = IFNBLNK( message )
iEnd = ILNBLNK( message )
C-- Test to see if in multi-process ( or multi-threaded ) mode.
C If so include process or thread identifier.
IF ( numberOfProcs .EQ. 0 .AND. nThreads .EQ. 1 ) THEN
C-- Write single process format
IF ( message .EQ. ' ' ) THEN
WRITE(errorMessageUnit,'(A,1X,A)') ERROR_HEADER, ' '
ELSE
WRITE(errorMessageUnit,'(A,1X,A)') ERROR_HEADER,
& message(iStart:iEnd)
ENDIF
ELSEIF ( pidIO .EQ. myProcId ) THEN
C-- Write multi-process format
#ifndef FMTFTN_IO_THREAD_SAFE
_BEGIN_CRIT(myThid)
#endif
WRITE(idString,'(I4.4,A,I4.4)') myProcId,'.',myThid
#ifndef FMTFTN_IO_THREAD_SAFE
_END_CRIT(myThid)
#endif
IF ( message .EQ. ' ' ) THEN
C PRINT_ERROR can be called by several threads simulataneously.
C The write statement may need to be marked as a critical section.
#ifndef FMTFTN_IO_THREAD_SAFE
_BEGIN_CRIT(myThid)
#endif
WRITE(errorMessageUnit,'(A,A,1X,A,A,A,A,A)',ERR=999)
& '(',PROCESS_HEADER,idString,')',ERROR_HEADER,' ',
& ' '
#ifndef FMTFTN_IO_THREAD_SAFE
_END_CRIT(myThid)
#endif
ELSE
#ifndef FMTFTN_IO_THREAD_SAFE
_BEGIN_CRIT(myThid)
#endif
WRITE(errorMessageUnit,'(A,A,1X,A,A,A,A,A)',ERR=999)
& '(',PROCESS_HEADER,idString,')',ERROR_HEADER,' ',
& message(iStart:iEnd)
#ifndef FMTFTN_IO_THREAD_SAFE
_END_CRIT(myThid)
#endif
ENDIF
ENDIF
C
1000 CONTINUE
RETURN
999 CONTINUE
ioErrorCount(myThid) = ioErrorCount(myThid)+1
GOTO 1000
END
CBOP
C !ROUTINE: PRINT_LIST_I
C !INTERFACE:
SUBROUTINE PRINT_LIST_I( fld, lFld, index_type,
& markEnd, compact, ioUnit )
IMPLICIT NONE
C !DESCRIPTION:
C *==========================================================*
C | o SUBROUTINE PRINT_LIST_I
C *==========================================================*
C | Routine for producing list of values for a field with
C | duplicate values collected into
C | n @ value
C | record.
C *==========================================================*
C !USES:
C == Global data ==
#include "SIZE.h"
#include "EEPARAMS.h"
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C fld :: Data to be printed
C lFld :: Number of elements to be printed
C index_type :: Flag indicating which type of index to print
C INDEX_K => /* K = nnn */
C INDEX_I => /* I = nnn */
C INDEX_J => /* J = nnn */
C INDEX_NONE =>
C compact :: Flag to control use of repeat symbol for same valued
C fields.
C markEnd :: Flag to control whether there is a separator after the
C last element
C ioUnit :: Unit number for IO.
INTEGER lFld
INTEGER index_type
INTEGER fld(lFld)
LOGICAL markEnd
LOGICAL compact
INTEGER ioUnit
C !LOCAL VARIABLES:
C == Local variables ==
C iLo - Range index holders for selecting elements with
C iHi with the same value
C nDup - Number of duplicates
C xNew, xOld - Hold current and previous values of field
C punc - Field separator
C msgBuf - IO buffer
C index_lab - Index for labelling elements
C K - Loop counter
INTEGER iLo
INTEGER iHi
INTEGER nDup
INTEGER xNew, xOld
CHARACTER punc
CHARACTER*(MAX_LEN_MBUF) msgBuf
CHARACTER*2 commOpen,commClose
CHARACTER*3 index_lab
INTEGER K
CEOP
IF ( index_type .EQ. INDEX_I ) THEN
index_lab = 'I ='
ELSEIF ( index_type .EQ. INDEX_J ) THEN
index_lab = 'J ='
ELSEIF ( index_type .EQ. INDEX_K ) THEN
index_lab = 'K ='
ELSE
index_lab = '?='
ENDIF
commOpen = '/*'
commClose = '*/'
iLo = 1
iHi = 1
punc = ','
xOld = fld(1)
DO K=2,lFld
xNew = fld(K )
IF ( .NOT. compact .OR. (xNew .NE. xOld) ) THEN
nDup = iHi-iLo+1
IF ( nDup .EQ. 1 ) THEN
WRITE(msgBuf,'(A,I9,A)') ' ',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,1X,A)')
& commOpen,index_lab,iLo,commClose
ELSE
WRITE(msgBuf,'(I5,'' '',A,I9,A)') nDup,'@',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,A,I3,1X,A)')
& commOpen,index_lab,iLo,':',iHi,commClose
ENDIF
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT , 1)
iLo = K
iHi = K
xOld = xNew
ELSE
iHi = K
ENDIF
ENDDO
punc = ' '
IF ( markEnd ) punc = ','
nDup = iHi-iLo+1
IF ( nDup .EQ. 1 ) THEN
WRITE(msgBuf,'(A,I9,A)') ' ',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,1X,A)')
& commOpen,index_lab,iLo,commClose
ELSEIF( nDup .GT. 1 ) THEN
WRITE(msgBuf,'(I5,'' '',A,I9,A)') nDup,'@',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,A,I3,1X,A)')
& commOpen,index_lab,iLo,':',iHi,commClose
ENDIF
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT , 1)
RETURN
END
CBOP
C !ROUTINE: PRINT_LIST_L
C !INTERFACE:
SUBROUTINE PRINT_LIST_L( fld, lFld, index_type, markEnd,
& compact, ioUnit )
IMPLICIT NONE
C !DESCRIPTION:
C *==========================================================*
C | o SUBROUTINE PRINT_LIST_L
C *==========================================================*
C | Routine for producing list of values for a field with
C | duplicate values collected into
C | n @ value
C | record.
C *==========================================================*
C !USES:
C == Global data ==
#include "SIZE.h"
#include "EEPARAMS.h"
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C fld - Data to be printed
C lFld - Number of elements to be printed
C index_type - Flag indicating which type of index to print
C INDEX_K => /* K = nnn */
C INDEX_I => /* I = nnn */
C INDEX_J => /* J = nnn */
C INDEX_NONE =>
C compact - Flag to control use of repeat symbol for same valued
C fields.
C markEnd - Flag to control whether there is a separator after the
C last element
C ioUnit - Unit number for IO.
INTEGER lFld
INTEGER index_type
LOGICAL fld(lFld)
LOGICAL markEnd
LOGICAL compact
INTEGER ioUnit
C !LOCAL VARIABLES:
C == Local variables ==
C iLo - Range index holders for selecting elements with
C iHi with the same value
C nDup - Number of duplicates
C xNew, xOld - Hold current and previous values of field
C punc - Field separator
C msgBuf - IO buffer
C index_lab - Index for labelling elements
C K - Loop counter
INTEGER iLo
INTEGER iHi
INTEGER nDup
LOGICAL xNew, xOld
CHARACTER punc
CHARACTER*(MAX_LEN_MBUF) msgBuf
CHARACTER*2 commOpen,commClose
CHARACTER*3 index_lab
INTEGER K
CEOP
IF ( index_type .EQ. INDEX_I ) THEN
index_lab = 'I ='
ELSEIF ( index_type .EQ. INDEX_J ) THEN
index_lab = 'J ='
ELSEIF ( index_type .EQ. INDEX_K ) THEN
index_lab = 'K ='
ELSE
index_lab = '?='
ENDIF
commOpen = '/*'
commClose = '*/'
iLo = 1
iHi = 1
punc = ','
xOld = fld(1)
DO K=2,lFld
xNew = fld(K )
IF ( .NOT. compact .OR. (xNew .NEQV. xOld) ) THEN
nDup = iHi-iLo+1
IF ( nDup .EQ. 1 ) THEN
WRITE(msgBuf,'(A,L5,A)') ' ',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,1X,A)')
& commOpen,index_lab,iLo,commClose
ELSE
WRITE(msgBuf,'(I5,'' '',A,L5,A)') nDup,'@',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,L3,A,I3,1X,A)')
& commOpen,index_lab,iLo,':',iHi,commClose
ENDIF
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT , 1)
iLo = K
iHi = K
xOld = xNew
ELSE
iHi = K
ENDIF
ENDDO
punc = ' '
IF ( markEnd ) punc = ','
nDup = iHi-iLo+1
IF ( nDup .EQ. 1 ) THEN
WRITE(msgBuf,'(A,L5,A)') ' ',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,1X,A)')
& commOpen,index_lab,iLo,commClose
ELSEIF( nDup .GT. 1 ) THEN
WRITE(msgBuf,'(I5,'' '',A,L5,A)') nDup,'@',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,A,I3,1X,A)')
& commOpen,index_lab,iLo,':',iHi,commClose
ENDIF
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT , 1)
RETURN
END
CBOP
C !ROUTINE: PRINT_LIST_R8
C !INTERFACE:
SUBROUTINE PRINT_LIST_R8( fld, lFld, index_type,
& markEnd, compact, ioUnit )
IMPLICIT NONE
C !DESCRIPTION:
C *==========================================================*
C | o SUBROUTINE PRINT_LIST_R8
C *==========================================================*
C | Routine for producing list of values for a field with
C | duplicate values collected into
C | n @ value
C | record.
C *==========================================================*
C !USES:
C == Global data ==
#include "SIZE.h"
#include "EEPARAMS.h"
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C fld - Data to be printed
C lFld - Number of elements to be printed
C index_type - Flag indicating which type of index to print
C INDEX_K => /* K = nnn */
C INDEX_I => /* I = nnn */
C INDEX_J => /* J = nnn */
C INDEX_NONE =>
C compact - Flag to control use of repeat symbol for same valued
C fields.
C markEnd - Flag to control whether there is a separator after the
C last element
C ioUnit - Unit number for IO.
INTEGER lFld
INTEGER index_type
Real*8 fld(lFld)
LOGICAL markEnd
LOGICAL compact
INTEGER ioUnit
C !LOCA VARIABLES:
C == Local variables ==
C iLo - Range index holders for selecting elements with
C iHi with the same value
C nDup - Number of duplicates
C xNew, xOld - Hold current and previous values of field
C punc - Field separator
C msgBuf - IO buffer
C index_lab - Index for labelling elements
C K - Loop counter
INTEGER iLo
INTEGER iHi
INTEGER nDup
Real*8 xNew, xOld
CHARACTER punc
CHARACTER*(MAX_LEN_MBUF) msgBuf
CHARACTER*2 commOpen,commClose
CHARACTER*3 index_lab
INTEGER K
CEOP
IF ( index_type .EQ. INDEX_I ) THEN
index_lab = 'I ='
ELSEIF ( index_type .EQ. INDEX_J ) THEN
index_lab = 'J ='
ELSEIF ( index_type .EQ. INDEX_K ) THEN
index_lab = 'K ='
ELSE
index_lab = '?='
ENDIF
commOpen = '/*'
commClose = '*/'
iLo = 1
iHi = 1
punc = ','
xOld = fld(1)
DO K=2,lFld
xNew = fld(K )
IF ( .NOT. compact .OR. (xNew .NE. xOld) ) THEN
nDup = iHi-iLo+1
IF ( nDup .EQ. 1 ) THEN
WRITE(msgBuf,'(A,1PE23.15,A)') ' ',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,1X,A)')
& commOpen,index_lab,iLo,commClose
ELSE
WRITE(msgBuf,'(I5,'' '',A,1PE23.15,A)') nDup,'@',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,A,I3,1X,A)')
& commOpen,index_lab,iLo,':',iHi,commClose
ENDIF
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , 1)
iLo = K
iHi = K
xOld = xNew
ELSE
iHi = K
ENDIF
ENDDO
punc = ' '
IF ( markEnd ) punc = ','
nDup = iHi-iLo+1
IF ( nDup .EQ. 1 ) THEN
WRITE(msgBuf,'(A,1PE23.15,A)') ' ',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,1X,A)')
& commOpen,index_lab,iLo,commClose
ELSEIF( nDup .GT. 1 ) THEN
WRITE(msgBuf,'(I5,'' '',A,1PE23.15,A)') nDup,'@',xOld,punc
IF ( index_type .NE. INDEX_NONE )
& WRITE(msgBuf(45:),'(A,1X,A,I3,A,I3,1X,A)')
& commOpen,index_lab,iLo,':',iHi,commClose
ENDIF
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , 1)
RETURN
END
CBOP
C !ROUTINE: PRINT_MAPRS
C !INTERFACE:
SUBROUTINE PRINT_MAPRS ( fld, fldTitle, plotMode,
I iLo, iHi, jLo, jHi, kLo, kHi, nBx, nBy,
I iMin, iMax, iStr,
I jMin, jMax, jStr,
I kMin, kMax, kStr,
I bxMin, bxMax, bxStr,
I byMin, byMax, byStr )
IMPLICIT NONE
C !DESCRIPTION:
C *==========================================================*
C | SUBROUTINE PRINT_MAPR4
C | o Does textual mapping printing of a field.
C *==========================================================*
C | This routine does the actual formatting of the data
C | and printing to a file. It assumes an array using the
C | MITgcm UV indexing scheme and base index variables.
C | User code should call an interface routine like
C | PLOT_FIELD_XYR4( ... ) rather than this code directly.
C | Text plots can be oriented XY, YZ, XZ. An orientation
C | is specficied through the "plotMode" argument. All the
C | plots made by a single call to this routine will use the
C | same contour interval. The plot range (iMin,...,byStr)
C | can be three-dimensional. A separate plot is made for
C | each point in the plot range normal to the orientation.
C | e.g. if the orientation is XY (plotMode = PRINT_MAP_XY).
C | kMin =1, kMax = 5 and kStr = 2 will produce three XY
C | plots - one for K=1, one for K=3 and one for K=5.
C | Each plot would have extents iMin:iMax step iStr
C | and jMin:jMax step jStr.
C *==========================================================*
C !USES:
C == Global variables ==
#include "SIZE.h"
#include "EEPARAMS.h"
#include "EESUPPORT.h"
INTEGER IFNBLNK
EXTERNAL IFNBLNK
INTEGER ILNBLNK
EXTERNAL ILNBLNK
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C fld - Real*4 array holding data to be plotted
C fldTitle - Name of field to be plotted
C plotMode - Text string indicating plot orientation
C ( see - EEPARAMS.h for valid values ).
C iLo, iHi, - Dimensions of array fld. fld is assumed to
C jLo, jHi be five-dimensional.
C kLo, kHi
C nBx, nBy
C iMin, iMax - Indexing for points to plot. Points from
C iStr iMin -> iMax in steps of iStr are plotted
C jMin. jMax and similarly for jMin, jMax, jStr and
C jStr kMin, kMax, kStr and bxMin, bxMax, bxStr
C kMin, kMax byMin, byMax, byStr.
C kStr
CHARACTER*(*) fldTitle
CHARACTER*(*) plotMode
INTEGER iLo, iHi
INTEGER jLo, jHi
INTEGER kLo, kHi
INTEGER nBx, nBy
_RS fld(iLo:iHi,jLo:jHi,kLo:kHi,nBx,nBy)
INTEGER iMin, iMax, iStr
INTEGER jMin, jMax, jStr
INTEGER kMin, kMax, kStr
INTEGER bxMin, bxMax, bxStr
INTEGER byMin, byMax, byStr
C !LOCAL VARIABLES:
C == Local variables ==
C plotBuf - Buffer for building plot record
C chList - Character string used for plot
C fMin, fMax - Contour min, max and range
C fRange
C val - Value of element to be "plotted"
C small - Lowest range for which contours are plotted
C accXXX - Variables used in indexing accross page records.
C dwnXXX Variables used in indexing down the page.
C pltXXX Variables used in indexing multiple plots ( multiple
C plots use same contour range).
C Lab - Label
C Base - Base number for element indexing
C The process bottom, left coordinate in the
C global domain.
C Step - Block size
C Blo - Start block
C Bhi - End block
C Bstr - Block stride
C Min - Start index within block
C Max - End index within block
C Str - stride within block
INTEGER MAX_LEN_PLOTBUF
PARAMETER ( MAX_LEN_PLOTBUF = MAX_LEN_MBUF-4 )
CHARACTER*(MAX_LEN_PLOTBUF) plotBuf
CHARACTER*(MAX_LEN_MBUF) msgBuf
INTEGER lChList
PARAMETER ( lChList = 28 )
CHARACTER*(lChList) chList
_RL fMin
_RL fMax
_RL fRange
_RL val
_RL small
CHARACTER*2 accLab
CHARACTER*7 dwnLab
CHARACTER*3 pltLab
INTEGER accBase, dwnBase, pltBase
INTEGER accStep, dwnStep, pltStep
INTEGER accBlo, dwnBlo, pltBlo
INTEGER accBhi, dwnBhi, pltBhi
INTEGER accBstr, dwnBstr, pltBstr
INTEGER accMin, dwnMin, pltMin
INTEGER accMax, dwnMax, pltMax
INTEGER accStr, dwnStr, pltStr
INTEGER I, J, K, iStrngLo, iStrngHi, iBuf, iDx
INTEGER bi, bj, bk
LOGICAL validRange
CEOP
chList = '-abcdefghijklmnopqrstuvwxyz+'
small = 1. _d -15
fMin = 1. _d 32
fMax = -1. _d 32
validRange = .FALSE.
C-- Calculate field range
DO bj=byMin, byMax, byStr
DO bi=bxMin, bxMax, bxStr
DO K=kMin, kMax, kStr
DO J=jMin, jMax, jStr
DO I=iMin, iMax, iStr
IF (printMapIncludesZeros .OR. fld(I,J,K,bi,bj) .NE. 0.) THEN
IF ( fld(I,J,K,bi,bj) .LT. fMin )
& fMin = fld(I,J,K,bi,bj)
IF ( fld(I,J,K,bi,bj) .GT. fMax )
& fMax = fld(I,J,K,bi,bj)
ENDIF
ENDDO
ENDDO
ENDDO
ENDDO
ENDDO
fRange = fMax-fMin
IF ( fRange .GT. small ) THEN
validRange = .TRUE.
ENDIF
C-- Write field title and statistics
msgBuf =
& '// ======================================================='
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
iStrngLo = IFNBLNK(fldTitle)
iStrngHi = ILNBLNK(fldTitle)
IF ( iStrngLo .LE. iStrngHi ) THEN
WRITE(msgBuf,'(A)') fldTitle(iStrngLo:iStrngHi)
ELSE
msgBuf = '// UNKNOWN FIELD'
ENDIF
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,1PE30.15)')
& '// CMIN = ', fMin
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,1PE30.15)')
& '// CMAX = ', fMax
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
IF ( validRange ) THEN
WRITE(msgBuf,'(A,1PE30.15)')
& '// CINT = ', fRange/FLOAT(lChlist-1)
ELSE
WRITE(msgBuf,'(A,1PE30.15)')
& '// CINT = ', 0.
ENDIF
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,1024A1)')
& '// SYMBOLS (CMIN->CMAX): ',(chList(I:I),I=1,lChList)
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,1024A1)')
& '// 0.0: ','.'
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,3(A,I4),A)')
& '// RANGE I (Lo:Hi:Step):',
& '(',myXGlobalLo-1+(bxMin-1)*sNx+iMin,
& ':',myXGlobalLo-1+(bxMax-1)*sNx+iMax,
& ':',iStr,')'
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,3(A,I4),A)')
& '// RANGE J (Lo:Hi:Step):',
& '(',myYGlobalLo-1+(byMin-1)*sNy+jMin,
& ':',myYGlobalLo-1+(byMax-1)*sNy+jMax,
& ':',jStr,')'
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
WRITE(msgBuf,'(A,3(A,I4),A)')
& '// RANGE K (Lo:Hi:Step):',
& '(',kMin,
& ':',kMax,
& ':',kStr,')'
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
msgBuf =
& '// ======================================================='
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
C-- Write field
C Figure out slice type and set plotting parameters appropriately
C acc = accross the page
C dwn = down the page
IF ( plotMode .EQ. PRINT_MAP_XY ) THEN
C X across, Y down slice
accLab = 'I='
accBase = myXGlobalLo
accStep = sNx
accBlo = bxMin
accBhi = bxMax
accBStr = bxStr
accMin = iMin
accMax = iMax
accStr = iStr
dwnLab = '|--J--|'
dwnBase = myYGlobalLo
dwnStep = sNy
dwnBlo = byMin
dwnBhi = byMax
dwnBStr = byStr
dwnMin = jMin
dwnMax = jMax
dwnStr = jStr
pltBlo = 1
pltBhi = 1
pltBstr = 1
pltMin = kMin
pltMax = kMax
pltStr = kStr
pltBase = 1
pltStep = 1
pltLab = 'K ='
ELSEIF ( plotMode .EQ. PRINT_MAP_YZ ) THEN
C Y across, Z down slice
accLab = 'J='
accBase = myYGlobalLo
accStep = sNy
accBlo = byMin
accBhi = byMax
accBStr = byStr
accMin = jMin
accMax = jMax
accStr = jStr
dwnLab = '|--K--|'
dwnBase = 1
dwnStep = 1
dwnBlo = 1
dwnBhi = 1
dwnBStr = 1
dwnMin = kMin
dwnMax = kMax
dwnStr = kStr
pltBlo = bxMin
pltBhi = bxMax
pltBstr = bxStr
pltMin = iMin
pltMax = iMax
pltStr = iStr
pltBase = myXGlobalLo
pltStep = sNx
pltLab = 'I ='
ELSEIF ( plotMode .EQ. PRINT_MAP_XZ ) THEN
C X across, Z down slice
accLab = 'I='
accBase = myXGlobalLo
accStep = sNx
accBlo = bxMin
accBhi = bxMax
accBStr = bxStr
accMin = iMin
accMax = iMax
accStr = iStr
dwnLab = '|--K--|'
dwnBase = 1
dwnStep = 1
dwnBlo = 1
dwnBhi = 1
dwnBStr = 1
dwnMin = kMin
dwnMax = kMax
dwnStr = kStr
pltBlo = byMin
pltBhi = byMax
pltBstr = byStr
pltMin = jMin
pltMax = jMax
pltStr = jStr
pltBase = myYGlobalLo
pltStep = sNy
pltLab = 'J ='
ENDIF
C IF ( validRange ) THEN
C Header
C Data
DO bk=pltBlo, pltBhi, pltBstr
DO K=pltMin,pltMax,pltStr
WRITE(plotBuf,'(A,I4,I4,I4,I4)') pltLab,
& pltBase-1+(bk-1)*pltStep+K
CALL PRINT_MESSAGE(plotBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
plotBuf = ' '
iBuf = 6
DO bi=accBlo, accBhi, accBstr
DO I=accMin, accMax, accStr
iDx = accBase-1+(bi-1)*accStep+I
iBuf = iBuf + 1
IF ( 10*((iBuf-6)/10) .EQ. iBuf-6 ) THEN
IF ( iDx. LT. 10 ) THEN
WRITE(plotBuf(iBuf:),'(A,I1)') accLab,iDx
ELSEIF ( iDx. LT. 100 ) THEN
WRITE(plotBuf(iBuf:),'(A,I2)') accLab,iDx
ELSEIF ( iDx. LT. 1000 ) THEN
WRITE(plotBuf(iBuf:),'(A,I3)') accLab,iDx
ELSEIF ( iDx. LT. 10000 ) THEN
WRITE(plotBuf(iBuf:),'(A,I4)') accLab,iDx
ENDIF
ENDIF
ENDDO
ENDDO
WRITE(msgBuf,'(A,A)') '// ',plotBuf
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
plotBuf = dwnLab
iBuf = 7
DO bi=accBlo, accBhi, accBstr
DO I=accMin, accMax, accStr
iDx = accBase-1+(bi-1)*accStep+I
iBuf = iBuf+1
IF ( 10*((iBuf-7)/10) .EQ. iBuf-7 ) THEN
WRITE(plotBuf(iBuf:),'(A)') '|'
ELSE
WRITE(plotBuf(iBuf:iBuf),'(I1)') MOD(iDx,10)
ENDIF
ENDDO
ENDDO
WRITE(msgBuf,'(A,A)') '// ',plotBuf
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
DO bj=dwnBlo, dwnBhi, dwnBStr
DO J=dwnMin, dwnMax, dwnStr
WRITE(plotBuf,'(1X,I5,1X)')
& dwnBase-1+(bj-1)*dwnStep+J
iBuf = 7
DO bi=accBlo,accBhi,accBstr
DO I=accMin,accMax,accStr
iBuf = iBuf + 1
IF ( plotMode .EQ. PRINT_MAP_XY ) THEN
val = fld(I,J,K,bi,bj)
ELSEIF ( plotMode .EQ. PRINT_MAP_XZ ) THEN
val = fld(I,K,J,bi,bk)
ELSEIF ( plotMode .EQ. PRINT_MAP_YZ ) THEN
val = fld(K,I,J,bk,bi)
ENDIF
IF ( validRange .AND. val .NE. 0. ) THEN
IDX = NINT(
& FLOAT( lChList-1 )*( val-fMin ) / (fRange)
& )+1
ELSE
IDX = 1
ENDIF
IF ( iBuf .LE. MAX_LEN_PLOTBUF )
& plotBuf(iBuf:iBuf) = chList(IDX:IDX)
IF ( val .EQ. 0. ) THEN
IF ( iBuf .LE. MAX_LEN_PLOTBUF )
& plotBuf(iBuf:iBuf) = '.'
ENDIF
ENDDO
ENDDO
WRITE(msgBuf,'(A,A)') '// ',plotBuf
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
ENDDO
ENDDO
ENDDO
ENDDO
C ENDIF
C-- Write delimiter
msgBuf =
& '// ======================================================='
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
msgBuf =
& '// END OF FIELD ='
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
msgBuf =
& '// ======================================================='
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
msgBuf = ' '
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, 1)
RETURN
END
CBOP
C !ROUTINE: PRINT_MAPRL
C !INTERFACE:
SUBROUTINE PRINT_MAPRL ( fld, fldTitle, plotMode,
I iLo, iHi, jLo, jHi, kLo, kHi, nBx, nBy,
I iMin, iMax, iStr,
I jMin, jMax, jStr,
I kMin, kMax, kStr,
I bxMin, bxMax, bxStr,
I byMin, byMax, byStr )
IMPLICIT NONE
C !DESCRIPTION:
C *==========================================================*
C | SUBROUTINE PRINT_MAPRL
C | o Does textual mapping printing of a field.
C *==========================================================*
C | This routine does the actual formatting of the data
C | and printing to a file. It assumes an array using the
C | MITgcm UV indexing scheme and base index variables.
C | User code should call an interface routine like
C | PLOT_FIELD_XYR8( ... ) rather than this code directly.
C | Text plots can be oriented XY, YZ, XZ. An orientation
C | is specficied through the "plotMode" argument. All the
C | plots made by a single call to this routine will use the
C | same contour interval. The plot range (iMin,...,byStr)
C | can be three-dimensional. A separate plot is made for
C | each point in the plot range normal to the orientation.
C | e.g. if the orientation is XY (plotMode = PRINT_MAP_XY).
C | kMin =1, kMax = 5 and kStr = 2 will produce three XY
C | plots - one for K=1, one for K=3 and one for K=5.
C | Each plot would have extents iMin:iMax step iStr
C | and jMin:jMax step jStr.
C *==========================================================*
C !USES:
C == Global variables ==
#include "SIZE.h"
#include "EEPARAMS.h"
#include "EESUPPORT.h"
INTEGER IFNBLNK
EXTERNAL IFNBLNK
INTEGER ILNBLNK
EXTERNAL ILNBLNK
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C fld - Real*8 array holding data to be plotted
C fldTitle - Name of field to be plotted
C plotMode - Text string indicating plot orientation
C ( see - EEPARAMS.h for valid values ).
C iLo, iHi, - Dimensions of array fld. fld is assumed to
C jLo, jHi be five-dimensional.
C kLo, kHi
C nBx, nBy
C iMin, iMax - Indexing for points to plot. Points from
C iStr iMin -> iMax in steps of iStr are plotted
C jMin. jMax and similarly for jMin, jMax, jStr and
C jStr kMin, kMax, kStr and bxMin, bxMax, bxStr
C kMin, kMax byMin, byMax, byStr.
C kStr
CHARACTER*(*) fldTitle
CHARACTER*(*) plotMode
INTEGER iLo, iHi
INTEGER jLo, jHi
INTEGER kLo, kHi
INTEGER nBx, nBy
_RL fld(iLo:iHi,jLo:jHi,kLo:kHi,nBx,nBy)
INTEGER iMin, iMax, iStr
INTEGER jMin, jMax, jStr
INTEGER kMin, kMax, kStr
INTEGER bxMin, bxMax, bxStr
INTEGER byMin, byMax, byStr
C !LOCAL VARIABLES:
C == Local variables ==
C plotBuf - Buffer for building plot record
C chList - Character string used for plot
C fMin, fMax - Contour min, max and range
C fRange
C val - Value of element to be "plotted"
C small - Lowest range for which contours are plotted
C accXXX - Variables used in indexing accross page records.
C dwnXXX Variables used in indexing down the page.
C pltXXX Variables used in indexing multiple plots ( multiple
C plots use same contour range).
C Lab - Label
C Base - Base number for element indexing
C The process bottom, left coordinate in the
C global domain.
C Step - Block size
C Blo - Start block
C Bhi - End block