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

Last change on this file since 272 was 240, checked in by pinsard, 17 years ago

replace some print by some report in some .pro (continuation)

  • 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;-
29;
30FUNCTION read3fromopa, unit, params, num
31;
32  compile_opt idl2, strictarrsubs
33;
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
38end
39;
40;+
41;
42; @file_comments
43;
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
59;
60; @keyword JPBYT {default=8L}
61; Jpbyt size
62;
63; @keyword NUMREC {default=19L*jpk}
64; Number of records in the file.
65;
66; @history
67; Sebastien Masson (smasson\@lodyc.jussieu.fr)
68;                      June, 2002
69;
70; @version
71; $Id$
72;
73;-
74;
75FUNCTION readoldopadistcoast, filename, jpiglo, jpjglo, jpk, IBLOC = ibloc, JPBYT = jpbyt, NUMREC = numrec
76;
77;
78  compile_opt idl2, strictarrsubs
79;
80   iname_file = findfile(filename)
81   if iname_file[0] EQ '' then begin
82      ras = report( 'Bad file name')
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)
89; default parameter definition for ORCA2
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
105      ras = report(['The size of the file is not the expected one!', $
106      'Check your file or the values of ibloc, jpiglo,', $
107      'jpjglo, jpk, jpbyt, numrec in this program'])
108      return, -1
109   endif
110; first record: six 64-bit integer to read.
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
118      ras = report( 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1))
119      return, -1
120   endif
121   if ijmlu NE jpjglo then begin
122      ras = report( 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1))
123      return, -1
124   endif
125   if ikmlu NE jpk then begin
126      ras = report( 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1))
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}
138end
Note: See TracBrowser for help on using the repository browser.