source: trunk/SRC/ReadWrite/readoldopadistcoast.pro

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • Property svn:keywords set to Id
File size: 3.4 KB
RevLine 
[44]1;+
[232]2;
[106]3; @file_comments
[130]4; read the old binary direct access file that contains the
5; distance to the coast in OPA.
[372]6;
[130]7; based on the OPA subroutines dtacof and parctl
[44]8;
[238]9; @categories
[157]10; For OPA
[44]11;
[157]12; @param UNIT
13;
[238]14; @param PARAMS
[157]15;
16; @param NUM
17;
[238]18; @returns
[136]19; a structure that contains two elements: tdistcoast (the
[495]20; distance for the t-points) and fdistcoast (the distance for the
[44]21; f-points).
22;
[238]23; @history
24; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[44]25;                      June, 2002
[238]26; @version
27; $Id$
28;
[44]29;-
30FUNCTION read3fromopa, unit, params, num
[114]31;
32  compile_opt idl2, strictarrsubs
33;
[44]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
[238]39;
[106]40;+
[238]41;
[157]42; @file_comments
[121]43;
[157]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
[238]59;
[157]60; @keyword JPBYT {default=8L}
61; Jpbyt size
[238]62;
[157]63; @keyword NUMREC {default=19L*jpk}
64; Number of records in the file.
65;
66; @history
67; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[106]68;                      June, 2002
[157]69;
70; @version
71; $Id$
[238]72;
[106]73;-
[327]74FUNCTION readoldopadistcoast, filename, jpiglo, jpjglo, jpk $
75                            , IBLOC=ibloc, JPBYT=jpbyt, NUMREC=numrec
[44]76;
[114]77  compile_opt idl2, strictarrsubs
78;
[44]79   iname_file = findfile(filename)
80   if iname_file[0] EQ '' then begin
[236]81      ras = report( 'Bad file name')
[44]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
[495]87   fileparameters = fstat(numcost)
[121]88; default parameter definition for ORCA2
[44]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
[495]98; difference between the record length and the size of the contained
[44]99; array.
100   toomuch = reclen-jpiglo*jpjglo*jpbyt
101; expected size computation
102   size = numrec*reclen-toomuch
[495]103   if size NE fileparameters.size then begin
[240]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'])
[44]107      return, -1
108   endif
[130]109; first record: six 64-bit integer to read.
[44]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
[236]117      ras = report( 'iimlu = '+strtrim(iimlu, 1)+' differs from jpiglo ='+strtrim(jpiglo, 1))
[44]118      return, -1
119   endif
120   if ijmlu NE jpjglo then begin
[236]121      ras = report( 'ijmlu = '+strtrim(ijmlu, 1)+' differs from jpjglo ='+strtrim(jpjglo, 1))
[44]122      return, -1
123   endif
124   if ikmlu NE jpk then begin
[236]125      ras = report( 'ikmlu = '+strtrim(ikmlu, 1)+' differs from jpk ='+strtrim(jpk, 1))
[44]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.