source: trunk/SRC/ReadWrite/readoldopadistcoast.pro @ 326

Last change on this file since 326 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1;+
2;
3; @file_comments
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
7;
8; @categories
9; For OPA
10;
11; @param UNIT
12;
13; @param PARAMS
14;
15; @param NUM
16;
17; @returns
18; a structure that contains two elements: tdistcoast (the
19; distance for the t-points) and fdiscoast (the distance for the
20; f-points).
21;
22; @history
23; Sebastien Masson (smasson\@lodyc.jussieu.fr)
24;                      June, 2002
25; @version
26; $Id$
27;
28;-
29FUNCTION read3fromopa, unit, params, num
30;
31  compile_opt idl2, strictarrsubs
32;
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
37end
38;
39;+
40;
41; @file_comments
42;
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
58;
59; @keyword JPBYT {default=8L}
60; Jpbyt size
61;
62; @keyword NUMREC {default=19L*jpk}
63; Number of records in the file.
64;
65; @history
66; Sebastien Masson (smasson\@lodyc.jussieu.fr)
67;                      June, 2002
68;
69; @version
70; $Id$
71;
72;-
73FUNCTION readoldopadistcoast, filename, jpiglo, jpjglo, jpk, IBLOC = ibloc, JPBYT = jpbyt, NUMREC = numrec
74;
75;
76  compile_opt idl2, strictarrsubs
77;
78   iname_file = findfile(filename)
79   if iname_file[0] EQ '' then begin
80      ras = report( 'Bad file name')
81      return, -1
82   ENDIF ELSE iname_file = iname_file[0]
83; open the file
84   openr,numcost , iname_file, /get_lun, /swap_if_little_endian
85; check the size of the file
86   filepamameters = fstat(numcost)
87; default parameter definition for ORCA2
88   IF keyword_set(ibloc) THEN ibloc = long(ibloc) ELSE ibloc = 4096L
89   jpiglo = long(jpiglo)
90   jpjglo = long(jpjglo)
91   jpk = long(jpk)
92   IF keyword_set(jpbyt) THEN jpbyt = long(jpbyt) ELSE jpbyt = 8L
93; record length computation
94   reclen = ibloc*((jpiglo*jpjglo*jpbyt-1 )/ibloc+1)
95; number of records
96   IF keyword_set(numrec) THEN numrec = long(numrec) ELSE numrec = 3L*jpk
97; difference between the record length and the size of the contened
98; array.
99   toomuch = reclen-jpiglo*jpjglo*jpbyt
100; expected size computation
101   size = numrec*reclen-toomuch
102   if size NE filepamameters.size then begin
103      ras = report(['The size of the file is not the expected one!', $
104      'Check your file or the values of ibloc, jpiglo,', $
105      'jpjglo, jpk, jpbyt, numrec in this program'])
106      return, -1
107   endif
108; first record: six 64-bit integer to read.
109; default definition
110   iimlu = long64(999)
111   ijmlu = long64(999)
112   ikmlu = long64(999)
113; read
114   readu, numcost, iimlu, ijmlu, ikmlu
115   if iimlu NE jpiglo then begin
116      ras = report( 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1))
117      return, -1
118   endif
119   if ijmlu NE jpjglo then begin
120      ras = report( 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1))
121      return, -1
122   endif
123   if ikmlu NE jpk then begin
124      ras = report( 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1))
125      return, -1
126   endif
127; other records
128   params = {jpiglo:jpiglo, jpjglo:jpjglo, jpk:jpk, reclen:reclen}
129   tdistcoast = read3fromopa(numcost, params, 2)
130   fdistcoast = read3fromopa(numcost, params, 3)
131;
132   close, numcost
133   free_lun, numcost
134
135   return, {tdistcoast:tdistcoast, fdistcoast:fdistcoast}
136end
Note: See TracBrowser for help on using the repository browser.