37 '$Id: Timing_Utility.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 38 INTEGER,
PARAMETER ::
ml = 256
59 LOGICAL :: is_valid = .false.
61 INTEGER :: begin_clock = 0
62 INTEGER :: end_clock = 0
102 CALL system_clock( count_rate=self%Hertz, &
103 count =self%Begin_Clock )
104 IF ( self%Hertz == 0 )
RETURN 105 self%Is_Valid = .true.
133 CALL system_clock( count=self%End_Clock )
173 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: caller
176 CHARACTER(ML) :: routine_name
179 routine_name =
'Timing_Display' 180 IF (
PRESENT(caller) ) routine_name = trim(adjustl(caller))
182 IF ( .NOT. self%Is_Valid )
THEN 183 msg =
'Invalid timing structure!' 218 WRITE(*,
'(1x,"Timing OBJECT")')
219 WRITE(*,
'(3x,"Hertz : ",i0)') self%Hertz
220 WRITE(*,
'(3x,"Begin_Clock : ",i0)') self%Begin_Clock
221 WRITE(*,
'(3x,"End_Clock : ",i0)') self%End_Clock
222 WRITE(*,
'(3x,"Is_Valid : ",l1)') self%Is_Valid
278 Seconds , & ! Optional input
283 LOGICAL ,
OPTIONAL,
INTENT(IN) :: seconds
284 CHARACTER(*) ,
OPTIONAL,
INTENT(IN) :: fmt_string
288 REAL(fp),
PARAMETER :: n_seconds_in_hour = 3600.0_fp
289 REAL(fp),
PARAMETER :: n_seconds_in_minute = 60.0_fp
290 REAL(fp),
PARAMETER :: n_milliseconds_in_second = 1000.0_fp
294 REAL(fp) :: total_time
298 INTEGER :: n_milliseconds
303 IF (
PRESENT(seconds) ) hhmmss = .NOT. seconds
305 IF (
PRESENT(fmt_string) ) fmt = adjustl(fmt_string)
315 n_hours = int(total_time / n_seconds_in_hour)
316 n_minutes = int(mod(total_time,n_seconds_in_hour) / n_seconds_in_minute)
317 n_seconds = int(mod(mod(total_time,n_seconds_in_hour), n_seconds_in_minute))
318 n_milliseconds = int((total_time - aint(total_time,
fp)) * n_milliseconds_in_second)
320 WRITE(
string,
'(i2.2,":",i2.2,":",i2.2,".",i3.3 )' ) &
321 n_hours, n_minutes, n_seconds, n_milliseconds
324 WRITE(
string,fmt=fmt ) total_time
340 INTEGER,
OPTIONAL,
INTENT(IN) :: hertz
341 INTEGER,
OPTIONAL,
INTENT(IN) :: begin_clock
342 INTEGER,
OPTIONAL,
INTENT(IN) :: end_clock
343 LOGICAL,
OPTIONAL,
INTENT(IN) :: is_valid
345 IF (
PRESENT(hertz ) ) self%Hertz = hertz
346 IF (
PRESENT(begin_clock) ) self%Begin_Clock = begin_clock
347 IF (
PRESENT(end_clock ) ) self%End_Clock = end_clock
348 IF (
PRESENT(is_valid ) ) self%Is_Valid = is_valid
362 INTEGER,
OPTIONAL,
INTENT(OUT) :: hertz
363 INTEGER,
OPTIONAL,
INTENT(OUT) :: begin_clock
364 INTEGER,
OPTIONAL,
INTENT(OUT) :: end_clock
365 LOGICAL,
OPTIONAL,
INTENT(OUT) :: is_valid
367 IF (
PRESENT(hertz ) ) hertz = self%Hertz
368 IF (
PRESENT(begin_clock) ) begin_clock = self%Begin_Clock
369 IF (
PRESENT(end_clock ) ) end_clock = self%End_Clock
370 IF (
PRESENT(is_valid ) ) is_valid = self%Is_Valid
446 CHARACTER(*) ,
INTENT(IN) :: filename
447 LOGICAL ,
OPTIONAL,
INTENT(IN) :: clobber
448 CHARACTER(*) ,
OPTIONAL,
INTENT(IN) :: heading(:)
452 CHARACTER(*),
PARAMETER :: routine_name =
'Timing_WriteFile' 454 CHARACTER(ML) :: msg, io_msg
455 CHARACTER(ML) :: current_time
456 CHARACTER(ML) :: title(
size(timing_array))
457 CHARACTER(ML) :: elapsed_time(
size(timing_array))
458 CHARACTER(ML) :: output_fmt
459 CHARACTER(8) :: status, position
463 INTEGER :: i, n_times
464 INTEGER :: sl_current_time
465 INTEGER :: sl_elapsed_time
470 IF ( .NOT. all(timing_array%Is_Valid) )
THEN 472 msg =
'Input timing array contains invalid elements' 475 n_times =
SIZE(timing_array)
478 IF (
PRESENT(clobber) ) append = .NOT. clobber
480 IF (
PRESENT(heading) )
THEN 481 IF (
SIZE(heading) /= n_times )
THEN 483 msg =
'Input heading array different size from timing array' 487 title(i) =
'| '//trim(heading(i))
491 WRITE(title(i),
'("| Time ",i0)') i
511 msg =
'Error obtaining free logical unit number' 515 OPEN( fid, file = filename , &
516 form =
'FORMATTED', &
518 position = position , &
521 IF ( io_stat /= 0 )
THEN 523 msg =
'Error opening file '//trim(filename)//
' - '//trim(io_msg)
530 sl_current_time = len_trim(current_time)
535 sl_elapsed_time =
max(maxval(len_trim(elapsed_time)), maxval(len_trim(title)))
539 WRITE(output_fmt,
'("(a",i0,",",i0,"(2x,a",i0,"))")') &
540 sl_current_time, n_times, sl_elapsed_time
544 IF ( trim(status) ==
'NEW' )
THEN 545 WRITE(fid,fmt = output_fmt, iostat = io_stat, iomsg = io_msg) &
546 'Current time', (trim(title(i)), i = 1, n_times)
547 IF ( io_stat /= 0 )
THEN 549 msg =
'Error writing header to '//trim(filename)//
' - '//trim(io_msg)
556 WRITE(fid,fmt = output_fmt, iostat = io_stat, iomsg = io_msg) &
557 trim(current_time), &
558 (trim(elapsed_time(i)), i = 1, n_times)
559 IF ( io_stat /= 0 )
THEN 561 msg =
'Error writing timing data to '//trim(filename)//
' - '//trim(io_msg)
567 CLOSE(fid, iostat = io_stat, &
569 IF ( io_stat /= 0 )
THEN 571 msg =
'Error closing file '//trim(filename)//
' - '//trim(io_msg)
590 REAL(fp) :: elapsed_time
591 elapsed_time = 0.0_fp
592 IF ( .NOT. self%Is_Valid )
RETURN 593 elapsed_time =
REAL(self%End_Clock - self%Begin_Clock, fp) /
REAL(self%hertz,
fp)
integer, parameter, public failure
integer, parameter, public fp
subroutine, public timing_set(self, Hertz, Begin_Clock, End_Clock, Is_Valid)
subroutine, public timing_get(self, Hertz, Begin_Clock, End_Clock, Is_Valid)
integer function, public get_lun()
elemental character(80) function timing_tostring(self, Seconds, Fmt_String)
subroutine, public timing_display(self, Caller)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
type(datetime_type) function, public datetime_now()
subroutine, public timing_end(self)
elemental character(80) function, public datetime_tostring(DateTime, Format)
elemental real(fp) function timing_elapsedtime(self)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software 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 If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
character(*), parameter module_version_id
subroutine, public timing_begin(self)
integer, parameter, public success
integer, parameter, public information
subroutine, public timing_inspect(self)
integer function, public timing_writefile(Timing_Array, Filename, Clobber, Heading)