forked from HYCOM/HYCOM-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blkdat.F90
2810 lines (2810 loc) · 98.4 KB
/
blkdat.F90
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
subroutine blkdat(linit)
use mod_xc ! HYCOM communication interface
use mod_cb_arrays ! HYCOM saved arrays
use mod_incupd ! HYCOM incremental update (for data assimilation)
use mod_floats ! HYCOM synthetic floats, drifters and moorings
use mod_tides ! HYCOM tides
#if defined(STOKES)
use mod_stokes ! HYCOM Stokes Drift effects from Wave fields
#endif
implicit none
!
real day1,hybrlx,cplifq,frzifq
integer k,kdmblk,mlflag,thflag,trcflg1
integer lngblk
character sigfmt*26
logical linit
!
# include "stmt_fns.h"
!
! --- initialize common variables.
!
open(unit=uoff+99,file=trim(flnminp)//'blkdat.input') !on all nodes
!
! --- 'lp' = logical unit number for printer output
! lp = 6 !now defined in xcspmd
!
! --- four lines (80-characters) describing the simulation
read( uoff+99,'(a80/a80/a80/a80)') ctitle
if (mnproc.eq.1) then
write(lp,*)
write(lp,'(a80/a80/a80/a80)') ctitle
call flush(lp)
endif !1st tile
!
! --- 'iversn' = hycom version number x10
! --- 'iexpt' = experiment number x10
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(iversn,'iversn')
call blkini(iexpt, 'iexpt ')
!
if (iversn.lt.23 .or. iversn.gt.23) then
if (mnproc.eq.1) then
write(lp,'(/ a,i3,a,i3 /)') &
'error - iversn must be between',23,' and',23
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
!
! --- 'idm ' = longitudinal array size
! --- 'jdm ' = latitudinal array size
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(itest ,'idm ')
call blkini(jtest ,'jdm ')
!
if (itdm.eq.-1) then !serial relo case only
itdm = itest
idm = itest
ii = itest
jtdm = jtest
jdm = jtest
jj = jtest
endif
!
if (itest.ne.itdm) then
if (mnproc.eq.1) then
write(lp,'(/ a,i5 /)') &
'error - expected idm =',itdm
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (jtest.ne.jtdm) then
if (mnproc.eq.1) then
write(lp,'(/ a,i5 /)') &
'error - expected jdm =',jtdm
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
!
! --- 'itest,jtest' = grid point where detailed diagnostics are desired
! --- itest=jtest=0 turns off all detailed diagnostics
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(ittest,'itest ')
call blkini(jttest,'jtest ')
!
if (ittest.gt.itdm) then
if (mnproc.eq.1) then
write(lp,'(/ a,i5 /)') &
'error - maximum itest is',itdm
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (jttest.gt.jtdm) then
if (mnproc.eq.1) then
write(lp,'(/ a,i5 /)') &
'error - maximum jtest is',jtdm
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
!
! --- map global ittest,jttest to local itest,jtest
if (ittest.gt.i0 .and. ittest.le.i0+ii .and. &
jttest.gt.j0 .and. jttest.le.j0+jj ) then
itest = ittest - i0
jtest = jttest - j0
else
itest = -99
jtest = -99
endif
!
! if (mnproc.eq.1) then
! write(lp,*)
! endif !1st tile
! call xcsync(flush_lp)
! do k= 1,ijpr
! if (mnproc.eq.k) then
! write(lp,'(a,3i5)') 'mnproc,[ij]test =',mnproc,itest,jtest
! endif
! call xcsync(flush_lp)
! enddo !k
!
! --- 'kdm ' = number of layers
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(kdmblk,'kdm ')
!
#if defined(RELO)
kdm = kdmblk
kk = kdmblk
!
allocate( &
dx0k(kdm), &
dp0k(kdm), &
ds0k(kdm), &
sigma(kdm), &
salmin(kdm) )
call mem_stat_add( 4*kdm )
#else
if (kdmblk.ne.kdm) then
if (mnproc.eq.1) then
write(lp,'(/ a,i3 /)') &
'error - expected kdm =',kdm
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
#endif
!
! --- 'nhybrd' = number of hybrid levels (0=all isopycnal)
! --- 'nsigma' = number of sigma levels (nhybrd-nsigma z-levels)
! --- 'dx00' = maximum layer thickness minimum, optional (m)
! --- 'dx00x' = maximum layer thickness maximum, optional (m)
! --- 'dx00f' = maximum layer thickness stretching factor (1.0=const)
! --- 'dp00' = deep z-level spacing minimum thickness (m)
! --- 'dp00x' = deep z-level spacing maximum thickness (m)
! --- 'dp00f' = deep z-level spacing stretching factor (1.0=const.z)
! --- 'ds00' = shallow z-level spacing minimum thickness (m)
! --- 'ds00x' = shallow z-level spacing maximum thickness (m)
! --- 'ds00f' = shallow z-level spacing stretching factor (1.0=const.z)
! --- 'dp00i' = deep iso-pycnal spacing minimum thickness (m)
! --- 'isotop' = shallowest depth for isopycnal layers (m), <0 from file
!
! --- the above specifies a vertical coord. that is isopycnal or:
! --- near surface z in deep water, based on dp00,dp00x,dp00f
! --- near surface z in shallow water, based on ds00,ds00x,ds00f and nsigma
! --- sigma between them, based on ds00,ds00x,ds00f and nsigma
!
! --- d[ps].k/d[ps].1 = d[ps]00f**(k-1) unless limited by d[ps]00x.
! --- if d[ps]00f>1, d[ps]00x (> d[ps]00) is the maximum thickness.
! --- if d[ps]00f<1, d[ps]00x (< d[ps]00) is the minimum thickness.
!
! --- near the surface (i.e. shallower than isotop), layers are always fixed
! --- depth (z or sigma). layer 1 is always fixed, so isotop=0.0 is not
! --- allowed. if isotop<0.0 then isotop(1:idm,1:jdm) is a spacially
! --- varying array, input from the file iso.top.[ab].
!
! --- away from the surface, the minimum layer thickness is dp00i.
! --- to recover original hybrid behaviour, set dp00i=dp00x
! --- for z-only, sigma-only or sigma-z only, set dp00i=dp00x
!
! --- for z-only set nsigma=0 (and ds00,ds00x,ds00f=dp00,dp00x,dp00f)
! --- for sigma-z (shallow-deep) use a very small ds00
! --- (pure sigma-z also has ds00f=dp00f and ds00x=dp00x*ds00/dp00)
! --- for z-sigma (shallow-deep) use a very large dp00 (not recommended)
! --- for sigma-only set nsigma=kdm, dp00 large, and ds00 small
!
! --- for an entirely fixed vertical coordinate (no isopycnal layers), set
! --- isotop large or make all target densities (sigma(k), below) very small.
!
! --- or, in place of 'd?00','d?00x','d?00f' specify:
! --- 'dx0k ' = layer k maximum layer thickness (m)
! --- 'dp0k ' = layer k deep z-level spacing minimum thickness (m)
! --- k=1,kdm; dp0k must be zero for k>nhybrd
! --- 'ds0k ' = layer k shallow z-level spacing minimum thickness (m)
! --- k=1,nsigma
!
! --- uses version 2.2.58 definition of deep and shallow z-levels.
! --- terrain following starts at depth dpns=sum(dp0k(k),k=1,nsigma) and
! --- ends at depth dsns=sum(ds0k(k),k=1,nsigma), and the depth of the
! --- k-th layer interface varies linearly with total depth between
! --- these two reference depths.
!
! --- previous to 2.2.58, it was layer thickness (not layer interface
! --- depth) that varied linearly with total depth. These two approachs
! --- are identical for "pure sigma-z", but differ if ds00f/=dp00f.
!
! --- dx0* is optional, and is disabled if not present. It "inflates"
! --- zero thickness layers at the bottom if the layer above is thicker
! --- than its maximum. This replaces very thick isopycnal layers with
! --- several thinner layers that might still have about the same
! --- density but can have different velocities. Hence increasing the
! --- deep vertical resolution. The idea behind dx0k comes from
! --- MOM6's HYCOM1 option MAX_LAYER_THICKNESS.
!
call blkini(nhybrd,'nhybrd')
call blkini(nsigma,'nsigma')
call blkinr9(dp00,k, &
'dp00 ','(a6," =",f10.4," m")', &
'dp0k ','(a6," =",f10.4," m")', &
'dx00 ','(a6," =",f10.4," m")', &
'dx0k ','(a6," =",f10.4," m")', &
'XXXXXX','(a6," =",f10.4," ")', &
'XXXXXX','(a6," =",f10.4," ")', &
'XXXXXX','(a6," =",f10.4," ")', &
'XXXXXX','(a6," =",f10.4," ")', &
'XXXXXX','(a6," =",f10.4," ")')
if (k.eq.3) then !dx00
dx00 = dp00
call blkinr(dx00x, 'dx00x ','(a6," =",f10.4," m")')
call blkinr(dx00f, 'dx00f ','(a6," =",f10.4," ")')
call blkinr2(dp00,k, &
'dp00 ','(a6," =",f10.4," m")', &
'dp0k ','(a6," =",f10.4," m")' )
elseif (k.eq.4) then !dx0k
dx0k(1) = dp00
dx00 = -1.0 !signal that dx00 is not input
do k=2,kdmblk
call blkinr(dx0k(k), 'dx0k ','(a6," =",f10.4," m")')
enddo !k
call blkinr2(dp00,k, &
'dp00 ','(a6," =",f10.4," m")', &
'dp0k ','(a6," =",f10.4," m")' )
else !no dx0*
dx00 = 9999.0
dx00x = 9999.0
dx00f = 1.0
endif
if (k.eq.1) then !dp00
call blkinr(dp00x, 'dp00x ','(a6," =",f10.4," m")')
call blkinr(dp00f, 'dp00f ','(a6," =",f10.4," ")')
call blkinr(ds00, 'ds00 ','(a6," =",f10.4," m")')
call blkinr(ds00x, 'ds00x ','(a6," =",f10.4," m")')
call blkinr(ds00f, 'ds00f ','(a6," =",f10.4," ")')
else !dp0k
dp0k(1) = dp00
dp00 = -1.0 !signal that dp00 is not input
do k=2,kdm
call blkinr(dp0k(k), 'dp0k ','(a6," =",f10.4," m")')
!
if (k.gt.nhybrd .and. dp0k(k).ne.0.0) then
if (mnproc.eq.1) then
write(lp,'(/ a,i3 /)') &
'error - dp0k must be zero for k>nhybrd'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !k>nhybrd&dp0k(k)!=0
enddo !k
do k=1,nsigma
call blkinr(ds0k(k), 'ds0k ','(a6," =",f10.4," m")')
enddo !k
endif !dp00:dp0k
call blkinr(dp00i, 'dp00i ','(a6," =",f10.4," m")')
call blkinr(isotop,'isotop','(a6," =",f10.4," m")')
!
! --- isopycnal (MICOM-like) iff nhybrd is 0
isopyc = nhybrd .eq. 0
hybrid = .not. isopyc
if (hybrid .and. nsigma.le.1) then
nsigma=1
if (dp00.lt.0.0) then
ds0k(1) = dp0k(1)
endif
endif
if (isopyc .and. sigver.gt.2) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - MICOM-like requires the 7-term eqn. of state'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
!
if (nhybrd.gt.kdm) then
if (mnproc.eq.1) then
write(lp,'(/ a,i3 /)') &
'error - maximum nhybrd is kdm =',kdm
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (nsigma.gt.nhybrd) then
if (mnproc.eq.1) then
write(lp,'(/ a,i3 /)') &
'error - maximum nsigma is nhybrd =',nhybrd
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (dp00.ge.0.0) then
if (isopyc .and. max(dp00,dp00x).ne.0.0) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - must have dp00x==dp00==0.0 for isopycnal case'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (dp00f.eq.1.0 .and. dp00.ne.dp00x) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - must have dp00x==dp00 for dp00f==1.0'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (dp00f.gt.1.0 .and. dp00.ge.dp00x) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - dp00x must be > dp00 for dp00f>1'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (dp00f.lt.1.0 .and. dp00.le.dp00x) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - dp00x must be < dp00 for dp00f<1'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (ds00.gt.dp00) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - must have ds00 <= dp00'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (ds00.le.0.0 .and. .not.isopyc) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - must have ds00>0.0'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (ds00f.eq.1.0 .and. ds00.ne.ds00x) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - must have ds00x==ds00 for ds00f==1.0'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (ds00f.gt.1.0 .and. ds00.ge.ds00x) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - ds00x must be > ds00 for ds00f>1'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (ds00f.lt.1.0 .and. ds00.le.ds00x) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - ds00x must be < ds00 for ds00f<1'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
if (isotop.eq.0.0) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - isotop cannot be 0.0 (layer 1 never isopycnal)'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !error
endif !dp00 used
!
! --- 'oneta0' = minimum 1+eta, must be > 0.0
! --- 'saln0' = initial salinity value (psu), only used for iniflg<2
! --- 'locsig' = locally-referenced potential density for stability (0=F,1=T)
! --- 'kapref' = thermobaric reference state (-1=input,0=none,1,2,3=constant)
! --- 1=Arctic/Antarctic; 2=Atlantic; 3=Mediterranean
! --- 'thflag' = reference pressure flag (0=Sigma-0, 2=Sigma-2)
! --- this is a check on the compile-time stmt_funcs.h setup.
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkinr(oneta0,'oneta0','(a6," =",f10.4," ")')
call blkinr(saln0, 'saln0 ','(a6," =",f10.4," psu")')
call blkinl(locsig,'locsig')
call blkini(kapref,'kapref')
call blkini(thflag,'thflag')
! --- kapnum is number of thermobaric reference states (1 or 2)
if (kapref.ne.-1) then
kapnum=1
else
kapnum=2
endif
!
if (oneta0.le.0.0 .or. oneta0.ge.1.0) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - oneta0 must be above 0.0 and below 1.0'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !oneta0 error
if (kapref.lt.-1 .or. kapref.gt.3) then
if (mnproc.eq.1) then
write(lp,'(/ a,i1 /)') &
'error - kapref must be between -1 and 3'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !kapref error
if (thflag.eq.0) then
if (sigver.eq.1) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 7-term sigma-0'
call flush(lp)
endif !1st tile
elseif (sigver.eq.3) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 9-term sigma-0'
call flush(lp)
endif !1st tile
elseif (sigver.eq.5) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 17-term sigma-0'
call flush(lp)
endif !1st tile
elseif (sigver.eq.7) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 12-term sigma-0'
call flush(lp)
endif !1st tile
else
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - thflag not consistent with sig()'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !7-term:9-term:error
elseif (thflag.eq.2) then
if (sigver.eq.2) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 7-term sigma-2'
call flush(lp)
endif !1st tile
elseif (sigver.eq.4) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 9-term sigma-2'
call flush(lp)
endif !1st tile
elseif (sigver.eq.6) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 17-term sigma-2'
call flush(lp)
endif !1st tile
elseif (sigver.eq.8) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'equation of state is 12-term sigma-2'
call flush(lp)
endif !1st tile
else
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - thflag not consistent with sig()'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !7-term:9-term:error
else
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - thflag must be 0 or 2'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !thflag
if (thflag.eq.0) then
sigfmt = '(a6," =",f10.4," sigma-0")'
elseif (thflag.eq.2) then
sigfmt = '(a6," =",f10.4," sigma-2")'
endif
!
! --- 'thbase' = reference density (sigma units)
call blkinr(thbase,'thbase',sigfmt)
!
! --- 'vsigma' = spacially varying isopycnal layer target densities (0=F,1=T)
! --- if true, target densities input from file iso.sigma.[ab]
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkinl(vsigma,'vsigma')
!
! --- 'sigma ' = isopycnal layer target densities (sigma units)
do k=1,kdm
call blkinr(sigma(k),'sigma ',sigfmt)
!
if (k.gt.1) then
if (sigma(k).le.sigma(k-1)) then
if (mnproc.eq.1) then
write(lp,'(/ a,i3 /)') &
'error - sigma is not stabally stratified'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif !sigma(k).le.sigma(k-1)
endif !k>1
enddo !k
!
! --- 'iniflg' = initial state flag (0=level,1=zonal,2=climatology)
! --- 'jerlv0' = initial jerlov water type (1 to 5; 0 kpar, -1 chl)
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(iniflg,'iniflg')
call blkini(jerlv0,'jerlv0')
!
if (iniflg.lt.0 .or. iniflg.gt.3) then !inicon==3 ok, for old .inputs
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - iniflg must be between 0 and 2'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
if (jerlv0.lt.-1 .or. jerlv0.gt.5) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
'error - jerlv0 must be -1 or 0 or between 1 and 5'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
!
! --- 'yrflag' = days in year flag (0=360,1=366,2=366Jan1,3=actual)
! --- (-2=366Jan1 with 732-day forcing repeat)
! --- 'sshflg' = diagnostic SSH flag (0=SSH,1=SSH&stericSSH,2=SSH&stericMONTG)
! --- note that sshflg==1 implies reading relax.ssh.a
! --- and that sshflg==2 implies reading relax.montg.a
! --- 'dsurfq' = number of days between model diagnostics at the surface
! --- (-ve to output only the .txt file at itest,jtest)
! --- 'diagfq' = number of days between model diagnostics
! --- (-ve same as -diagfq but always write archive at end)
! --- 'proffq' = number of days between model diagnostics at selected locations
! --- 'tilefq' = number of days between model diagnostics on selected tiles
! --- 'meanfq' = number of days between model diagnostics (time averaged)
! --- 'rstrfq' = number of days between model restart output
! --- (-ve same as -rstrfq but no restart at end)
! --- 'bnstfq' = number of days between baro nesting archive input
! --- (-ve for mean archives spanning -bnstfq days;
! --- 0.0 if lbflag is not 2 or 4)
! --- 'nestfq' = number of days between 3-d nesting archive input
! --- (-ve for mean archives spanning -nestfq days;
! --- 0.0 turns off relaxation to 3-d nesting input)
! --- 'cplifq' = number of days (or time steps) between sea ice coupling
! --- (positive days or negative time steps)
! --- 'baclin' = baroclinic time step (seconds), int. divisor of 86400
! --- 'batrop' = barotropic time step (seconds), int. divisor of baclin/2
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(yrflag,'yrflag')
call blkini(sshflg,'sshflg')
call blkinr(dsurfq,'dsurfq','(a6," =",f10.4," days")')
call blkinr(diagfq,'diagfq','(a6," =",f10.4," days")')
call blkinr(proffq,'proffq','(a6," =",f10.4," days")')
call blkinr(tilefq,'tilefq','(a6," =",f10.4," days")')
call blkinr(meanfq,'meanfq','(a6," =",f10.4," days")')
call blkinr(rstrfq,'rstrfq','(a6," =",f10.4," days")')
call blkinr(bnstfq,'bnstfq','(a6," =",f10.4, &
&" days (-ve mean span)")')
call blkinr(nestfq,'nestfq','(a6," =",f10.4, &
&" days (-ve mean span)")')
call blkinr(cplifq,'cplifq','(a6," =",f10.4, &
&" days (-ve time steps)")')
call blkinr(baclin,'baclin','(a6," =",f10.4," sec")')
call blkinr(batrop,'batrop','(a6," =",f10.4," sec")')
!
if (yrflag.eq.-2) then
yrflag = 2
wndrep = 732.0d0 !two year forcing repeat period
elseif (yrflag.eq. 2) then
wndrep = 366.0d0 !one year forcing repeat period
elseif (yrflag.eq. 4) then
wndrep = 365.0d0 !one year forcing repeat period
endif
#if defined(RELO)
if (yrflag.lt.2) then
natm = 4 !monthly forcing
else
natm = 2 !high-frequency forcing
endif
#else
if (yrflag.lt.2) then
if (natm.lt.4) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - natm must be 4 for monthly forcing (yrflag==0,1)'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
else
if (natm.ne.2) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'warning - natm can be 2 for this forcing (yrflag!=0,1)'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
endif
#endif
!
dsur1p = dsurfq .lt. 0.0
if (dsur1p) then
dsurfq = -dsurfq
endif
!
arcend = diagfq.lt.0.0
diagfq = abs(diagfq)
!
if (cplifq.ge.0.0) then
icpfrq = nint( cplifq*(86400.0/baclin) )
else
icpfrq = nint(-cplifq)
endif
if (mnproc.eq.1) then
write(lp,*)
write(lp,'(a,i10)') 'icpfrq =',icpfrq
endif !1st tile
!
if (yrflag.lt.0 .or. yrflag.gt.4) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - yrflag must be between 0 and 4'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
if (yrflag.le.1) then ! monthly forcing
if (abs(nint(86400.0/baclin)-86400.0/baclin).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - baclin not an integer divisor of 24 hours'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old baclin = ',baclin
baclin = 86400.0/nint(86400.0/baclin)
! write(lp,*) 'new baclin = ',baclin
endif
else ! high frequency forcing
if (abs(nint(21600.0/baclin)-21600.0/baclin).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - baclin not an integer divisor of 6 hours'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old baclin = ',baclin
baclin = 21600.0/nint(21600.0/baclin)
! write(lp,*) 'new baclin = ',baclin
endif
endif
if (abs(nint(0.5*baclin/batrop)- &
0.5*baclin/batrop ).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - batrop not an integer divisor of baclin/2'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old batrop = ',batrop
batrop = baclin/nint(baclin/batrop)
! write(lp,*) 'new batrop = ',batrop
endif
if (abs(nint((dsurfq*86400.d0)/baclin)- &
(dsurfq*86400.d0)/baclin ).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a,a /)') &
&'error - ', &
&'dsurfq is not a whole number of baroclinic time steps'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old dsurfq = ',dsurfq
dsurfq = nint((dsurfq*86400.d0)/baclin)*(baclin/86400.d0)
! write(lp,*) 'new dsurfq = ',dsurfq
endif
if (abs(nint((diagfq*86400.d0)/baclin)- &
(diagfq*86400.d0)/baclin ).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a,a /)') &
&'error - ', &
&'diagfq is not a whole number of baroclinic time steps'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old diagfq = ',diagfq
diagfq = nint((diagfq*86400.d0)/baclin)*(baclin/86400.d0)
! write(lp,*) 'new diagfq = ',diagfq
endif
if (abs(nint((proffq*86400.d0)/baclin)- &
(proffq*86400.d0)/baclin ).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a,a /)') &
&'error - ', &
&'proffq is not a whole number of baroclinic time steps'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old proffq = ',proffq
proffq = nint((proffq*86400.d0)/baclin)*(baclin/86400.d0)
! write(lp,*) 'new proffq = ',tilefq
endif
if (abs(nint((tilefq*86400.d0)/baclin)- &
(tilefq*86400.d0)/baclin ).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a,a /)') &
&'error - ', &
&'tilefq is not a whole number of baroclinic time steps'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old tilefq = ',tilefq
tilefq = nint((tilefq*86400.d0)/baclin)*(baclin/86400.d0)
! write(lp,*) 'new tilefq = ',tilefq
endif
if (abs(nint((meanfq*86400.d0)/baclin)- &
(meanfq*86400.d0)/baclin ).gt.0.01) then
if (mnproc.eq.1) then
write(lp,'(/ a,a /)') &
&'error - ', &
&'meanfq is not a whole number of baroclinic time steps'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
else ! make it exact
! write(lp,*) 'old meanfq = ',meanfq
meanfq = nint((meanfq*86400.d0)/baclin)*(baclin/86400.d0)
! write(lp,*) 'new meanfq = ',meanfq
endif
#if defined(RELO)
if (nestfq.ne.0.0) then
kknest = kdm
else
kknest = 1
endif
#else
if (kknest.ne.kdm .and. nestfq.ne.0.0) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - kknest (dimensions.h) must be kdm when nesting'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
#endif
!
! --- 'incflg' = incremental update flag (0=no, -/+1=yes, -/+2=full-velocity)
! -ve to read in difference archive for increment
! --- 'incstp' = no. timesteps for full update (1=full insertion)
! --- 'incupf' = number of days of incremental updating input
! --- (-ve to write a restart after each update completes)
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(incflg, 'incflg')
call blkini(incstp, 'incstp')
call blkini(incupf, 'incupf')
!
! --- 'stfflg' = stochastic anomaly forcing flag (0=no, 1=TS, 2=TSV)
! --- 'stfrdt' = stochastic T anomaly forcing e-folding depth (m)
! --- 'stfrds' = stochastic S anomaly forcing e-folding depth (m)
! --- 'stfrdv' = stochastic V anomaly forcing e-folding depth (m)
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkini(stfflg, 'stfflg')
call blkinr(stfrdt, 'stfrdt','(a6," =",f10.4," m")')
call blkinr(stfrds, 'stfrds','(a6," =",f10.4," m")')
call blkinr(stfrdv, 'stfrdv','(a6," =",f10.4," m")')
!
! --- 'ra2fac' = weight for Robert-Asselin time filter
! --- (old equivalent: wuv2=wts2=0.5*ra2fac,
! --- wuv2>wts2 no longer supported)
! --- 'wbaro ' = weight for time smoothing of barotropic fields
! --- 'btrlfr' = leapfrog barotropic time step (0=F,1=T)
! --- 'btrmas' = barotropic is mass conserving (0=F,1=T)
! --- 'hybraf' = HYBGEN: Robert-Asselin flag (0=F,1=T)
! --- (use 'hybraf'=0 to recover pre-2.2.38 behaviour)
! --- 'hybrlx' = HYBGEN: inverse relaxation coefficient (time steps)
! (1.0 for no relaxation)
! --- 'hybiso' = HYBGEN: Use PCM if layer is within hybiso of target density
! (0.0 for no PCM; large to recover pre-2.2.09 behaviour)
! --- 'hybthn' = HYBGEN: ratio of layer thicknesses to select the thiner
! (1.0 for original behaviour, i.e. key only on thickness;
! 5.0 to favor the larger density anomaly over thickness)
! --- 'hybmap' = HYBGEN: remapper flag (0=PCM, 1=PLM, 2=PPM, 3=WENO-like)
! --- 'hybflg' = HYBGEN: generator flag (0=T&S, 1=th&S, 2=th&T)
! --- 'advflg' = thermal advection flag (0=T&S, 1=th&S, 2=th&T)
! --- 'advtyp' = scalar advection type (0=PCM, 1=MPDATA, 2=FCT2, 4=FCT4)
! --- 'momtyp' = momentum advection type (2=2nd; 3=S.QUICK; 4=M.S.QUICK)
! --- 'slip' = +1 free-slip, +1<slip<-1 partial, -1 no-slip boundary conditions
! --- 'visco2' = deformation-dependent Laplacian viscosity factor
! --- 'visco4' = deformation-dependent biharmonic viscosity factor
! --- 'facdf4' = speed-dependent biharmonic viscosity factor
! --- (diffusion velocity is facdf4*|v|)
! --- 'veldf2' = diffusion velocity (m/s) for Laplacian momentum dissipation
! --- (negative to input spacially varying diffusion velocity)
! --- 'veldf4' = diffusion velocity (m/s) for biharmonic momentum dissipation
! --- (negative to input spacially varying diffusion velocity)
! --- 'thkdf2' = diffusion velocity (m/s) for Laplacian thickness diffusion
! --- 'thkdf4' = diffusion velocity (m/s) for biharmonic thickness diffusion
! --- (negative to input spacially varying diffusion velocity)
! --- 'temdf2' = diffusion velocity (m/s) for Laplacian temp/saln diffusion
! --- 'temdfc' = temp diffusion conservation (0.0,1.0 all dens,temp resp.)
! --- 'vertmx' = diffusion velocity (m/s) for mom.mixing at mix.layr.base
! --- (vertmx only used in MICOM-like isopycnal mode)
! --- 'cbar' = rms flow speed (m/s) for linear bottom friction
! --- (negative to input spacially varying rms flow speed)
! --- 'cb' = coefficient of quadratic bottom friction
! --- (negative to input spacially varying coefficient)
! --- 'drglim' = limiter for explicit friction (1.0 no limiter, 0.0 implicit)
if (mnproc.eq.1) then
write(lp,*)
endif !1st tile
call blkinr(ra2fac,'ra2fac','(a6," =",f10.4," ")')
call blkinr(wbaro ,'wbaro ','(a6," =",f10.4," ")')
call blkinl(btrlfr,'btrlfr')
call blkinl(btrmas,'btrmas')
call blkinl(hybraf,'hybraf')
call blkinr(hybrlx,'hybrlx','(a6," =",f10.4," time steps")')
call blkinr(hybiso,'hybiso','(a6," =",f10.4," kg/m^3")')
call blkinr(hybthn,'hybthn','(a6," =",f10.4," ")')
call blkini(hybmap,'hybmap')
call blkini(hybflg,'hybflg')
call blkini(advflg,'advflg')
call blkini(advtyp,'advtyp')
call blkini(momtyp,'momtyp')
call blkinr(slip, 'slip ', &
&'(a6," =",f10.4," (-1=no-slip, -1>:>+1=partial, +1=free)")')
call blkinr(visco2,'visco2','(a6," =",f10.4," ")')
call blkinr(visco4,'visco4','(a6," =",f10.4," ")')
call blkinr(facdf4,'facdf4','(a6," =",f10.4," ")')
call blkinr(veldf2,'veldf2','(a6," =",f10.4, &
&" m/s (-ve if variable)")')
call blkinr(veldf4,'veldf4','(a6," =",f10.4, &
&" m/s (-ve if variable)")')
call blkinr(thkdf2,'thkdf2','(a6," =",f10.4," m/s")')
call blkinr(thkdf4,'thkdf4','(a6," =",f10.4, &
&" m/s (-ve if variable)")')
call blkinr(temdf2,'temdf2','(a6," =",f10.4," m/s")')
call blkinr(temdfc,'temdfc', &
&'(a6," =",f10.4," (0.0,1.0 conserve dens,temp resp.)")')
call blkinr(vertmx,'vertmx','(a6," =",f10.4," m/s")')
call blkinr(cbar, 'cbar ','(a6," =",f10.4, &
&" m/s (-ve if variable)")')
call blkinr(cb, 'cb ','(a6," =",f10.4, &
&" (-ve if variable)")')
call blkinr(drglim,'drglim','(a6," =",f10.4," ")')
!
if (hybrlx.lt.1.0) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - hybrlx must be at least 1.0'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
qhybrlx = 1.0/hybrlx
!
if (hybthn.lt.1.0) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - hybthn must be at least 1.0'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
!
if (btrmas .and. .not.btrlfr) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - btrmas==.true. requires btrlfr==.true.'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
!
isopcm = hybiso.gt.0.0 !use PCM for isopycnal layers?
if (hybmap.lt.0 .or. hybmap.gt.3) then
if (mnproc.eq.1) then
write(lp,'(/ a,a /)') &
&'error - hybmap must be ', &
&'0 (PCM) or 1 (PLM) or 2 (PPM) or 3 (WENO-like)'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
if (hybflg.lt.0 .or. hybflg.gt.2) then
if (mnproc.eq.1) then
write(lp,'(/ a /)') &
&'error - hybflg must be 0 (T&S) or 1 (th&S) or 2 (th&T)'
call flush(lp)
endif !1st tile
call xcstop('(blkdat)')
stop '(blkdat)'
endif
if (hybflg.ne.0 .and. (sigver.eq.5 .or. sigver.eq.6)) then