[44] | 1 | ;+ |
---|
[232] | 2 | ; |
---|
[106] | 3 | ; @file_comments |
---|
[130] | 4 | ; read the old binary direct access file that contains the |
---|
| 5 | ; distance to the coast in OPA. |
---|
| 6 | ; based on the OPA subroutines dtacof and parctl |
---|
[44] | 7 | ; |
---|
[238] | 8 | ; @categories |
---|
[157] | 9 | ; For OPA |
---|
[44] | 10 | ; |
---|
[157] | 11 | ; @param UNIT |
---|
| 12 | ; |
---|
[238] | 13 | ; @param PARAMS |
---|
[157] | 14 | ; |
---|
| 15 | ; @param NUM |
---|
| 16 | ; |
---|
[238] | 17 | ; @returns |
---|
[136] | 18 | ; a structure that contains two elements: tdistcoast (the |
---|
[44] | 19 | ; distance for the t-points) and fdiscoast (the distance for the |
---|
| 20 | ; f-points). |
---|
| 21 | ; |
---|
[238] | 22 | ; @history |
---|
| 23 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[44] | 24 | ; June, 2002 |
---|
[238] | 25 | ; @version |
---|
| 26 | ; $Id$ |
---|
| 27 | ; |
---|
[44] | 28 | ;- |
---|
| 29 | FUNCTION read3fromopa, unit, params, num |
---|
[114] | 30 | ; |
---|
| 31 | compile_opt idl2, strictarrsubs |
---|
| 32 | ; |
---|
[44] | 33 | offset=params.reclen*params.jpk*(num-1L) |
---|
| 34 | a=assoc(unit,dblarr(params.jpiglo,params.jpjglo,params.jpk,/nozero),offset) |
---|
| 35 | b = a[0] |
---|
| 36 | return, b |
---|
| 37 | end |
---|
[238] | 38 | ; |
---|
[106] | 39 | ;+ |
---|
[238] | 40 | ; |
---|
[157] | 41 | ; @file_comments |
---|
[121] | 42 | ; |
---|
[157] | 43 | ; @categories |
---|
| 44 | ; For OPA |
---|
| 45 | ; |
---|
| 46 | ; @param FILENAME {in}{required} |
---|
| 47 | ; Filename (with the whole path if necessary) |
---|
| 48 | ; |
---|
| 49 | ; @param JPIGLO {in}{required} |
---|
| 50 | ; |
---|
| 51 | ; @param JPJGLO {in}{required} |
---|
| 52 | ; |
---|
| 53 | ; @param JPK {in}{required} |
---|
| 54 | ; Dimensions of the opa grid |
---|
| 55 | ; |
---|
| 56 | ; @keyword IBLOC {default=4096L} |
---|
| 57 | ; Ibloc size |
---|
[238] | 58 | ; |
---|
[157] | 59 | ; @keyword JPBYT {default=8L} |
---|
| 60 | ; Jpbyt size |
---|
[238] | 61 | ; |
---|
[157] | 62 | ; @keyword NUMREC {default=19L*jpk} |
---|
| 63 | ; Number of records in the file. |
---|
| 64 | ; |
---|
| 65 | ; @history |
---|
| 66 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[106] | 67 | ; June, 2002 |
---|
[157] | 68 | ; |
---|
| 69 | ; @version |
---|
| 70 | ; $Id$ |
---|
[238] | 71 | ; |
---|
[106] | 72 | ;- |
---|
[327] | 73 | FUNCTION readoldopadistcoast, filename, jpiglo, jpjglo, jpk $ |
---|
| 74 | , IBLOC=ibloc, JPBYT=jpbyt, NUMREC=numrec |
---|
[44] | 75 | ; |
---|
[114] | 76 | ; |
---|
| 77 | compile_opt idl2, strictarrsubs |
---|
| 78 | ; |
---|
[44] | 79 | iname_file = findfile(filename) |
---|
| 80 | if iname_file[0] EQ '' then begin |
---|
[236] | 81 | ras = report( 'Bad file name') |
---|
[44] | 82 | return, -1 |
---|
| 83 | ENDIF ELSE iname_file = iname_file[0] |
---|
| 84 | ; open the file |
---|
| 85 | openr,numcost , iname_file, /get_lun, /swap_if_little_endian |
---|
| 86 | ; check the size of the file |
---|
| 87 | filepamameters = fstat(numcost) |
---|
[121] | 88 | ; default parameter definition for ORCA2 |
---|
[44] | 89 | IF keyword_set(ibloc) THEN ibloc = long(ibloc) ELSE ibloc = 4096L |
---|
| 90 | jpiglo = long(jpiglo) |
---|
| 91 | jpjglo = long(jpjglo) |
---|
| 92 | jpk = long(jpk) |
---|
| 93 | IF keyword_set(jpbyt) THEN jpbyt = long(jpbyt) ELSE jpbyt = 8L |
---|
| 94 | ; record length computation |
---|
| 95 | reclen = ibloc*((jpiglo*jpjglo*jpbyt-1 )/ibloc+1) |
---|
| 96 | ; number of records |
---|
| 97 | IF keyword_set(numrec) THEN numrec = long(numrec) ELSE numrec = 3L*jpk |
---|
| 98 | ; difference between the record length and the size of the contened |
---|
| 99 | ; array. |
---|
| 100 | toomuch = reclen-jpiglo*jpjglo*jpbyt |
---|
| 101 | ; expected size computation |
---|
| 102 | size = numrec*reclen-toomuch |
---|
| 103 | if size NE filepamameters.size then begin |
---|
[240] | 104 | ras = report(['The size of the file is not the expected one!', $ |
---|
| 105 | 'Check your file or the values of ibloc, jpiglo,', $ |
---|
| 106 | 'jpjglo, jpk, jpbyt, numrec in this program']) |
---|
[44] | 107 | return, -1 |
---|
| 108 | endif |
---|
[130] | 109 | ; first record: six 64-bit integer to read. |
---|
[44] | 110 | ; default definition |
---|
| 111 | iimlu = long64(999) |
---|
| 112 | ijmlu = long64(999) |
---|
| 113 | ikmlu = long64(999) |
---|
| 114 | ; read |
---|
| 115 | readu, numcost, iimlu, ijmlu, ikmlu |
---|
| 116 | if iimlu NE jpiglo then begin |
---|
[236] | 117 | ras = report( 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1)) |
---|
[44] | 118 | return, -1 |
---|
| 119 | endif |
---|
| 120 | if ijmlu NE jpjglo then begin |
---|
[236] | 121 | ras = report( 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1)) |
---|
[44] | 122 | return, -1 |
---|
| 123 | endif |
---|
| 124 | if ikmlu NE jpk then begin |
---|
[236] | 125 | ras = report( 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1)) |
---|
[44] | 126 | return, -1 |
---|
| 127 | endif |
---|
| 128 | ; other records |
---|
| 129 | params = {jpiglo:jpiglo, jpjglo:jpjglo, jpk:jpk, reclen:reclen} |
---|
| 130 | tdistcoast = read3fromopa(numcost, params, 2) |
---|
| 131 | fdistcoast = read3fromopa(numcost, params, 3) |
---|
| 132 | ; |
---|
| 133 | close, numcost |
---|
| 134 | free_lun, numcost |
---|
| 135 | |
---|
| 136 | return, {tdistcoast:tdistcoast, fdistcoast:fdistcoast} |
---|
| 137 | end |
---|