-
Notifications
You must be signed in to change notification settings - Fork 0
/
setocn.F
2417 lines (2400 loc) · 71 KB
/
setocn.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
subroutine setocn
c
c=======================================================================
c
c set up everything which must be done only once per run
c
c=======================================================================
c
logical error, vmixset, hmixset
parameter (ifdmax=100)
character*30 cifdef(ifdmax)
c
#include "param.h"
#include "accel.h"
#include "calendar.h"
#ifdef sponges
# include "sponge.h"
#else
logical annlev
#endif
#include "coord.h"
#if defined fourfil || defined firfil
# include "cpolar.h"
#endif
#include "cprnts.h"
#include "cregin.h"
#include "csbc.h"
#ifdef shortwave
# include "cshort.h"
#endif
#include "csnap.h"
#include "ctmb.h"
#include "diag.h"
#include "docnam.h"
#include "emode.h"
#include "grdvar.h"
#include "hmixc.h"
#include "index.h"
#include "iounit.h"
#ifdef isopycmix
# include "isopyc.h"
#endif
#include "levind.h"
#include "mw.h"
#ifdef trajectories
# include "ptraj.h"
#else
logical initpt
#endif
#include "scalar.h"
#include "stab.h"
#include "state.h"
#include "switch.h"
#include "tmngr.h"
#include "topog.h"
#include "vmixc.h"
#if defined fourfil || defined firfil
dimension kmz(imt,jmt)
#endif
character*80 momver
c
namelist /contrl/ init, runlen, rununits, segtim, restrt, initpt
namelist /mbcin/ mapsbc, sbcname, dunits, coabc, crits
&, numpas, bwidth
namelist /tsteps/ dtts, dtuv, dtsf
namelist /riglid/ mxscan, sor, tolrsf, tolrsp, tolrfs
namelist /mixing/ am, ah, ambi, ahbi
&, kappa_m, kappa_h, cdbot
&, aq, aidif
&, ncon, nmix, eb, acor, dampts, dampdz, annlev
&, alph, gam, theta
namelist /diagn/ tsiint, tavgint, itavg, tmbint, itmb, stabint
&, zmbcint, glenint, trmbint, itrmb, vmsfint
&, gyreint, extint, prxzint, trajint, exconvint
&, dspint, snapint, snapls, snaple, snapde
&, timavgint, cmixint
&, prlat, prslon, prelon, prsdpt, predpt
&, slatxy, elatxy, slonxy, elonxy
&, cflons, cflone, cflats, cflate, cfldps, cfldpe
&, maxcfl, xbtint
namelist /io/ expnam, iotavg
&, iotmb, iotrmb
&, ioglen, iovmsf, iogyre
&, ioprxz, ioext, iodsp, iotsi, iozmbc, iotraj
&, ioxbt
namelist /ictime/ year0, month0, day0, hour0, min0, sec0
&, ryear, rmonth, rday, rhour, rmin, rsec
&, refrun, refinit, refuser, eqyear, eqmon, monlen
c
c-----------------------------------------------------------------------
c INITIALIZATIONS
c
c grep xxx *.h to find the description (where xxx is what you want)
c
c-----------------------------------------------------------------------
#ifdef timing
call tic ('driver', 'setocn')
#endif
c
c is the MW (memory window) opened all the way or not?
c
if (jmw .eq. jmt) then
wide_open_mw = .true.
else
wide_open_mw = .false.
endif
c
c-----------------------------------------------------------------------
c time at initial conditions.
c-----------------------------------------------------------------------
c
year0 =1
month0 =1
day0 =1
hour0 =0
min0 =0
sec0 =0
c
c-----------------------------------------------------------------------
c set whether calculations for logical switches are referenced to
c
c refrun = T ==> the start of each run
c refinit = T ==> initial condition time given by:
c year0, month0, day0, hour0, min0, sec0
c refuser = T ==> user specified reference time
c ryear, rmonth, rday, rhour, rmin, rsec
c
c choose by setting one of the above to TRUE
c-----------------------------------------------------------------------
c
refrun = .false.
refinit = .true.
refuser = .false.
c
c set the date and time for referencing switches
c (only needed if rfuser = .T.)
c
ryear = 1900
rmonth = 1
rday = 1
rhour = 0
rmin = 0
rsec = 0
c
c-----------------------------------------------------------------------
c set type of year (eqyear = F => real calendar with leap years)
c (eqyear = T => idealized calendar)
c
c if calendar is idealized then there are two choices:
c eqmon = F => the usual number of days per month (31, 28, 31, ...)
c and the length of a year is 365 days
c (monlen is not used in this case)
c eqmon = T => a fixed number of days per month set by "monlen"
c and the length of a year is 12*monlen
c-----------------------------------------------------------------------
c
eqyear = .false.
eqmon = .false.
monlen = 30
c
c stability diagnostic
c
call stabi
c
c misc variables
c
error = .false.
vmixset = .false.
hmixset = .false.
momver = ' GFDL MOM 2.0'
expnam = ' MOM test case '
init =.true.
initpt =.true.
bwidth = 0.0
numpas = 100
c
c initialize ifdef list
c
do n=1,ifdmax
cifdef(n) = ' '
enddo
c
nifdef = 0
cifdef(1) = 'no ifdefs enabled (turned on)'
c
c integration time related variables
c
runlen = 5.0
rununits = 'days'
segtim = 1.0
dtts = -3600.0
dtuv = -3600.0
dtsf = -3600.0
do k=1,km
dtxcel(k) = 1.0
enddo
c
c control for leapfrog/mixing time steps
c
nmix = 17
eb = .true.
c
c tolerance settings for poisson solvers
c
tolrsf = 1.0e8
tolrsp = 5.0e4
tolrfs = 5.0e4
c
c vertical and horizontal mixing + newtonain damping variables
c
kappa_h = 1.0
kappa_m = 20.0
am = 1.0e9
ah = 2.0e7
ambi = 1.0e23
ahbi = 5.0e22
cdbot = 0.0
visc_cbu_limit = 1.0e6
diff_cbt_limit = 1.0e6
c
c damping time scales and depths for test case
c
do n=1,nt
dampts(n) = 50.0
dampdz(n) = 26.575e2
enddo
annlev = .false.
c
c number of convective passes for standard explicit convection
c
ncon = 1
c
c physical constants
c
rho0 = 1.035
rho0r = c1/rho0
grav = 980.6
radius = 6370.0e5
c
c time centering for equations
c
#if defined implicitvmix || defined isopycmix
aidif = 0.5
#else
aidif = 0.0
#endif
c
#ifdef rigid_lid_surface_pressure
alph = 1.0
gam = 0.0
theta = 1.0
#endif
c
#ifdef implicit_free_surface
alph = 0.3333333
gam = 0.3333333
theta = 0.5
#endif
c
#ifdef linearized_density
c
c eliminate the pressure effect when using linearized density
c
do k=1,km
to(k) = 0.0
so(k) = 0.0
enddo
#endif
c
c
c
c-----------------------------------------------------------------------
c write MOM version number
c-----------------------------------------------------------------------
c
write (stdout,'(/1x,a14,a80/)') 'MOM version = ',momver
c
c-----------------------------------------------------------------------
c provide for change in above presets using "namelist"
c-----------------------------------------------------------------------
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, contrl)
write (stdout,contrl)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, mbcin)
write (stdout,mbcin)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, tsteps)
write (stdout,tsteps)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, riglid)
write (stdout,riglid)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, mixing)
write (stdout,mixing)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, diagn)
write (stdout,diagn)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, io)
write (stdout,io)
call relunit (ioun)
c
call getunit (ioun, 'namelist', 'fsr')
read (ioun, ictime)
write (stdout,ictime)
call relunit (ioun)
c
call getunit (iodoc, 'document.dta', 'fsr')
write (iodoc, contrl)
write (iodoc, mbcin)
write (iodoc, tsteps)
write (iodoc, riglid)
write (iodoc, mixing)
write (iodoc, diagn)
write (iodoc, io)
write (iodoc, ictime)
write (iodoc,'(a,i6)') 'imt=', imt, 'jmt=', jmt, 'km=', km
&, 'nt=', nt, 'nvar=', nvar
c
c user specified tracer names are placed into "trname" here.
c
do m=1,nt
trname(m) = '**unknown***'
enddo
trname(1) = 'potentl_temp'
trname(2) = 'salinity '
write (iodoc,'(a,a)') 'trname(1)=', trname(1)
&, 'trname(2)=', trname(2)
call relunit (iodoc)
c
c-----------------------------------------------------------------------
c open i/o units needed for prognostic variables
c nbuf = number of i/o buffers (currently not used)
c-----------------------------------------------------------------------
c
#if defined ramdrive
call getunitnumber (kflds)
call getunitnumber (latdisk(1))
call getunitnumber (latdisk(2))
#endif
c
nbuf = 2
call ostart (kflds, 'kflds', nkflds*nwds, nwds, nbuf)
call ostart (latdisk(1), 'latdisk1', jmt*nslab, nslab, nbuf)
call ostart (latdisk(2), 'latdisk2', jmt*nslab, nslab, nbuf)
c
c-----------------------------------------------------------------------
c set up the grids in x (longitude), y (latitude), and z (depth)
c corresponding to Arakawa "b" gird system
c-----------------------------------------------------------------------
c
call grids
c
c-----------------------------------------------------------------------
c check that the density coefficients are consistent with the
c depths generated by grids
c-----------------------------------------------------------------------
c
cksum = checksum (zt, km, 1)
if (abs(cksum - cksumzt) .gt. 1.e-6*cksumzt )then
write (stdout,'(a/a)')
& '=>Error: density coeffs were calculated for depth levels that'
&,' differ from those used in this model run'
write (stdout,*) 'checksum from setocn = ',cksum
write (stdout,*) 'checksum from dncoef.h = ',cksumzt
stop 'setocn'
endif
c
#ifdef linearized_advection
c
c set the initial idealized stratification as a function of
c temperature only.
c
tzero = 7.5
tone = 10.0
z0 = 30.0e2
bigl = 80.0e2
write (stdout,'(//a/)')
& 'Temperature stratification for linearized advection'
do k=1,km
tbarz(k) = tzero*(1.0-tanh((zt(k)-bigl)/z0)) +
& tone*(1.0-zt(k)/zt(km))
write (stdout,'(1x,"k=",i3," tbarz=",e14.7)') k, tbarz(k)
enddo
#endif
c
c-----------------------------------------------------------------------
c set the earth`s rotation rate to computer precision
c-----------------------------------------------------------------------
c
omega = pi/43082.0
call getunit (iodoc, 'document.dta', 'fsa')
write (iodoc,'(a,e14.7)') 'omega=', omega
call relunit (iodoc)
c
c-----------------------------------------------------------------------
c if the MW is not fully opened, then set time level indicators in
c the MW ("tau-1" "tau" "tau+1") to constant values.
c-----------------------------------------------------------------------
c
if (.not. wide_open_mw) then
taum1 = -1
tau = 0
taup1 = +1
endif
c
c-----------------------------------------------------------------------
c set prognostic quantities to either initial conditions or restart
c-----------------------------------------------------------------------
c
if (init) then
c
c generate topographic levels "kmt" on "t" cells.
c
call topog (kmt, map, xt, yt, zt, xu, yu, zw, imt, jmt, km)
c
c construct depth arrays associated with "u" cells
c
call depth_u (kmt, imt, jmt, zw, km, kmu, h, hr)
c
c initialize two dimensional fields on disk
c
#if defined rigid_lid_surface_pressure || defined implicit_free_surface
c
c initialize surface pressure fields in memory
c
do jrow=1,jmt
do i=1,imt
ps(i,jrow,1) = c0
ps(i,jrow,2) = c0
pguess(i,jrow) = c0
ubar(i,jrow,1) = c0
ubar(i,jrow,2) = c0
ubarm1(i,jrow,1) = c0
ubarm1(i,jrow,2) = c0
enddo
enddo
#endif
#ifdef stream_function
c
c initialize stream function fields in memory
c
do n=1,2
do jrow=1,jmt
do i=1,imt
psi(i,jrow,n) = c0
ptd(i,jrow) = c0
enddo
enddo
enddo
c
c initialize stream function guess fields on disk
c block`s 1 & 2 are for the stream function guess field on disk
c
do n=1,nkflds
call oput (kflds, nwds, n, ptd(1,1))
enddo
#endif
c
c initialize all latitude rows
c
call rowi
c
c initialize time step counter = 0
c
itt = 0
irstdy = 0
msrsdy = 0
else
c
c initialize all prognostic quantities from the restart
c
call read_restart
c
c compute a topography checksum
c
cksum = 0.0
do jrow=1,jmt
do i=1,imt
cksum = cksum + i*jrow*kmt(i,jrow)
enddo
enddo
write (stdout,*) ' "kmt" checksum = ', cksum
endif
c
c-----------------------------------------------------------------------
c initialize the time manager with specified initial conditions
c time, user reference time, model time, and how long to integrate.
c-----------------------------------------------------------------------
c
call tmngri (year0, month0, day0, hour0, min0, sec0
&, ryear, rmonth, rday, rhour, rmin, rsec
&, irstdy, msrsdy
&, runlen, rununits, rundays, dtts)
c
#ifdef stability_tests
c
c-----------------------------------------------------------------------
c convert starting and ending longitudes for the stability tests
c to nearest model grid points.
c-----------------------------------------------------------------------
c
if (stabint .ge. c0) then
iscfl = max(indp (cflons, xt, imt), 2)
cflons = xt(iscfl)
iecfl = min(indp (cflone, xt, imt), imt-1)
cflone = xt(iecfl)
jscfl = max(indp (cflats, yt, jmt), 2)
cflats = yt(jscfl)
jecfl = min(indp (cflate, yt, jmt), jmt-1)
cflate = yt(jecfl)
kscfl = indp (cfldps, zt, km)
cfldps = zt(kscfl)
kecfl = indp (cfldpe, zt, km)
cfldpe = zt(kecfl)
endif
#endif
c
#ifdef restorst
c
c-----------------------------------------------------------------------
c damp surface tracers back to data. schematically, the restoring
c term will be = (dampdz/(dampts*86400)) * (data - t)
c where dampdz is the thicness (cm) and dampts is the time
c scale (days)
c-----------------------------------------------------------------------
c
do n=1,nt
write (stdout,'(/,1x,a,i2,a,a,/,1x,1pe14.7,a,1pe14.7,a,/)')
& ' Surface tracer #',n,' will be damped back to data using a'
&, ' Newtonian restoring time scale of '
&, dampts(n),' days. and a level thickness =', dampdz(n),' cm.'
enddo
call getunit (iodoc, 'document.dta', 'fsa')
write (iodoc,'(a,(1x,e14.7))') 'dampts=', dampts
write (iodoc,'(a,(1x,e14.7))') 'dampdz=',dampdz
call relunit (iodoc)
#endif
c
#if defined fourfil || defined firfil
c
c compute sin and cos values for vector correction before filtering
c
fx = 1.0e-10
fxa = dxt(1)/radius
c
do i=2,imtm1
fxb = fxa*float(i-2)
spsin(i) = sin(fxb)
spcos(i) = cos(fxb)
if (abs(spsin(i)) .lt. fx) spsin(i) = c0
if (abs(spcos(i)) .lt. fx) spcos(i) = c0
enddo
c
spsin(1) = c0
spcos(1) = c0
spsin(imt) = c0
spcos(imt) = c0
c
c set up model indices for filtering high latitudes
c
jfrst = indp (rjfrst, yt, jmt)
jft0 = indp (rjft0, yt, jmt)
jft1 = indp (rjft1, yt, jmt)
jft2 = indp (rjft2, yt, jmt)
jfu0 = indp (rjfu0, yu, jmt)
jfu1 = indp (rjfu1, yu, jmt)
jfu2 = indp (rjfu2, yu, jmt)
call getunit (iodoc, 'document.dta', 'fsa')
write (iodoc,'(a,i6)') 'jfrst=', jfrst, 'jft0=',jft0
&, 'jft1=',jft1, 'jft2=',jft2, 'jfu0=',jfu0, 'jfu1=',jfu1
&, 'jfu2=',jfu2
call relunit (iodoc)
jskpt = jft2-jft1
jskpu = jfu2-jfu1
njtbft = (jft1-jfrst+1)+(jmtm1-jft2+1)
njtbfu = (jfu1-jfrst+1)+(jmtm1-jfu2+1)
if (njtbft .gt. jmtfil .or. njtbfu .gt. jmtfil) then
write (stdout,9599) njtbft, njtbfu
write (stderr,9599) njtbft, njtbfu
stop '>ocean 1'
endif
9551 format (/' ==== start and end indices for fourier filtering ====')
9552 format (' only 11 sets of indices fit across the page.',
& ' others will not be printed.'/)
9553 format (/,' == filtering indices for t,s ==')
9554 format (/,' == filtering indices for u,v ==')
9555 format (/,' == filtering indices for stream function ==')
9599 format (/,' error => jmtfil must be >= max(njtbft,njtbfu)',
& /,' njtbft=',i8,' njtbfu=',i8)
c
# ifdef firfil
c
c set "numflt" and "numflu" to filter more at higher latitudes
c using "jft0" and "jfu0" as reference latitude rows.
c
numfmx = imt * p25
refcos = cst(jft0)
write(stdout,9501) refcos, yt(jft0)
do jrow=jfrst,jmt
if ((jrow .le. jft1 .or. jrow .ge. jft2) .and. jrow .ge. jfrst)
& then
jj = jrow - jfrst + 1
if (jrow .ge. jft2) jj = jj - jskpt + 1
numflt(jj) = max(1,int(refcos/cst(jrow)))
if (numflt(jj) .gt. numfmx) numflt(jj) = numfmx
write(stdout,9502) jrow, jj, numflt(jj), yt(jrow)
if (jj .gt. jmtfil) then
write (stdout,'(1x,a,i4,a,i4,a)')
& 'Error: jj exceeds jmtfil. jj=',jj, ' jmtfil=',jmtfil
&, '. increase jmtfil'
stop "=>setocn"
endif
endif
enddo
refcos = csu(jfu0)
write(stdout,9503) refcos, yu(jfu0)
do jrow=jfrst,jmt
if ((jrow .le. jfu1 .or. jrow .ge. jfu2) .and. jrow .ge. jfrst)
& then
jj = jrow - jfrst + 1
if (jrow .ge. jfu2) jj = jj - jskpu + 1
numflu(jj) = max(1,int(refcos/csu(jrow)))
if (numflu(jj) .gt. numfmx) numflu(jj) = numfmx
write(stdout,9502) jrow, jj, numflu(jj), yu(jrow)
if (jj .gt. jmtfil) then
write (stdout,'(1x,a,i4,a,i4,a)')
& 'Error: jj exceeds jmtfil. jj=',jj, ' jmtfil=',jmtfil
&, '. increase jmtfil'
stop "=>setocn"
endif
endif
enddo
c
9501 format(/' firfil reference cosine for tracers =',e12.6,' (',
& f7.3,' deg)'/' jrow jj numflt(jj) latitude')
9502 format(1x,3i8,6x,f7.3)
9503 format(/' firfil reference cosine for velocities =',e12.6,' (',
& f7.3,' deg)'/' jrow jj numflu(jj) latitude')
# endif
#endif
c
#ifdef sponges
c
c-----------------------------------------------------------------------
c set latitude functions for newtonian damping term in sponge layers
c near artificial northern and southern boundaries in limited
c domain models.
c schematically: damping = - sponge(j) * (t(i,k,j) - levitus(i,k,j))
c all related data is assumed to have been prepared using the
c "sponge" routines in the MOM dataset.
c disk resource factor of 13 is for 12 months + 1 annual mean
c-----------------------------------------------------------------------
c
lrec = 4 + 4 + 2*jmt + 4*imt*km
write (opt_sponge,'(a,1x,i8)') 'u d words =',lrec
write (stdout,'(/a,1pg10.3,a)')
& ' Sequential access disk resource for file "sponge.mom" = '
&,lrec*13*1.e-6,' (MW)'
call getunit (ionew1, 'sponge.mom', 'u s r ieee')
write (stdout,'(/a,1pg10.3,a)')
& ' Direct access disk resource for file "sponges" = '
&,lrec*13*1.e-6,' (MW)'
call getunit (ionew2, 'sponges', opt_sponge)
c
sum = 0.0
cksum = 0.0
do m=1,13
read (ionew1)
read (ionew1) sstamp, spdpm, im, kk, jm, j1, j2, mm
&, spngs, spngn, spbuf1
write (ionew2, rec=m) sstamp, spdpm, im, kk, jm, spngs, spngn
&, spbuf1
if (m .le. 12) then
spgdpm(m) = spdpm
sum = sum + spdpm
tspng(m) = sum - 0.5*spdpm
endif
do n=1,4
cksum = cksum + checksum (spbuf1(1,1,n), imt, km)
enddo
enddo
print *,' checksum for sponge data = ',cksum
if (annlev) then
write (stdout,'(/a)')
& ' => Annual mean levitus data will be used for Newtonain sponge'
do m=1,12
write (ionew2, rec=m) sstamp, spdpm, im, kk, jm, spngs, spngn
&, spbuf1
enddo
else
write (stdout,'(/a)')
& ' => Monthly levitus data will be used for Newtonain sponge'
endif
write (stdout,'(1a/)') ' Newtonian damping zone setup:'
do jrow=1,jmt
if (spngs(jrow) .ne. c0) then
write (stdout,'(a,i3,a,f7.2,a,e10.3,a,e10.3)') ' jrow='
&, jrow,', yt(jrow)=',yt(jrow), ', spngs(jrow) =',spngs(jrow)
&, ', Newtonain time scale (days)=',secday/spngs(jrow)
endif
if (spngn(jrow) .ne. c0) then
write (stdout,'(a,i3,a,f7.2,a,e10.3,a,e10.3)') ' jrow='
&, jrow,', yt(jrow)=',yt(jrow), ', spngn(jrow) =',spngn(jrow)
&, ', Newtonain time scale (days)=',secday/spngn(jrow)
endif
if (spngn(jrow) .ne. c0 .and. spngs(jrow) .ne. c0) then
write (stdout,'(/a/)')
& ' Error: Overlapping north and south sponges not allowed'
stop '=>setocn'
endif
enddo
write (stdout,*) ' '
c
c set the current model time in days and initialize interpolation
c information
c
begtim = (realdays(initial) - 1.0) + realdays(imodeltime)
c
if (.not.eqyear) then
write (stdout,*) '=>Warning leap year being used with '
&, ' climatological sponges?'
endif
iprev = 1
inext = 2
indxsp = 5
method = 3
call timeinterp(begtim, indxsp, tspng, spgdpm, 12, .true., method
&, inextd, iprevd, wprev, readsp, inext, iprev)
c
read (ionew2, rec=iprevd) stprev, spdpmp, im, kk, jm, spngs
&, spngn, spbuf1
do n=1,4
do k=1,km
do i=1,imt
spbuf(i,k,n,iprev) = spbuf1(i,k,n)
enddo
enddo
enddo
read (ionew2, rec=inextd) stnext, spdpmn, im, kk, jm, spngs
&, spngn, spbuf1
do n=1,4
do k=1,km
do i=1,imt
spbuf(i,k,n,inext) = spbuf1(i,k,n)
enddo
enddo
enddo
c
write (stdout,'(2(/a,i3,1x,a,a,i2)/a,g14.7,1x,a,a,g14.7/)')
& ' reading sponge record ', iprevd, stprev, ' into buffer ', iprev
&,' reading sponge record ', inextd, stnext, ' into buffer ', inext
&,' for day =', begtim, stamp, ' weight =',wprev
write (stdout,'(/a,i2,a,i2/)') 'sponge is dataset index ',indxsp
&,' for time interpolation using method #',method
call relunit (ionew1)
call relunit (ionew2)
#endif
c
#ifdef shortwave
c
c-----------------------------------------------------------------------
c Solar Shortwave energy penetrates below the ocean surface. Clear
c water assumes energy partitions between two exponentials as
c follows:
c
c 58% of the energy decays with a 35 cm e-folding scale
c 42% of the energy decays with a 23 m e-folding scale
c
c if the thickness of the first ocean level "dzt(1)" is 50 meters,
c then shortwave penetration wouldn't matter. however, for
c dzt(1) = 10 meters, the effect can be significant. this can be
c particularly noticable in the summer hemisphere.
c
c Paulson and Simpson (1977 Irradiance measurements in the upper
c ocean JPO 7, 952-956)
c Also see ... Jerlov (1968 Optical oceanography. Elsevier)
c A General Circulation Model for Upper Ocean
c Simulaton (Rosati and Miyakoda JPO vol 18,Nov 1988)
c-----------------------------------------------------------------------
c
write (stdout,'(/a/)')
&' => Shortwave penetration is a double exponential as follows:'
rpart = 0.58
efold1 = 35.0e0
efold2 = 23.0e2
rscl1 = 1.0/efold1
rscl2 = 1.0/efold2
call getunit (iodoc, 'document.dta', 'fsa')
write (iodoc,'(a,e14.7)') 'rpart=', rpart, 'efold1=',efold1
&, 'efold2=',efold2
call relunit (iodoc)
c
c note that pen(0) is set 0.0 instead of 1.0 to compensate for the
c shortwave part of the total surface flux in "stf(i,1)"
c
pen(0) = c0
c
do k=1,km
swarg1 = -min(zw(k)*rscl1,70.0)
swarg2 = -min(zw(k)*rscl2,70.0)
pen(k) = rpart*exp(swarg1) + (c1-rpart)*exp(swarg2)
divpen(k) = (pen(k-1) - pen(k))/dzt(k)
write (stdout,9200) k, zw(k)*1.e-2, pen(k), zt(k)*1.e-2
&, divpen(k)
enddo
write (stdout,*) ' '
9200 format (1x,'k=',i3,' zw(k)=',f8.2,'(m) pen(k)=',e14.7
&, ' zt(k)=',f8.2,'(m) divpen(k)=',e14.7)
#endif
c
c-----------------------------------------------------------------------
c compute surface area and volume of ocean ("t" cells and "u" cells)
c (note that areas are defined at each level)
c-----------------------------------------------------------------------
c
do k=1,km
tcella(k) = c0
ucella(k) = c0
enddo
ocnp = c0
tcellv = c0
ucellv = c0
c
c this comment directive turns off autotasking on the YMP
c for the following loop
c
cfpp$ noconcur l
do jrow=2,jmtm1
do i=2,imtm1
if (kmt(i,jrow) .gt. 0) then
do k=1,kmt(i,jrow)
tcella(k) = tcella(k) + cst(jrow)*dxt(i)*dyt(jrow)
enddo
tcellv = tcellv + cst(jrow)*dxt(i)*dyt(jrow)*zw(kmt(i,jrow))
ocnp = ocnp + float(kmt(i,jrow))
endif
if (kmu(i,jrow) .gt. 0) then
do k=1,kmu(i,jrow)
ucella(k) = ucella(k) + csu(jrow)*dxu(i)*dyu(jrow)
enddo
ucellv = ucellv + csu(jrow)*dxu(i)*dyu(jrow)*zw(kmu(i,jrow))
endif
enddo
enddo
c
write (stdout,9341) tcella(1), tcellv, ucella(1), ucellv
c
#if defined tracer_averages || defined term_balances || gyre_components
c
c---------------------------------------------------------------------
c set the horizontal regional masks and names to be used when
c computing averages on the "t" grid in subroutine "region.F".
c also set the vertical regional masks and names for use (along
c with the horizontal ones) in term balance calculations for
c tracers & momentum. For term balance calculations the number
c of masks is the product of horizonatl & vertical regions.
c---------------------------------------------------------------------
c
# ifdef readrmsk
c
c read in horizontal & vertical regional masks ("mskhr" & "mskvr")
c and names ("hregnm" & "vregnm") on unit iormsk
c
call getunit (iormsk, 'region_masks', 'fsr')
call reg1st (iormsk, .true., .false., .false., .false., .true.)
call relunit (iormsk)
# else
c
c set up the horizontal regions:
c specify "mskhr" and "hregnm" values rather than reading them in
c from a file (arbitrarily defaulted below for 5 zonal bands).
c note: there must be "nhreg" calls ... one for each horizontal
c region. The form is:
c call sethr (region number, starting lon, ending lon, starting lat,
c ending lat)
c where the lon and lat limits are for the edges of the "t" cells
c "sethr" will fit the region using the nearest model grid points
c
do jrow=1,jmt
do i=1,imt
mskhr(i,jrow) = 0
enddo
enddo
c
call sethr (1, xu(1), xu(imtm1), -90.0, -60.1)
call sethr (2, xu(1), xu(imtm1), -60.1, -24.9)
call sethr (3, xu(1), xu(imtm1), -24.9, 24.9)
call sethr (4, xu(1), xu(imtm1), 24.9, 59.9)
call sethr (5, xu(1), xu(imtm1), 59.9, 90.0)
c
do jrow=1,jmt
mskhr(1,jrow) = 0
mskhr(imt,jrow) = 0
enddo
c
c set up the vertical regions:
c specify "mskvr" and "vregnm" values. also the starting & ending
c levels for the vertical regions (arbitrarily defaulted for two
c vertical regions). Note: there must be "nvreg" calls... one for
c each vertical region.
c The form is:
c call setvr (region number, starting depth, ending depth)
c where the depth limits are for the edges of the "t" cells
c "setvr" will fit the region using the nearest model grid points
c
n = 1
call setvr (n, 0.0e2, 245.0e2)
n = n + 1
call setvr (n, 245.0e2, 1570.e2)
c
c Note: additional vertical regions can be added as follows:
c
c n = n + 1
c call setvr (n, 1570.0e2, 2500.e2)
c
if (n .gt. nvreg) then
write (stdout,*) "=>Error: increase parameter 'nvreg' "
write (stdout,*) " stop in setocn"
stop
endif
c
do k=1,km
mskvr(k) = 0
enddo
do n=1,nvreg
ks = llvreg(n,1)
ke = llvreg(n,2)
do k=ks,ke
mskvr(k) = n
enddo
enddo
# endif
#ifdef tracer_averages
c
c print out regional mask info for tracer average diagnostic
c
if ((iotavg .ne. stdout .or. iotavg .lt. 0) .and. itavg) then
call getunit (iou, 'tracer_avg.dta','u s a ieee')
call reg1st (iou, .false., .false., .false., .true., .false.)
call relunit (iou)
endif
if ((iotavg .eq. stdout .or. iotavg .lt. 0) .and. itavg) then
call reg1st (stdout, .true., .false., .false., .true., .false.)
endif
#endif
#ifdef term_balances
c
c print out regional mask info for term balance diagnostic
c
if ((iotrmb .ne. stdout .or. iotrmb .lt. 0) .and. itrmb) then
call getunit (iou, 'term_bal.dta','u s a ieee')
call reg1st (iou, .false., .false., .false., .true., .false.)
call relunit (iou)
endif
#endif
c
c-----------------------------------------------------------------------
c compute the surface area and volume of the ocean regions. index 0
c refers to the sum of all regions.
c (values used in subroutine region are done in terms of meters,
c rather than centimeters)
c-----------------------------------------------------------------------
c
areag = c0
volgt = c0
c
do k=1,km
volgk(k) = c0
enddo
c
do n=0,numreg
areat(n) = c0
areau(n) = c0
volt(n) = c0
volu(n) = c0
enddo
do mask=1,nhreg
areab(mask) = c0
volbt(mask) = c0
do k=1,km
volbk(mask,k) = c0
enddo
enddo
c
do jrow=2,jmtm1