10 use shr_kind_mod
, only: r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs
11 use pmgrid
, only: plat, plev
12 use spmd_utils
, only: masterproc
13 use abortutils
, only: endrun
15 use shr_sys_mod
, only: shr_sys_flush
16 use physics_types
, only: physics_state, physics_tend
17 use cam_control_mod
, only: nsrest, print_step_cost, obliqr, lambm0, mvelpp, eccen
18 use dyn_comp
, only: dyn_import_t, dyn_export_t
19 use ppgrid
, only: begchunk, endchunk
21 use cam_logfile
, only: iulog
22 use physics_buffer
, only: physics_buffer_desc
23 use offline_driver
, only: offline_driver_init, offline_driver_readnl
24 use offline_driver
, only: offline_driver_dorun, offline_driver_run, offline_driver_done
42 real(r8) :: cam_time_beg
43 real(r8) :: cam_time_end
44 real(r8) :: stepon_time_beg = -1.0_r8
45 real(r8) :: stepon_time_end = -1.0_r8
46 integer :: nstep_beg = -1
52 real(r8) :: etamid(plev)
55 type(dyn_import_t
) :: dyn_in
56 type(dyn_export_t
) :: dyn_out
58 type(physics_state
),
pointer :: phys_state(:) => null()
59 type(physics_tend
),
pointer :: phys_tend(:) => null()
60 type(physics_buffer_desc
),
pointer :: pbuf2d(:,:) => null()
62 real(r8) :: wcstart, wcend
63 real(r8) :: usrstart, usrend
64 real(r8) :: sysstart, sysend
73 subroutine cam_init( cam_out, cam_in, mpicom_atm, &
74 start_ymd, start_tod, ref_ymd, ref_tod, stop_ymd, stop_tod, &
75 perpetual_run, perpetual_ymd, calendar)
83 use infnan
, only: nan, assignment(=)
84 use history_defaults
, only: bldfld
85 use cam_initfiles
, only: cam_initfiles_open
86 use inital
, only: cam_initial
87 use cam_restart
, only: cam_read_restart
88 use stepon
, only: stepon_init
89 use physpkg
, only: phys_init, phys_register
91 use dycore
, only: dycore_is
92 #if (defined BFB_CAM_SCAM_IOP)
93 use history_defaults
, only: initialize_iop_history
97 use cam_history
, only: addfld, add_default, phys_decomp, intht, init_masterlinkedlist
98 use history_scam
, only: scm_intht
99 use scammod
, only: single_column
100 use cam_pio_utils
, only: init_pio_subsystem
101 use cam_instance
, only: inst_suffix
104 real(r8) :: mpi_wtime
111 type(cam_in_t) ,
pointer :: cam_in(:)
112 integer ,
intent(in) :: mpicom_atm
113 integer ,
intent(in) :: start_ymd
114 integer ,
intent(in) :: start_tod
115 integer ,
intent(in) :: ref_ymd
116 integer ,
intent(in) :: ref_tod
117 integer ,
intent(in) :: stop_ymd
118 integer ,
intent(in) :: stop_tod
119 logical ,
intent(in) :: perpetual_run
120 integer ,
intent(in) :: perpetual_ymd
121 character(len=cs) ,
intent(in) :: calendar
126 character(len=cs) :: filein
133 cam_time_beg = mpi_wtime()
139 call init_masterlinkedlist()
151 filein =
"atm_in" // trim(inst_suffix)
156 call init_pio_subsystem(filein)
159 call offline_driver_readnl(filein)
161 if ( nsrest == 0 )
then
163 call cam_initfiles_open()
164 call cam_initial(dyn_in, dyn_out, nlfilename=filein)
172 call cam_read_restart( cam_out, dyn_in, dyn_out, pbuf2d, stop_ymd, stop_tod, nlfilename=filein )
175 #if (defined BFB_CAM_SCAM_IOP)
176 call initialize_iop_history()
181 call phys_init( phys_state, phys_tend, pbuf2d, cam_out )
195 call stepon_init( gw, etamid, dyn_in, dyn_out )
197 if (single_column) call scm_intht()
203 call offline_driver_init()
219 use physpkg
, only: phys_run1
220 use stepon
, only: stepon_run1
222 use mpishorthand
, only: mpicom
224 use time_manager
, only: get_nstep
226 type(cam_in_t) :: cam_in(begchunk:endchunk)
227 type(cam_out_t) :: cam_out(begchunk:endchunk)
230 real(r8) :: mpi_wtime
235 if (stepon_time_beg == -1.0_r8) stepon_time_beg = mpi_wtime()
236 if (nstep_beg == -1) nstep_beg = get_nstep()
238 if (masterproc .and. print_step_cost)
then
239 call t_stampf(wcstart, usrstart, sysstart)
242 if (offline_driver_dorun)
return
248 call t_barrierf(
'sync_stepon_run1', mpicom)
249 call t_startf(
'stepon_run1')
250 call stepon_run1( dtime, phys_state, phys_tend, pbuf2d, dyn_in, dyn_out )
251 call t_stopf(
'stepon_run1')
258 call t_barrierf(
'sync_phys_run1', mpicom)
259 call t_startf(
'phys_run1')
260 call phys_run1(phys_state, dtime, phys_tend, pbuf2d, cam_in, cam_out)
261 call t_stopf(
'phys_run1')
280 use physpkg
, only: phys_run2
281 use stepon
, only: stepon_run2
282 use time_manager
, only: is_first_step, is_first_restart_step
284 use mpishorthand
, only: mpicom
287 type(cam_out_t),
intent(inout) :: cam_out(begchunk:endchunk)
288 type(cam_in_t),
intent(inout) :: cam_in(begchunk:endchunk)
290 if (offline_driver_dorun)
then
291 call offline_driver_run( phys_state, pbuf2d, cam_out, cam_in, dtime )
298 call t_barrierf(
'sync_phys_run2', mpicom)
299 call t_startf(
'phys_run2')
300 call phys_run2(phys_state, dtime, phys_tend, pbuf2d, cam_out, cam_in )
301 call t_stopf(
'phys_run2')
306 call t_barrierf(
'sync_stepon_run2', mpicom)
307 call t_startf(
'stepon_run2')
308 call stepon_run2( phys_state, phys_tend, dyn_in, dyn_out )
310 call t_stopf(
'stepon_run2')
312 if (is_first_step() .or. is_first_restart_step())
then
313 call t_startf(
'cam_run2_memusage')
314 call t_stopf(
'cam_run2_memusage')
331 use stepon
, only: stepon_run3
332 use time_manager
, only: is_first_step, is_first_restart_step
334 use mpishorthand
, only: mpicom
337 type(cam_out_t),
intent(inout) :: cam_out(begchunk:endchunk)
340 if (offline_driver_dorun)
return
345 call t_barrierf(
'sync_stepon_run3', mpicom)
346 call t_startf(
'stepon_run3')
347 call stepon_run3( dtime, etamid, cam_out, phys_state, dyn_in, dyn_out )
349 call t_stopf(
'stepon_run3')
351 if (is_first_step() .or. is_first_restart_step())
then
352 call t_startf(
'cam_run3_memusage')
353 call t_stopf(
'cam_run3_memusage')
361 subroutine cam_run4( cam_out, cam_in, rstwr, nlend, &
362 yr_spec, mon_spec, day_spec, sec_spec )
371 use cam_history
, only: wshist, wrapup
372 use cam_restart
, only: cam_write_restart
373 use dycore
, only: dycore_is
375 use mpishorthand
, only: mpicom
378 type(cam_out_t),
intent(inout) :: cam_out(begchunk:endchunk)
379 type(cam_in_t) ,
intent(inout) :: cam_in(begchunk:endchunk)
380 logical ,
intent(in) :: rstwr
381 logical ,
intent(in) :: nlend
382 integer ,
intent(in),
optional :: yr_spec
383 integer ,
intent(in),
optional :: mon_spec
384 integer ,
intent(in),
optional :: day_spec
385 integer ,
intent(in),
optional :: sec_spec
388 real(r8) :: mpi_wtime
398 if (.not.offline_driver_done)
then
399 call t_barrierf(
'sync_wshist', mpicom)
400 call t_startf(
'wshist')
402 call t_stopf(
'wshist')
406 stepon_time_end = mpi_wtime()
412 call t_startf(
'cam_write_restart')
413 if (present(yr_spec).and.present(mon_spec).and.present(day_spec).and.present(sec_spec))
then
414 call cam_write_restart( cam_out, dyn_out, pbuf2d, &
415 yr_spec=yr_spec, mon_spec=mon_spec, day_spec=day_spec, sec_spec= sec_spec )
417 call cam_write_restart( cam_out, dyn_out, pbuf2d )
419 call t_stopf(
'cam_write_restart')
422 call t_startf(
'cam_run4_wrapup')
423 call wrapup(rstwr, nlend)
424 call t_stopf(
'cam_run4_wrapup')
426 if (masterproc .and. print_step_cost)
then
427 call t_startf(
'cam_run4_print')
428 call t_stampf(wcend, usrend, sysend)
429 write(iulog,
'(a,3f8.3,a)')
'Prv timestep wallclock, usr, sys=', &
430 wcend-wcstart, usrend-usrstart, sysend-sysstart, &
432 call t_stopf(
'cam_run4_print')
436 call t_startf(
'cam_run4_flush')
437 call shr_sys_flush(iulog)
438 call t_stopf(
'cam_run4_flush')
453 use units
, only: getunit
454 use time_manager
, only: get_nstep, get_step_size
456 use mpishorthand
, only: mpicom, mpiint, &
457 nsend, nrecv, nwsend, nwrecv
458 use spmd_utils
, only: iam, npes
460 use stepon
, only: stepon_final
461 use physpkg
, only: phys_final
462 use cam_initfiles
, only: cam_initfiles_close
468 type(cam_in_t),
pointer :: cam_in(:)
477 character*24 :: filenam
480 real(r8) :: mpi_wtime
483 call phys_final( phys_state, phys_tend , pbuf2d)
484 call stepon_final(dyn_in, dyn_out)
487 call cam_initfiles_close()
495 write(iulog,*)
'The following stats are exclusive of initialization/boundary datasets'
496 write(iulog,*)
'Number of messages sent by proc ',iam,
' is ',nsend
497 write(iulog,*)
'Number of messages recv by proc ',iam,
' is ',nrecv
508 call shr_sys_flush( 0 )
509 call shr_sys_flush( iulog )
514 cam_time_end = mpi_wtime()
517 write(iulog,9300) nstep-1,nstep
518 9300
format (//
'Number of completed timesteps:',i6,/,
'Time step ',i6, &
519 ' partially done to provide convectively adjusted and ', &
520 'time filtered values for history tape.')
521 write(iulog,*)
'------------------------------------------------------------'
524 write(iulog,*)
' Total run time (sec) : ', cam_time_end-cam_time_beg
525 write(iulog,*)
' Time Step Loop run time(sec) : ', stepon_time_end-stepon_time_beg
526 if (((nstep-1)-nstep_beg) > 0)
then
527 write(iulog,*)
' SYPD : ', &
528 236.55_r8/((86400._r8/(dtime*((nstep-1)-nstep_beg)))*(stepon_time_end-stepon_time_beg))
532 write(iulog,*)
'******* END OF MODEL RUN *******'
536 #if ( defined SPMDSTATS )
537 if (t_single_filef())
then
538 write(filenam,
'(a17)')
'spmdstats_cam.all'
541 open (unit=iu, file=filenam, form=
'formatted', status=
'replace')
544 call mpirecv(signal, 1, mpiint, iam-1, iam, mpicom)
545 open (unit=iu, file=filenam, form=
'formatted', status=
'old', position=
'append')
547 write (iu,*)
'************ PROCESS ',iam,
' ************'
548 write (iu,*)
'iam ',iam,
' msgs sent =',nsend
549 write (iu,*)
'iam ',iam,
' msgs recvd=',nrecv
550 write (iu,*)
'iam ',iam,
' words sent =',nwsend
551 write (iu,*)
'iam ',iam,
' words recvd=',nwrecv
554 if (iam+1 < npes)
then
555 call mpisend(signal, 1, mpiint, iam+1, iam+1, mpicom)
559 write(filenam,
'(a14,i5.5)')
'spmdstats_cam.', iam
560 open (unit=iu, file=filenam, form=
'formatted', status=
'replace')
561 write (iu,*)
'************ PROCESS ',iam,
' ************'
562 write (iu,*)
'iam ',iam,
' msgs sent =',nsend
563 write (iu,*)
'iam ',iam,
' msgs recvd=',nrecv
564 write (iu,*)
'iam ',iam,
' words sent =',nwsend
565 write (iu,*)
'iam ',iam,
' words recvd=',nwrecv
subroutine, public cam_init(cam_out, cam_in, mpicom_atm, start_ymd, start_tod, ref_ymd, ref_tod, stop_ymd, stop_tod, perpetual_run, perpetual_ymd, calendar)
subroutine, public cam_final(cam_out, cam_in)
subroutine, public cam_run2(cam_out, cam_in)
subroutine, public cam_run1(cam_in, cam_out)
subroutine, public atm2hub_alloc(cam_out)
Initialize objects of type cam_out_t.
subroutine, public cam_run3(cam_out)
subroutine, public cam_run4(cam_out, cam_in, rstwr, nlend, yr_spec, mon_spec, day_spec, sec_spec)
subroutine, public atm2hub_deallocate(cam_out)
Destroy objects of type cam_out_t.
subroutine, public hub2atm_alloc(cam_in)
Initialize objects of type cam_in_t.
subroutine, public hub2atm_deallocate(cam_in)
Destroy objects of type cam_in_t.