Skip to content

Commit 8215b70

Browse files
Merge pull request mom-ocean#163 from NCAR/stdout
Introduce a controllable stdout unit in MOM_io
2 parents 0c16805 + 3f09291 commit 8215b70

12 files changed

Lines changed: 119 additions & 128 deletions

config_src/mct_driver/mom_ocean_model_mct.F90

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module MOM_ocean_model_mct
5656
use coupler_types_mod, only : coupler_type_set_diags, coupler_type_send_data
5757
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain
5858
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
59-
use fms_mod, only : stdout
59+
use MOM_io, only : stdout
6060
use mpp_mod, only : mpp_chksum
6161
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
6262
use MOM_wave_interface, only : wave_parameters_CS, MOM_wave_interface_init
@@ -409,10 +409,6 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
409409

410410
call close_param_file(param_file)
411411
call diag_mediator_close_registration(OS%diag)
412-
413-
if (is_root_pe()) &
414-
write(*,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'
415-
416412
call callTree_leave("ocean_model_init(")
417413
end subroutine ocean_model_init
418414

@@ -1053,20 +1049,18 @@ subroutine ocean_public_type_chksum(id, timestep, ocn)
10531049
integer, intent(in) :: timestep !< The number of elapsed timesteps
10541050
type(ocean_public_type), intent(in) :: ocn !< A structure containing various publicly
10551051
!! visible ocean surface fields.
1056-
integer :: n, m, outunit
1057-
1058-
outunit = stdout()
1059-
1060-
write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
1061-
write(outunit,100) 'ocean%t_surf ',mpp_chksum(ocn%t_surf )
1062-
write(outunit,100) 'ocean%s_surf ',mpp_chksum(ocn%s_surf )
1063-
write(outunit,100) 'ocean%u_surf ',mpp_chksum(ocn%u_surf )
1064-
write(outunit,100) 'ocean%v_surf ',mpp_chksum(ocn%v_surf )
1065-
write(outunit,100) 'ocean%sea_lev ',mpp_chksum(ocn%sea_lev)
1066-
write(outunit,100) 'ocean%frazil ',mpp_chksum(ocn%frazil )
1067-
write(outunit,100) 'ocean%melt_potential ',mpp_chksum(ocn%melt_potential)
1068-
1069-
call coupler_type_write_chksums(ocn%fields, outunit, 'ocean%')
1052+
integer :: n, m
1053+
1054+
write(stdout,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
1055+
write(stdout,100) 'ocean%t_surf ',mpp_chksum(ocn%t_surf )
1056+
write(stdout,100) 'ocean%s_surf ',mpp_chksum(ocn%s_surf )
1057+
write(stdout,100) 'ocean%u_surf ',mpp_chksum(ocn%u_surf )
1058+
write(stdout,100) 'ocean%v_surf ',mpp_chksum(ocn%v_surf )
1059+
write(stdout,100) 'ocean%sea_lev ',mpp_chksum(ocn%sea_lev)
1060+
write(stdout,100) 'ocean%frazil ',mpp_chksum(ocn%frazil )
1061+
write(stdout,100) 'ocean%melt_potential ',mpp_chksum(ocn%melt_potential)
1062+
1063+
call coupler_type_write_chksums(ocn%fields, stdout, 'ocean%')
10701064
100 FORMAT(" CHECKSUM::",A20," = ",Z20)
10711065

10721066
end subroutine ocean_public_type_chksum

config_src/mct_driver/mom_surface_forcing_mct.F90

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ module MOM_surface_forcing_mct
3434
use coupler_types_mod, only : coupler_type_initialized, coupler_type_spawn
3535
use coupler_types_mod, only : coupler_type_copy_data
3636
use data_override_mod, only : data_override_init, data_override
37-
use fms_mod, only : stdout
3837
use mpp_mod, only : mpp_chksum
3938
use time_interp_external_mod, only : init_external_field, time_interp_external
4039
use time_interp_external_mod, only : time_interp_external_init
40+
use MOM_io, only: stdout
4141

4242
implicit none ; private
4343

@@ -1361,37 +1361,35 @@ subroutine ice_ocn_bnd_type_chksum(id, timestep, iobt)
13611361
!! ocean in a coupled model whose checksums are reported
13621362

13631363
! local variables
1364-
integer :: n,m, outunit
1365-
1366-
outunit = stdout()
1367-
1368-
write(outunit,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
1369-
write(outunit,100) 'iobt%u_flux ' , mpp_chksum( iobt%u_flux )
1370-
write(outunit,100) 'iobt%v_flux ' , mpp_chksum( iobt%v_flux )
1371-
write(outunit,100) 'iobt%t_flux ' , mpp_chksum( iobt%t_flux )
1372-
write(outunit,100) 'iobt%q_flux ' , mpp_chksum( iobt%q_flux )
1373-
write(outunit,100) 'iobt%salt_flux ' , mpp_chksum( iobt%salt_flux )
1374-
write(outunit,100) 'iobt%seaice_melt_heat' , mpp_chksum( iobt%seaice_melt_heat)
1375-
write(outunit,100) 'iobt%seaice_melt ' , mpp_chksum( iobt%seaice_melt )
1376-
write(outunit,100) 'iobt%lw_flux ' , mpp_chksum( iobt%lw_flux )
1377-
write(outunit,100) 'iobt%sw_flux_vis_dir' , mpp_chksum( iobt%sw_flux_vis_dir)
1378-
write(outunit,100) 'iobt%sw_flux_vis_dif' , mpp_chksum( iobt%sw_flux_vis_dif)
1379-
write(outunit,100) 'iobt%sw_flux_nir_dir' , mpp_chksum( iobt%sw_flux_nir_dir)
1380-
write(outunit,100) 'iobt%sw_flux_nir_dif' , mpp_chksum( iobt%sw_flux_nir_dif)
1381-
write(outunit,100) 'iobt%lprec ' , mpp_chksum( iobt%lprec )
1382-
write(outunit,100) 'iobt%fprec ' , mpp_chksum( iobt%fprec )
1383-
write(outunit,100) 'iobt%runoff ' , mpp_chksum( iobt%runoff )
1384-
write(outunit,100) 'iobt%calving ' , mpp_chksum( iobt%calving )
1385-
write(outunit,100) 'iobt%p ' , mpp_chksum( iobt%p )
1364+
integer :: n,m
1365+
1366+
write(stdout,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
1367+
write(stdout,100) 'iobt%u_flux ' , mpp_chksum( iobt%u_flux )
1368+
write(stdout,100) 'iobt%v_flux ' , mpp_chksum( iobt%v_flux )
1369+
write(stdout,100) 'iobt%t_flux ' , mpp_chksum( iobt%t_flux )
1370+
write(stdout,100) 'iobt%q_flux ' , mpp_chksum( iobt%q_flux )
1371+
write(stdout,100) 'iobt%salt_flux ' , mpp_chksum( iobt%salt_flux )
1372+
write(stdout,100) 'iobt%seaice_melt_heat' , mpp_chksum( iobt%seaice_melt_heat)
1373+
write(stdout,100) 'iobt%seaice_melt ' , mpp_chksum( iobt%seaice_melt )
1374+
write(stdout,100) 'iobt%lw_flux ' , mpp_chksum( iobt%lw_flux )
1375+
write(stdout,100) 'iobt%sw_flux_vis_dir' , mpp_chksum( iobt%sw_flux_vis_dir)
1376+
write(stdout,100) 'iobt%sw_flux_vis_dif' , mpp_chksum( iobt%sw_flux_vis_dif)
1377+
write(stdout,100) 'iobt%sw_flux_nir_dir' , mpp_chksum( iobt%sw_flux_nir_dir)
1378+
write(stdout,100) 'iobt%sw_flux_nir_dif' , mpp_chksum( iobt%sw_flux_nir_dif)
1379+
write(stdout,100) 'iobt%lprec ' , mpp_chksum( iobt%lprec )
1380+
write(stdout,100) 'iobt%fprec ' , mpp_chksum( iobt%fprec )
1381+
write(stdout,100) 'iobt%runoff ' , mpp_chksum( iobt%runoff )
1382+
write(stdout,100) 'iobt%calving ' , mpp_chksum( iobt%calving )
1383+
write(stdout,100) 'iobt%p ' , mpp_chksum( iobt%p )
13861384
if (associated(iobt%ustar_berg)) &
1387-
write(outunit,100) 'iobt%ustar_berg ' , mpp_chksum( iobt%ustar_berg )
1385+
write(stdout,100) 'iobt%ustar_berg ' , mpp_chksum( iobt%ustar_berg )
13881386
if (associated(iobt%area_berg)) &
1389-
write(outunit,100) 'iobt%area_berg ' , mpp_chksum( iobt%area_berg )
1387+
write(stdout,100) 'iobt%area_berg ' , mpp_chksum( iobt%area_berg )
13901388
if (associated(iobt%mass_berg)) &
1391-
write(outunit,100) 'iobt%mass_berg ' , mpp_chksum( iobt%mass_berg )
1389+
write(stdout,100) 'iobt%mass_berg ' , mpp_chksum( iobt%mass_berg )
13921390
100 FORMAT(" CHECKSUM::",A20," = ",Z20)
13931391

1394-
call coupler_type_write_chksums(iobt%fluxes, outunit, 'iobt%')
1392+
call coupler_type_write_chksums(iobt%fluxes, stdout, 'iobt%')
13951393

13961394
end subroutine ice_ocn_bnd_type_chksum
13971395

config_src/mct_driver/ocn_comp_mct.F90

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module ocn_comp_mct
4242
use MOM_constants, only: CELSIUS_KELVIN_OFFSET
4343
use MOM_domains, only: AGRID, BGRID_NE, CGRID_NE, pass_vector
4444
use mpp_domains_mod, only: mpp_get_compute_domain
45+
use MOM_io, only: stdout
4546

4647
! Previously inlined - now in separate modules
4748
use MOM_ocean_model_mct, only: ocean_public_type, ocean_state_type
@@ -88,7 +89,6 @@ module ocn_comp_mct
8889
type(cpl_indices_type) :: ind !< Variable IDs
8990
logical :: sw_decomp !< Controls whether shortwave is decomposed into 4 components
9091
real :: c1, c2, c3, c4 !< Coeffs. used in the shortwave decomposition i/o
91-
integer :: stdout !< standard output unit. (by default, points to ocn.log.* )
9292
character(len=384) :: pointer_filename !< Name of the ascii file that contains the path
9393
!! and filename of the latest restart file.
9494
end type MCT_MOM_Data
@@ -194,14 +194,14 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
194194
call shr_file_getLogUnit (shrlogunit)
195195
call shr_file_getLogLevel(shrloglev)
196196

197-
glb%stdout = shr_file_getUnit() ! get an unused unit number
197+
stdout = shr_file_getUnit() ! get an unused unit number
198198

199199
! open the ocn_modelio.nml file and then open a log file associated with stdout
200200
ocn_modelio_name = 'ocn_modelio.nml' // trim(inst_suffix)
201-
call shr_file_setIO(ocn_modelio_name,glb%stdout)
201+
call shr_file_setIO(ocn_modelio_name,stdout)
202202

203203
! set the shr log io unit number
204-
call shr_file_setLogUnit(glb%stdout)
204+
call shr_file_setLogUnit(stdout)
205205
end if
206206

207207
call set_calendar_type(NOLEAP) !TODO: confirm this
@@ -218,23 +218,23 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
218218

219219
! Debugging clocks
220220
if (debug .and. is_root_pe()) then
221-
write(glb%stdout,*) 'ocn_init_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
221+
write(stdout,*) 'ocn_init_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
222222

223223
call ESMF_ClockGet(EClock, StartTime=time_var, rc=rc)
224224
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
225-
write(glb%stdout,*) 'ocn_init_mct, start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
225+
write(stdout,*) 'ocn_init_mct, start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
226226

227227
call ESMF_ClockGet(EClock, StopTime=time_var, rc=rc)
228228
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
229-
write(glb%stdout,*) 'ocn_init_mct, stop time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
229+
write(stdout,*) 'ocn_init_mct, stop time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
230230

231231
call ESMF_ClockGet(EClock, PrevTime=time_var, rc=rc)
232232
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
233-
write(glb%stdout,*) 'ocn_init_mct, previous time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
233+
write(stdout,*) 'ocn_init_mct, previous time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
234234

235235
call ESMF_ClockGet(EClock, TimeStep=ocn_cpl_interval, rc=rc)
236236
call ESMF_TimeIntervalGet(ocn_cpl_interval, yy=year, mm=month, d=day, s=seconds, sn=seconds_n, sd=seconds_d, rc=rc)
237-
write(glb%stdout,*) 'ocn_init_mct, time step: y,m,d-',year,month,day,'s,sn,sd=',seconds,seconds_n,seconds_d
237+
write(stdout,*) 'ocn_init_mct, time step: y,m,d-',year,month,day,'s,sn,sd=',seconds,seconds_n,seconds_d
238238
endif
239239

240240
npes = num_pes()
@@ -298,7 +298,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
298298
! read name of restart file in the pointer file
299299
nu = shr_file_getUnit()
300300
restart_pointer_file = trim(glb%pointer_filename)
301-
if (is_root_pe()) write(glb%stdout,*) 'Reading ocn pointer file: ',restart_pointer_file
301+
if (is_root_pe()) write(stdout,*) 'Reading ocn pointer file: ',restart_pointer_file
302302
restartfile = ""; restartfiles = "";
303303
open(nu, file=restart_pointer_file, form='formatted', status='unknown')
304304
do
@@ -316,13 +316,13 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
316316
enddo
317317
close(nu)
318318
if (is_root_pe()) then
319-
write(glb%stdout,*) 'Reading restart file(s): ',trim(restartfiles)
319+
write(stdout,*) 'Reading restart file(s): ',trim(restartfiles)
320320
end if
321321
call shr_file_freeUnit(nu)
322322
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfiles))
323323
endif
324324
if (is_root_pe()) then
325-
write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'
325+
write(stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'
326326
end if
327327

328328
! Initialize ocn_state%sfc_state out of sight
@@ -383,7 +383,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
383383
ncouple_per_day = seconds_in_day / ocn_cpl_dt
384384
mom_cpl_dt = seconds_in_day / ncouple_per_day
385385
if (mom_cpl_dt /= ocn_cpl_dt) then
386-
write(glb%stdout,*) 'ERROR mom_cpl_dt and ocn_cpl_dt must be identical'
386+
write(stdout,*) 'ERROR mom_cpl_dt and ocn_cpl_dt must be identical'
387387
call exit(0)
388388
end if
389389

@@ -457,7 +457,7 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
457457
if (is_root_pe()) then
458458
call shr_file_getLogUnit(shrlogunit)
459459
call shr_file_getLogLevel(shrloglev)
460-
call shr_file_setLogUnit(glb%stdout)
460+
call shr_file_setLogUnit(stdout)
461461
endif
462462

463463
! Query the beginning time of the current coupling interval
@@ -484,7 +484,7 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
484484
if (runtype /= "continue" .and. runtype /= "branch") then
485485

486486
if (debug .and. is_root_pe()) then
487-
write(glb%stdout,*) 'doubling first interval duration!'
487+
write(stdout,*) 'doubling first interval duration!'
488488
endif
489489

490490
! shift back the start time by one coupling interval (to align the start time with other components)
@@ -500,19 +500,19 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
500500
if (debug .and. is_root_pe()) then
501501
call ESMF_ClockGet(EClock, CurrTime=time_var, rc=rc)
502502
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
503-
write(glb%stdout,*) 'ocn_run_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
503+
write(stdout,*) 'ocn_run_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
504504
call ESMF_ClockGet(EClock, StartTime=time_var, rc=rc)
505505
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
506-
write(glb%stdout,*) 'ocn_run_mct, start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
506+
write(stdout,*) 'ocn_run_mct, start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
507507
call ESMF_ClockGet(EClock, StopTime=time_var, rc=rc)
508508
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
509-
write(glb%stdout,*) 'ocn_run_mct, stop time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
509+
write(stdout,*) 'ocn_run_mct, stop time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
510510
call ESMF_ClockGet(EClock, PrevTime=time_var, rc=rc)
511511
call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
512-
write(glb%stdout,*) 'ocn_run_mct, previous time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
512+
write(stdout,*) 'ocn_run_mct, previous time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds
513513
call ESMF_ClockGet(EClock, TimeStep=ocn_cpl_interval, rc=rc)
514514
call ESMF_TimeIntervalGet(ocn_cpl_interval, yy=year, mm=month, d=day, s=seconds, sn=seconds_n, sd=seconds_d, rc=rc)
515-
write(glb%stdout,*) 'ocn_init_mct, time step: y,m,d-',year,month,day,'s,sn,sd=',seconds,seconds_n,seconds_d
515+
write(stdout,*) 'ocn_init_mct, time step: y,m,d-',year,month,day,'s,sn,sd=',seconds,seconds_n,seconds_d
516516
endif
517517

518518
! set the cdata pointers:
@@ -525,10 +525,10 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
525525
!glb%sw_decomp = .false.
526526
!END TODO:
527527
if (glb%sw_decomp) then
528-
call ocn_import(x2o_o%rattr, glb%ind, glb%grid, Ice_ocean_boundary, glb%ocn_public, glb%stdout, Eclock, &
528+
call ocn_import(x2o_o%rattr, glb%ind, glb%grid, Ice_ocean_boundary, glb%ocn_public, stdout, Eclock, &
529529
c1=glb%c1, c2=glb%c2, c3=glb%c3, c4=glb%c4)
530530
else
531-
call ocn_import(x2o_o%rattr, glb%ind, glb%grid, Ice_ocean_boundary, glb%ocn_public, glb%stdout, Eclock )
531+
call ocn_import(x2o_o%rattr, glb%ind, glb%grid, Ice_ocean_boundary, glb%ocn_public, stdout, Eclock )
532532
end if
533533

534534
! Update internal ocean
@@ -540,7 +540,7 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
540540
!--- write out intermediate restart file when needed.
541541
! Check alarms for flag to write restart at end of day
542542
write_restart_at_eod = seq_timemgr_RestartAlarmIsOn(EClock)
543-
if (debug .and. is_root_pe()) write(glb%stdout,*) 'ocn_run_mct, write_restart_at_eod=', write_restart_at_eod
543+
if (debug .and. is_root_pe()) write(stdout,*) 'ocn_run_mct, write_restart_at_eod=', write_restart_at_eod
544544

545545
if (write_restart_at_eod) then
546546
! case name
@@ -575,7 +575,7 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
575575
endif
576576

577577
close(nu)
578-
write(glb%stdout,*) 'ocn restart pointer file written: ',trim(restartname)
578+
write(stdout,*) 'ocn restart pointer file written: ',trim(restartname)
579579
endif
580580
call shr_file_freeUnit(nu)
581581

@@ -761,7 +761,7 @@ end subroutine ocn_domain_mct
761761
else if (trim(starttype) == trim(seq_infodata_start_type_brnch)) then
762762
get_runtype = "branch"
763763
else
764-
write(glb%stdout,*) 'ocn_comp_mct ERROR: unknown starttype'
764+
write(stdout,*) 'ocn_comp_mct ERROR: unknown starttype'
765765
call exit(0)
766766
end if
767767
return

0 commit comments

Comments
 (0)