-
Notifications
You must be signed in to change notification settings - Fork 400
Expand file tree
/
Copy pathmpas_atm_core.F
More file actions
1853 lines (1469 loc) · 76.3 KB
/
mpas_atm_core.F
File metadata and controls
1853 lines (1469 loc) · 76.3 KB
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
! Copyright (c) 2013, Los Alamos National Security, LLC (LANS)
! and the University Corporation for Atmospheric Research (UCAR).
!
! Unless noted otherwise source code is licensed under the BSD license.
! Additional copyright and license information can be found in the LICENSE file
! distributed with this code, or at http://mpas-dev.github.com/license.html
!
module atm_core
use mpas_derived_types
use mpas_pool_routines
use mpas_dmpar
use mpas_log, only : mpas_log_write, mpas_log_info
use mpas_io_units, only : mpas_new_unit, mpas_release_unit
! Provides definition of halo_exchange_routine
#include "mpas_halo_interface.inc"
type (MPAS_Clock_type), pointer :: clock
contains
function atm_core_init(domain, startTimeStamp) result(ierr)
use mpas_timekeeping
use mpas_kind_types
use mpas_stream_manager
use mpas_atm_dimensions, only : mpas_atm_set_dims
use mpas_atm_diagnostics_manager, only : mpas_atm_diag_setup
use mpas_atm_threading, only : mpas_atm_threading_init
use atm_time_integration, only : mpas_atm_dynamics_init, &
mpas_atm_pre_dynamics, mpas_atm_post_dynamics
use mpas_timer, only : mpas_timer_start, mpas_timer_stop
use mpas_attlist, only : mpas_modify_att
use mpas_string_utils, only : mpas_string_replace
use mpas_atm_halos, only: atm_build_halo_groups, exchange_halo_group
#ifdef DO_CHEMISTRY
use mpas_atm_chemistry, only: chemistry_init
#endif
implicit none
type (domain_type), intent(inout) :: domain
character(len=*), intent(out) :: startTimeStamp
integer :: ierr
real (kind=RKIND), pointer :: dt
type (block_type), pointer :: block
logical, pointer :: config_do_restart
type (mpas_pool_type), pointer :: state
type (mpas_pool_type), pointer :: mesh
type (mpas_pool_type), pointer :: diag
type (field2DReal), pointer :: u_field, pv_edge_field, ru_field, rw_field
type (field0DReal), pointer :: Time_field
character (len=StrKIND), pointer :: xtime
character (len=StrKIND), pointer :: initial_time1, initial_time2
type (MPAS_Time_Type) :: startTime
real (kind=RKIND), pointer :: nominalMinDc
real (kind=RKIND), pointer :: config_len_disp
real (kind=RKIND), pointer :: Time
integer, pointer :: nVertLevels, maxEdges, maxEdges2, num_scalars
character (len=ShortStrKIND) :: init_stream_name
real (kind=R8KIND) :: input_start_time, input_stop_time
ierr = 0
!
! Setup threading
!
call mpas_atm_threading_init(domain % blocklist, ierr)
if ( ierr /= 0 ) then
call mpas_log_write('Threading setup failed for core '//trim(domain % core % coreName), messageType=MPAS_LOG_CRIT)
end if
!
! Set up inner dimensions used by arrays in optimized dynamics routines
!
call mpas_pool_get_subpool(domain % blocklist % structs, 'state', state)
call mpas_pool_get_dimension(state, 'nVertLevels', nVertLevels)
call mpas_pool_get_dimension(state, 'maxEdges', maxEdges)
call mpas_pool_get_dimension(state, 'maxEdges2', maxEdges2)
call mpas_pool_get_dimension(state, 'num_scalars', num_scalars)
call mpas_atm_set_dims(nVertLevels, maxEdges, maxEdges2, num_scalars)
!
! Set "local" clock to point to the clock contained in the domain type
!
clock => domain % clock
mpas_log_info => domain % logInfo
!
! Build halo exchange groups and set method for exchanging halos in a group
!
call atm_build_halo_groups(domain, ierr)
if (ierr /= 0) then
call mpas_log_write('Failed to build halo exchange groups.', messageType=MPAS_LOG_ERR)
return
end if
call mpas_pool_get_config(domain % blocklist % configs, 'config_do_restart', config_do_restart)
call mpas_pool_get_config(domain % blocklist % configs, 'config_dt', dt)
!
! By default, the 'invariant' stream has an input_interval of "none", so
! the following stream read has no effect. However, in case the 'invariant'
! stream is defined with an input_interval of "initial_only", we read
! time-invariant fields first.
!
call MPAS_stream_mgr_read(domain % streamManager, streamID='invariant', whence=MPAS_STREAM_NEAREST, ierr=ierr)
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='invariant', direction=MPAS_STREAM_INPUT, ierr=ierr)
!
! If this is a restart run, read the restart stream, else read the input
! stream.
! Regardless of which stream we read for initial conditions, reset the
! input alarms for both input and restart before reading any remaining
! input streams.
!
call mpas_timer_start('read_ICs')
if (config_do_restart) then
init_stream_name = 'restart'
else
init_stream_name = 'input'
end if
call mpas_log_write('Reading initial state from '''//trim(init_stream_name)//''' stream')
call mpas_dmpar_get_time(input_start_time)
call MPAS_stream_mgr_read(domain % streamManager, streamID=trim(init_stream_name), ierr=ierr)
call mpas_dmpar_get_time(input_stop_time)
call mpas_timer_stop('read_ICs')
if (ierr /= MPAS_STREAM_MGR_NOERR) then
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_ERR)
call mpas_log_write('Error reading initial conditions', messageType=MPAS_LOG_ERR)
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_CRIT)
end if
call mpas_log_write(' Timing for read of '''//trim(init_stream_name)//''' stream: $r s', &
realArgs=(/real(input_stop_time - input_start_time, kind=RKIND)/))
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='input', direction=MPAS_STREAM_INPUT, ierr=ierr)
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='restart', direction=MPAS_STREAM_INPUT, ierr=ierr)
call mpas_log_write(' ----- done reading initial state -----')
!
! Determine horizontal length scale used by horizontal diffusion and 3-d divergence damping
!
call mpas_pool_get_subpool(domain % blocklist % structs, 'mesh', mesh)
nullify(nominalMinDc)
call mpas_pool_get_array(mesh, 'nominalMinDc', nominalMinDc)
nullify(config_len_disp)
call mpas_pool_get_config(domain % blocklist % configs, 'config_len_disp', config_len_disp)
call mpas_log_write('')
!
! If config_len_disp was specified as a valid value, use that
!
if (config_len_disp > 0.0_RKIND) then
call mpas_log_write('Setting nominalMinDc to $r based on namelist option config_len_disp', realArgs=[config_len_disp])
!
! But if nominalMinDc was available in the input file and is different, print a warning
!
if (nominalMinDc > 0.0_RKIND .and. abs(nominalMinDc - config_len_disp) > 1.0e-6_RKIND * config_len_disp) then
call mpas_log_write('nominalMinDc was read from input file as a positive value ($r) that differs', &
realArgs=[nominalMinDc], messageType=MPAS_LOG_WARN)
call mpas_log_write('from the specified config_len_disp value ($r)', &
realArgs=[config_len_disp], messageType=MPAS_LOG_WARN)
end if
nominalMinDc = config_len_disp
!
! Otherwise, try to use nominalMinDc
!
else
if (nominalMinDc > 0.0_RKIND) then
call mpas_log_write('Setting config_len_disp to $r based on nominalMinDc value in input file', realArgs=[nominalMinDc])
config_len_disp = nominalMinDc
else
call mpas_log_write('Both config_len_disp and nominalMinDc are <= 0.0.', messageType=MPAS_LOG_ERR)
call mpas_log_write('Please either specify config_len_disp in the &nhyd_model namelist group,', &
messageType=MPAS_LOG_ERR)
call mpas_log_write('or use an input file that provides a valid value for the nominalMinDc variable.', &
messageType=MPAS_LOG_ERR)
ierr = 1
return
end if
end if
!
! Read all other inputs
! For now we don't do this here to match results with previous code; to match requires
! that we read in SST and seaice fields after the call to atm_mpas_init_block()
!
! call MPAS_stream_mgr_read(domain % streamManager, ierr=ierr)
! call MPAS_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_INPUT, ierr=ierr)
if (.not. config_do_restart) then
block => domain % blocklist
do while (associated(block))
call mpas_pool_get_subpool(block % structs, 'state', state)
call mpas_pool_initialize_time_levels(state)
block => block % next
end do
end if
!
! Read a new data stream for Incremental Analysis Update (IAU), if config_IAU_option /= 'off' : HA (June-15-2016)
! FIXME: should I check xtime for the IAU fields? Maybe not.
! Note: Because the 'iau' stream has the 'iau' package attached to it, the MPAS_stream_mgr_read( )
! call here will actually try to read the stream only if IAU is being used in the run.
!
call MPAS_stream_mgr_read(domain % streamManager, streamID='iau', whence=MPAS_STREAM_NEAREST, ierr=ierr)
if (ierr /= MPAS_STREAM_MGR_NOERR) then
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_ERR)
call mpas_log_write('Error reading IAU files', messageType=MPAS_LOG_ERR)
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_CRIT)
end if
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='iau', ierr=ierr)
!
! Set startTimeStamp based on the start time of the simulation clock
!
startTime = mpas_get_clock_time(clock, MPAS_START_TIME, ierr)
call mpas_get_time(startTime, dateTimeString=startTimeStamp)
call exchange_halo_group(domain, 'initialization:u')
!
! Perform basic compatibility checks among the fields that were read and the run-time options that were selected
!
call mpas_atm_run_compatibility(domain % dminfo, domain % blocklist, domain % streamManager, ierr)
if (ierr /= 0) then
call mpas_log_write('Please correct issues with the model input fields and/or namelist.', messageType=MPAS_LOG_ERR)
return
end if
block => domain % blocklist
do while (associated(block))
call mpas_pool_get_subpool(block % structs, 'mesh', mesh)
call mpas_pool_get_subpool(block % structs, 'state', state)
call atm_mpas_init_block(domain % dminfo, domain % streamManager, block, mesh, dt)
call mpas_pool_get_array(state, 'xtime', xtime, 1)
xtime = startTimeStamp
! Initialize initial_time in second time level. We need to do this because initial state
! is read into time level 1, and if we write output from the set of state arrays that
! represent the original time level 2, the initial_time field will be invalid.
call mpas_pool_get_array(state, 'initial_time', initial_time1, 1)
call mpas_pool_get_array(state, 'initial_time', initial_time2, 2)
initial_time2 = initial_time1
! Set the units to be cf compliant 'seconds since <cf-timestamp>'
call mpas_pool_get_field(state, 'Time', Time_field)
call mpas_modify_att(Time_field % attLists(1) % attList, 'units', &
'seconds since ' // mpas_string_replace(initial_time1, '_', ' '))
block => block % next
end do
call exchange_halo_group(domain, 'initialization:pv_edge,ru,rw')
call mpas_atm_diag_setup(domain % streamManager, domain % blocklist % configs, &
domain % blocklist % structs, domain % clock, domain % dminfo)
!
! Prepare the dynamics for integration
!
call mpas_atm_dynamics_init(domain)
!
! Initialize the chemistry package
!
#ifdef DO_CHEMISTRY
call chemistry_init(domain % blocklist % configs, domain % blocklist % dimensions)
#endif
end function atm_core_init
subroutine atm_simulation_clock_init(core_clock, configs, ierr)
use mpas_timekeeping
implicit none
type (MPAS_Clock_type), intent(inout) :: core_clock
type (mpas_pool_type), intent(inout) :: configs
integer, intent(out) :: ierr
type (MPAS_Time_Type) :: startTime, stopTime
type (MPAS_TimeInterval_type) :: runDuration, timeStep
integer :: local_err
real (kind=RKIND), pointer :: config_dt
character (len=StrKIND), pointer :: config_start_time
character (len=StrKIND), pointer :: config_restart_timestamp_name
character (len=StrKIND), pointer :: config_run_duration
character (len=StrKIND), pointer :: config_stop_time
character (len=StrKIND) :: startTimeStamp
integer :: iounit
ierr = 0
call mpas_pool_get_config(configs, 'config_dt', config_dt)
call mpas_pool_get_config(configs, 'config_start_time', config_start_time)
call mpas_pool_get_config(configs, 'config_restart_timestamp_name', config_restart_timestamp_name)
call mpas_pool_get_config(configs, 'config_run_duration', config_run_duration)
call mpas_pool_get_config(configs, 'config_stop_time', config_stop_time)
if(trim(config_start_time) == 'file') then
call mpas_new_unit(iounit)
open(iounit,file=trim(config_restart_timestamp_name),form='formatted',status='old')
read(iounit,*) startTimeStamp
close(iounit)
call mpas_release_unit(iounit)
else
startTimeStamp = config_start_time
end if
call mpas_set_time(curr_time=startTime, dateTimeString=startTimeStamp, ierr=local_err)
call mpas_set_timeInterval(timeStep, dt=config_dt, ierr=local_err)
if (trim(config_run_duration) /= "none") then
call mpas_set_timeInterval(runDuration, timeString=config_run_duration, ierr=local_err)
call mpas_create_clock(core_clock, startTime=startTime, timeStep=timeStep, runDuration=runDuration, ierr=local_err)
if (trim(config_stop_time) /= "none") then
call mpas_set_time(curr_time=stopTime, dateTimeString=config_stop_time, ierr=local_err)
if(startTime + runduration /= stopTime) then
call mpas_log_write('config_run_duration and config_stop_time are inconsistent: using config_run_duration.', messageType=MPAS_LOG_WARN)
end if
end if
else if (trim(config_stop_time) /= "none") then
call mpas_set_time(curr_time=stopTime, dateTimeString=config_stop_time, ierr=local_err)
call mpas_create_clock(core_clock, startTime=startTime, timeStep=timeStep, stopTime=stopTime, ierr=local_err)
else
call mpas_log_write('Neither config_run_duration nor config_stop_time were specified.', messageType=MPAS_LOG_ERR)
ierr = 1
end if
!TODO: set phyics alarms here...
!....
!....
end subroutine atm_simulation_clock_init
subroutine atm_mpas_init_block(dminfo, stream_manager, block, mesh, dt)
use atm_time_integration
use mpas_rbf_interpolation
use mpas_vector_reconstruction
use mpas_stream_manager
use mpas_atm_boundaries, only : mpas_atm_setup_bdy_masks
#ifdef DO_PHYSICS
! use mpas_atmphys_aquaplanet
use mpas_atmphys_control
use mpas_atmphys_init
use mpas_atmphys_manager
#endif
implicit none
type (dm_info), intent(in) :: dminfo
type (MPAS_streamManager_type), intent(inout) :: stream_manager
type (block_type), intent(inout) :: block
type (mpas_pool_type), intent(inout) :: mesh !MGD does this need to be a pointer?
real (kind=RKIND), intent(in) :: dt
type (mpas_pool_type), pointer :: state
type (mpas_pool_type), pointer :: diag
type (mpas_pool_type), pointer :: tend
type (mpas_pool_type), pointer :: tend_physics
type (mpas_pool_type), pointer :: sfc_input
type (mpas_pool_type), pointer :: diag_physics
type (mpas_pool_type), pointer :: diag_physics_noahmp
type (mpas_pool_type), pointer :: ngw_input
type (mpas_pool_type), pointer :: atm_input
type (mpas_pool_type), pointer :: output_noahmp
integer :: iCell,iEdge,iVertex,k
real (kind=RKIND), dimension(:,:), pointer :: u, uReconstructX, uReconstructY, uReconstructZ, uReconstructZonal, uReconstructMeridional
real (kind=RKIND), dimension(:), pointer :: meshScalingDel2, meshScalingDel4
real (kind=RKIND), dimension(:), pointer :: areaCell, invAreaCell
real (kind=RKIND), dimension(:), pointer :: dvEdge, invDvEdge
real (kind=RKIND), dimension(:), pointer :: dcEdge, invDcEdge
real (kind=RKIND), dimension(:), pointer :: areaTriangle, invAreaTriangle
integer, pointer :: nCells_ptr, nEdges_ptr, nVertices_ptr, nVertLevels_ptr, nEdgesSolve
integer :: nCells, nEdges, nVertices, nVertLevels
integer :: thread
character(len=StrKIND), pointer :: mminlu
integer, pointer :: nThreads
integer, dimension(:), pointer :: cellThreadStart, cellThreadEnd
integer, dimension(:), pointer :: cellSolveThreadStart, cellSolveThreadEnd
integer, dimension(:), pointer :: edgeThreadStart, edgeThreadEnd
integer, dimension(:), pointer :: edgeSolveThreadStart, edgeSolveThreadEnd
integer, dimension(:), pointer :: vertexThreadStart, vertexThreadEnd
integer, dimension(:), pointer :: vertexSolveThreadStart, vertexSolveThreadEnd
logical, pointer :: config_do_restart, config_do_DAcycling
logical, pointer :: on_a_sphere
real (kind=RKIND), pointer :: sphere_radius
call atm_compute_signs(mesh)
call mpas_pool_get_subpool(block % structs, 'diag', diag)
call mpas_pool_get_subpool(block % structs, 'state', state)
call mpas_pool_get_subpool(block % structs, 'state', state)
call mpas_pool_get_config(block % configs, 'config_do_restart', config_do_restart)
call mpas_pool_get_config(block % configs, 'config_do_DAcycling', config_do_DAcycling)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! Compute inverses to avoid divides later
call mpas_pool_get_array(mesh, 'areaCell', areaCell)
call mpas_pool_get_array(mesh, 'invAreaCell', invAreaCell)
call mpas_pool_get_array(mesh, 'dvEdge', dvEdge)
call mpas_pool_get_array(mesh, 'dcEdge', dcEdge)
call mpas_pool_get_array(mesh, 'invDvEdge', invDvEdge)
call mpas_pool_get_array(mesh, 'invDcEdge', invDcEdge)
call mpas_pool_get_array(mesh, 'areaTriangle', areaTriangle)
call mpas_pool_get_array(mesh, 'invAreaTriangle', invAreaTriangle)
call mpas_pool_get_dimension(mesh, 'nCells', nCells_ptr)
call mpas_pool_get_dimension(mesh, 'nEdges', nEdges_ptr)
call mpas_pool_get_dimension(mesh, 'nVertices', nVertices_ptr)
nCells = nCells_ptr
nEdges = nEdges_ptr
nVertices = nVertices_ptr
do iCell=1,nCells
invAreaCell(iCell) = 1.0_RKIND / areaCell(iCell)
end do
do iEdge=1,nEdges
invDvEdge(iEdge) = 1.0_RKIND / dvEdge(iEdge)
end do
do iEdge=1,nEdges
invDcEdge(iEdge) = 1.0_RKIND / dcEdge(iEdge)
end do
do iVertex=1,nVertices
invAreaTriangle(iVertex) = 1.0_RKIND / areaTriangle(iVertex)
end do
!!!!! End compute inverses
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call mpas_pool_get_config(mesh, 'on_a_sphere', on_a_sphere)
call mpas_pool_get_config(mesh, 'sphere_radius', sphere_radius)
call atm_initialize_deformation_weights(mesh, nCells, on_a_sphere, sphere_radius)
call atm_adv_coef_compression(mesh)
call atm_couple_coef_3rd_order(mesh, block % configs)
call mpas_pool_get_dimension(state, 'nVertices', nVertices_ptr)
call mpas_pool_get_dimension(state, 'nVertLevels', nVertLevels_ptr)
nVertices = nVertices_ptr
nVertLevels = nVertLevels_ptr
allocate(ke_vertex(nVertLevels,nVertices+1)) ! ke_vertex is a module variable defined in mpas_atm_time_integration.F
allocate(ke_edge(nVertLevels,nEdges+1)) ! ke_edge is a module variable defined in mpas_atm_time_integration.F
!$acc parallel default(present)
!$acc loop vector
do k = 1, nVertLevels
ke_vertex(k,nVertices+1) = 0.0_RKIND
ke_edge(k,nEdges+1) = 0.0_RKIND
end do
!$acc end parallel
call mpas_pool_get_dimension(block % dimensions, 'nThreads', nThreads)
call mpas_pool_get_dimension(block % dimensions, 'cellThreadStart', cellThreadStart)
call mpas_pool_get_dimension(block % dimensions, 'cellThreadEnd', cellThreadEnd)
call mpas_pool_get_dimension(block % dimensions, 'cellSolveThreadStart', cellSolveThreadStart)
call mpas_pool_get_dimension(block % dimensions, 'cellSolveThreadEnd', cellSolveThreadEnd)
call mpas_pool_get_dimension(block % dimensions, 'vertexThreadStart', vertexThreadStart)
call mpas_pool_get_dimension(block % dimensions, 'vertexThreadEnd', vertexThreadEnd)
call mpas_pool_get_dimension(block % dimensions, 'vertexSolveThreadStart', vertexSolveThreadStart)
call mpas_pool_get_dimension(block % dimensions, 'vertexSolveThreadEnd', vertexSolveThreadEnd)
call mpas_pool_get_dimension(block % dimensions, 'edgeThreadStart', edgeThreadStart)
call mpas_pool_get_dimension(block % dimensions, 'edgeThreadEnd', edgeThreadEnd)
call mpas_pool_get_dimension(block % dimensions, 'edgeSolveThreadStart', edgeSolveThreadStart)
call mpas_pool_get_dimension(block % dimensions, 'edgeSolveThreadEnd', edgeSolveThreadEnd)
call mpas_atm_pre_compute_solve_diagnostics(block)
!$OMP PARALLEL DO
do thread=1,nThreads
if (.not. config_do_restart .or. (config_do_restart .and. config_do_DAcycling)) then
call atm_init_coupled_diagnostics(state, 1, diag, mesh, block % configs, &
cellThreadStart(thread), cellThreadEnd(thread), &
vertexThreadStart(thread), vertexThreadEnd(thread), &
edgeThreadStart(thread), edgeThreadEnd(thread), &
cellSolveThreadStart(thread), cellSolveThreadEnd(thread), &
vertexSolveThreadStart(thread), vertexSolveThreadEnd(thread), &
edgeSolveThreadStart(thread), edgeSolveThreadEnd(thread))
end if
call atm_compute_solve_diagnostics(dt, state, 1, diag, mesh, block % configs, &
cellThreadStart(thread), cellThreadEnd(thread), &
vertexThreadStart(thread), vertexThreadEnd(thread), &
edgeThreadStart(thread), edgeThreadEnd(thread))
end do
!$OMP END PARALLEL DO
call mpas_atm_post_compute_solve_diagnostics(block)
deallocate(ke_vertex)
deallocate(ke_edge)
call mpas_rbf_interp_initialize(mesh)
call mpas_init_reconstruct(mesh)
call mpas_pool_get_array(state, 'u', u, 1)
call mpas_pool_get_array(diag, 'uReconstructX', uReconstructX)
call mpas_pool_get_array(diag, 'uReconstructY', uReconstructY)
call mpas_pool_get_array(diag, 'uReconstructZ', uReconstructZ)
call mpas_pool_get_array(diag, 'uReconstructZonal', uReconstructZonal)
call mpas_pool_get_array(diag, 'uReconstructMeridional', uReconstructMeridional)
call mpas_reconstruct_2d_h2d(mesh, u, uReconstructX, uReconstructY, uReconstructZ, &
uReconstructZonal, uReconstructMeridional)
call mpas_reconstruct(mesh, u, &
uReconstructX, &
uReconstructY, &
uReconstructZ, &
uReconstructZonal, &
uReconstructMeridional, &
lACC = .true. &
)
call mpas_reconstruct_2d_d2h(mesh, u, uReconstructX, uReconstructY, uReconstructZ, &
uReconstructZonal, uReconstructMeridional)
#ifdef DO_PHYSICS
!proceed with initialization of physics parameterization if moist_physics is set to true:
call mpas_pool_get_subpool(block % structs, 'sfc_input', sfc_input)
! Before calling physics_init, ensure that mminlu contains the name of the land use dataset
call mpas_pool_get_array(sfc_input, 'mminlu', mminlu)
if (len_trim(mminlu) == 0) then
call mpas_log_write('****************************************************************')
call mpas_log_write('No information on land use dataset is available.')
call mpas_log_write('Assume that we are using ''USGS''.')
call mpas_log_write('****************************************************************')
write(mminlu,'(a)') 'USGS'
end if
if (moist_physics) then
!initialization of some input variables in registry:
call mpas_pool_get_subpool(block % structs, 'tend', tend)
call mpas_pool_get_subpool(block % structs, 'tend_physics', tend_physics)
call mpas_pool_get_subpool(block % structs, 'diag_physics', diag_physics)
call mpas_pool_get_subpool(block % structs, 'diag_physics_noahmp', diag_physics_noahmp)
call mpas_pool_get_subpool(block % structs, 'ngw_input', ngw_input)
call mpas_pool_get_subpool(block % structs, 'atm_input', atm_input)
call mpas_pool_get_subpool(block % structs, 'output_noahmp', output_noahmp)
call physics_tables_init(dminfo, block % configs)
call physics_registry_init(mesh, block % configs, sfc_input)
call physics_run_init(block % configs, mesh, state, clock, stream_manager)
!initialization of all physics:
call physics_init(dminfo, stream_manager, clock, block % configs, mesh, diag, tend, tend_physics, state, 1, &
diag_physics, diag_physics_noahmp, ngw_input, atm_input, sfc_input, output_noahmp)
endif
#endif
call atm_compute_mesh_scaling(mesh, block % configs)
call atm_compute_damping_coefs(mesh, block % configs)
!
! Set up mask fields used in limited-area simulations
!
call mpas_atm_setup_bdy_masks(mesh, block % configs)
call mpas_pool_get_dimension(mesh, 'nEdgesSolve', nEdgesSolve)
call mpas_pool_get_array(mesh, 'meshScalingDel2', meshScalingDel2)
call mpas_pool_get_array(mesh, 'meshScalingDel4', meshScalingDel4)
call mpas_log_write('min/max of meshScalingDel2 = $r $r', &
realArgs=(/minval(meshScalingDel2(1:nEdgesSolve)), maxval(meshScalingDel2(1:nEdgesSolve))/))
call mpas_log_write('min/max of meshScalingDel4 = $r $r', &
realArgs=(/minval(meshScalingDel4(1:nEdgesSolve)), maxval(meshScalingDel4(1:nEdgesSolve))/))
end subroutine atm_mpas_init_block
function atm_core_run(domain) result(ierr)
use mpas_timekeeping
use mpas_kind_types
use mpas_stream_manager
use mpas_derived_types, only : MPAS_STREAM_LATEST_BEFORE, MPAS_STREAM_INPUT, MPAS_STREAM_INPUT_OUTPUT
use mpas_timer, only : mpas_timer_start, mpas_timer_stop
use mpas_atm_boundaries, only : mpas_atm_update_bdy_tend
use mpas_atm_diagnostics_manager, only : mpas_atm_diag_update, mpas_atm_diag_compute, mpas_atm_diag_reset
implicit none
type (domain_type), intent(inout) :: domain
integer :: ierr
real (kind=RKIND) :: dt
logical, pointer :: config_do_restart
logical, pointer :: config_apply_lbcs
type (block_type), pointer :: block_ptr
type (MPAS_Time_Type) :: currTime
character(len=StrKIND) :: timeStamp
character (len=StrKIND), pointer :: config_restart_timestamp_name
integer :: itimestep
integer :: iounit
integer :: stream_dir
character(len=StrKIND) :: input_stream, read_time
type (mpas_pool_type), pointer :: state, diag, mesh, diag_physics, tend, tend_physics
! For timing information
real (kind=R8KIND) :: integ_start_time, integ_stop_time
real (kind=R8KIND) :: diag_start_time, diag_stop_time
real (kind=R8KIND) :: input_start_time, input_stop_time
real (kind=R8KIND) :: output_start_time, output_stop_time
ierr = 0
clock => domain % clock
mpas_log_info => domain % logInfo
call mpas_get_timeInterval(mpas_get_clock_timestep(clock, ierr), dt=dt)
call mpas_pool_get_config(domain % blocklist % configs, 'config_do_restart', config_do_restart)
call mpas_pool_get_config(domain % blocklist % configs, 'config_restart_timestamp_name', config_restart_timestamp_name)
! Avoid writing a restart file at the initial time
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='restart', direction=MPAS_STREAM_OUTPUT, ierr=ierr)
! Also, for restart runs, avoid writing the initial history or diagnostics fields to avoid overwriting those from the preceding run
if (config_do_restart) then
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='output', direction=MPAS_STREAM_OUTPUT, ierr=ierr)
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='diagnostics', direction=MPAS_STREAM_OUTPUT, ierr=ierr)
end if
call mpas_dmpar_get_time(diag_start_time)
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)) then
block_ptr => domain % blocklist
do while (associated(block_ptr))
call mpas_pool_get_subpool(block_ptr % structs, 'state', state)
call mpas_pool_get_subpool(block_ptr % structs, 'diag', diag)
#ifdef DO_PHYSICS
call mpas_pool_get_subpool(block_ptr % structs, 'diag_physics', diag_physics)
#endif
call mpas_pool_get_subpool(block_ptr % structs, 'mesh', mesh)
call atm_compute_output_diagnostics(state, 1, diag, mesh)
block_ptr => block_ptr % next
end do
end if
call mpas_timer_start('diagnostic_fields')
call mpas_atm_diag_reset()
call mpas_atm_diag_update()
call mpas_atm_diag_compute()
call mpas_timer_stop('diagnostic_fields')
call mpas_dmpar_get_time(diag_stop_time)
call mpas_timer_start('stream_output')
call mpas_dmpar_get_time(output_start_time)
call mpas_stream_mgr_write(domain % streamManager, ierr=ierr)
call mpas_dmpar_get_time(output_stop_time)
call mpas_timer_stop('stream_output')
if (ierr /= MPAS_STREAM_MGR_NOERR .and. &
ierr /= MPAS_STREAM_MGR_ERR_CLOBBER_FILE .and. &
ierr /= MPAS_STREAM_MGR_ERR_CLOBBER_REC) then
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_ERR)
call mpas_log_write('Error writing one or more output streams', messageType=MPAS_LOG_ERR)
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_CRIT)
end if
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)) then
call mpas_log_write('Timing for diagnostic computation: $r s', realArgs=(/real(diag_stop_time - diag_start_time, kind=RKIND)/))
call mpas_log_write('Timing for stream output: $r s', realArgs=(/real(output_stop_time - output_start_time, kind=RKIND)/))
end if
call mpas_timer_start('diagnostic_fields')
call mpas_atm_diag_reset()
call mpas_timer_stop('diagnostic_fields')
call mpas_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)
block_ptr => domain % blocklist
call mpas_pool_get_subpool(block_ptr % structs, 'mesh', mesh)
call mpas_pool_get_subpool(block_ptr % structs, 'state', state)
call mpas_pool_get_subpool(block_ptr % structs, 'diag', diag)
#ifdef DO_PHYSICS
call mpas_pool_get_subpool(block_ptr % structs, 'diag_physics', diag_physics)
#endif
call mpas_pool_get_config(domain % blocklist % configs, 'config_apply_lbcs', config_apply_lbcs)
!
! Read initial boundary state
!
if (config_apply_lbcs .and. &
MPAS_stream_mgr_ringing_alarms(domain % streamManager, streamID='lbc_in', direction=MPAS_STREAM_INPUT, ierr=ierr)) then
block_ptr => domain % blocklist
do while (associated(block_ptr))
call mpas_atm_update_bdy_tend(clock, domain % streamManager, block_ptr, .true., ierr)
if (ierr /= 0) then
currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp)
call mpas_log_write('Failed to process LBC data on or before '//trim(timeStamp), messageType=MPAS_LOG_ERR)
return
end if
block_ptr => block_ptr % next
end do
end if
! During integration, time level 1 stores the model state at the beginning of the
! time step, and time level 2 stores the state advanced dt in time by timestep(...)
itimestep = 1
do while (.not. mpas_is_clock_stop_time(clock))
currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
call mpas_log_write('')
call mpas_log_write('Begin timestep '//trim(timeStamp))
!
! Read future boundary state and compute boundary tendencies
!
if (config_apply_lbcs .and. &
MPAS_stream_mgr_ringing_alarms(domain % streamManager, streamID='lbc_in', direction=MPAS_STREAM_INPUT, ierr=ierr)) then
block_ptr => domain % blocklist
do while (associated(block_ptr))
call mpas_atm_update_bdy_tend(clock, domain % streamManager, block_ptr, .false., ierr)
if (ierr /= 0) then
call mpas_log_write('Failed to process LBC data at next time after '//trim(timeStamp), messageType=MPAS_LOG_ERR)
return
end if
block_ptr => block_ptr % next
end do
end if
! Regardless of whether boundary tendencies were updated, above, we do not want to read the 'lbc_in' stream
! as a general input stream, below.
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='lbc_in', direction=MPAS_STREAM_INPUT, ierr=ierr)
!
! Read external field updates
!
call MPAS_stream_mgr_begin_iteration(domain % streamManager, ierr=ierr)
do while (MPAS_stream_mgr_get_next_stream(domain % streamManager, streamID=input_stream, directionProperty=stream_dir))
if (stream_dir == MPAS_STREAM_INPUT .or. stream_dir == MPAS_STREAM_INPUT_OUTPUT) then
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, streamID=input_stream, &
direction=MPAS_STREAM_INPUT, ierr=ierr)) then
call mpas_timer_start('stream_input')
call mpas_dmpar_get_time(input_start_time)
call MPAS_stream_mgr_read(domain % streamManager, streamID=input_stream, whence=MPAS_STREAM_LATEST_BEFORE, &
actualWhen=read_time, ierr=ierr)
call mpas_dmpar_get_time(input_stop_time)
call mpas_timer_stop('stream_input')
if (ierr /= MPAS_STREAM_MGR_NOERR) then
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_ERR)
call mpas_log_write('Error reading input stream '//trim(input_stream), messageType=MPAS_LOG_ERR)
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_CRIT)
end if
call mpas_log_write('----------------------------------------------------------------------')
call mpas_log_write(' Read '''//trim(input_stream)//''' input stream valid at '//trim(read_time))
call mpas_log_write(' Timing for stream input: $r s', realArgs=(/real(input_stop_time - input_start_time, kind=RKIND)/))
call mpas_log_write('----------------------------------------------------------------------')
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID=input_stream, direction=MPAS_STREAM_INPUT, ierr=ierr)
end if
end if
end do
call mpas_timer_start("time integration")
call mpas_dmpar_get_time(integ_start_time)
call atm_do_timestep(domain, dt, itimestep)
call mpas_dmpar_get_time(integ_stop_time)
call mpas_timer_stop("time integration")
call mpas_log_write(' Timing for integration step: $r s', realArgs=(/real(integ_stop_time - integ_start_time, kind=RKIND)/))
! Move time level 2 fields back into time level 1 for next time step
call mpas_pool_get_subpool(domain % blocklist % structs, 'state', state)
call mpas_pool_shift_time_levels(state)
! Advance clock before writing output
itimestep = itimestep + 1
call mpas_advance_clock(clock)
currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
call mpas_dmpar_get_time(diag_start_time)
!
! Write any output streams that have alarms ringing, after computing diagnostics fields
!
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)) then
block_ptr => domain % blocklist
do while (associated(block_ptr))
call mpas_pool_get_subpool(block_ptr % structs, 'state', state)
call mpas_pool_get_subpool(block_ptr % structs, 'diag', diag)
#ifdef DO_PHYSICS
call mpas_pool_get_subpool(block_ptr % structs, 'diag_physics', diag_physics)
call mpas_pool_get_subpool(block_ptr % structs, 'tend_physics', tend_physics)
#endif
call mpas_pool_get_subpool(block_ptr % structs, 'mesh', mesh)
call mpas_pool_get_subpool(block_ptr % structs, 'tend', tend)
call atm_compute_output_diagnostics(state, 1, diag, mesh)
block_ptr => block_ptr % next
end do
end if
call mpas_timer_start('diagnostic_fields')
call mpas_atm_diag_update()
call mpas_atm_diag_compute()
call mpas_timer_stop('diagnostic_fields')
call mpas_dmpar_get_time(diag_stop_time)
call mpas_timer_start('stream_output')
call mpas_dmpar_get_time(output_start_time)
call mpas_stream_mgr_write(domain % streamManager, ierr=ierr)
call mpas_dmpar_get_time(output_stop_time)
call mpas_timer_stop('stream_output')
if (ierr /= MPAS_STREAM_MGR_NOERR .and. &
ierr /= MPAS_STREAM_MGR_ERR_CLOBBER_FILE .and. &
ierr /= MPAS_STREAM_MGR_ERR_CLOBBER_REC) then
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_ERR)
call mpas_log_write('Error writing one or more output streams', messageType=MPAS_LOG_ERR)
call mpas_log_write('********************************************************************************', messageType=MPAS_LOG_CRIT)
end if
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)) then
call mpas_log_write('Timing for diagnostic computation: $r s', realArgs=(/real(diag_stop_time - diag_start_time, kind=RKIND)/))
call mpas_log_write('Timing for stream output: $r s', realArgs=(/real(output_stop_time - output_start_time, kind=RKIND)/))
end if
! reset any diagnostics here
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, streamID='diagnostics', direction=MPAS_STREAM_OUTPUT, ierr=ierr)) then
block_ptr => domain % blocklist
do while (associated(block_ptr))
#ifdef DO_PHYSICS
call mpas_pool_get_subpool(block_ptr % structs, 'diag_physics', diag_physics)
#endif
call atm_reset_diagnostics(diag_physics)
block_ptr => block_ptr % next
end do
end if
! Only after we've successfully written the restart file should we we
! write the restart_timestamp file
if (MPAS_stream_mgr_ringing_alarms(domain % streamManager, streamID='restart', direction=MPAS_STREAM_OUTPUT, ierr=ierr)) then
if (domain % dminfo % my_proc_id == 0) then
call mpas_new_unit(iounit)
open(iounit,file=trim(config_restart_timestamp_name),form='formatted',status='replace')
write(iounit,*) trim(timeStamp)
close(iounit)
call mpas_release_unit(iounit)
end if
end if
call mpas_timer_start('diagnostic_fields')
call mpas_atm_diag_reset()
call mpas_timer_stop('diagnostic_fields')
call mpas_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)
end do
end function atm_core_run
subroutine atm_compute_output_diagnostics(state, time_lev, diag, mesh)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Compute diagnostic fields for a domain to be written to history files
!
! Input: state - contains model prognostic fields
! mesh - contains grid metadata
!
! Output: state - upon returning, diagnostic fields will have be computed
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use mpas_constants
implicit none
type (mpas_pool_type), intent(inout) :: state
integer, intent(in) :: time_lev ! which time level to use from state
type (mpas_pool_type), intent(inout) :: diag
type (mpas_pool_type), intent(in) :: mesh
integer :: iCell, k
integer, pointer :: nCells, nVertLevels, index_qv
real (kind=RKIND), dimension(:,:), pointer :: theta, rho, theta_m, rho_zz, zz
real (kind=RKIND), dimension(:,:), pointer :: pressure_base, pressure_p, pressure
real (kind=RKIND), dimension(:,:,:), pointer :: scalars
call mpas_pool_get_dimension(mesh, 'nCells', nCells)
call mpas_pool_get_dimension(mesh, 'nVertLevels', nVertLevels)
call mpas_pool_get_dimension(state, 'index_qv', index_qv)
call mpas_pool_get_array(state, 'theta_m', theta_m, time_lev)
call mpas_pool_get_array(state, 'rho_zz', rho_zz, time_lev)
call mpas_pool_get_array(state, 'scalars', scalars, time_lev)
call mpas_pool_get_array(diag, 'theta', theta)
call mpas_pool_get_array(diag, 'rho', rho)
call mpas_pool_get_array(diag, 'pressure_p', pressure_p)
call mpas_pool_get_array(diag, 'pressure_base', pressure_base)
call mpas_pool_get_array(diag, 'pressure', pressure)
call mpas_pool_get_array(mesh, 'zz', zz)
do iCell=1,nCells
do k=1,nVertLevels
theta(k,iCell) = theta_m(k,iCell) / (1._RKIND + rvord * scalars(index_qv,k,iCell))
rho(k,iCell) = rho_zz(k,iCell) * zz(k,iCell)
pressure(k,iCell) = pressure_base(k,iCell) + pressure_p(k,iCell)
end do
end do
end subroutine atm_compute_output_diagnostics
subroutine atm_reset_diagnostics(diag_physics)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! reset some diagnostics after output
!
! Input: diag_physics - contains physics diagnostic fields
!
! Output: whatever diagnostics need resetting after output
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
type (mpas_pool_type), pointer :: diag_physics
real (kind=RKIND), dimension(:), pointer :: refl10cm_1km_max
#ifdef DO_PHYSICS
call mpas_pool_get_array(diag_physics, 'refl10cm_1km_max', refl10cm_1km_max)
if(associated(refl10cm_1km_max)) then
refl10cm_1km_max(:) = 0.
endif
#endif
end subroutine atm_reset_diagnostics
subroutine atm_do_timestep(domain, dt, itimestep)
use mpas_timekeeping
use mpas_kind_types
use atm_time_integration
#ifdef DO_PHYSICS
use mpas_atmphys_control
use mpas_atmphys_driver