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

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

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • 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 $
74                            , IBLOC=ibloc, JPBYT=jpbyt, NUMREC=numrec
75;
76;
77  compile_opt idl2, strictarrsubs
78;
79   iname_file = findfile(filename)
80   if iname_file[0] EQ '' then begin
81      ras = report( 'Bad file name')
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)
88; default parameter definition for ORCA2
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
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'])
107      return, -1
108   endif
109; first record: six 64-bit integer to read.
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
117      ras = report( 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1))
118      return, -1
119   endif
120   if ijmlu NE jpjglo then begin
121      ras = report( 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1))
122      return, -1
123   endif
124   if ikmlu NE jpk then begin
125      ras = report( 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1))
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}
137end
Note: See TracBrowser for help on using the repository browser.