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