-
Notifications
You must be signed in to change notification settings - Fork 94
/
ocean_model.F90
3364 lines (2892 loc) · 143 KB
/
ocean_model.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
module ocean_model_mod
!
!<CONTACT EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Stephen M. Griffies
!</CONTACT>
!
!<CONTACT EMAIL="GFDL.Climate.Model.Info@noaa.gov"> Matt Harrison
!</CONTACT>
!
!<OVERVIEW>
! Time step the ocean model using either a twolevel staggered scheme
! (the default) or threelevel leap-frog scheme (the older approach).
! Threelevel scheme remains only for legacy purposes and is not
! recommended for normal use.
!</OVERVIEW>
!
!<DESCRIPTION>
! Top level module for ocean model. Contains routines for
! initialization, termination, and update of ocean model state.
!
! Design consideration: declarations of top level ocean variables
! are private to this module and hence are only available to other routines
! through argument lists. For instance, timestep information is passed to
! the various modules on the initialization call and stored internally
! in the respective modules. This is a crucial design consideration sinces
! it maintains modularity and hence maintainability of the code.
!</DESCRIPTION>
!
!<NAMELIST NAME="ocean_model_nml">
! <DATA NAME="layout" TYPE="integer">
! Processor domain layout for ocean model.
! </DATA>
!
! <DATA NAME="io_layout" TYPE="integer, dimension(2)">
! Processor IO domain layout for ocean model. The default value is (0,0).
! If either io_layout(1) or (2) is 0, it will default to the number of
! processors in the computational layout, except restart file will default
! to single file if fms_io_nml fileset_write is set to 'single'. When
! both entry of io_layout is positive, io_domain will be defined(a pointer in domain2d)
! and number of distributed files will be layout(1)*layout(2). For example, assume
! the restart file is ocean_velocity.res.nc and the diagnostics file is ocean_daily.nc,
! if the layout = (1,2), the restart files will be ocean_velocity.res.nc.0000 and
! ocean_veloicity.res.nc.0001, the diagnostics files will be ocean_daily.res.nc.0000
! and ocean_daily.res.nc.0001. When the io_domain is defined, restart file and
! diagnostics file name will be controlled by the io_domain (ignoring fms_io_nml fileset_write).
! </DATA>
!
! <DATA NAME="dt_ocean" TYPE="integer" DEFAULT="-1">
! Ocean model time step in seconds.
! </DATA>
!
! <DATA NAME="time_tendency" TYPE="character">
!
! Possible time stepping schemes are the following.
!
! 1. "threelevel" has the following characteristics
!
! leap-frog for the time tendency which means the
! inviscid/nondissipative processes are at time tau.
!
! forward for lateral mixing processes (dissipation at taum1)
!
! implicit for vertical dissipative (with aidif = 1.0)
!
! semi-implicit for Coriolis (with acor>0)
!
! Because of the need to apply time filters to suppress
! leap-frog splitting, the threelevel time stepping scheme
! does not conserve total tracer content in the model.
!
! 2. "twolevel" has the following characteristics:
!
! staggered 2nd order forward time tendency, which means
! that tracer advection, lateral tracer and velocity mixing,
! are at time tau. Pressure gradients are at taup1.
!
! Adams-Bashforth (either 2nd or 3rd order) for velocity advection
! Third order is default as it is more stable.
!
! implicit vertical mixing (with aidif = 1.0)
!
! semi-implicit for Coriolis (with acor > 0)
!
! This scheme conserves total volume and tracer in the ocean model.
!
! </DATA>
!
! <DATA NAME="vertical_coordinate" TYPE="character">
! This string determines the vertical coordinate used in MOM.
!
! There are 3 + 3 options in MOM:
! Depth-based Boussinesq are 'geopotential', 'zstar', 'zsigma',
! Pressure-based non-Boussinesq are 'pressure', 'pstar', and 'psigma'.
!
! The two terrain-following sigma options are not well tested in MOM,
! whereas the other options are standard. The recommended Boussinesq
! vertical coordinate is zstar, and the recommended non-Boussineq
! coordinate is pstar. The default is vertical_coordinate='zstar'.
! </DATA>
!
! <DATA NAME="horizontal_grid" TYPE="character">
! This string determines the arrangement of variables on the
! discrete horizontal grid. The standard case is horizontal_grid='bgrid'.
! However, the C-grid is being developed in MOM. It is not yet
! supported for general use. Default horizontal_grid='bgrid'.
! </DATA>
!
! <DATA NAME="impose_init_from_restart" TYPE="logical">
! Consider the following situation: We have run the model for many years
! and generated restarts. Time%init is then .false. Then, we wish to start
! a series of perturbation experiments from this restart file. The generic
! situation is for Time%init to then be .true. However, we need it to be
! .false. in MOM in order to have a proper reading of the full restart
! information. Setting impose_init_from_restart=.true. will facilitate
! this setup. The default is impose_init_from_restart=.false., in which case
! the model will run through its normal start/stop segments using restarts.
! </DATA>
!
! <DATA NAME="baroclinic_split" TYPE="integer">
! baroclinic_split = dtts/dtuv
! = (tracer time step)/(baroclinic time step)
! = (ocean model time step)/(baroclinic time step)
! Transients corrupted if baroclinic_split > 1, so it is recommended
! to use baroclinic_split=1.
! </DATA>
!
! <DATA NAME="barotropic_split" TYPE="integer">
! Ratio barotropic_split = dtuv/dtbt
! = (baroclinic time step)/(barotropic time step).
! Must be large enough to resolve the barotropic gravity waves
! captured by the barotropic part of the model.
! Barotropic waves are dissipated when this splitting
! is greater than unity. Model algorithm is not fully
! implemented when barotropic_split=1, so user beware
! if wishing to run an unsplit model simulation.
! </DATA>
!
! <DATA NAME="surface_height_split" TYPE="integer">
! Ratio surface_height_split = dtts/dteta
! = (tracer time step)/(surface height time step)
! = (tracer time step)/(bottom pressure time step)
! Typically this split is set to unity for models where baroclinic_split=1,
! but something larger when baroclinic_split is order 10. dteta is the time
! step used for update of eta_t or pbot_t. If surface_height_split is
! not equal to unity, then tracer conservation properties are compromised.
! </DATA>
!
! <DATA NAME="reinitialize_thickness" TYPE="logical">
! When initialized with a nontrivial eta field, it is
! necessary to reinitialize the thickness arrays.
! </DATA>
!
! <DATA NAME="cmip_units" TYPE="logical">
! For CMIP output, we need to have temperature in K (if cmip_version<=5)
! and mass transport in kg/s. The flag cmip_units=.true. will
! diagnose CMIP5-related fields with the CMIP units for sending
! to the diagnostic manager.
! Default cmip_units=.false.
! </DATA>
!
! <DATA NAME="cmip_version" TYPE="integer">
! Specifies CMIP version used when cmip_units=.true.
! Temperature is in K if cmip_version<=5, otherwise degrees C.
! Default cmip_version=5.
! </DATA>
!
! <DATA NAME="use_blobs" TYPE="logical">
! For using Lagrangian blobs.
! Default use_blobs=.false.
! </DATA>
!
! <DATA NAME="introduce_blobs" TYPE="logical">
! For the Lagrangian blobs after a model has already been running.
! Default introduce_blobs=.false.
! </DATA>
!
! <DATA NAME="use_velocity_override" TYPE="logical">
! For over-riding the velocity field with values from
! a file. Note that we need separate files for
! (u,v) read into ocean_velocity.F90, as well as
! (udrho,vdrho) read into ocean_barotropic.F90.
! Default use_velocity_override=.false.
! </DATA>
!
! <DATA NAME="debug" TYPE="logical">
! For overall model debugging. Set true to print cksums at
! each timestep for debugging purposes.
! </DATA>
!
! <DATA NAME="mask_table" TYPE="character">
! A text file to specify n_mask, layout and mask_list. This table
! aims to reduce the number of processors that are cycling over pure
! land regions. These processors will be masked out of regions that
! which contain all land points.
!
! The default file name of mask_table is "INPUT/ocean_mask_table".
! Please note that the file name must begin with "INPUT/".
!
! The first line of mask_table is the number of region to be masked out.
! The second line is the layout of the model. User need to set ocean_model_nml
! variable layout to be the same as the second line of the mask table.
! The following n_mask line will be the position of the processor to be masked out.
!
! The mask_table could be created by tools check_mask.
!
! For example the mask_table will be as following if n_mask=2, layout=4,6 and
! the processor (1,2) and (3,6) are to be masked out.
! 2
! 4,6
! 1,2
! 3,6
! </DATA>
!
!</NAMELIST>
use fms_mod, only: FATAL, NOTE, WARNING, file_exist
use fms_mod, only: write_version_number, open_namelist_file, close_file, check_nml_error
use fms_mod, only: clock_flag_default
use fms_io_mod, only: set_domain, nullify_domain, parse_mask_table
use mpp_domains_mod, only: domain2d, BITWISE_EXACT_SUM, NON_BITWISE_EXACT_SUM
use mpp_domains_mod, only: mpp_update_domains, BGRID_NE, CGRID_NE, mpp_get_compute_domain
use mpp_mod, only: input_nml_file, mpp_error, mpp_pe, mpp_root_pe, mpp_npes, mpp_chksum, stdlog, stdout
use mpp_mod, only: mpp_clock_id, mpp_clock_begin, mpp_clock_end
use mpp_mod, only: CLOCK_COMPONENT, CLOCK_SUBCOMPONENT, CLOCK_MODULE, CLOCK_ROUTINE
use stock_constants_mod, only: ISTOCK_WATER, ISTOCK_HEAT, ISTOCK_SALT
use time_interp_external_mod, only: time_interp_external_init
use time_manager_mod, only: JULIAN, get_date, get_time, print_time
use time_manager_mod, only: time_type, operator( /= ), operator( < ), operator ( / )
use time_manager_mod, only: set_time, operator(-), operator( + ), operator( == )
use time_manager_mod, only: operator(*)
use ocean_advection_velocity_mod, only: ocean_advection_velocity_init, ocean_advection_velocity
use ocean_advection_velocity_mod, only: ocean_advection_velocity_end
use ocean_barotropic_mod, only: ocean_barotropic_init, ocean_barotropic_end
use ocean_barotropic_mod, only: update_ocean_barotropic
use ocean_barotropic_mod, only: ocean_barotropic_forcing, ocean_mass_forcing
use ocean_barotropic_mod, only: ocean_eta_smooth, ocean_pbot_smooth
use ocean_barotropic_mod, only: eta_and_pbot_update, eta_and_pbot_diagnose, eta_and_pbot_tendency
use ocean_barotropic_mod, only: ocean_barotropic_restart
use ocean_bbc_mod, only: ocean_bbc_init, get_ocean_bbc
use ocean_bih_friction_mod, only: ocean_bih_friction_init, ocean_bih_friction_end
use ocean_bih_friction_mod, only: ocean_bih_friction_restart
use ocean_blob_mod, only: ocean_blob_init, ocean_blob_update, ocean_blob_cell_update
use ocean_blob_mod, only: update_L_thickness, ocean_blob_diagnose_depth, ocean_blob_end
use ocean_blob_mod, only: init_blob_thickness, calculate_rhoT
use ocean_convect_mod, only: ocean_convect_init
use ocean_coriolis_mod, only: ocean_coriolis_init
use ocean_density_mod, only: ocean_density_init, ocean_density_end
use ocean_density_mod, only: update_ocean_density
use ocean_density_mod, only: update_ocean_density_salinity
use ocean_density_mod, only: ocean_density_restart, ocean_density_diag
use ocean_diagnostics_mod, only: ocean_diag_init, ocean_diagnostics
use ocean_domains_mod, only: ocean_domain_init, set_ocean_domain, get_local_indices
use ocean_form_drag_mod, only: ocean_form_drag_init, compute_visc_form_drag
use ocean_grids_mod, only: ocean_grids_init, set_ocean_grid_size
use ocean_grids_mod, only: set_ocean_hgrid_arrays, set_ocean_vgrid_arrays, init_grids_diag
use ocean_increment_eta_mod, only: ocean_increment_eta_init, ocean_increment_eta_source
use ocean_increment_tracer_mod, only: ocean_increment_tracer_init, ocean_increment_tracer_source
use ocean_increment_velocity_mod, only: ocean_increment_velocity_init, ocean_increment_velocity_source
use ocean_lap_tracer_mod, only: ocean_lap_tracer_init
use ocean_bih_tracer_mod, only: ocean_bih_tracer_init
use ocean_lap_friction_mod, only: ocean_lap_friction_init, ocean_lap_friction_end
use ocean_lap_friction_mod, only: ocean_lap_friction_restart
use ocean_mixdownslope_mod, only: ocean_mixdownslope_init, mixdownslope
use ocean_momentum_source_mod, only: ocean_momentum_source_init
use ocean_nphysics_mod, only: ocean_nphysics_init, ocean_nphysics_end, neutral_physics
use ocean_nphysics_mod, only: ocean_nphysics_restart
use ocean_nphysics_new_mod, only: ocean_nphysics_new_init, ocean_nphysics_new_end, neutral_physics_new
use ocean_nphysics_new_mod, only: ocean_nphysics_new_restart
use ocean_obc_mod, only: ocean_obc_init, ocean_obc_end
use ocean_obc_mod, only: ocean_obc_update_boundary, ocean_obc_prepare
use ocean_obc_mod, only: ocean_obc_restart
use ocean_operators_mod, only: ocean_operators_init
use ocean_overexchange_mod, only: ocean_overexchange_init, overexchange
use ocean_overflow_mod, only: ocean_overflow_init, overflow
use ocean_overflow_OFP_mod, only: ocean_overflow_OFP_init, overflow_OFP
use ocean_passive_mod, only: ocean_passive_tracer_init
use ocean_pressure_mod, only: ocean_pressure_init
use ocean_rivermix_mod, only: ocean_rivermix_init, rivermix
use ocean_riverspread_mod, only: ocean_riverspread_init
use ocean_parameters_mod, only: ocean_parameters_init, ocean_parameters_end
use ocean_parameters_mod, only: MOM_BGRID, MOM_CGRID
use ocean_parameters_mod, only: TWO_LEVEL, THREE_LEVEL
use ocean_parameters_mod, only: GEOPOTENTIAL, ZSTAR, ZSIGMA, PRESSURE, PSTAR, PSIGMA
use ocean_parameters_mod, only: DEPTH_BASED, PRESSURE_BASED
use ocean_parameters_mod, only: QUASI_HORIZONTAL, TERRAIN_FOLLOWING
use ocean_parameters_mod, only: VERTMIX_GOTM, cp_ocean
use ocean_sbc_mod, only: ocean_sbc_init, initialize_ocean_sfc, ocean_sfc_end
use ocean_sbc_mod, only: sum_ocean_sfc, avg_ocean_sfc, get_ocean_sbc, flux_adjust
use ocean_sbc_mod, only: ocean_sfc_restart
use ocean_shortwave_mod, only: ocean_shortwave_init, sw_source
use ocean_sigma_transport_mod, only: ocean_sigma_transport_init, sigma_transport, ocean_sigma_transport_end
use ocean_sigma_transport_mod, only: ocean_sigma_transport_restart
use ocean_sponges_eta_mod, only: ocean_sponges_eta_init, sponge_eta_source
use ocean_sponges_tracer_mod, only: ocean_sponges_tracer_init, sponge_tracer_source
use ocean_sponges_velocity_mod, only: ocean_sponges_velocity_init, sponge_velocity_source
use ocean_submesoscale_mod, only: ocean_submesoscale_init, submeso_restrat
use ocean_tempsalt_mod, only: ocean_tempsalt_ideal_reinit
use ocean_thickness_mod, only: ocean_thickness_init, ocean_thickness_init_adjust
use ocean_thickness_mod, only: ocean_thickness_end, rho_dzt_tendency
use ocean_thickness_mod, only: update_tcell_thickness, update_ucell_thickness
use ocean_thickness_mod, only: update_tcell_thick_blob, update_E_thickness
use ocean_thickness_mod, only: ocean_thickness_restart, dzt_dst_update
use ocean_topog_mod, only: ocean_topog_init
use ocean_tracer_advect_mod, only: ocean_tracer_advect_init, ocean_tracer_advect_end
use ocean_tracer_advect_mod, only: ocean_tracer_advect_restart
use ocean_tracer_mod, only: ocean_prog_tracer_init, ocean_diag_tracer_init
use ocean_tracer_mod, only: update_ocean_tracer, ocean_tracer_end, compute_tmask_limit
use ocean_tracer_mod, only: ocean_tracer_diagnostics_init, ocean_tracer_restart
use ocean_tracer_util_mod, only: ocean_tracer_util_init
use ocean_tpm_mod, only: ocean_tpm_source, ocean_tpm_bbc, ocean_tpm_tracer
use ocean_tpm_mod, only: ocean_tpm_end, ocean_tpm_start
use ocean_tpm_mod, only: ocean_tpm_flux_init, ocean_tpm_init_sfc
use ocean_types_mod, only: ocean_time_type, ocean_time_steps_type
use ocean_types_mod, only: ocean_grid_type, ocean_thickness_type
use ocean_types_mod, only: ocean_domain_type, ice_ocean_boundary_type, ocean_public_type
use ocean_types_mod, only: ocean_external_mode_type, ocean_adv_vel_type
use ocean_types_mod, only: ocean_velocity_type, ocean_density_type, ocean_options_type
use ocean_types_mod, only: ocean_prog_tracer_type, ocean_diag_tracer_type
use ocean_types_mod, only: ocean_types_init, ocean_lagrangian_type, blob_diag_type
use ocean_util_mod, only: ocean_util_init, write_timestamp
use ocean_velocity_advect_mod, only: ocean_velocity_advect_init
use ocean_velocity_diag_mod, only: pressure_conversion, energy_analysis
use ocean_velocity_mod, only: ocean_velocity_init, ocean_velocity_end
use ocean_velocity_mod, only: update_ocean_velocity_bgrid, update_ocean_velocity_cgrid
use ocean_velocity_mod, only: ocean_explicit_accel_a, ocean_explicit_accel_b, ocean_implicit_accel
use ocean_velocity_mod, only: ocean_velocity_restart
use ocean_vert_mix_mod, only: ocean_vert_mix_init, ocean_vert_mix_end, vert_mix_coeff
use ocean_vert_mix_mod, only: ocean_vert_mix_restart
use ocean_vert_gotm_mod, only: advect_gotm_compute
use ocean_workspace_mod, only: ocean_workspace_init, wrk1
use ocean_xlandinsert_mod, only: ocean_xlandinsert_init, xlandinsert
use ocean_xlandmix_mod, only: ocean_xlandmix_init, xlandmix
use ocean_drifters_mod, only: ocean_drifters_init, update_ocean_drifters, ocean_drifters_end
use wave_types_mod, only: ocean_wave_type
use ocean_wave_mod, only: ocean_wave_init, ocean_wave_end, ocean_wave_model
#if defined(COSIMA_VERSION)
use version_mod, only: MOM_COMMIT_HASH
#endif
#if defined(ACCESS_CM) || defined(ACCESS_OM)
use auscom_ice_mod, only: auscom_ice_init
use auscom_ice_parameters_mod, only: redsea_gulfbay_sfix, do_sfix_now
#else
use sat_vapor_pres_mod, only: sat_vapor_pres_init
#endif
#ifdef ENABLE_ODA
#ifdef ENABLE_ECDA
use oda_types_mod, only : da_flux_type
use oda_driver_ecda_mod, only : init_oda, oda, oda_end
#else
use oda_driver_mod, only : init_oda, oda
#endif
#endif
implicit none
private
#include <ocean_memory.h>
#if defined (ENABLE_ODA) && defined (ENABLE_ECDA)
integer :: is_sfc, ie_sfc, js_sfc, je_sfc, i_shift, j_shift, ii, jj ! snz
#endif
#ifdef MOM_STATIC_ARRAYS
real, dimension(isd:ied,jsd:jed,nk,2) :: diff_cbt ! diffusion coefficient at base of tracer cells (m^2/sec):
! n=1 for temp; n=2 for salinity and passive scalars
real, dimension(isd:ied,jsd:jed,nk) :: visc_cbu ! viscosity at base of B-grid velocity cells (m^2/sec)
real, dimension(isd:ied,jsd:jed,nk) :: visc_cbt ! viscosity acting on C-grid u/v-velocity (m^2/sec)
real, dimension(isd:ied,jsd:jed,nk) :: gm_diffusivity ! diffusivity from GM on T-cells (m^2/sec)
real, dimension(isd:ied,jsd:jed,nk,2) :: visc_cbu_form_drag ! viscosity (m^2/sec) from Greatbatch form drag
real, dimension(isd:ied,jsd:jed) :: pme ! mass flux per horz area of precip-evap (kg/(s*m^2))
real, dimension(isd:ied,jsd:jed) :: melt ! mass flux per horz area of ice melt water (kg/(s*m^2))
real, dimension(isd:ied,jsd:jed,2) :: upme ! horizontal velocity of precip minus evap (m/s)
real, dimension(isd:ied,jsd:jed) :: river ! mass flux of river (runoff+calving) per horz area (kg/(s*m^2))
real, dimension(isd:ied,jsd:jed) :: runoff ! mass flux of river runoff (liquid) per horz area from (kg/(s*m^2))
real, dimension(isd:ied,jsd:jed) :: calving ! mass flux of calving land ice per horz area from (kg/(s*m^2))
real, dimension(isd:ied,jsd:jed,2) :: uriver ! horizontal velocity from river runoff+calving
real, dimension(isd:ied,jsd:jed) :: patm ! pressure at ocean top from atmosphere and/or ice (Pa)
real, dimension(isd:ied,jsd:jed) :: swflx ! short wave radiation flux (W/m^2)
real, dimension(isd:ied,jsd:jed) :: swflx_vis ! visible short wave radiation flux (W/m^2)
real, dimension(isd:ied,jsd:jed,nk) :: sw_frac_zt ! short wave radiation flux fraction
real, dimension(isd:ied,jsd:jed,nk) :: opacity ! attenuation of visible light (1/metre)
real, dimension(isd:ied,jsd:jed) :: surf_blthick ! surf boundary layer depth from vertical mixing scheme (m)
real, dimension(isd:ied,jsd:jed) :: bott_blthick ! bottom boundary layer depth from sigma transport (m)
real, dimension(isd:ied,jsd:jed) :: rossby_radius ! rossby radius (m)
real, dimension(isd:ied,jsd:jed,nk) :: swheat ! external shortwave heating source W/m^2
#else
real, pointer, dimension(:,:,:,:) :: diff_cbt =>NULL() ! diffusion coefficient at base of tracer cells (m^2/sec):
! n=1 for temp; n=2 for salinity and passive scalars
real, pointer, dimension(:,:,:) :: visc_cbu =>NULL() ! viscosity at base of Bgrid velocity cells (m^2/sec)
real, pointer, dimension(:,:,:) :: visc_cbt =>NULL() ! viscosity acting on C-grid u/v-velocity (m^2/sec)
real, pointer, dimension(:,:,:) :: gm_diffusivity =>NULL() ! diffusivity for GM on T-cells (m^2/sec)
real, pointer, dimension(:,:,:,:) :: visc_cbu_form_drag =>NULL() ! viscosity (m^2/sec) from Greatbatch form drag
real, pointer, dimension(:,:) :: pme =>NULL() ! mass flux per horz area from precip-evap (kg/(s*m^2))
real, pointer, dimension(:,:) :: melt =>NULL() ! mass flux per horz area of ice melt water (kg/(s*m^2))
real, pointer, dimension(:,:,:) :: upme =>NULL() ! horizontal velocity of precip minus evap (m/s)
real, pointer, dimension(:,:) :: river =>NULL() ! mass flux of river (runoff+calving) per horz area (kg/(s*m^2))
real, pointer, dimension(:,:) :: runoff =>NULL() ! mass flux of river runoff (liquid) per horz area from (kg/(s*m^2))
real, pointer, dimension(:,:) :: calving =>NULL() ! mass flux of calving land ice per horz area (kg/(s*m^2))
real, pointer, dimension(:,:,:) :: uriver =>NULL() ! horizontal velocity from river (m/s)
real, pointer, dimension(:,:) :: patm =>NULL() ! pressure at ocean top from sea ice and/or atmosphere (Pa)
real, pointer, dimension(:,:) :: swflx =>NULL() ! short wave radiation flux (W/m^2)
real, pointer, dimension(:,:) :: swflx_vis =>NULL() ! short wave radiation flux (W/m^2)
real, pointer, dimension(:,:,:) :: sw_frac_zt =>NULL() ! short wave radiation flux fraction
real, pointer, dimension(:,:,:) :: opacity =>NULL() ! attenuation of visible light (1/metre)
real, pointer, dimension(:,:) :: surf_blthick =>NULL() ! surf boundary layer depth from vertical mixing scheme (m)
real, pointer, dimension(:,:) :: bott_blthick =>NULL() ! bottom boundary layer depth from sigma transport (m)
real, pointer, dimension(:,:) :: rossby_radius =>NULL() ! rossby radius (m)
real, pointer, dimension(:,:,:) :: swheat =>NULL() ! external shortwave heating source W/m^2
#endif
! for running Time%init=.true. yet using a restart file
logical :: impose_init_from_restart=.false.
! to initialize with a nontrivial eta or pbot (from ocean_barotropic)
! we then need to reinitialize the thickness arrays, since they originally
! assumed eta_t=0 and pbot_t=pbot0.
logical :: reinitialize_thickness=.false.
! for running with an externally provided shortwave heating source
logical :: ext_swheat_is_set=.false.
! time step related variables
real :: dtts=0 ! tracer timestep (seconds)
real :: dtuv=0 ! internal mode timestep (seconds)
real :: dtbt=0 ! external mode timestep (seconds)
real :: dteta=0 ! ocean volume time step (eta_t) (seconds)
real :: dtime_t ! 2*dtts for threelevel and dtts for twolevel
real :: dtime_u ! 2*dtuv for threelevel and dtvu for twolevel
real :: dtime_e ! 2*dteta for threelevel and dteta for twolevel
! setting the number of prognostic and diagnostic tracers
! both determined by reading field_table
integer :: num_prog_tracers=-1 ! (e.g., temp, salt, age)
integer :: num_diag_tracers=-1 ! (e.g., frazil, pH)
! number of ocean calls
integer :: num_ocean_calls
logical :: first_ocn_call=.true.
! for setting model time steps
integer :: baroclinic_split =1 ! ratio of tracer timestep dtts to baroclinic timestep dtuv
integer :: surface_height_split=1 ! ratio of tracer timestep dtts to the eta_t (or pbot_t) timestep dteta
integer :: barotropic_split =30 ! ratio of baroclinic timestep dtuv to barotropic timestep dtbt
! for setting how terms in the equations are time stepped
! select time tendency ('threelevel' or 'twolevel")
! tendency is an integer corresponding to choice of time tendency
character(len=32) :: time_tendency='twolevel'
integer :: tendency=0
! valid vertical coordinate options are the following:
! geopotential, zstar, zsigma, pressure, pstar, psigma
character(len=32) :: vertical_coordinate='zstar'
! integers corresponding to choice of vertical coordinate
integer :: vert_coordinate
integer :: vert_coordinate_class
integer :: vert_coordinate_type
! horizontal grid options 'bgrid' and 'cgrid'
character(len=32) :: horizontal_grid='bgrid'
integer :: horz_grid=1
character(len=128) :: version = '$Id: ocean_model.F90,v 20.0 2013/12/14 00:10:47 fms Exp $'
character(len=128) :: tagname = '$Name: tikal $'
type(ocean_external_mode_type), save :: Ext_mode
type(ocean_adv_vel_type), save :: Adv_vel
type(ocean_density_type), target, save :: Dens
type(ocean_domain_type), target, save :: Domain
type(ocean_grid_type), target, save :: Grid
type(ocean_thickness_type), target, save :: Thickness
type(ocean_time_type), target, save :: Time
type(ocean_time_steps_type), target, save :: Time_steps
type(ocean_options_type), target, save :: Ocean_options
type(ocean_velocity_type), target, save :: Velocity
type(ocean_lagrangian_type), target, save :: Lagrangian_system
type(blob_diag_type), dimension(:), allocatable, save :: EL_diag
type(ocean_prog_tracer_type), dimension(:), pointer, save :: T_prog =>NULL()
type(ocean_diag_tracer_type), dimension(:), pointer, save :: T_diag =>NULL()
type(ocean_wave_type), target, save :: Waves
#if defined (ENABLE_ODA) && defined (ENABLE_ECDA)
type(da_flux_type), target, save :: da_flux ! snz
#endif
! identification numbers for mpp clocks
integer :: id_init=0
integer :: id_advect=0
integer :: id_vmix=0
integer :: id_neutral=0
integer :: id_compute_visc_form_drag=0
integer :: id_submesoscale=0
integer :: id_sw=0
integer :: id_sponges_tracer=0
integer :: id_sponges_eta=0
integer :: id_sponges_velocity=0
integer :: id_sigma=0
integer :: id_tracer=0
integer :: id_bbc=0
integer :: id_sbc=0
integer :: id_flux_adjust=0
integer :: id_explicit_accel_a=0
integer :: id_explicit_accel_b=0
integer :: id_implicit_accel=0
integer :: id_bottom_smooth=0
integer :: id_surface_smooth=0
integer :: id_eta_and_pbot_tendency=0
integer :: id_eta_and_pbot_update=0
integer :: id_eta_and_pbot_diagnose=0
integer :: id_rho_dzt_tendency=0
integer :: id_dzt_dst_update=0
integer :: id_mass_forcing =0
integer :: id_barotropic_forcing=0
integer :: id_barotropic_update=0
integer :: id_velocity=0
integer :: id_xlandinsert=0
integer :: id_xlandmix=0
integer :: id_overflow=0
integer :: id_overflow_OFP=0
integer :: id_overexchange=0
integer :: id_mixdownslope=0
integer :: id_blob_update=0
integer :: id_blob_cell_update=0
integer :: id_blob_diagnose_depth=0
integer :: id_tcell_thickness_blob=0
integer :: id_update_L_thickness=0
integer :: id_update_E_thickness=0
integer :: id_rivermix=0
integer :: id_density=0
integer :: id_density_diag=0
integer :: id_otpm_source=0
integer :: id_otpm_bbc=0
integer :: id_otpm_tracer=0
integer :: id_diagnostics=0
integer :: id_tcell_thickness=0
integer :: id_ucell_thickness=0
integer :: id_update_halo_tracer=0
integer :: id_update_halo_velocity=0
integer :: id_oda=0
integer :: id_ocean_sfc=0
integer :: id_ocean_seg_end=0
integer :: id_tmask_limit=0
integer :: id_ocean=0
integer :: id_advect_gotm=0
integer :: id_increment_tracer=0
integer :: id_increment_eta=0
integer :: id_increment_velocity=0
integer :: id_salinity=0
integer :: id_wave=0
#if defined(ACCESS_CM) || defined(ACCESS_OM)
integer :: id_sfix=0
#endif
public ocean_model_init
public ocean_model_end
public update_ocean_model
public get_ocean_domain
public get_ocean_grid_size
public ocean_public_type
public ice_ocean_boundary_type
public ocean_model_init_sfc
public ocean_model_flux_init
public ocean_stock_pe
public ocean_model_restart
! routines for interfacing to other models
public mom4_get_Tsurf
public mom4_get_Ssurf
public mom4_get_UVsurf
public mom4_get_thickness
public mom4_get_density
public mom4_get_prog_tracer
public mom4_get_temperature_index
public mom4_get_salinity_index
public mom4_get_UV
public mom4_get_dimensions
public mom4_get_diag_axes
public mom4_get_num_diag_tracers
public mom4_get_num_prog_tracers
public mom4_get_ocean_data
public mom4_get_surface_tmask
public mom4_get_latlon_UV
public mom4_set_swheat
public ocean_model_data_get
interface ocean_model_data_get
module procedure ocean_model_data1D_get
module procedure ocean_model_data2D_get
end interface
public ice_ocn_bnd_type_chksum
public ocean_public_type_chksum
! for the temperature variable
integer :: temp_variable=0
! index for temperature (degC) and salinity (psu or g/kg)
integer :: index_temp =-1
integer :: index_salt =-1
! index for FAFMIP redistributed heat tracer (degC)
integer :: index_redist_heat=-1
! domain layout for parallel processors. for npe=1, layout(2)=(/1,1/)
integer :: layout(2)=(/1,1/)
! IO domain layout for parallel processors.
integer :: io_layout(2)=(/0,0/)
! to print various cksums for debugging purposes
logical :: debug = .false.
! mask_table contains information for masking domain ( n_mask, layout and mask_list).
character(len=128) :: mask_table = "INPUT/ocean_mask_table"
logical :: module_is_initialized =.false.
logical :: have_obc =.false.
logical :: cmip_units =.false.
integer :: cmip_version =5
logical :: use_blobs =.false.
logical :: introduce_blobs =.false.
logical :: use_velocity_override =.false.
logical :: do_wave =.false.
! Namelist variables for ECDA
real :: beta_txty = 0.0
real :: beta_tf = 0.0
real :: beta_qf = 0.0
real :: beta_lwsw = 0.0
type, public :: ocean_state_type; private
! This type is private, and can therefore vary between different ocean models.
! All information entire ocean state may be contained here, although it is not
! necessary that this is implemented with all models.
logical :: is_ocean_pe = .false. ! .true. on processors that run the ocean model.
end type ocean_state_type
integer :: dt_ocean = -1 ! ocean tracer timestep
namelist /ocean_model_nml/ time_tendency, impose_init_from_restart, reinitialize_thickness, &
baroclinic_split, barotropic_split, surface_height_split, &
layout, io_layout, debug, vertical_coordinate, dt_ocean, &
cmip_units, cmip_version, horizontal_grid, &
use_blobs, use_velocity_override, mask_table, &
introduce_blobs, beta_txty, beta_tf, beta_qf, beta_lwsw, do_wave
contains
!#######################################################################
! <SUBROUTINE NAME="ocean_model_init">
!
! <DESCRIPTION>
! Initialize the ocean model.
! Arguments:
! Ocean (inout) - A structure containing various publicly visible ocean
! surface properties after initialization.
! OS (pointer)- A structure whose internal contents are private
! to ocean_model_mod that may be used to contain all
! information about the ocean's interior state.
! Time_init (in) - The start time for the coupled model's calendar.
! Time_in (in) - The time at which to initialize the ocean model.
! ocean_timestep (in) - Ocean model time step in seconds. If present
! replaces dt_ocean set in ocean_model_nml
! </DESCRIPTION>
!
subroutine ocean_model_init(Ocean, Ocean_state, Time_init, Time_in, &
ocean_timestep)
type(ocean_public_type), intent(inout) :: Ocean
type(ocean_state_type), pointer :: Ocean_state
type(time_type), intent(in) :: Time_init
type(time_type), intent(in) :: Time_in
integer, optional, intent(in) :: ocean_timestep
type(time_type) :: Time_step_ocean
integer :: secs, days, secs0, days0
integer :: n
integer :: ioun, io_status, ierr
integer :: stdoutunit,stdlogunit
stdoutunit=stdout()
stdlogunit=stdlog()
if (mpp_pe() == mpp_root_pe()) then
write(stdoutunit,*) MOM_COMMIT_HASH
endif
if (module_is_initialized) then
call mpp_error(FATAL, &
'==>Error in ocean_model_mod (ocean_model_init): module already initialized')
endif
module_is_initialized = .true.
if (associated(Ocean_state)) then
call mpp_error(WARNING, "ocean_model_init called with an associated "// &
"ocean_state_type structure. Model is already initialized.")
return
endif
allocate(Ocean_state)
Ocean_state%is_ocean_pe = Ocean%is_ocean_pe !This is Not utilized in MOM currently
call ocean_parameters_init()
! set clock ids
id_ocean = mpp_clock_id( 'Ocean', flags=clock_flag_default,grain=CLOCK_COMPONENT )
id_init = mpp_clock_id('(Ocean initialization) ' ,grain=CLOCK_SUBCOMPONENT)
id_oda = mpp_clock_id('(Ocean ODA)' ,grain=CLOCK_SUBCOMPONENT)
#if defined(ACCESS_CM) || defined(ACCESS_OM)
id_sfix = mpp_clock_id('(Red Sea/Gulf Bay salinity fix)',grain=CLOCK_MODULE)
#endif
id_advect = mpp_clock_id('(Ocean advection velocity) ' ,grain=CLOCK_MODULE)
id_density_diag = mpp_clock_id('(Ocean density diag) ' ,grain=CLOCK_MODULE)
id_density = mpp_clock_id('(Ocean update density) ' ,grain=CLOCK_MODULE)
id_vmix = mpp_clock_id('(Ocean vertical mixing coeff) ' ,grain=CLOCK_MODULE)
id_neutral = mpp_clock_id('(Ocean neutral physics) ' ,grain=CLOCK_MODULE)
id_compute_visc_form_drag = mpp_clock_id('(Ocean viscous form drag) ' ,grain=CLOCK_MODULE)
id_submesoscale = mpp_clock_id('(Ocean submesoscale restrat)' ,grain=CLOCK_MODULE)
id_sw = mpp_clock_id('(Ocean shortwave) ' ,grain=CLOCK_MODULE)
id_sponges_eta = mpp_clock_id('(Ocean sponges_eta) ' ,grain=CLOCK_MODULE)
id_sponges_tracer = mpp_clock_id('(Ocean sponges_tracer) ' ,grain=CLOCK_MODULE)
id_sponges_velocity = mpp_clock_id('(Ocean sponges_velocity) ' ,grain=CLOCK_MODULE)
id_xlandinsert = mpp_clock_id('(Ocean xlandinsert) ' ,grain=CLOCK_MODULE)
id_xlandmix = mpp_clock_id('(Ocean xlandmix) ' ,grain=CLOCK_MODULE)
id_rivermix = mpp_clock_id('(Ocean rivermix) ' ,grain=CLOCK_MODULE)
id_overexchange = mpp_clock_id('(Ocean overexchange) ' ,grain=CLOCK_MODULE)
id_mixdownslope = mpp_clock_id('(Ocean mixdownslope) ' ,grain=CLOCK_MODULE)
id_blob_update = mpp_clock_id('(Ocean blob update)' ,grain=CLOCK_MODULE)
id_blob_cell_update = mpp_clock_id('(Ocean blob cell update)' ,grain=CLOCK_MODULE)
id_blob_diagnose_depth = mpp_clock_id('(Ocean blob diagnose depth)' ,grain=CLOCK_MODULE)
id_overflow = mpp_clock_id('(Ocean overflow) ' ,grain=CLOCK_MODULE)
id_overflow_OFP = mpp_clock_id('(Ocean overflow_OFP) ' ,grain=CLOCK_MODULE)
id_sigma = mpp_clock_id('(Ocean sigma transport) ' ,grain=CLOCK_MODULE)
id_tracer = mpp_clock_id('(Ocean tracer update) ' ,grain=CLOCK_MODULE)
id_sbc = mpp_clock_id('(Ocean surface flux) ' ,grain=CLOCK_MODULE)
id_bbc = mpp_clock_id('(Ocean bottom flux) ' ,grain=CLOCK_MODULE)
id_flux_adjust = mpp_clock_id('(Ocean restoring flux) ' ,grain=CLOCK_MODULE)
id_otpm_source = mpp_clock_id('(Ocean TPM source) ' ,grain=CLOCK_MODULE)
id_otpm_bbc = mpp_clock_id('(Ocean TPM bbc) ' ,grain=CLOCK_MODULE)
id_otpm_tracer = mpp_clock_id('(Ocean TPM tracer) ' ,grain=CLOCK_MODULE)
id_explicit_accel_a = mpp_clock_id('(Ocean explicit accel_a) ' ,grain=CLOCK_MODULE)
id_explicit_accel_b = mpp_clock_id('(Ocean explicit accel_b) ' ,grain=CLOCK_MODULE)
id_implicit_accel = mpp_clock_id('(Ocean implicit accel) ' ,grain=CLOCK_MODULE)
id_eta_and_pbot_tendency= mpp_clock_id('(Ocean eta and pbot tendency)' ,grain=CLOCK_MODULE)
id_eta_and_pbot_update = mpp_clock_id('(Ocean eta and pbot update)' ,grain=CLOCK_MODULE)
id_eta_and_pbot_diagnose= mpp_clock_id('(Ocean eta and pbot diagnose)' ,grain=CLOCK_MODULE)
id_rho_dzt_tendency = mpp_clock_id('(Ocean rho_dzt tendency)' ,grain=CLOCK_MODULE)
id_dzt_dst_update = mpp_clock_id('(Ocean dzt_dst update)' ,grain=CLOCK_MODULE)
id_surface_smooth = mpp_clock_id('(Ocean surface height smooth)' ,grain=CLOCK_MODULE)
id_bottom_smooth = mpp_clock_id('(Ocean bottom pressure smooth)' ,grain=CLOCK_MODULE)
id_mass_forcing = mpp_clock_id('(Ocean mass forcing) ' ,grain=CLOCK_MODULE)
id_barotropic_forcing = mpp_clock_id('(Ocean barotropic forcing) ' ,grain=CLOCK_MODULE)
id_barotropic_update = mpp_clock_id('(Ocean barotropic dynamics)' ,grain=CLOCK_MODULE)
id_velocity = mpp_clock_id('(Ocean velocity update) ' ,grain=CLOCK_MODULE)
id_diagnostics = mpp_clock_id('(Ocean diagnostics)' ,grain=CLOCK_MODULE)
id_tcell_thickness = mpp_clock_id('(Ocean update T-cell thickness)' ,grain=CLOCK_MODULE)
id_tcell_thickness_blob = mpp_clock_id('(Ocean update Total thickness)' ,grain=CLOCK_ROUTINE)
id_update_L_thickness = mpp_clock_id('(Ocean update L sys. thickness)' ,grain=CLOCK_ROUTINE)
id_update_E_thickness = mpp_clock_id('(Ocean update E sys. thickness)' ,grain=CLOCK_ROUTINE)
id_ucell_thickness = mpp_clock_id('(Ocean update U-cell thickness)' ,grain=CLOCK_MODULE)
id_update_halo_tracer = mpp_clock_id('(Ocean tracer halo updates)' ,grain=CLOCK_MODULE)
id_update_halo_velocity = mpp_clock_id('(Ocean velocity halo update)' ,grain=CLOCK_MODULE)
id_ocean_sfc = mpp_clock_id('(Ocean sum ocean surface)' ,grain=CLOCK_MODULE)
id_ocean_seg_end = mpp_clock_id('(Ocean average state)' ,grain=CLOCK_MODULE)
id_tmask_limit = mpp_clock_id('(Ocean tracer tmask limit)' ,grain=CLOCK_MODULE)
id_advect_gotm = mpp_clock_id('(Ocean gotm: advection)' ,grain=CLOCK_ROUTINE)
id_increment_eta = mpp_clock_id('(Ocean increment eta)' ,grain=CLOCK_MODULE)
id_increment_tracer = mpp_clock_id('(Ocean increment tracer)' ,grain=CLOCK_MODULE)
id_increment_velocity = mpp_clock_id('(Ocean increment velocity)' ,grain=CLOCK_MODULE)
id_salinity = mpp_clock_id('(Ocean update rho_salinity)' ,grain=CLOCK_MODULE)
id_wave = mpp_clock_id('(Ocean idealized surface waves)' ,grain=CLOCK_MODULE)
call mpp_clock_begin(id_init)
call write_version_number(version, tagname)
write(stdoutunit,'(/54x,a/)') '======== STARTING MOM INITIALIZATION ========'
#ifdef STATIC_MEMORY
write(stdoutunit,*) ' '
write(stdoutunit,*)'==>Error: MOM4.0 cpp option "STATIC_MEMORY" is now called "MOM_STATIC_ARRAYS" in MOM.'
write(stdoutunit,*)' Recompile code with this new name. Apologies for the inconvenience.'
call mpp_error(FATAL, &
'==>Error: Change compiler option "STATIC_MEMORY" to "MOM_STATIC_ARRAYS" and then recompile.')
#endif
#ifdef MOM4_STATIC_ARRAYS
write(stdoutunit,*) ' '
write(stdoutunit,*)'==>Error: MOM4p1 cpp option "MOM4_STATIC_ARRAYS" is now called "MOM_STATIC_ARRAYS" in MOM.'
write(stdoutunit,*)' Recompile code with this new name. Apologies for the inconvenience.'
call mpp_error(FATAL, &
'==>Error: Change compiler option "MOM4_STATIC_ARRAYS" to "MOM_STATIC_ARRAYS" and then recompile.')
#endif
#ifdef MOM_STATIC_ARRAYS
write(stdoutunit,*) ' '
write(stdoutunit,*)'==>NOTE: Using MOM_STATIC_ARRAYS cpp option in MOM.'
#else
write(stdoutunit,*) ' '
write(stdoutunit,*)'==>NOTE: Using dynamically allocated array option in MOM'
#endif
call time_interp_external_init()
! provide for namelist over-ride of defaults
#ifdef INTERNAL_FILE_NML
read (input_nml_file, nml=ocean_model_nml, iostat=io_status)
ierr = check_nml_error(io_status,'ocean_model_nml')
#else
ioun = open_namelist_file()
read (ioun, ocean_model_nml,iostat=io_status)
ierr = check_nml_error(io_status,'ocean_model_nml')
call close_file (ioun)
#endif
write (stdoutunit,'(/)')
write (stdoutunit, ocean_model_nml)
write (stdlogunit, ocean_model_nml)
write (stdoutunit,'(/a,i6,a/)') ' ==>Note: Running MOM using',mpp_npes(),' computer processors.'
! initialize ocean time type information
Time%calendar = JULIAN
if(time_tendency=='threelevel') then
tendency = THREE_LEVEL
Time%taum1 = 1
Time%tau = 2
Time%taup1 = 3
Time%tau_m2 = 1
Time%tau_m1 = 2
Time%tau_m0 = 3
write (stdoutunit,*) ' '
write (stdoutunit,*) '==>Note: Running MOM with a leap frog to discretize the time tendency.'
write (stdoutunit,*) ' Unfortunately, this method does not conserve volume and tracer because'
write (stdoutunit,*) ' it is necessary to use time filtering. Use the "twolevel" scheme to conserve.'
write (stdoutunit,*) ' '
if (use_blobs) then
write (stdoutunit,*) ' '
write (stdoutunit,*) '==>Fatal: You are running MOM with time_tendency=threelevel and use_blobs=.true.'
write (stdoutunit,*) ' These options are mutually exclusive. Please choose either '
write (stdoutunit,*) ' time_tendency=twolevel, or use_blobs=.false. '
write (stdoutunit,*) ' '
call mpp_error(FATAL,&
'==>Error from ocean_model_mod: time_tendency must be "twolevel" for use_blobs=.true.')
if (introduce_blobs) then
if(file_exist('INPUT/ocean_blobs_gridded.res.nc')) then
write (stdoutunit,*) ' '
Write (stdoutunit,*) '==>Fatal: You are running MOM with introduce_blobs=.true. and use_blobs=.true.'
write (stdoutunit,*) ' But blob restart exists so blobs have already run. '
write (stdoutunit,*) ' Please set introduce_blobs=.false. '
write (stdoutunit,*) ' '
call mpp_error(FATAL,&
'==>Error from ocean_model_mod: introduce_blobs=.true. but blobs have been run previously')
else
write (stdoutunit,*) ' '
write (stdoutunit,*) '==>Note: You are running MOM with introduce_blobs=.true. and use_blobs=.true. '
write (stdoutunit,*) ' Blobs are being introduced to a run that did not previously have them.'
write (stdoutunit,*) ' '
endif
endif
endif
elseif(time_tendency=='twolevel') then
tendency = TWO_LEVEL
Time%taum1 = 2
Time%tau = 2
Time%taup1 = 3
Time%tau_m2 = 1
Time%tau_m1 = 2
Time%tau_m0 = 3
write (stdoutunit,*) ' '
write (stdoutunit,*) &
'==>Note: Running MOM with staggered twotime level scheme to compute time tendencies.'
write (stdoutunit,*) &
' This is the default. Mass/volume and tracer are conserved with this scheme.'
write (stdoutunit,*) ' '
else
call mpp_error(FATAL,&
'==>Error from ocean_model_mod: time_tendency must be "twolevel" or "threelevel".')
endif
! If the timestep has been passed in then use it to over-ride the namelist
! setting. This is useful for coupled model setups -- for example it allows
! them to avoid setting the timestep in multiple places.
if (present(ocean_timestep)) then
if (dt_ocean /= -1) then
call mpp_error(FATAL, '==>Error from ocean_model_mod: conflicting '// &
'values for dt_ocean, passed as an argument and in '// &
'ocean_model_nml.')
endif
dt_ocean = ocean_timestep
endif
if(dt_ocean .lt. 0.0) call mpp_error(FATAL,&
'==>Error from ocean_model_mod: dt_ocean must be set to a positive integer in ocean_model_nml.')
Time_step_ocean = set_time (dt_ocean,0)
Time%init = (Time_in == Time_init)
Time%Time_init = Time_init
Time%Time_step = Time_step_ocean
Time%model_time = Time_in
Time%itt = 0
call get_time(Time_step_ocean, secs, days)
call get_time(Time_in-Time_init, secs0, days0)
Time%itt0 = nint((days0+secs0/86400.0)/(days+secs/86400.0))
write(stdoutunit,'(/a)')&
' ==>Note: Time%Time_init = time stamp at very start of the MOM experiment is given by'
call write_timestamp(Time%Time_init)
write(stdoutunit,'(/a)') &
' ==>Note: Time%model_time = time stamp at start of this leg of the MOM experiment is'
call write_timestamp(Time%model_time)
if(impose_init_from_restart) then
Time%init=.false.
write(stdoutunit,'(/a)')&
' ==>Note: impose_init_from_restart=.true., so will initialize model from a restart file.'
endif
if(Time%init) then
write(stdoutunit,'(/a)')&
' ==>Note: Time%init=.true. =>MOM will start from user specified initial conditions.'
endif
if(.not. Time%init) then
write(stdoutunit,'(/a)') &
' ==>Note: Time%init=.false. =>MOM will start from restart conditions from previous leg of experiment.'
endif
dtts = secs + days*86400
dtuv = dtts/baroclinic_split
dteta = dtts/surface_height_split
dtbt = dtuv/barotropic_split
if(tendency==THREE_LEVEL) then
dtime_t = 2.0*dtts
dtime_u = 2.0*dtuv
dtime_e = 2.0*dteta
elseif(tendency==TWO_LEVEL) then
dtime_t = dtts
dtime_u = dtuv
dtime_e = dteta
endif
Time_steps%time_tendency = time_tendency
Time_steps%tendency = tendency
Time_steps%dtts = dtts
Time_steps%dtuv = dtuv
Time_steps%dtbt = dtbt
Time_steps%dteta = dteta
Time_steps%dtime_t = dtime_t
Time_steps%dtime_u = dtime_u
Time_steps%dtime_e = dtime_e
write(stdoutunit,'(/a)')' ==> Note: time steps (seconds) used for MOM'
write(stdoutunit,'(a,f10.2)')' dtts (tracer) = ',dtts
write(stdoutunit,'(a,f10.2)')' dtuv (baroclinic) = ',dtuv
write(stdoutunit,'(a,f10.2)')' dteta (surface height or bottom pressure) = ',dteta
write(stdoutunit,'(a,f10.2)')' dtbt (barotropic) = ',dtbt
if(baroclinic_split < 1) then
call mpp_error(FATAL,&
'==>Error from ocean_model_mod(ocean_model_init): baroclinic_split must be an integer >= 1')
endif
if(baroclinic_split > 1) then
call mpp_error(NOTE,&
'==>ocean_model_mod: baroclinic_split > 1 corrupts transients & can be unstable. Use with caution.')
write(stdoutunit,'(/a/)') &
'==>ocean_model_mod: baroclinic_split > 1 corrupts transients & can be unstable. Use with caution.'
endif
if(surface_height_split < 1) then
call mpp_error(FATAL,&
'==>Error from ocean_model_mod(ocean_model_init): surface_height_split must be an integer >= 1')
endif
if(surface_height_split > 1) then
call mpp_error(NOTE, &
'==>ocean_model_mod: surface_height_split > 1 corrupts transients. Use with caution.')
write(stdoutunit,'(/a/)') &
'==>ocean_model_mod: surface_height_split > 1 corrupts transients. Use with caution.'