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

Last change on this file since 177 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; @file_comments
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
9;
10; @categories
11; For OPA
12;
13; @param UNIT
14;
15;
16; @param PARAMS
17;
18;
19; @param NUM
20;
21;
22; @returns 
23; a structure that contains two elements: tdistcoast (the
24; distance for the t-points) and fdiscoast (the distance for the
25; f-points).
26;
27; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
28;                      June, 2002
29; @version $Id$
30;-
31;------------------------------------------------------------
32;------------------------------------------------------------
33;------------------------------------------------------------
34
35FUNCTION read3fromopa, unit, params, num
36;
37  compile_opt idl2, strictarrsubs
38;
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
43end
44
45;+
46; @file_comments
47;
48;
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)
75;                      June, 2002
76;
77; @version
78; $Id$
79;-
80FUNCTION readoldopadistcoast, filename, jpiglo, jpjglo, jpk, IBLOC = ibloc, JPBYT = jpbyt, NUMREC = numrec
81;
82;
83  compile_opt idl2, strictarrsubs
84;
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)
94; default parameter definition for ORCA2
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
115; first record: six 64-bit integer to read.
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
123      print, 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1)
124      return, -1
125   endif
126   if ijmlu NE jpjglo then begin
127      print, 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1)
128      return, -1
129   endif
130   if ikmlu NE jpk then begin
131      print, 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1)
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}
143end
Note: See TracBrowser for help on using the repository browser.