-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoupler_main.F90
2336 lines (2040 loc) · 99.5 KB
/
coupler_main.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
!***********************************************************************
!* GNU Lesser General Public License
!*
!* This file is part of the GFDL Flexible Modeling System (FMS) Coupler.
!*
!* FMS Coupler is free software: you can redistribute it and/or modify
!* it under the terms of the GNU Lesser General Public License as
!* published by the Free Software Foundation, either version 3 of the
!* License, or (at your option) any later version.
!*
!* FMS Coupler is distributed in the hope that it will be useful, but
!* WITHOUT ANY WARRANTY; without even the implied warranty of
!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
!* General Public License for more details.
!*
!* You should have received a copy of the GNU Lesser General Public
!* License along with FMS Coupler.
!* If not, see <http://www.gnu.org/licenses/>.
!***********************************************************************
!
!> \mainpage
!!
!! \brief coupler_main couples component models for atmosphere, ocean,
!! land and sea ice on independent grids. It also controls the time integration.
!!
!! \author Bruce Wyman <Bruce.Wyman@noaa.gov>
!! \author V. Balaji <V.Balaji@noaa.gov>
!!
!! This version couples model components representing atmosphere, ocean, land
!! and sea ice on independent grids. Each model component is represented by a
!! data type giving the instantaneous model state.
!!
!! The component models are coupled to allow implicit vertical diffusion of
!! heat and moisture at the interfaces of the atmosphere, land, and ice models.
!! As a result, the atmosphere, land, and ice models all use the same time step.
!! The atmospheric model has been separated into down and up calls that
!! correspond to the down and up sweeps of the standard tridiagonal elimination.
!!
!! The ocean interface uses explicit mixing. Fluxes to and from the ocean must
!! be passed through the ice model. This includes atmospheric fluxes as well as
!! fluxes from the land to the ocean (runoff).
!!
!! This program contains the model's main time loop. Each iteration of the
!! main time loop is one coupled (slow) time step. Within this slow time step
!! loop is a fast time step loop, using the atmospheric time step, where the
!! tridiagonal vertical diffusion equations are solved. Exchange between sea
!! ice and ocean occurs once every slow timestep.
!!
!! \section coupler_namelists Namelists
!!
!! The three components of coupler: coupler_main, flux_exchange_mod, and surface_flux_mod
!! are configured through three namelists
!! * \ref coupler_config "coupler_nml"
!! * \ref flux_exchange_config "flux_exchange_nml"
!! * \ref surface_flux_config "surface_flux_nml"
!!
!!
!! \note
!! -# If no value is set for current_date, start_date, or calendar (or default value
!! specified) then the value from restart file "INPUT/coupler.res" will be used.
!! If neither a namelist value or restart file value exist the program will fail.
!! -# The actual run length will be the sum of months, days, hours, minutes, and
!! seconds. A run length of zero is not a valid option.
!! -# The run length must be an intergal multiple of the coupling timestep dt_cpld.
!!
!! \section Main Program Example
!!
!! ~~~~~~~~~~{.f90}
!! DO slow time steps (ocean)
!! call flux_ocean_to_ice
!!
!! call set_ice_surface_fields
!!
!! DO fast time steps (atmos)
!! call flux_calculation
!!
!! call ATMOS_DOWN
!!
!! call flux_down_from_atmos
!!
!! call LAND_FAST
!!
!! call ICE_FAST
!!
!! call flux_up_to_atmos
!!
!! call ATMOS_UP
!! ENDDO
!!
!! call ICE_SLOW
!!
!! call flux_ice_to_ocean
!!
!! call OCEAN
!! ENDDO
!! ~~~~~~~~~~
!> \page coupler_config Coupler Configuration
!!
!! coupler_main is configured via the coupler_nml namelist in the `input.nml` file.
!! The following table contains the available namelist variables.
!!
!! <table>
!! <tr>
!! <th>Variable Name</th>
!! <th>Type</th>
!! <th>Default Value</th>
!! <th>Description</th>
!! </tr>
!! <tr>
!! <td>current_date</td>
!! <td>integer, dimension(6)</td>
!! <td>(/0,0,0,0,0,0/)</td>
!! <td>The date that the current integration starts with.</td>
!! </tr>
!! <tr>
!! <td>force_date_from_namelist</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>Flag that determines whether the namelist variable current_date should
!! override the date in the restart file INPUT/coupler.res. If the restart
!! file does not exist then force_date_from_namelist has not effect, the
!! value of current_date will be used.</td>
!! </tr>
!! <tr>
!! <td>calendar</td>
!! <td>character(len=17)</td>
!! <td>''</td>
!! <td>The calendar type used by the current integration. Valid values are
!! consistent with the time_manager module: 'gregorian','julian', 'noleap', or
!! 'thirty_day'. The value 'no_calendar' can not be used because the
!! time_manager's date function are used. All values must be
!! lowercase.</td>
!! </tr>
!! <tr>
!! <td>months</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>The number of months that the current integration will be run for.</td>
!! </tr>
!! <tr>
!! <td>days</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>The number of days that the current integration will be run for.</td>
!! </tr>
!! <tr>
!! <td>hours</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>The number of hours that the current integration will be run for.</td>
!! </tr>
!! <tr>
!! <td>minutes</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>The number of minutes that the current integration will be run for.</td>
!! </tr>
!! <tr>
!! <td>seconds</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>The number of seconds that the current integration will be run for.</td>
!! </tr>
!! <tr>
!! <td>dt_atmos</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>Atmospheric model time step in seconds, including the fast coupling
!! with land and sea ice.</td>
!! </tr>
!! <tr>
!! <td>dt_cpld</td>
!! <td>integer</td>
!! <td>0</td>
!! <td>Time step in seconds for coupling between ocean and atmospheric models:
!! must be an integral multiple of dt_atmos and dt_ocean. This is the
!! "slow" timestep.</td>
!! </tr>
!! <tr>
!! <td>do_atmos, do_ocean, do_ice, do_land, do_flux</td>
!! <td>logical</td>
!! <td>.TRUE.</td>
!! <td>If true (default), that particular model component (atmos, etc.) is
!! run. If false, the execution of that component is skipped. This is used
!! when ALL the output fields sent by that component to the coupler have
!! been overridden using the data_override feature. For advanced users
!! only: if you're not sure, you should leave these values at TRUE.</td>
!! </tr>
!! <tr>
!! <td>concurrent</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>If true, the ocean executes concurrently with the atmosphere-land-ocean
!! on a separate set of PEs. If false (default), the execution is serial:
!! call atmos... followed by call ocean... If using concurrent execution,
!! you must set one of atmos_npes and ocean_npes, see below.</td>
!! </tr>
!! <tr>
!! <td>do_concurrent_radiation</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>If true then radiation is done concurrently.</td>
!! </tr>
!! <tr>
!! <td>atmos_npes, ocean_npes</td>
!! <td>integer</td>
!! <td>none</td>
!! <td>If concurrent is set to true, we use these to set the list of PEs on
!! which each component runs. At least one of them must be set to a number
!! between 0 and NPES. If exactly one of these two is set non-zero, the
!! other is set to the remainder from NPES. If both are set non-zero they
!! must add up to NPES.</td>
!! </tr>
!! <tr>
!! <td>atmos_nthreads, ocean_nthreads</td>
!! <td>integer</td>
!! <td>1</td>
!! <td>We set here the number of OpenMP threads to use separately for each
!! component.</td>
!! </tr>
!! <tr>
!! <td>radiation_nthreads</td>
!! <td>integer</td>
!! <td>1</td>
!! <td>Number of threads to use for the concurrent radiation
!! when do_concurrent_radiation = .true., otherwise is equal
!! to atmos_nthreads </td>
!! </tr>
!! <tr>
!! <td>use_lag_fluxes</td>
!! <td>logical</td>
!! <td>.TRUE.</td>
!! <td> If true, the ocean is forced with SBCs from one coupling timestep ago.
!! If false, the ocean is forced with most recent SBCs. For an old leapfrog
!! MOM4 coupling with dt_cpld=dt_ocean, lag fluxes can be shown to be stable
!! and current fluxes to be unconditionally unstable. For dt_cpld>dt_ocean there
!! is probably sufficient damping for MOM4. For more modern ocean models (such as
!! MOM5, GOLD or MOM6) that do not use leapfrog timestepping, use_lag_fluxes=.False.
!! should be much more stable.</td>
!! </tr>
!! <tr>
!! <td>concurrent_ice</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>If true, the slow sea-ice is forced with the fluxes that were used for
!! the fast ice processes one timestep before. When used in conjuction with
!! setting slow_ice_with_ocean=true, this approach allows the atmosphere and
!! ocean to run concurrently even if use_lag_fluxes=.FALSE., and it can be
!! shown to ameliorate or eliminate several ice-ocean coupled instabilities.</td>
!! </tr>
!! <tr>
!! <td>slow_ice_with_ocean</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>If true, the slow sea-ice is advanced on the ocean processors. Otherwise
!! the slow sea-ice processes are on the same PEs as the fast sea-ice.</td>
!! </tr>
!! <tr>
!! <td>restart_interval</td>
!! <td>integer, dimension(6)</td>
!! <td>(/0,0,0,0,0,0/)</td>
!! <td>The time interval that write out intermediate restart file. The format
!! is (yr,mo,day,hr,min,sec). When restart_interval is all zero, no
!! intermediate restart file will be written out.</td>
!! </tr>
!! <tr>
!! <td>do_debug</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>If .TRUE. print additional debugging messages.</td>
!! </tr>
!! <tr>
!! <td>do_chksum</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>Turns on/off checksum of certain variables.</td>
!! </tr>
!! <tr>
!! <td>do_endpoint_chksum</td>
!! <td>logical</td>
!! <td>.TRUE.</td>
!! <td>Report checksums of the start and end states of certain variables.</td>
!! </tr>
!! </table>
!!
!! \note
!! -# If no value is set for current_date, start_date, or calendar (or default value specified) then the value from
!! restart file "INPUT/coupler.res" will be used. If neither a namelist value or restart file value exist the
!! program will fail.
!! -# The actual run length will be the sum of months, days, hours, minutes, and seconds. A run length of zero is not a
!! valid option.
!! -# The run length must be an intergal multiple of the coupling timestep dt_cpld.
!> \throw FATAL, "no namelist value for current_date"
!! A namelist value for current_date must be given if no restart file for
!! coupler_main (INPUT/coupler.res) is found.
!! \throw FATAL, "invalid namelist value for calendar"
!! The value of calendar must be 'gregorian','julian', 'noleap', or 'thirty_day'.
!! See the namelist documentation.
!! \throw FATAL, "no namelist value for calendar"
!! If no restart file is present, then a namelist value for calendar
!! must be specified.
!! \throw FATAL, "initial time is greater than current time"
!! If a restart file is present, then the namelist value for either
!! current_date or start_date was incorrectly set.
!! \throw FATAL, "run length must be multiple of ocean time step"
!! There must be an even number of ocean time steps for the requested run length.
!! \throw FATAL, "final time does not match expected ending time"
!! This error should probably not occur because of checks done at initialization time.
program coupler_main
use constants_mod, only: constants_init
use time_manager_mod, only: time_type, set_calendar_type, set_time
use time_manager_mod, only: set_date, get_date, days_in_month, month_name
use time_manager_mod, only: operator(+), operator(-), operator (<)
use time_manager_mod, only: operator (>), operator ( /= ), operator ( / )
use time_manager_mod, only: operator (*), THIRTY_DAY_MONTHS, JULIAN
use time_manager_mod, only: GREGORIAN, NOLEAP, NO_CALENDAR, INVALID_CALENDAR
use time_manager_mod, only: date_to_string, increment_date
use time_manager_mod, only: operator(>=), operator(<=), operator(==)
use fms_mod, only: open_namelist_file, field_exist, file_exist, check_nml_error
use fms_mod, only: uppercase, error_mesg, write_version_number
use fms_mod, only: fms_init, fms_end, stdout
use fms_mod, only: read_data, write_data
use fms_io_mod, only: fms_io_exit
use fms_io_mod, only: restart_file_type, register_restart_field
use fms_io_mod, only: save_restart, restore_state
use diag_manager_mod, only: diag_manager_init, diag_manager_end, diag_grid_end
use diag_manager_mod, only: DIAG_OCEAN, DIAG_OTHER, DIAG_ALL, get_base_date
use diag_manager_mod, only: diag_manager_set_time_end
use field_manager_mod, only: MODEL_ATMOS, MODEL_LAND, MODEL_ICE
use tracer_manager_mod, only: tracer_manager_init, get_tracer_index
use tracer_manager_mod, only: get_number_tracers, get_tracer_names, NO_TRACER
use coupler_types_mod, only: coupler_types_init, coupler_1d_bc_type
use coupler_types_mod, only: coupler_type_write_chksums
use coupler_types_mod, only: coupler_type_register_restarts, coupler_type_restore_state
use data_override_mod, only: data_override_init
!
! model interfaces used to couple the component models:
! atmosphere, land, ice, and ocean
!
use atmos_model_mod, only: atmos_model_init, atmos_model_end
use atmos_model_mod, only: update_atmos_model_dynamics
use atmos_model_mod, only: update_atmos_model_down
use atmos_model_mod, only: update_atmos_model_up
use atmos_model_mod, only: atmos_data_type
use atmos_model_mod, only: land_ice_atmos_boundary_type
use atmos_model_mod, only: atmos_data_type_chksum
use atmos_model_mod, only: lnd_ice_atm_bnd_type_chksum
use atmos_model_mod, only: lnd_atm_bnd_type_chksum
use atmos_model_mod, only: ice_atm_bnd_type_chksum
use atmos_model_mod, only: atmos_model_restart
use atmos_model_mod, only: update_atmos_model_radiation
use atmos_model_mod, only: update_atmos_model_state
use land_model_mod, only: land_model_init, land_model_end
use land_model_mod, only: land_data_type, atmos_land_boundary_type
use land_model_mod, only: update_land_model_fast, update_land_model_slow
use land_model_mod, only: atm_lnd_bnd_type_chksum
use land_model_mod, only: land_data_type_chksum
use land_model_mod, only: land_model_restart
use ice_model_mod, only: ice_model_init, share_ice_domains, ice_model_end, ice_model_restart
use ice_model_mod, only: update_ice_model_fast, set_ice_surface_fields
use ice_model_mod, only: ice_data_type, land_ice_boundary_type
use ice_model_mod, only: ocean_ice_boundary_type, atmos_ice_boundary_type
use ice_model_mod, only: ice_data_type_chksum, ocn_ice_bnd_type_chksum
use ice_model_mod, only: atm_ice_bnd_type_chksum, lnd_ice_bnd_type_chksum
use ice_model_mod, only: unpack_ocean_ice_boundary, exchange_slow_to_fast_ice
use ice_model_mod, only: ice_model_fast_cleanup, unpack_land_ice_boundary
use ice_model_mod, only: exchange_fast_to_slow_ice, update_ice_model_slow
use ocean_model_mod, only: update_ocean_model, ocean_model_init, ocean_model_end
use ocean_model_mod, only: ocean_public_type, ocean_state_type, ice_ocean_boundary_type
use ocean_model_mod, only: ocean_model_restart
use ocean_model_mod, only: ocean_public_type_chksum, ice_ocn_bnd_type_chksum
use combined_ice_ocean_driver, only: update_slow_ice_and_ocean, ice_ocean_driver_type
use combined_ice_ocean_driver, only: ice_ocean_driver_init, ice_ocean_driver_end
!
! flux_ calls translate information between model grids - see flux_exchange.f90
!
use flux_exchange_mod, only: flux_exchange_init, gas_exchange_init, sfc_boundary_layer
use flux_exchange_mod, only: generate_sfc_xgrid, send_ice_mask_sic
use flux_exchange_mod, only: flux_down_from_atmos, flux_up_to_atmos
use flux_exchange_mod, only: flux_land_to_ice, flux_ice_to_ocean, flux_ocean_to_ice
use flux_exchange_mod, only: flux_ice_to_ocean_finish, flux_ocean_to_ice_finish
use flux_exchange_mod, only: flux_check_stocks, flux_init_stocks
use flux_exchange_mod, only: flux_ocean_from_ice_stocks, flux_ice_to_ocean_stocks
use flux_exchange_mod, only: flux_atmos_to_ocean, flux_ex_arrays_dealloc
use atmos_tracer_driver_mod, only: atmos_tracer_driver_gather_data
use mpp_mod, only: mpp_clock_id, mpp_clock_begin, mpp_clock_end, mpp_chksum
use mpp_mod, only: mpp_init, mpp_pe, mpp_npes, mpp_root_pe, mpp_sync
use mpp_mod, only: stderr, stdlog, mpp_error, NOTE, FATAL, WARNING
use mpp_mod, only: mpp_set_current_pelist, mpp_declare_pelist
use mpp_mod, only: input_nml_file
use mpp_io_mod, only: mpp_open, mpp_close, mpp_io_clock_on
use mpp_io_mod, only: MPP_NATIVE, MPP_RDONLY, MPP_DELETE
use mpp_domains_mod, only: mpp_broadcast_domain
use memutils_mod, only: print_memuse_stats
use iso_fortran_env
implicit none
!-----------------------------------------------------------------------
character(len=128) :: version = '$Id$'
character(len=128) :: tag = '$Name$'
!-----------------------------------------------------------------------
!---- model defined-types ----
type (atmos_data_type) :: Atm
type (land_data_type) :: Land
type (ice_data_type) :: Ice
! allow members of ocean type to be aliased (ap)
type (ocean_public_type), target :: Ocean
type (ocean_state_type), pointer :: Ocean_state => NULL()
type(atmos_land_boundary_type) :: Atmos_land_boundary
type(atmos_ice_boundary_type) :: Atmos_ice_boundary
type(land_ice_atmos_boundary_type) :: Land_ice_atmos_boundary
type(land_ice_boundary_type) :: Land_ice_boundary
type(ice_ocean_boundary_type) :: Ice_ocean_boundary
type(ocean_ice_boundary_type) :: Ocean_ice_boundary
type(ice_ocean_driver_type), pointer :: ice_ocean_driver_CS => NULL()
!-----------------------------------------------------------------------
! ----- coupled model time -----
type (time_type) :: Time, Time_init, Time_end, &
Time_step_atmos, Time_step_cpld
type(time_type) :: Time_atmos, Time_ocean
type(time_type) :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice
integer :: num_atmos_calls, na
integer :: num_cpld_calls, nc
!------ for intermediate restart
type(restart_file_type), dimension(:), pointer :: &
Ice_bc_restart => NULL(), Ocn_bc_restart => NULL()
integer :: num_ice_bc_restart=0, num_ocn_bc_restart=0
type(time_type) :: Time_restart, Time_restart_current, Time_start
character(len=32) :: timestamp
! ----- coupled model initial date -----
integer :: date_init(6) = (/ 0, 0, 0, 0, 0, 0 /)
integer :: calendar_type = INVALID_CALENDAR
!-----------------------------------------------------------------------
!------ namelist interface -------
integer, dimension(6) :: restart_interval = (/ 0, 0, 0, 0, 0, 0/) !< The time interval that write out intermediate restart file.
!! The format is (yr,mo,day,hr,min,sec). When restart_interval
!! is all zero, no intermediate restart file will be written out
integer, dimension(6) :: current_date = (/ 0, 0, 0, 0, 0, 0 /) !< The date that the current integration starts with. (See
!! force_date_from_namelist.)
character(len=17) :: calendar = ' ' !< The calendar type used by the current integration. Valid values are
!! consistent with the time_manager module: 'gregorian', 'julian', 'noleap', or 'thirty_day'.
!! The value 'no_calendar' cannot be used because the time_manager's date
!! functions are used. All values must be lower case.
logical :: force_date_from_namelist = .false. !< Flag that determines whether the namelist variable current_date should override
!! the date in the restart file `INPUT/coupler.res`. If the restart file does not
!! exist then force_date_from_namelist has no effect, the value of current_date
!! will be used.
integer :: months=0 !< Number of months the current integration will be run
integer :: days=0 !< Number of days the current integration will be run
integer :: hours=0 !< Number of hours the current integration will be run
integer :: minutes=0 !< Number of minutes the current integration will be run
integer :: seconds=0 !< Number of seconds the current integration will be run
integer :: dt_atmos = 0 !< Atmospheric model time step in seconds, including the fat coupling with land and sea ice
integer :: dt_cpld = 0 !< Time step in seconds for coupling between ocean and atmospheric models. This must be an
!! integral multiple of dt_atmos and dt_ocean. This is the "slow" timestep.
integer :: atmos_npes=0 !< The number of MPI tasks to use for the atmosphere
integer :: ocean_npes=0 !< The number of MPI tasks to use for the ocean
integer :: ice_npes=0 !< The number of MPI tasks to use for the ice
integer :: land_npes=0 !< The number of MPI tasks to use for the land
integer :: atmos_nthreads=1 !< Number of OpenMP threads to use in the atmosphere
integer :: ocean_nthreads=1 !< Number of OpenMP threads to use in the ocean
integer :: radiation_nthreads=1 !< Number of threads to use for the radiation.
logical :: do_atmos =.true. !< Indicates if this component should be executed. If .FALSE., then execution is skipped.
!! This is used when ALL the output fields sent by this component to the coupler have been
!! overridden using the data_override feature. This is for advanced users only.
logical :: do_land =.true. !< See do_atmos
logical :: do_ice =.true. !< See do_atmos
logical :: do_ocean=.true. !< See do_atmos
logical :: do_flux =.true. !< See do_atmos
logical :: concurrent=.FALSE. !< If .TRUE., the ocean executes concurrently with the atmosphere-land-ice on a separate
!! set of PEs. Concurrent should be .TRUE. if concurrent_ice is .TRUE.
!! If .FALSE., the execution is serial: call atmos... followed by call ocean...
logical :: do_concurrent_radiation=.FALSE. !< If .TRUE. then radiation is done concurrently
logical :: use_lag_fluxes=.TRUE. !< If .TRUE., the ocean is forced with SBCs from one coupling timestep ago.
!! If .FALSE., the ocean is forced with most recent SBCs. For an old leapfrog
!! MOM4 coupling with dt_cpld=dt_ocean, lag fluxes can be shown to be stable
!! and current fluxes to be unconditionally unstable. For dt_cpld>dt_ocean there
!! is probably sufficient damping for MOM4. For more modern ocean models (such as
!! MOM5, GOLD or MOM6) that do not use leapfrog timestepping, use_lag_fluxes=.False.
!! should be much more stable.
logical :: concurrent_ice=.FALSE. !< If .TRUE., the slow sea-ice is forced with the fluxes that were used for the
!! fast ice processes one timestep before. When used in conjuction with setting
!! slow_ice_with_ocean=.TRUE., this approach allows the atmosphere and
!! ocean to run concurrently even if use_lag_fluxes=.FALSE., and it can
!! be shown to ameliorate or eliminate several ice-ocean coupled instabilities.
logical :: slow_ice_with_ocean=.FALSE. !< If true, the slow sea-ice is advanced on the ocean processors. Otherwise
!! the slow sea-ice processes are on the same PEs as the fast sea-ice.
logical :: combined_ice_and_ocean=.FALSE. !< If true, there is a single call from the coupler to advance
!! both the slow sea-ice and the ocean. slow_ice_with_ocean and
!! concurrent_ice must both be true if combined_ice_and_ocean is true.
logical :: do_chksum=.FALSE. !! If .TRUE., do multiple checksums throughout the execution of the model.
logical :: do_endpoint_chksum=.TRUE. !< If .TRUE., do checksums of the initial and final states.
logical :: do_debug=.FALSE. !< If .TRUE. print additional debugging messages.
integer :: check_stocks = 0 ! -1: never 0: at end of run only n>0: every n coupled steps
logical :: use_hyper_thread = .false.
integer :: ncores_per_node = 0
logical :: debug_affinity = .false.
namelist /coupler_nml/ current_date, calendar, force_date_from_namelist, &
months, days, hours, minutes, seconds, dt_cpld, dt_atmos, &
do_atmos, do_land, do_ice, do_ocean, do_flux, &
atmos_npes, ocean_npes, ice_npes, land_npes, &
atmos_nthreads, ocean_nthreads, radiation_nthreads, &
concurrent, do_concurrent_radiation, use_lag_fluxes, &
check_stocks, restart_interval, do_debug, do_chksum, &
use_hyper_thread, ncores_per_node, debug_affinity, &
concurrent_ice, slow_ice_with_ocean, do_endpoint_chksum, &
combined_ice_and_ocean
integer :: initClock, mainClock, termClock
integer :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7
integer :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e
integer :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka
integer :: newClockb, newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki
integer :: newClockj, newClockk, newClockl
integer :: id_atmos_model_init, id_land_model_init, id_ice_model_init
integer :: id_ocean_model_init, id_flux_exchange_init
character(len=80) :: text
character(len=48), parameter :: mod_name = 'coupler_main_mod'
integer :: outunit
integer :: ensemble_id = 1
integer, allocatable :: ensemble_pelist(:, :)
integer, allocatable :: slow_ice_ocean_pelist(:)
integer :: conc_nthreads = 1
integer :: omp_get_thread_num, omp_get_num_threads
real :: omp_get_wtime
real :: dsec, omp_sec(2)=0.0, imb_sec(2)=0.0
!#######################################################################
INTEGER :: i, status, arg_count
CHARACTER(len=256) :: executable_name, arg, fredb_id
#ifdef FREDB_ID
#define xstr(s) str(s)
#define str(s) #s
fredb_id = xstr(FREDB_ID)
#else
#warning "FREDB_ID not defined. Continuing as normal."
fredb_id = 'FREDB_ID was not defined (e.g. -DFREDB_ID=...) during preprocessing'
#endif
arg_count = command_argument_count()
DO i=0, arg_count
CALL get_command_argument(i, arg, status=status)
if (status .ne. 0) then
write (error_unit,*) 'get_command_argument failed: status = ', status, ' arg = ', i
stop 1
end if
if (i .eq. 0) then
executable_name = arg
else if (arg == '--fredb_id') then
write (output_unit,*) TRIM(fredb_id)
stop
end if
END DO
if (arg_count .ge. 1) then
write (error_unit,*) 'Usage: '//TRIM(executable_name)//' [--fredb_id]'
stop 1
end if
call mpp_init()
!these clocks are on the global pelist
initClock = mpp_clock_id( 'Initialization' )
call mpp_clock_begin(initClock)
call fms_init
call constants_init
call coupler_init
if (do_chksum) call coupler_chksum('coupler_init+', 0)
call mpp_set_current_pelist()
call mpp_clock_end (initClock) !end initialization
call mpp_clock_begin(mainClock) !begin main loop
!-----------------------------------------------------------------------
!------ ocean/slow-ice integration loop ------
if (check_stocks >= 0) then
call mpp_set_current_pelist()
call flux_init_stocks(Time, Atm, Land, Ice, Ocean_state)
endif
if (Atm%pe) then
call mpp_set_current_pelist(Atm%pelist)
newClock1 = mpp_clock_id( 'generate_sfc_xgrid' )
endif
if (Ice%slow_ice_PE .or. Ocean%is_ocean_pe) then
call mpp_set_current_pelist(slow_ice_ocean_pelist)
newClock2 = mpp_clock_id( 'flux_ocean_to_ice' )
newClock3 = mpp_clock_id( 'flux_ice_to_ocean' )
endif
if (Atm%pe) then
call mpp_set_current_pelist(Atm%pelist)
newClock5 = mpp_clock_id( 'ATM' )
newClock7 = mpp_clock_id( ' ATM: atmos loop' )
newClocka = mpp_clock_id( ' A-L: atmos_tracer_driver_gather_data' )
newClockb = mpp_clock_id( ' A-L: sfc_boundary_layer' )
newClockl = mpp_clock_id( ' A-L: update_atmos_model_dynamics')
if (.not. do_concurrent_radiation) then
newClockj = mpp_clock_id( ' A-L: serial radiation' )
endif
newClockc = mpp_clock_id( ' A-L: update_atmos_model_down' )
newClockd = mpp_clock_id( ' A-L: flux_down_from_atmos' )
newClocke = mpp_clock_id( ' A-L: update_land_model_fast' )
newClockf = mpp_clock_id( ' A-L: update_ice_model_fast' )
newClockg = mpp_clock_id( ' A-L: flux_up_to_atmos' )
newClockh = mpp_clock_id( ' A-L: update_atmos_model_up' )
if (do_concurrent_radiation) then
newClockj = mpp_clock_id( ' A-L: concurrent radiation' )
newClocki = mpp_clock_id( ' A-L: concurrent atmos' )
endif
newClockk = mpp_clock_id( ' A-L: update_atmos_model_state')
newClock8 = mpp_clock_id( ' ATM: update_land_model_slow' )
newClock9 = mpp_clock_id( ' ATM: flux_land_to_ice' )
endif
if (Ice%pe) then
if (Ice%fast_ice_pe) call mpp_set_current_pelist(Ice%fast_pelist)
newClock6f = mpp_clock_id( ' Ice: set_ice_surface fast' )
newClock10f = mpp_clock_id( ' Ice: update_ice_model_slow fast' )
if (Ice%slow_ice_pe) call mpp_set_current_pelist(Ice%slow_pelist)
newClock6s = mpp_clock_id( ' Ice: set_ice_surface slow' )
newClock10s = mpp_clock_id( ' Ice: update_ice_model_slow slow' )
newClock11 = mpp_clock_id( ' Ice: flux_ice_to_ocean_stocks' )
call mpp_set_current_pelist(Ice%pelist)
newClock6e = mpp_clock_id( ' Ice: set_ice_surface exchange' )
newClock10e = mpp_clock_id( ' Ice: update_ice_model_slow exchange' )
endif
if (Ocean%is_ocean_pe) then
call mpp_set_current_pelist(Ocean%pelist)
newClock12 = mpp_clock_id( 'OCN' )
endif
call mpp_set_current_pelist()
newClock4 = mpp_clock_id( 'flux_check_stocks' )
newClock13 = mpp_clock_id( 'intermediate restart' )
newClock14 = mpp_clock_id( 'final flux_check_stocks' )
do nc = 1, num_cpld_calls
if (do_chksum) call coupler_chksum('top_of_coupled_loop+', nc)
call mpp_set_current_pelist()
if (do_chksum) then
if (Atm%pe) then
call mpp_set_current_pelist(Atm%pelist)
call atmos_ice_land_chksum('MAIN_LOOP-', nc, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
endif
if (Ocean%is_ocean_pe) then
call mpp_set_current_pelist(Ocean%pelist)
call ocean_chksum('MAIN_LOOP-', nc, Ocean, Ice_ocean_boundary)
endif
call mpp_set_current_pelist()
endif
! Calls to flux_ocean_to_ice and flux_ice_to_ocean are all PE communication
! points when running concurrently. The calls are placed next to each other in
! concurrent mode to avoid multiple synchronizations within the main loop.
! With concurrent_ice, these only occur on the ocean PEs.
if (Ice%slow_ice_PE .or. Ocean%is_ocean_pe) then
! If the slow ice is on a subset of the ocean PEs, use the ocean PElist.
call mpp_set_current_pelist(slow_ice_ocean_pelist)
call mpp_clock_begin(newClock2)
!Redistribute quantities from Ocean to Ocean_ice_boundary
!Ice intent is In.
!Ice is used only for accessing Ice%area and knowing if we are on an Ice pe
call flux_ocean_to_ice( Time, Ocean, Ice, Ocean_ice_boundary )
Time_flux_ocean_to_ice = Time
call mpp_clock_end(newClock2)
! Update Ice_ocean_boundary; the first iteration is supplied by restarts
if (use_lag_fluxes) then
call mpp_clock_begin(newClock3)
call flux_ice_to_ocean( Time, Ice, Ocean, Ice_ocean_boundary )
Time_flux_ice_to_ocean = Time
call mpp_clock_end(newClock3)
endif
endif
if (do_chksum) then
call coupler_chksum('flux_ocn2ice+', nc)
if (Atm%pe) then
call mpp_set_current_pelist(Atm%pelist)
call atmos_ice_land_chksum('fluxocn2ice+', nc, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
endif
if (Ocean%is_ocean_pe) then
call mpp_set_current_pelist(Ocean%pelist)
call ocean_public_type_chksum('fluxocn2ice+', nc, Ocean)
endif
call mpp_set_current_pelist()
endif
! To print the value of frazil heat flux at the right time the following block
! needs to sit here rather than at the end of the coupler loop.
if (check_stocks > 0) then
call mpp_clock_begin(newClock4)
if (check_stocks*((nc-1)/check_stocks) == nc-1 .AND. nc > 1) then
call mpp_set_current_pelist()
call flux_check_stocks(Time=Time, Atm=Atm, Lnd=Land, Ice=Ice, Ocn_state=Ocean_state)
endif
call mpp_clock_end(newClock4)
endif
if (do_ice .and. Ice%pe) then
if (Ice%slow_ice_pe) then
call mpp_set_current_pelist(Ice%slow_pelist)
call mpp_clock_begin(newClock6s)
! This may do data override or diagnostics on Ice_ocean_boundary.
call flux_ocean_to_ice_finish( Time_flux_ocean_to_ice, Ice, Ocean_Ice_Boundary )
call unpack_ocean_ice_boundary( Ocean_ice_boundary, Ice )
if (do_chksum) call slow_ice_chksum('update_ice_slow+', nc, Ice, Ocean_ice_boundary)
call mpp_clock_end(newClock6s)
endif
! This could be a point where the model is serialized if the fast and
! slow ice are on different PEs.
if (.not.Ice%shared_slow_fast_PEs) call mpp_set_current_pelist(Ice%pelist)
call mpp_clock_begin(newClock6e)
call exchange_slow_to_fast_ice(Ice)
call mpp_clock_end(newClock6e)
if (concurrent_ice) then
! This call occurs all ice PEs.
call mpp_clock_begin(newClock10e)
call exchange_fast_to_slow_ice(Ice)
call mpp_clock_end(newClock10e)
endif
if (Ice%fast_ice_pe) then
if (.not.Ice%shared_slow_fast_PEs) call mpp_set_current_pelist(Ice%fast_pelist)
call mpp_clock_begin(newClock6f)
call set_ice_surface_fields(Ice)
call mpp_clock_end(newClock6f)
endif
endif
if (Atm%pe) then
if (.NOT.(do_ice .and. Ice%pe) .OR. (ice_npes .NE. atmos_npes)) &
call mpp_set_current_pelist(Atm%pelist)
call mpp_clock_begin(newClock5)
if (do_chksum) call atmos_ice_land_chksum('set_ice_surface+', nc, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
call mpp_clock_begin(newClock1)
call generate_sfc_xgrid( Land, Ice )
call mpp_clock_end(newClock1)
call send_ice_mask_sic(Time)
!-----------------------------------------------------------------------
! ------ atmos/fast-land/fast-ice integration loop -------
call mpp_clock_begin(newClock7)
do na = 1, num_atmos_calls
if (do_chksum) call atmos_ice_land_chksum('top_of_atmos_loop-', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
Time_atmos = Time_atmos + Time_step_atmos
if (do_atmos) then
call mpp_clock_begin(newClocka)
call atmos_tracer_driver_gather_data(Atm%fields, Atm%tr_bot)
call mpp_clock_end(newClocka)
endif
if (do_flux) then
call mpp_clock_begin(newClockb)
call sfc_boundary_layer( REAL(dt_atmos), Time_atmos, &
Atm, Land, Ice, Land_ice_atmos_boundary )
if (do_chksum) call atmos_ice_land_chksum('sfc+', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
call mpp_clock_end(newClockb)
endif
!$OMP PARALLEL &
!$OMP& NUM_THREADS(conc_nthreads) &
!$OMP& DEFAULT(NONE) &
!$OMP& PRIVATE(conc_nthreads) &
!$OMP& SHARED(atmos_nthreads, radiation_nthreads, nc, na, num_atmos_calls, atmos_npes, land_npes, ice_npes) &
!$OMP& SHARED(Time_atmos, Atm, Land, Ice, Land_ice_atmos_boundary, Atmos_land_boundary, Atmos_ice_boundary) &
!$OMP& SHARED(Ocean_ice_boundary) &
!$OMP& SHARED(do_debug, do_chksum, do_atmos, do_land, do_ice, do_concurrent_radiation, omp_sec, imb_sec) &
!$OMP& SHARED(newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki, newClockj, newClockl)
!$ if (omp_get_thread_num() == 0) then
!$OMP PARALLEL &
!$OMP& NUM_THREADS(1) &
!$OMP& DEFAULT(NONE) &
!$OMP& PRIVATE(dsec) &
!$OMP& SHARED(atmos_nthreads, radiation_nthreads, nc, na, num_atmos_calls, atmos_npes, land_npes, ice_npes) &
!$OMP& SHARED(Time_atmos, Atm, Land, Ice, Land_ice_atmos_boundary, Atmos_land_boundary, Atmos_ice_boundary) &
!$OMP& SHARED(Ocean_ice_boundary) &
!$OMP& SHARED(do_debug, do_chksum, do_atmos, do_land, do_ice, do_concurrent_radiation, omp_sec, imb_sec) &
!$OMP& SHARED(newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki, newClockj, newClockl)
!$ call omp_set_num_threads(atmos_nthreads)
!$ dsec=omp_get_wtime()
if (do_concurrent_radiation) call mpp_clock_begin(newClocki)
! ---- atmosphere dynamics ----
if (do_atmos) then
call mpp_clock_begin(newClockl)
call update_atmos_model_dynamics( Atm )
call mpp_clock_end(newClockl)
endif
if (do_chksum) call atmos_ice_land_chksum('update_atmos_model_dynamics', (nc-1)*num_atmos_calls+na, &
Atm, Land, Ice, Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update dyn')
! ---- SERIAL atmosphere radiation ----
if (.not.do_concurrent_radiation) then
call mpp_clock_begin(newClockj)
call update_atmos_model_radiation( Land_ice_atmos_boundary, Atm )
call mpp_clock_end(newClockj)
endif
if (do_chksum) call atmos_ice_land_chksum('update_atmos_model_radiation(ser)', (nc-1)*num_atmos_calls+na, &
Atm, Land, Ice, Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update serial rad')
! ---- atmosphere down ----
if (do_atmos) then
call mpp_clock_begin(newClockc)
call update_atmos_model_down( Land_ice_atmos_boundary, Atm )
call mpp_clock_end(newClockc)
endif
if (do_chksum) call atmos_ice_land_chksum('update_atmos_down+', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update down')
call mpp_clock_begin(newClockd)
call flux_down_from_atmos( Time_atmos, Atm, Land, Ice, &
Land_ice_atmos_boundary, &
Atmos_land_boundary, &
Atmos_ice_boundary )
call mpp_clock_end(newClockd)
if (do_chksum) call atmos_ice_land_chksum('flux_down_from_atmos+', (nc-1)*num_atmos_calls+na, Atm, Land, &
Ice, Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
! --------------------------------------------------------------
! ---- land model ----
call mpp_clock_begin(newClocke)
if (do_land .AND. land%pe) then
if (land_npes .NE. atmos_npes) call mpp_set_current_pelist(Land%pelist)
call update_land_model_fast( Atmos_land_boundary, Land )
endif
if (land_npes .NE. atmos_npes) call mpp_set_current_pelist(Atm%pelist)
call mpp_clock_end(newClocke)
if (do_chksum) call atmos_ice_land_chksum('update_land_fast+', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update land')
! ---- ice model ----
call mpp_clock_begin(newClockf)
if (do_ice .AND. Ice%fast_ice_pe) then
if (ice_npes .NE. atmos_npes)call mpp_set_current_pelist(Ice%fast_pelist)
call update_ice_model_fast( Atmos_ice_boundary, Ice )
endif
if (ice_npes .NE. atmos_npes) call mpp_set_current_pelist(Atm%pelist)
call mpp_clock_end(newClockf)
if (do_chksum) call atmos_ice_land_chksum('update_ice_fast+', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update ice')
! --------------------------------------------------------------
! ---- atmosphere up ----
call mpp_clock_begin(newClockg)
call flux_up_to_atmos( Time_atmos, Land, Ice, Land_ice_atmos_boundary, &
Atmos_land_boundary, Atmos_ice_boundary )
call mpp_clock_end(newClockg)
if (do_chksum) call atmos_ice_land_chksum('flux_up2atmos+', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
call mpp_clock_begin(newClockh)
if (do_atmos) &
call update_atmos_model_up( Land_ice_atmos_boundary, Atm)
call mpp_clock_end(newClockh)
if (do_chksum) call atmos_ice_land_chksum('update_atmos_up+', (nc-1)*num_atmos_calls+na, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update up')
call flux_atmos_to_ocean(Time_atmos, Atm, Atmos_ice_boundary, Ice)
call flux_ex_arrays_dealloc
!--------------
if (do_concurrent_radiation) call mpp_clock_end(newClocki)
!$ omp_sec(1) = omp_sec(1) + (omp_get_wtime() - dsec)
!$OMP END PARALLEL
!$ endif
!$ if (omp_get_thread_num() == max(0,omp_get_num_threads()-1)) then
! ---- atmosphere radiation ----
if (do_concurrent_radiation) then
!$OMP PARALLEL &
!$OMP& NUM_THREADS(1) &
!$OMP& DEFAULT(NONE) &
!$OMP& PRIVATE(dsec) &
!$OMP& SHARED(Atm, Land, Ice, Land_ice_atmos_boundary, Atmos_ice_boundary, Ocean_ice_boundary, Atmos_land_boundary) &
!$OMP& SHARED(do_chksum, do_debug, omp_sec, num_atmos_calls, na, radiation_nthreads) &
!$OMP& SHARED(newClockj)
!$ call omp_set_num_threads(radiation_nthreads)
!$ dsec=omp_get_wtime()
call mpp_clock_begin(newClockj)
call update_atmos_model_radiation( Land_ice_atmos_boundary, Atm )
call mpp_clock_end(newClockj)
!$ omp_sec(2) = omp_sec(2) + (omp_get_wtime() - dsec)
!---CANNOT PUT AN MPP_CHKSUM HERE AS IT REQUIRES THE ABILITY TO HAVE TWO DIFFERENT OPENMP THREADS
!---INSIDE OF MPI AT THE SAME TIME WHICH IS NOT CURRENTLY ALLOWED
! if (do_chksum) call atmos_ice_land_chksum('update_atmos_model_radiation(conc)', (nc-1)*num_atmos_calls+na, &
! Atm, Land, Ice, Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update concurrent rad')
!$OMP END PARALLEL
endif
!$ endif
!$ imb_sec(omp_get_thread_num()+1) = imb_sec(omp_get_thread_num()+1) - omp_get_wtime()
!$OMP END PARALLEL
!$ imb_sec(1) = imb_sec(1) + omp_get_wtime()
!$ if (do_concurrent_radiation) imb_sec(2) = imb_sec(2) + omp_get_wtime()
!$ call omp_set_num_threads(atmos_nthreads+(conc_nthreads-1)*radiation_nthreads)
call mpp_clock_begin(newClockk)
call update_atmos_model_state( Atm )
if (do_chksum) call atmos_ice_land_chksum('update_atmos_model_state+', (nc-1)*num_atmos_calls+na, Atm, Land, &
Ice,Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
if (do_debug) call print_memuse_stats( 'update state')
call mpp_clock_end(newClockk)
enddo ! end of na (fast loop)
call mpp_clock_end(newClock7)
call mpp_clock_begin(newClock8)
! ------ end of atmospheric time step loop -----
if (do_land .AND. Land%pe) then
if (land_npes .NE. atmos_npes) call mpp_set_current_pelist(Land%pelist)
call update_land_model_slow(Atmos_land_boundary,Land)
endif
if (land_npes .NE. atmos_npes) call mpp_set_current_pelist(Atm%pelist)
!-----------------------------------------------------------------------
call mpp_clock_end(newClock8)
if (do_chksum) call atmos_ice_land_chksum('update_land_slow+', nc, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
!
! need flux call to put runoff and p_surf on ice grid
!
call mpp_clock_begin(newClock9)
call flux_land_to_ice( Time, Land, Ice, Land_ice_boundary )
call mpp_clock_end(newClock9)
if (do_chksum) call atmos_ice_land_chksum('fluxlnd2ice+', nc, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary)
Atmos_ice_boundary%p = 0.0 ! call flux_atmos_to_ice_slow ?
Time = Time_atmos
call mpp_clock_end(newClock5)