SUBROUTINE tool_origindate(netcdfid,varid,date_in_sec) IMPLICIT NONE #include "netcdf.inc" INTEGER :: netcdfid,varid CHARACTER*180 :: units CHARACTER*19 :: date INTEGER :: lenstr, luni, indst, ierr REAL*8 :: tool_datosec,date_in_sec ierr=nf_get_att_text(netcdfid, varid, 'units', units) if (ierr .eq. nf_noerr) then luni = lenstr(units) if (units(1:6).eq.'second')then ! Case units as the format 'seconds since YYYY-MM-DD hh:mm:ss' indst=15 ! position to start reading date elseif (units(1:3).eq.'day') then ! Case units as the format 'days since YYYY-MM-DD hh:mm:ss' indst=12 ! position to start reading date else write(*,'(/1x,2A/6x,A/10x,A)') & 'TOOL_ORIGINDATE ERROR: ', & 'unknown units of for time variable' ,& 'Time variable should follow Netcdf CF format: ',& '''seconds(days) since YYYY-MM-DD hh:mm:ss''' STOP endif else write(*,'(/1x,A/6x,A/10x,A)') & 'TOOL_ORIGINDATE ERROR: ',& 'Time variable should have a units attribute following Netcdf CF format: ',& '''seconds(days) since YYYY-MM-DD hh:mm:ss''' STOP endif if (luni