;+ ; ; @file_comments ; reading the bathymetry ASCII file of OPA ; ; @categories ; For OPA ; ; @param FILENAME {in}{required}{type=string} ; It contains the filename, ; ; @keyword ZERO to put 0 on land instead of negatives values for the islands. ; ; @returns ; a 2d array ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; May 31, 2002 ; based on batlec2.pro, written by Maurice Imbard, March 17, 1998 ; ; @version ; $Id$ ; ;- ; FUNCTION readbat, filename, ZERO = zero ; compile_opt idl2, strictarrsubs ; ;; ;; lecture de la bathymetrie ;; iname_file = findfile(filename) if iname_file[0] EQ '' then begin ras = report( 'Bad file name') return, -1 ENDIF ELSE iname_file = iname_file[0] openr, iunit, iname_file, /get_lun ; readf, iunit, FORMAT = '(16x,2i8)', iim, ijm ; iim = long(iim) ; ijm = long(ijm) tmp = '' readf, iunit, tmp tmp = strsplit(tmp,' ',/extract) iim = long(tmp[n_elements(tmp)-2]) ijm = long(tmp[n_elements(tmp)-1]) ; print, iim, ijm ifreq = 40L ifin = iim/ifreq+1 irest = iim-(ifin-1)*ifreq ; print, ifin,irest,ifreq zbati = intarr(ifreq) zbati2 = intarr(irest) zbat = intarr(iim,ijm) ; readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' il1 = 0 FOR jn = 1, ifin-1 DO BEGIN readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' il2 = min([ iim-1, il1+ifreq-1] ) readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' il3 = il2-(jn-1)*ifreq iformat = string('(', il3+2, 'i3)') ; print,jn,il1,il2,il3,ifreq-1 FOR jj = ijm-1, 0, -1 DO BEGIN readf, iunit, FORMAT = iformat, ij, zbati zbat[il1:il2, jj] = zbati ENDFOR il1 = il1 + ifreq ENDFOR readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' il2 = min([ iim-1, il1+ifreq-1] ) readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' readf, iunit, FORMAT = '(/)' il3 = il2-(ifin-1)*ifreq iformat = string('(', il3+2, 'i3)') ; print, irest-1,il1,il2,il3 FOR jj = ijm-1, 0, -1 DO BEGIN readf, iunit, FORMAT = iformat, ij, zbati2 zbat[il1:il2, jj] = zbati2 ENDFOR close, iunit free_lun, iunit ;; if keyword_set(zero) then zbat = 0 > zbat return, zbat end