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