!This program converts NCDC wind data files (*.wnd2): !to a format that can be read by the WERU wind_mdb program. !Referring to NCDC document 'Data documentation for data set TD-6421' !(TD-6421.doc), p 9-11 (section 4.3). !Data are not written out if missing (dr < 0 and/or sp < 0). !Data are not written out if wrong (flags Q , S). !Wind speed adjusted to 10 m height (sp10) is used. !If snow on the ground > 10 cm, sp_surf is used. !Wind speed is converted to m/s. !Examples: !ncdc2weru < 690070.wnd2 > 690070.org !ncdc2weru -b1980 -e1989 < 690070.wnd2 > 690070.org integer sp,dr, sp10, sp_surf, year, month, day, hour, count integer begin_year, end_year character *1 s,q,z character*25 argv real dr_real !want to write wind direction as a real begin_year = 1800 end_year = 2100 if (iargc() .gt. 0) then do 09 i = 1, iargc() call getarg(i,argv) if (argv(1:1) .ne. '-') then !make sure all options start with '-' write(*,*) trim(argv), ': Option ignored, it should start ',& & 'with a dash (-)' goto 09 !Go get next arg endif !command line help prompt if ((argv(2:2).eq.'?').or.(argv(2:2).eq.'h')) then write(*,*) 'Valid command line options:' write(*,*) '-? or -h Display this help screen' write(*,*) '-b# begin year, e.g. -b1980' write(*,*) '-e# end year, e.g. -e1989)' stop else if (argv(2:2) == 'b') then read(argv(3:),*) begin_year else if (argv(2:2) == 'e') then read(argv(3:),*) end_year end if 09 continue endif do while (2 > 1) !only leave this loop when eof. read(*,33,end=300)wmo6,year,month,day,hour,sp,dr,s,q,sp10,an,z, & & sp_surf 33 format(a6, i4,3i2.2,i4,1x,i3,2a1,i4,1x,f4.1,a1,i4) if (year >= begin_year .and. year <= end_year) then if (dr < 0) go to 100 !missing data if (sp < 0) go to 100 !missing data if (q .eq. 'Q') go to 100 !data wrong if (q .eq. 'S') go to 100 !data wrong if (z .eq. '2') sp10 = sp_surf !use snow adjusted wind speed sp10mps = sp10/10.0 !wind speed in m/s dr_real = dr write(*,34) year, month, day, hour, dr_real, sp10mps 34 format(x, 4i4, 2f6.1) end if 100 continue end do 300 end