-
Notifications
You must be signed in to change notification settings - Fork 371
/
cime_comp_mod.F90
5117 lines (4315 loc) · 223 KB
/
cime_comp_mod.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 cime_comp_mod
!-------------------------------------------------------------------------------
!
! Purpose: Main program for CIME cpl7. Can have different
! land, sea-ice, and ocean models plugged in at compile-time.
! These models can be either: stub, dead, data, or active
! components or some combination of the above.
!
! stub -------- Do nothing.
! dead -------- Send analytic data back.
! data -------- Send data back interpolated from input files.
! prognostic -- Prognostically simulate the given component.
!
! Method: Call appropriate initialization, run (time-stepping), and
! finalization routines.
!
!-------------------------------------------------------------------------------
!----------------------------------------------------------------------------
! share code & libs
!----------------------------------------------------------------------------
use shr_kind_mod, only: r8 => SHR_KIND_R8
use shr_kind_mod, only: i8 => SHR_KIND_I8
use shr_kind_mod, only: cs => SHR_KIND_CS
use shr_kind_mod, only: cl => SHR_KIND_CL
use shr_sys_mod, only: shr_sys_abort, shr_sys_flush, shr_sys_irtc
use shr_const_mod, only: shr_const_cday
use shr_file_mod, only: shr_file_setLogLevel, shr_file_setLogUnit
use shr_file_mod, only: shr_file_setIO, shr_file_getUnit, shr_file_freeUnit
use shr_scam_mod, only: shr_scam_checkSurface
use shr_map_mod, only: shr_map_setDopole
use shr_mpi_mod, only: shr_mpi_min, shr_mpi_max
use shr_mpi_mod, only: shr_mpi_bcast, shr_mpi_commrank, shr_mpi_commsize
use shr_mem_mod, only: shr_mem_init, shr_mem_getusage
use shr_cal_mod, only: shr_cal_date2ymd, shr_cal_ymd2date, shr_cal_advdateInt
use shr_cal_mod, only: shr_cal_ymds2rday_offset
use shr_orb_mod, only: shr_orb_params
use shr_frz_mod, only: shr_frz_freezetemp_init
use shr_reprosum_mod, only: shr_reprosum_setopts
use shr_taskmap_mod, only: shr_taskmap_write
use mct_mod ! mct_ wrappers for mct lib
use perf_mod
use ESMF
!----------------------------------------------------------------------------
! component model interfaces (init, run, final methods)
!----------------------------------------------------------------------------
use atm_comp_mct , only: atm_init=>atm_init_mct, atm_run=>atm_run_mct, atm_final=>atm_final_mct
use lnd_comp_mct , only: lnd_init=>lnd_init_mct, lnd_run=>lnd_run_mct, lnd_final=>lnd_final_mct
use ocn_comp_mct , only: ocn_init=>ocn_init_mct, ocn_run=>ocn_run_mct, ocn_final=>ocn_final_mct
use ice_comp_mct , only: ice_init=>ice_init_mct, ice_run=>ice_run_mct, ice_final=>ice_final_mct
use glc_comp_mct , only: glc_init=>glc_init_mct, glc_run=>glc_run_mct, glc_final=>glc_final_mct
use wav_comp_mct , only: wav_init=>wav_init_mct, wav_run=>wav_run_mct, wav_final=>wav_final_mct
use rof_comp_mct , only: rof_init=>rof_init_mct, rof_run=>rof_run_mct, rof_final=>rof_final_mct
use esp_comp_mct , only: esp_init=>esp_init_mct, esp_run=>esp_run_mct, esp_final=>esp_final_mct
use iac_comp_mct , only: iac_init=>iac_init_mct, iac_run=>iac_run_mct, iac_final=>iac_final_mct
!----------------------------------------------------------------------------
! cpl7 modules
!----------------------------------------------------------------------------
! mpi comm data & routines, plus logunit and loglevel
use seq_comm_mct, only: CPLID, GLOID, logunit, loglevel, info_taskmap_comp, info_taskmap_model, info_mprof, info_mprof_dt
use seq_comm_mct, only: ATMID, LNDID, OCNID, ICEID, GLCID, ROFID, WAVID, ESPID
use seq_comm_mct, only: ALLATMID,ALLLNDID,ALLOCNID,ALLICEID,ALLGLCID,ALLROFID,ALLWAVID,ALLESPID
use seq_comm_mct, only: CPLALLATMID,CPLALLLNDID,CPLALLOCNID,CPLALLICEID
use seq_comm_mct, only: CPLALLGLCID,CPLALLROFID,CPLALLWAVID,CPLALLESPID
use seq_comm_mct, only: CPLATMID,CPLLNDID,CPLOCNID,CPLICEID,CPLGLCID,CPLROFID,CPLWAVID,CPLESPID
use seq_comm_mct, only: IACID, ALLIACID, CPLALLIACID, CPLIACID
use seq_comm_mct, only: num_inst_atm, num_inst_lnd, num_inst_rof
use seq_comm_mct, only: num_inst_ocn, num_inst_ice, num_inst_glc
use seq_comm_mct, only: num_inst_wav, num_inst_esp
use seq_comm_mct, only: num_inst_iac
use seq_comm_mct, only: num_inst_xao, num_inst_frc, num_inst_phys
use seq_comm_mct, only: num_inst_total, num_inst_max
use seq_comm_mct, only: seq_comm_iamin, seq_comm_name, seq_comm_namelen
use seq_comm_mct, only: seq_comm_init, seq_comm_setnthreads, seq_comm_getnthreads
use seq_comm_mct, only: seq_comm_getinfo => seq_comm_setptrs, seq_comm_gloroot
use seq_comm_mct, only: cpl_inst_tag
use seq_comm_mct, only: driver_nnodes, driver_task_node_map
! clock & alarm routines and variables
use seq_timemgr_mod, only: seq_timemgr_type
use seq_timemgr_mod, only: seq_timemgr_clockInit
use seq_timemgr_mod, only: seq_timemgr_clockAdvance
use seq_timemgr_mod, only: seq_timemgr_clockPrint
use seq_timemgr_mod, only: seq_timemgr_EClockGetData
use seq_timemgr_mod, only: seq_timemgr_alarmIsOn
use seq_timemgr_mod, only: seq_timemgr_histavg_type
use seq_timemgr_mod, only: seq_timemgr_type_never
use seq_timemgr_mod, only: seq_timemgr_alarm_restart
use seq_timemgr_mod, only: seq_timemgr_alarm_stop
use seq_timemgr_mod, only: seq_timemgr_alarm_datestop
use seq_timemgr_mod, only: seq_timemgr_alarm_history
use seq_timemgr_mod, only: seq_timemgr_alarm_atmrun
use seq_timemgr_mod, only: seq_timemgr_alarm_lndrun
use seq_timemgr_mod, only: seq_timemgr_alarm_ocnrun
use seq_timemgr_mod, only: seq_timemgr_alarm_icerun
use seq_timemgr_mod, only: seq_timemgr_alarm_glcrun
use seq_timemgr_mod, only: seq_timemgr_alarm_glcrun_avg
use seq_timemgr_mod, only: seq_timemgr_alarm_ocnnext
use seq_timemgr_mod, only: seq_timemgr_alarm_tprof
use seq_timemgr_mod, only: seq_timemgr_alarm_histavg
use seq_timemgr_mod, only: seq_timemgr_alarm_rofrun
use seq_timemgr_mod, only: seq_timemgr_alarm_wavrun
use seq_timemgr_mod, only: seq_timemgr_alarm_esprun
use seq_timemgr_mod, only: seq_timemgr_alarm_iacrun
use seq_timemgr_mod, only: seq_timemgr_alarm_barrier
use seq_timemgr_mod, only: seq_timemgr_alarm_pause
use seq_timemgr_mod, only: seq_timemgr_pause_active
use seq_timemgr_mod, only: seq_timemgr_pause_component_active
use seq_timemgr_mod, only: seq_timemgr_pause_component_index
! "infodata" gathers various control flags into one datatype
use seq_infodata_mod, only: seq_infodata_putData, seq_infodata_GetData
use seq_infodata_mod, only: seq_infodata_init, seq_infodata_exchange
use seq_infodata_mod, only: seq_infodata_type, seq_infodata_orb_variable_year
use seq_infodata_mod, only: seq_infodata_print, seq_infodata_init2
! domain related routines
use seq_domain_mct, only : seq_domain_check
! history file routines
use seq_hist_mod, only : seq_hist_write, seq_hist_writeavg, seq_hist_writeaux
! restart file routines
use seq_rest_mod, only : seq_rest_read, seq_rest_write
! flux calc routines
use seq_flux_mct, only: seq_flux_init_mct, seq_flux_initexch_mct, seq_flux_ocnalb_mct
use seq_flux_mct, only: seq_flux_atmocn_mct, seq_flux_atmocnexch_mct, seq_flux_readnl_mct
! domain fraction routines
use seq_frac_mct, only : seq_frac_init, seq_frac_set
! i/o subroutines
use seq_io_mod, only : seq_io_cpl_init
! rearrange type routines
use cplcomp_exchange_mod, only: seq_mctext_decomp
! diagnostic routines
use seq_diag_mct, only : seq_diag_zero_mct , seq_diag_avect_mct, seq_diag_lnd_mct
use seq_diag_mct, only : seq_diag_rof_mct , seq_diag_ocn_mct , seq_diag_atm_mct
use seq_diag_mct, only : seq_diag_ice_mct , seq_diag_accum_mct, seq_diag_print_mct
use seq_diagBGC_mct, only : seq_diagBGC_zero_mct , seq_diagBGC_avect_mct, seq_diagBGC_lnd_mct
use seq_diagBGC_mct, only : seq_diagBGC_rof_mct , seq_diagBGC_ocn_mct , seq_diagBGC_atm_mct
use seq_diagBGC_mct, only : seq_diagBGC_ice_mct , seq_diagBGC_accum_mct
! list of fields transferred between components
use seq_flds_mod, only : seq_flds_a2x_fluxes, seq_flds_x2a_fluxes
use seq_flds_mod, only : seq_flds_i2x_fluxes, seq_flds_x2i_fluxes
use seq_flds_mod, only : seq_flds_l2x_fluxes, seq_flds_x2l_fluxes
use seq_flds_mod, only : seq_flds_o2x_fluxes, seq_flds_x2o_fluxes
use seq_flds_mod, only : seq_flds_g2x_fluxes, seq_flds_x2g_fluxes
use seq_flds_mod, only : seq_flds_w2x_fluxes, seq_flds_x2w_fluxes
use seq_flds_mod, only : seq_flds_r2x_fluxes, seq_flds_x2r_fluxes
use seq_flds_mod, only : seq_flds_set
use seq_flds_mod, only : seq_flds_z2x_fluxes, seq_flds_x2z_fluxes
! component type and accessor functions
use component_type_mod, only: component_get_iamin_compid, component_get_suffix
use component_type_mod, only: component_get_iamroot_compid
use component_type_mod, only: component_get_name, component_get_c2x_cx
use component_type_mod, only: atm, lnd, ice, ocn, rof, glc, wav, esp, iac
use component_mod, only: component_init_pre
use component_mod, only: component_init_cc, component_init_cx
use component_mod, only: component_run, component_final
use component_mod, only: component_init_areacor, component_init_aream
use component_mod, only: component_exch, component_diag
! prep routines (includes mapping routines between components and merging routines)
use prep_lnd_mod
use prep_ice_mod
use prep_wav_mod
use prep_rof_mod
use prep_glc_mod
use prep_ocn_mod
use prep_atm_mod
use prep_aoflux_mod
use prep_iac_mod
!--- mapping routines ---
use seq_map_type_mod
use seq_map_mod ! generic mapping
! --- timing routines ---
use t_drv_timers_mod
! --- control variables ---
use seq_flds_mod, only : rof_heat
implicit none
private
! public data
public :: timing_dir
public :: mpicom_GLOID
public :: cime_pre_init2_lb
! public routines
public :: cime_pre_init1
public :: cime_pre_init2
public :: cime_init
public :: cime_run
public :: cime_final
! private routines
private :: cime_esmf_readnl
private :: cime_printlogheader
private :: cime_comp_barriers
private :: cime_cpl_init
private :: cime_run_atmocn_fluxes
private :: cime_run_ocn_albedos
private :: cime_run_atm_setup_send
private :: cime_run_atm_recv_post
private :: cime_run_ocn_setup_send
private :: cime_run_ocn_recv_post
private :: cime_run_atmocn_setup
private :: cime_run_lnd_setup_send
private :: cime_run_lnd_recv_post
private :: cime_run_glc_setup_send
private :: cime_run_glc_accum_avg
private :: cime_run_glc_recv_post
private :: cime_run_rof_setup_send
private :: cime_run_rof_recv_post
private :: cime_run_ice_setup_send
private :: cime_run_ice_recv_post
private :: cime_run_wav_setup_send
private :: cime_run_wav_recv_post
private :: cime_run_iac_setup_send
private :: cime_run_iac_recv_post
private :: cime_run_update_fractions
private :: cime_run_calc_budgets1
private :: cime_run_calc_budgets2
private :: cime_run_calc_budgets3
private :: cime_run_write_history
private :: cime_run_write_restart
private :: cime_write_performance_checkpoint
#include <mpif.h>
!----------------------------------------------------------------------------
! temporary variables
!----------------------------------------------------------------------------
!- from prep routines (arrays of instances)
type(mct_aVect) , pointer :: a2x_ox(:) => null()
type(mct_aVect) , pointer :: o2x_ax(:) => null()
type(mct_aVect) , pointer :: xao_ox(:) => null()
type(mct_aVect) , pointer :: xao_ax(:) => null()
!- from component type (single instance inside array of components)
type(mct_aVect) , pointer :: o2x_ox => null()
type(mct_aVect) , pointer :: a2x_ax => null()
character(len=CL) :: inst_suffix
logical :: iamin_id
character(len=seq_comm_namelen) :: compname
!----------------------------------------------------------------------------
! domains & related
!----------------------------------------------------------------------------
!--- domain fractions (only defined on cpl pes) ---
type(mct_aVect) , pointer :: fractions_ax(:) ! Fractions on atm grid, cpl processes
type(mct_aVect) , pointer :: fractions_lx(:) ! Fractions on lnd grid, cpl processes
type(mct_aVect) , pointer :: fractions_ix(:) ! Fractions on ice grid, cpl processes
type(mct_aVect) , pointer :: fractions_ox(:) ! Fractions on ocn grid, cpl processes
type(mct_aVect) , pointer :: fractions_gx(:) ! Fractions on glc grid, cpl processes
type(mct_aVect) , pointer :: fractions_rx(:) ! Fractions on rof grid, cpl processes
type(mct_aVect) , pointer :: fractions_wx(:) ! Fractions on wav grid, cpl processes
type(mct_aVect) , pointer :: fractions_zx(:) ! Fractions on iac grid, cpl processes
!--- domain equivalent 2d grid size ---
integer :: atm_nx, atm_ny ! nx, ny of 2d grid, if known
integer :: lnd_nx, lnd_ny
integer :: ice_nx, ice_ny
integer :: ocn_nx, ocn_ny
integer :: rof_nx, rof_ny
integer :: glc_nx, glc_ny
integer :: wav_nx, wav_ny
integer :: iac_nx, iac_ny
!----------------------------------------------------------------------------
! Infodata: inter-model control flags, domain info
!----------------------------------------------------------------------------
type (seq_infodata_type), target :: infodata ! single instance for cpl and all comps
!----------------------------------------------------------------------------
! time management
!----------------------------------------------------------------------------
type (seq_timemgr_type), SAVE :: seq_SyncClock ! array of all clocks & alarm
type (ESMF_Clock), target :: EClock_d ! driver clock
type (ESMF_Clock), target :: EClock_a ! atmosphere clock
type (ESMF_Clock), target :: EClock_l ! land clock
type (ESMF_Clock), target :: EClock_o ! ocean clock
type (ESMF_Clock), target :: EClock_i ! ice clock
type (ESMF_Clock), target :: EClock_g ! glc clock
type (ESMF_Clock), target :: EClock_r ! rof clock
type (ESMF_Clock), target :: EClock_w ! wav clock
type (ESMF_Clock), target :: EClock_e ! esp clock
type (ESMF_Clock), target :: EClock_z ! iac clock
logical :: restart_alarm ! restart alarm
logical :: history_alarm ! history alarm
logical :: histavg_alarm ! history alarm
logical :: stop_alarm ! stop alarm
logical :: atmrun_alarm ! atm run alarm
logical :: lndrun_alarm ! lnd run alarm
logical :: icerun_alarm ! ice run alarm
logical :: ocnrun_alarm ! ocn run alarm
logical :: ocnnext_alarm ! ocn run alarm on next timestep
logical :: glcrun_alarm ! glc run alarm
logical :: glcrun_avg_alarm ! glc run averaging alarm
logical :: rofrun_alarm ! rof run alarm
logical :: wavrun_alarm ! wav run alarm
logical :: esprun_alarm ! esp run alarm
logical :: iacrun_alarm ! iac run alarm
logical :: tprof_alarm ! timing profile alarm
logical :: barrier_alarm ! barrier alarm
logical :: t1hr_alarm ! alarm every hour
logical :: t2hr_alarm ! alarm every two hours
logical :: t3hr_alarm ! alarm every three hours
logical :: t6hr_alarm ! alarm every six hours
logical :: t12hr_alarm ! alarm every twelve hours
logical :: t24hr_alarm ! alarm every twentyfour hours
logical :: t1yr_alarm ! alarm every year, at start of year
logical :: pause_alarm ! pause alarm
logical :: write_hist_alarm ! alarm to write a history file under multiple conditions
integer :: drv_index ! seq_timemgr index for driver
real(r8) :: days_per_year = 365.0 ! days per year
integer :: dtime ! dt of one coupling interval
integer :: ncpl ! number of coupling intervals per day
integer :: ymd ! Current date (YYYYMMDD)
integer :: year ! Current date (YYYY)
integer :: month ! Current date (MM)
integer :: day ! Current date (DD)
integer :: tod ! Current time of day (seconds)
integer :: ymdtmp ! temporary date (YYYYMMDD)
integer :: todtmp ! temporary time of day (seconds)
character(CL) :: orb_mode ! orbital mode
character(CS) :: tfreeze_option ! Freezing point calculation
integer :: orb_iyear ! orbital year
integer :: orb_iyear_align ! associated with model year
integer :: orb_cyear ! orbital year for current orbital computation
integer :: orb_nyear ! orbital year associated with currrent model year
real(r8) :: orb_eccen ! orbital eccentricity
real(r8) :: orb_obliq ! obliquity in degrees
real(r8) :: orb_mvelp ! moving vernal equinox long
real(r8) :: orb_obliqr ! Earths obliquity in rad
real(r8) :: orb_lambm0 ! Mean long of perihelion at vernal equinox (radians)
real(r8) :: orb_mvelpp ! moving vernal equinox long
real(r8) :: wall_time_limit ! wall time limit in hours
real(r8) :: wall_time ! current wall time used
character(CS) :: force_stop_at ! force stop at next (month, day, etc)
logical :: force_stop ! force the model to stop
integer :: force_stop_ymd ! force stop ymd
integer :: force_stop_tod ! force stop tod
!--- for documenting speed of the model ---
character(8) :: dstr ! date string
character(10) :: tstr ! time string
integer :: begStep, endStep ! Begining and ending step number
character(CL) :: calendar ! calendar name
real(r8) :: simDays ! Number of simulated days
real(r8) :: SYPD ! Simulated years per day
real(r8) :: Time_begin ! Start time
real(r8) :: Time_end ! Ending time
real(r8) :: Time_bstep ! Start time
real(r8) :: Time_estep ! Ending time
real(r8) :: time_brun ! Start time
real(r8) :: time_erun ! Ending time
real(r8) :: cktime ! delta time
real(r8) :: cktime_acc(10) ! cktime accumulator array 1 = all, 2 = atm, etc
integer :: cktime_cnt(10) ! cktime counter array
real(r8) :: max_cplstep_time
real(r8) :: mpi_init_time ! time elapsed in mpi_init call
real(r8) :: cime_pre_init2_lb ! time elapsed in cime_pre_init2 call after call to t_initf
character(CL) :: timing_file ! Local path to tprof filename
character(CL) :: timing_dir ! timing directory
character(CL) :: tchkpt_dir ! timing checkpoint directory
!----------------------------------------------------------------------------
! control flags
!----------------------------------------------------------------------------
logical :: atm_present ! .true. => atm is present
logical :: lnd_present ! .true. => land is present
logical :: ice_present ! .true. => ice is present
logical :: ocn_present ! .true. => ocn is present
logical :: glc_present ! .true. => glc is present
logical :: glclnd_present ! .true. => glc is computing land coupling
logical :: glcocn_present ! .true. => glc is computing ocean runoff
logical :: glcice_present ! .true. => glc is computing icebergs
logical :: rofice_present ! .true. => rof is computing icebergs
logical :: rof_present ! .true. => rof is present
logical :: flood_present ! .true. => rof is computing flood
logical :: wav_present ! .true. => wav is present
logical :: esp_present ! .true. => esp is present
logical :: iac_present ! .true. => iac is present
logical :: atm_prognostic ! .true. => atm comp expects input
logical :: lnd_prognostic ! .true. => lnd comp expects input
logical :: ice_prognostic ! .true. => ice comp expects input
logical :: iceberg_prognostic ! .true. => ice comp can handle iceberg input
logical :: ocn_prognostic ! .true. => ocn comp expects input
logical :: ocnrof_prognostic ! .true. => ocn comp expects runoff input
logical :: glc_prognostic ! .true. => glc comp expects input
logical :: rof_prognostic ! .true. => rof comp expects input
logical :: rofocn_prognostic ! .true. => rof comp expects ssh input
logical :: wav_prognostic ! .true. => wav comp expects input
logical :: esp_prognostic ! .true. => esp comp expects input
logical :: iac_prognostic ! .true. => iac comp expects input
logical :: atm_c2_lnd ! .true. => atm to lnd coupling on
logical :: atm_c2_rof ! .true. => atm to rof coupling on
logical :: atm_c2_ocn ! .true. => atm to ocn coupling on
logical :: atm_c2_ice ! .true. => atm to ice coupling on
logical :: atm_c2_wav ! .true. => atm to wav coupling on
logical :: lnd_c2_atm ! .true. => lnd to atm coupling on
logical :: lnd_c2_rof ! .true. => lnd to rof coupling on
logical :: lnd_c2_glc ! .true. => lnd to glc coupling on
logical :: ocn_c2_atm ! .true. => ocn to atm coupling on
logical :: ocn_c2_ice ! .true. => ocn to ice coupling on
logical :: ocn_c2_glcshelf ! .true. => ocn to glc ice shelf coupling on
logical :: ocn_c2_wav ! .true. => ocn to wav coupling on
logical :: ocn_c2_rof ! .true. => ocn to rof coupling on
logical :: ice_c2_atm ! .true. => ice to atm coupling on
logical :: ice_c2_ocn ! .true. => ice to ocn coupling on
logical :: ice_c2_wav ! .true. => ice to wav coupling on
logical :: rof_c2_lnd ! .true. => rof to lnd coupling on
logical :: rof_c2_ocn ! .true. => rof to ocn coupling on
logical :: rof_c2_ice ! .true. => rof to ice coupling on
logical :: glc_c2_lnd ! .true. => glc to lnd coupling on
logical :: glc_c2_ocn ! .true. => glc to ocn coupling on
logical :: glc_c2_ice ! .true. => glc to ice coupling on
logical :: glcshelf_c2_ocn ! .true. => glc ice shelf to ocn coupling on
logical :: glcshelf_c2_ice ! .true. => glc ice shelf to ice coupling on
logical :: wav_c2_ocn ! .true. => wav to ocn coupling on
logical :: iac_c2_lnd ! .true. => iac to lnd coupling on
logical :: iac_c2_atm ! .true. => iac to atm coupling on
logical :: lnd_c2_iac ! .true. => lnd to iac coupling on
logical :: dead_comps ! .true. => dead components
logical :: esmf_map_flag ! .true. => use esmf for mapping
logical :: areafact_samegrid ! areafact samegrid flag
logical :: single_column ! scm mode logical
logical :: scm_multcols ! scm mode over multiple columns logical
real(r8) :: scmlon ! single column lon
real(r8) :: scmlat ! single column lat
integer :: scm_nx ! points in x direction for SCM functionality
integer :: scm_ny ! points in y direction for SCM functionality
logical :: aqua_planet ! aqua planet mode
real(r8) :: nextsw_cday ! radiation control
logical :: atm_aero ! atm provides aerosol data
character(CL) :: cpl_seq_option ! coupler sequencing option
logical :: skip_ocean_run ! skip the ocean model first pass
logical :: cpl2ocn_first ! use to call initial cpl2ocn timer
logical :: run_barriers ! barrier the component run calls
character(CS) :: aoflux_grid ! grid for a/o flux calc: atm xor ocn
character(CS) :: vect_map ! vector mapping type
character(CL) :: atm_gnam ! atm grid
character(CL) :: lnd_gnam ! lnd grid
character(CL) :: ocn_gnam ! ocn grid
character(CL) :: ice_gnam ! ice grid
character(CL) :: rof_gnam ! rof grid
character(CL) :: glc_gnam ! glc grid
character(CL) :: wav_gnam ! wav grid
character(CL) :: iac_gnam ! iac grid
logical :: samegrid_ao ! samegrid atm and ocean
logical :: samegrid_al ! samegrid atm and land
logical :: samegrid_lr ! samegrid land and rof
logical :: samegrid_oi ! samegrid ocean and ice
logical :: samegrid_ro ! samegrid runoff and ocean
logical :: samegrid_aw ! samegrid atm and wave
logical :: samegrid_ow ! samegrid ocean and wave
logical :: samegrid_lg ! samegrid glc and land
logical :: samegrid_og ! samegrid glc and ocean
logical :: samegrid_ig ! samegrid glc and ice
logical :: samegrid_alo ! samegrid atm, lnd, ocean
logical :: samegrid_zl ! samegrid iac and land
logical :: read_restart ! local read restart flag
character(CL) :: rest_file ! restart file path + filename
logical :: shr_map_dopole ! logical for dopole in shr_map_mod
logical :: domain_check ! .true. => check consistency of domains
logical :: reprosum_use_ddpdd ! setup reprosum, use ddpdd
logical :: reprosum_allow_infnan ! setup reprosum, allow INF and NaN in summands
real(r8) :: reprosum_diffmax ! setup reprosum, set rel_diff_max
logical :: reprosum_recompute ! setup reprosum, recompute if tolerance exceeded
logical :: output_perf = .false. ! require timing data output for this pe
logical :: in_first_day = .true. ! currently simulating first day
!--- history & budgets ---
logical :: do_budgets ! heat/water budgets on
logical :: do_bgc_budgets ! BGC budgets on
logical :: do_histinit ! initial hist file
logical :: do_histavg ! histavg on or off
logical :: do_hist_r2x ! create aux files: r2x
logical :: do_hist_l2x ! create aux files: l2x
logical :: do_hist_a2x24hr ! create aux files: a2x
logical :: do_hist_l2x1yrg ! create aux files: l2x 1yr glc forcings
logical :: do_hist_a2x ! create aux files: a2x
logical :: do_hist_a2x3hrp ! create aux files: a2x 3hr precip
logical :: do_hist_a2x3hr ! create aux files: a2x 3hr states
logical :: do_hist_a2x1hri ! create aux files: a2x 1hr instantaneous
logical :: do_hist_a2x1hr ! create aux files: a2x 1hr
integer :: budget_inst ! instantaneous budget flag
integer :: budget_daily ! daily budget flag
integer :: budget_month ! monthly budget flag
integer :: budget_ann ! annual budget flag
integer :: budget_ltann ! long term budget flag for end of year writing
integer :: budget_ltend ! long term budget flag for end of run writing
character(CL) :: hist_a2x_flds = &
'Faxa_swndr:Faxa_swvdr:Faxa_swndf:Faxa_swvdf'
character(CL) :: hist_a2x3hrp_flds = &
'Faxa_rainc:Faxa_rainl:Faxa_snowc:Faxa_snowl'
character(CL) :: hist_a2x24hr_flds = &
'Faxa_bcphiwet:Faxa_bcphodry:Faxa_bcphidry:Faxa_ocphiwet:Faxa_ocphidry:&
&Faxa_ocphodry:Faxa_dstwet1:Faxa_dstdry1:Faxa_dstwet2:Faxa_dstdry2:Faxa_dstwet3:&
&Faxa_dstdry3:Faxa_dstwet4:Faxa_dstdry4:Sa_co2prog:Sa_co2diag'
character(CL) :: hist_a2x1hri_flds = &
'Faxa_swndr:Faxa_swvdr:Faxa_swndf:Faxa_swvdf'
character(CL) :: hist_a2x1hr_flds = &
'Sa_u:Sa_v'
character(CL) :: hist_a2x3hr_flds = &
'Sa_z:Sa_topo:Sa_u:Sa_v:Sa_tbot:Sa_ptem:Sa_shum:Sa_dens:Sa_pbot:Sa_pslv:Faxa_lwdn:&
&Faxa_rainc:Faxa_rainl:Faxa_snowc:Faxa_snowl:&
&Faxa_swndr:Faxa_swvdr:Faxa_swndf:Faxa_swvdf:&
&Sa_co2diag:Sa_co2prog'
! --- other ---
character(len=cs) :: cime_model
integer :: driver_id ! ID for multi-driver setup
integer :: ocnrun_count ! number of times ocn run alarm went on
logical :: exists ! true if file exists
integer :: ierr ! MPI error return
character(*), parameter :: NLFileName = "drv_in" ! input namelist filename
integer :: info_debug = 0 ! local info_debug level
!----------------------------------------------------------------------------
! memory monitoring
!----------------------------------------------------------------------------
real(r8) :: msize,msize0,msize1 ! memory size (high water)
real(r8) :: mrss ,mrss0 ,mrss1 ! resident size (current memory use)
real(r8),allocatable :: msizeOnTask(:),mrssOnTask(:) ! msize,mrss on each MPI task
real(r8),allocatable :: msizeOnNode(:),mrssOnNode(:) ! msize,mrss on each node
integer :: mlog
!----------------------------------------------------------------------------
! threading control
!----------------------------------------------------------------------------
integer :: nthreads_GLOID ! OMP global number of threads
integer :: nthreads_CPLID ! OMP cpl number of threads
integer :: nthreads_ATMID ! OMP atm number of threads
integer :: nthreads_LNDID ! OMP lnd number of threads
integer :: nthreads_ICEID ! OMP ice number of threads
integer :: nthreads_OCNID ! OMP ocn number of threads
integer :: nthreads_GLCID ! OMP glc number of threads
integer :: nthreads_ROFID ! OMP glc number of threads
integer :: nthreads_WAVID ! OMP wav number of threads
integer :: nthreads_ESPID ! OMP esp number of threads
integer :: nthreads_IACID ! OMP iac number of threads
integer :: pethreads_GLOID ! OMP number of threads per task
logical :: drv_threading ! driver threading control
!----------------------------------------------------------------------------
! communicator groups and related
!----------------------------------------------------------------------------
integer :: global_comm
integer :: mpicom_GLOID ! MPI global communicator
integer :: mpicom_CPLID ! MPI cpl communicator
integer :: mpicom_OCNID ! MPI ocn communicator for ensemble member 1
integer :: mpicom_CPLALLATMID ! MPI comm for CPLALLATMID
integer :: mpicom_CPLALLLNDID ! MPI comm for CPLALLLNDID
integer :: mpicom_CPLALLICEID ! MPI comm for CPLALLICEID
integer :: mpicom_CPLALLOCNID ! MPI comm for CPLALLOCNID
integer :: mpicom_CPLALLGLCID ! MPI comm for CPLALLGLCID
integer :: mpicom_CPLALLROFID ! MPI comm for CPLALLROFID
integer :: mpicom_CPLALLWAVID ! MPI comm for CPLALLWAVID
integer :: mpicom_CPLALLIACID ! MPI comm for CPLALLIACID
integer :: iam_GLOID ! pe number in global id
integer :: npes_GLOID ! global number of pes
logical :: iamin_CPLID ! pe associated with CPLID
logical :: iamroot_GLOID ! GLOID masterproc
logical :: iamroot_CPLID ! CPLID masterproc
logical :: iamin_CPLALLATMID ! pe associated with CPLALLATMID
logical :: iamin_CPLALLLNDID ! pe associated with CPLALLLNDID
logical :: iamin_CPLALLICEID ! pe associated with CPLALLICEID
logical :: iamin_CPLALLOCNID ! pe associated with CPLALLOCNID
logical :: iamin_CPLALLGLCID ! pe associated with CPLALLGLCID
logical :: iamin_CPLALLROFID ! pe associated with CPLALLROFID
logical :: iamin_CPLALLWAVID ! pe associated with CPLALLWAVID
logical :: iamin_CPLALLIACID ! pe associated with CPLALLIACID
integer :: atm_rootpe,lnd_rootpe,ice_rootpe,ocn_rootpe,&
glc_rootpe,rof_rootpe,wav_rootpe,iac_rootpe
!----------------------------------------------------------------------------
! complist: list of comps on this pe
!----------------------------------------------------------------------------
! allow enough room for names of all physical components + coupler,
! where each string can be up to (max_inst_name_len+1) characters
! long (+1 allows for a space before each name)
character(len=(seq_comm_namelen+1)*(num_inst_phys+1)) :: complist
!----------------------------------------------------------------------------
! comp_num_<comp>: unique component number for each component type
!----------------------------------------------------------------------------
integer, parameter :: comp_num_atm = 1
integer, parameter :: comp_num_lnd = 2
integer, parameter :: comp_num_ice = 3
integer, parameter :: comp_num_ocn = 4
integer, parameter :: comp_num_glc = 5
integer, parameter :: comp_num_rof = 6
integer, parameter :: comp_num_wav = 7
integer, parameter :: comp_num_esp = 8
integer, parameter :: comp_num_iac = 9
!----------------------------------------------------------------------------
! misc
!----------------------------------------------------------------------------
integer, parameter :: ens1=1 ! use first instance of ensemble only
integer, parameter :: fix1=1 ! temporary hard-coding to first ensemble, needs to be fixed
integer :: eai, eli, eoi, eii, egi, eri, ewi, eei, exi, efi, ezi ! component instance counters
!----------------------------------------------------------------------------
! formats
!----------------------------------------------------------------------------
character(*), parameter :: subname = '(seq_mct_drv)'
character(*), parameter :: F00 = "('"//subname//" : ', 4A )"
character(*), parameter :: F0L = "('"//subname//" : ', A, L6 )"
character(*), parameter :: F01 = "('"//subname//" : ', A, 2i8, 3x, A )"
character(*), parameter :: F0R = "('"//subname//" : ', A, 2g23.15 )"
character(*), parameter :: FormatA = '(A,": =============== ", A44, " ===============")'
character(*), parameter :: FormatD = '(A,": =============== ", A20,I10.8,I8,6x, " ===============")'
character(*), parameter :: FormatR = '(A,": =============== ", A31,F12.3,1x, " ===============")'
character(*), parameter :: FormatQ = '(A,": =============== ", A20,2F10.2,4x," ===============")'
!===============================================================================
contains
!===============================================================================
!===============================================================================
!*******************************************************************************
!===============================================================================
subroutine cime_pre_init1(esmf_log_option)
use shr_pio_mod, only : shr_pio_init1, shr_pio_init2
use seq_comm_mct, only: num_inst_driver
!----------------------------------------------------------
!| Initialize MCT and MPI communicators and IO
!----------------------------------------------------------
character(CS), intent(out) :: esmf_log_option ! For esmf_logfile_kind
integer, dimension(num_inst_total) :: comp_id, comp_comm, comp_comm_iam
logical :: comp_iamin(num_inst_total)
character(len=seq_comm_namelen) :: comp_name(num_inst_total)
integer :: it
integer :: driver_comm
integer :: npes_CPLID
logical :: verbose_taskmap_output
character(len=8) :: c_cpl_inst ! coupler instance number
character(len=8) :: c_cpl_npes ! number of pes in coupler
integer(i8) :: beg_count ! start time
integer(i8) :: end_count ! end time
integer(i8) :: irtc_rate ! factor to convert time to seconds
beg_count = shr_sys_irtc(irtc_rate)
call mpi_init(ierr)
call shr_mpi_chkerr(ierr,subname//' mpi_init')
end_count = shr_sys_irtc(irtc_rate)
mpi_init_time = real( (end_count-beg_count), r8)/real(irtc_rate, r8)
call mpi_comm_dup(MPI_COMM_WORLD, global_comm, ierr)
call shr_mpi_chkerr(ierr,subname//' mpi_comm_dup')
comp_comm = MPI_COMM_NULL
time_brun = mpi_wtime()
!--- Initialize multiple driver instances, if requested ---
call cime_cpl_init(global_comm, driver_comm, num_inst_driver, driver_id)
call shr_pio_init1(num_inst_total,NLFileName, driver_comm)
!
! If pio_async_interface is true Global_comm is MPI_COMM_NULL on the servernodes
! and server nodes do not return from shr_pio_init2
!
! if (Global_comm /= MPI_COMM_NULL) then
if (num_inst_driver > 1) then
call seq_comm_init(global_comm, driver_comm, NLFileName, drv_comm_ID=driver_id)
write(cpl_inst_tag,'("_",i4.4)') driver_id
else
call seq_comm_init(global_comm, driver_comm, NLFileName)
cpl_inst_tag = ''
end if
!--- set task based threading counts ---
call seq_comm_getinfo(GLOID,pethreads=pethreads_GLOID,iam=iam_GLOID,npes=npes_GLOID)
call seq_comm_setnthreads(pethreads_GLOID)
!--- get some general data ---
it=1
call seq_comm_getinfo(GLOID,mpicom=mpicom_GLOID,&
iamroot=iamroot_GLOID,nthreads=nthreads_GLOID)
if (iamroot_GLOID) output_perf = .true.
call seq_comm_getinfo(CPLID,mpicom=mpicom_CPLID,&
iamroot=iamroot_CPLID,npes=npes_CPLID, &
nthreads=nthreads_CPLID,iam=comp_comm_iam(it))
if (iamroot_CPLID) output_perf = .true.
comp_id(it) = CPLID
comp_comm(it) = mpicom_CPLID
iamin_CPLID = seq_comm_iamin(CPLID)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
atm_rootpe = seq_comm_gloroot(ALLATMID)
lnd_rootpe = seq_comm_gloroot(ALLLNDID)
ice_rootpe = seq_comm_gloroot(ALLICEID)
ocn_rootpe = seq_comm_gloroot(ALLOCNID)
glc_rootpe = seq_comm_gloroot(ALLGLCID)
rof_rootpe = seq_comm_gloroot(ALLROFID)
wav_rootpe = seq_comm_gloroot(ALLWAVID)
iac_rootpe = seq_comm_gloroot(ALLIACID)
do eai = 1,num_inst_atm
it=it+1
comp_id(it) = ATMID(eai)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(ATMID(eai), mpicom=comp_comm(it), &
nthreads=nthreads_ATMID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(ATMID(eai))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLATMID, mpicom=mpicom_CPLALLATMID)
iamin_CPLALLATMID = seq_comm_iamin(CPLALLATMID)
do eli = 1,num_inst_lnd
it=it+1
comp_id(it) = LNDID(eli)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(LNDID(eli), mpicom=comp_comm(it), &
nthreads=nthreads_LNDID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(LNDID(eli))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLLNDID, mpicom=mpicom_CPLALLLNDID)
iamin_CPLALLLNDID = seq_comm_iamin(CPLALLLNDID)
do eoi = 1,num_inst_ocn
it=it+1
comp_id(it) = OCNID(eoi)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(OCNID(eoi), mpicom=comp_comm(it), &
nthreads=nthreads_OCNID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(OCNID(eoi))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLOCNID, mpicom=mpicom_CPLALLOCNID)
iamin_CPLALLOCNID = seq_comm_iamin(CPLALLOCNID)
do eii = 1,num_inst_ice
it=it+1
comp_id(it) = ICEID(eii)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(ICEID(eii), mpicom=comp_comm(it), &
nthreads=nthreads_ICEID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(ICEID(eii))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLICEID, mpicom=mpicom_CPLALLICEID)
iamin_CPLALLICEID = seq_comm_iamin(CPLALLICEID)
do egi = 1,num_inst_glc
it=it+1
comp_id(it) = GLCID(egi)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(GLCID(egi), mpicom=comp_comm(it), nthreads=nthreads_GLCID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(GLCID(egi))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLGLCID, mpicom=mpicom_CPLALLGLCID)
iamin_CPLALLGLCID = seq_comm_iamin(CPLALLGLCID)
do eri = 1,num_inst_rof
it=it+1
comp_id(it) = ROFID(eri)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(ROFID(eri), mpicom=comp_comm(it), &
nthreads=nthreads_ROFID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(ROFID(eri))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLROFID, mpicom=mpicom_CPLALLROFID)
iamin_CPLALLROFID = seq_comm_iamin(CPLALLROFID)
do ewi = 1,num_inst_wav
it=it+1
comp_id(it) = WAVID(ewi)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(WAVID(ewi), mpicom=comp_comm(it), &
nthreads=nthreads_WAVID, iam=comp_comm_iam(it))
if (seq_comm_iamroot(WAVID(ewi))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLWAVID, mpicom=mpicom_CPLALLWAVID)
iamin_CPLALLWAVID = seq_comm_iamin(CPLALLWAVID)
! IAC mods
do ezi = 1,num_inst_iac
it=it+1
comp_id(it) = IACID(ezi)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(IACID(ezi), mpicom=comp_comm(it), &
nthreads=nthreads_IACID, iam=comp_comm_iam(it))
if (seq_comm_iamin(IACID(ezi))) then
complist = trim(complist)//' '//trim(seq_comm_name(IACID(ezi)))
endif
if (seq_comm_iamroot(IACID(ezi))) output_perf = .true.
enddo
call seq_comm_getinfo(CPLALLIACID, mpicom=mpicom_CPLALLIACID)
iamin_CPLALLIACID = seq_comm_iamin(CPLALLIACID)
do eei = 1,num_inst_esp
it=it+1
comp_id(it) = ESPID(eei)
comp_iamin(it) = seq_comm_iamin(comp_id(it))
comp_name(it) = seq_comm_name(comp_id(it))
call seq_comm_getinfo(ESPID(eei), mpicom=comp_comm(it), &
nthreads=nthreads_ESPID, iam=comp_comm_iam(it))
enddo
! ESP components do not use the coupler (they are 'external')
!----------------------------------------------------------
!| Set logging parameters both for shr code and locally
!----------------------------------------------------------
if (iamroot_CPLID) then
inquire(file='cpl_modelio.nml'//trim(cpl_inst_tag),exist=exists)
if (exists) then
logunit = shr_file_getUnit()
call shr_file_setIO('cpl_modelio.nml'//trim(cpl_inst_tag),logunit)
call shr_file_setLogUnit(logunit)
loglevel = 1
call shr_file_setLogLevel(loglevel)
endif
else
loglevel = 0
call shr_file_setLogLevel(loglevel)
endif
!----------------------------------------------------------
!| Output task-to-node mapping data for coupler
!----------------------------------------------------------
if (info_taskmap_comp > 0) then
! Identify SMP nodes and process/SMP mapping for the coupler.
! (Assume that processor names are SMP node names on SMP clusters.)
if (iamin_CPLID) then
if (info_taskmap_comp == 1) then
verbose_taskmap_output = .false.
else
verbose_taskmap_output = .true.
endif
write(c_cpl_inst,'(i8)') num_inst_driver
if (iamroot_CPLID) then
write(c_cpl_npes,'(i8)') npes_CPLID
write(logunit,'(3A)') trim(adjustl(c_cpl_npes)), &
' pes participating in computation of CPL instance #', &
trim(adjustl(c_cpl_inst))
call shr_sys_flush(logunit)
endif
call t_startf("shr_taskmap_write")
call shr_taskmap_write(logunit, mpicom_CPLID, &
'CPL #'//trim(adjustl(c_cpl_inst)), &
verbose=verbose_taskmap_output )
call t_stopf("shr_taskmap_write")
endif
endif
!----------------------------------------------------------
! Log info about the environment settings
!----------------------------------------------------------
if (iamroot_CPLID) then
#ifdef USE_ESMF_LIB
write(logunit,'(2A)') subname,' USE_ESMF_LIB is set'
#else
write(logunit,'(2A)') subname,' USE_ESMF_LIB is NOT set, using esmf_wrf_timemgr'
#endif
write(logunit,'(2A)') subname,' MCT_INTERFACE is set'
if (num_inst_driver > 1) &
write(logunit,'(2A,I0,A)') subname,' Driver is running with',num_inst_driver,'instances'
endif
!----------------------------------------------------------
! Read ESMF namelist settings
!----------------------------------------------------------
call cime_esmf_readnl(NLFileName, mpicom_GLOID, esmf_log_option)
!
! When using io servers (pio_async_interface=.true.) the server tasks do not return from
! shr_pio_init2
!
call shr_pio_init2(comp_id,comp_name,comp_iamin,comp_comm,comp_comm_iam)
end subroutine cime_pre_init1
!===============================================================================
subroutine cime_esmf_readnl(NLFileName, mpicom, esmf_logfile_kind)
use shr_file_mod, only: shr_file_getUnit, shr_file_freeUnit
character(len=*), intent(in) :: NLFileName
integer, intent(in) :: mpicom
character(len=CS), intent(out) :: esmf_logfile_kind
integer :: ierr ! I/O error code
integer :: unitn ! Namelist unit number to read
integer :: rank
character(len=*), parameter :: subname = '(esmf_readnl) '
namelist /esmf_inparm/ esmf_logfile_kind
esmf_logfile_kind = 'ESMF_LOGKIND_NONE'
call mpi_comm_rank(mpicom, rank, ierr)
!-------------------------------------------------------------------------
! Read in namelist
!-------------------------------------------------------------------------
if (rank == 0) then
unitn = shr_file_getUnit()
write(logunit,"(A)") subname,' read esmf_inparm namelist from: '//trim(NLFileName)
open(unitn, file=trim(NLFileName), status='old')
ierr = 1
do while( ierr /= 0 )
read(unitn, nml=esmf_inparm, iostat=ierr)
if (ierr < 0) then
call shr_sys_abort( subname//':: namelist read returns an'// &
' end of file or end of record condition' )
end if
end do
close(unitn)
call shr_file_freeUnit(unitn)
end if
call mpi_bcast(esmf_logfile_kind, CS, MPI_CHARACTER, 0, mpicom, ierr)
end subroutine cime_esmf_readnl
!===============================================================================
!*******************************************************************************
!===============================================================================