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

Last change on this file since 150 was 136, checked in by pinsard, 18 years ago

some improvements and corrections in some .pro file according to
aspell and idldoc log file

  • Property svn:keywords set to Id
File size: 3.6 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 for OPA before NetCDF
11;
12; @returns 
13; a structure that contains two elements: tdistcoast (the
14; distance for the t-points) and fdiscoast (the distance for the
15; f-points).
16;
17; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
18;                      June, 2002
19; @version $Id$
20;-
21;------------------------------------------------------------
22;------------------------------------------------------------
23;------------------------------------------------------------
24
25FUNCTION read3fromopa, unit, params, num
26;
27  compile_opt idl2, strictarrsubs
28;
29   offset=params.reclen*params.jpk*(num-1L)
30   a=assoc(unit,dblarr(params.jpiglo,params.jpjglo,params.jpk,/nozero),offset)
31   b = a[0]
32   return, b
33end
34
35;+
36; @param filename {in}{required} filename (with the whole path if necessary)
37; @param jpiglo {in}{required}
38; @param jpjglo {in}{required}
39; @param jpk {in}{required}
40; dimensions of the opa grid
41;
42; @keyword IBLOC {default=4096L} ibloc size
43; @keyword JPBYT {default=8L} jpbyt size
44; @keyword NUMREC {default=19L*jpk} number of records in the file.
45;
46; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
47;                      June, 2002
48;-
49FUNCTION readoldopadistcoast, filename, jpiglo, jpjglo, jpk, IBLOC = ibloc, JPBYT = jpbyt, NUMREC = numrec
50;
51;
52  compile_opt idl2, strictarrsubs
53;
54   iname_file = findfile(filename)
55   if iname_file[0] EQ '' then begin
56      print, 'Bad file name'
57      return, -1
58   ENDIF ELSE iname_file = iname_file[0]
59; open the file
60   openr,numcost , iname_file, /get_lun, /swap_if_little_endian
61; check the size of the file
62   filepamameters = fstat(numcost)
63; default parameter definition for ORCA2
64   IF keyword_set(ibloc) THEN ibloc = long(ibloc) ELSE ibloc = 4096L
65   jpiglo = long(jpiglo)
66   jpjglo = long(jpjglo)
67   jpk = long(jpk)
68   IF keyword_set(jpbyt) THEN jpbyt = long(jpbyt) ELSE jpbyt = 8L
69; record length computation
70   reclen = ibloc*((jpiglo*jpjglo*jpbyt-1 )/ibloc+1)
71; number of records
72   IF keyword_set(numrec) THEN numrec = long(numrec) ELSE numrec = 3L*jpk
73; difference between the record length and the size of the contened
74; array.
75   toomuch = reclen-jpiglo*jpjglo*jpbyt
76; expected size computation
77   size = numrec*reclen-toomuch
78   if size NE filepamameters.size then begin
79      print, 'The size of the file is not the expected one!'
80      print, 'Check your file or the values of ibloc, jpiglo,'
81      print, 'jpjglo, jpk, jpbyt, numrec in this program'
82      return, -1
83   endif
84; first record: six 64-bit integer to read.
85; default definition
86   iimlu = long64(999)
87   ijmlu = long64(999)
88   ikmlu = long64(999)
89; read
90   readu, numcost, iimlu, ijmlu, ikmlu
91   if iimlu NE jpiglo then begin
92      print, 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1)
93      return, -1
94   endif
95   if ijmlu NE jpjglo then begin
96      print, 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1)
97      return, -1
98   endif
99   if ikmlu NE jpk then begin
100      print, 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1)
101      return, -1
102   endif
103; other records
104   params = {jpiglo:jpiglo, jpjglo:jpjglo, jpk:jpk, reclen:reclen}
105   tdistcoast = read3fromopa(numcost, params, 2)
106   fdistcoast = read3fromopa(numcost, params, 3)
107;
108   close, numcost
109   free_lun, numcost
110
111   return, {tdistcoast:tdistcoast, fdistcoast:fdistcoast}
112end
Note: See TracBrowser for help on using the repository browser.