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

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

improvements/corrections of some *.pro headers

  • 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;
14; @param PARAMS
15;
16;
17; @param NUM
18;
19;
20; @returns 
21; a structure that contains two elements: tdistcoast (the
22; distance for the t-points) and fdiscoast (the distance for the
23; f-points).
24;
25; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
26;                      June, 2002
27; @version $Id$
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; @file_comments
42;
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;
53; @param JPJGLO {in}{required}
54;
55;
56; @param JPK {in}{required}
57; Dimensions of the opa grid
58;
59; @keyword IBLOC {default=4096L}
60; Ibloc size
61;
62; @keyword JPBYT {default=8L}
63; Jpbyt size
64;
65; @keyword NUMREC {default=19L*jpk}
66; Number of records in the file.
67;
68; @history
69; Sebastien Masson (smasson\@lodyc.jussieu.fr)
70;                      June, 2002
71;
72; @version
73; $Id$
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      print, '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      print, 'The size of the file is not the expected one!'
106      print, 'Check your file or the values of ibloc, jpiglo,'
107      print, '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      print, 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1)
119      return, -1
120   endif
121   if ijmlu NE jpjglo then begin
122      print, 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1)
123      return, -1
124   endif
125   if ikmlu NE jpk then begin
126      print, '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.