Opened 13 years ago

Last modified 13 years ago

#267 closed defect

Corrections to ropp_io_read_ncdf_get.f90 — at Version 2

Reported by: Ian Culverwell Owned by: Ian Culverwell
Priority: normal Milestone: 6.0
Component: ropp_io Version: 5.0
Keywords: lahey95, READ, string-to-integer Cc:

Description (last modified by Ian Culverwell)

ROPP6.0 beta testing with the (unsupported) Lahey95 compiler revealed a small problem while converting string to integer with READ statement. Problem sorted (by user): replace

READ(proc_date, "(i4.4,1x,i2.2,1x,i2.2,1x,i2.2,1x,i2.2,1x,i2.2,1x,i3.3)") &
       data%DTpro%Year,   &
       data%DTpro%Month,  &
       data%DTpro%Day,    &
       data%DTpro%Hour,   &
       data%DTpro%Minute, &       
       data%DTpro%Second, &
       data%DTpro%Msec

with

  READ(proc_date(1:4)  , *) data%DTpro%Year
  READ(proc_date(6:7)  , *) data%DTpro%Month
  READ(proc_date(9:10) , *) data%DTpro%Day
  READ(proc_date(12:13), *) data%DTpro%Hour
  READ(proc_date(15:16), *) data%DTpro%Minute
  READ(proc_date(18:19), *) data%DTpro%Second
  READ(proc_date(21:23), *) data%DTpro%Msec

Works OK for other compilers a in test code, and for the make test tests.

Putting in ROPP6.0.

Change history (2)

comment:1 by Ian Culverwell, 13 years ago

Component: ROPP (all)I/O

comment:2 by Ian Culverwell, 13 years ago

Description: modified (diff)

Not so fast, matey. ROPP test folder testing showed that the READ(proc_date(1:4) , *) business failed when proc_date(1:4) was fully blank. (Oddly, READ(proc_date(1:4) , "(i4.4)") - which generally failed on Lahey95 - coped OK with this, and returned zero as expected.)

Since the time elements of data%DTpro are initialised, it's safe to simply prefix the READ statements by IF ones:

  IF (proc_date( 1: 4) /= '    ') READ(proc_date( 1: 4), *) data%DTpro%Year
  IF (proc_date( 6: 7) /=   '  ') READ(proc_date( 6: 7), *) data%DTpro%Month
  IF (proc_date( 9:10) /=   '  ') READ(proc_date( 9:10), *) data%DTpro%Day
  IF (proc_date(12:13) /=   '  ') READ(proc_date(12:13), *) data%DTpro%Hour
  IF (proc_date(15:16) /=   '  ') READ(proc_date(15:16), *) data%DTpro%Minute
  IF (proc_date(18:19) /=   '  ') READ(proc_date(18:19), *) data%DTpro%Second
  IF (proc_date(21:23) /=  '   ') READ(proc_date(21:23), *) data%DTpro%Msec

This seems to work OK.

Note: See TracTickets for help on using tickets.