source: trunk/SRC/ReadWrite/readoldoparestart.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: 12.1 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @categories for OPA before NetCDF
7;
8; @restrictions
9; bug for etab and etan written on the same record???
10;
11; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
12;                      June 2002
13; @version $Id$
14;-
15;------------------------------------------------------------
16;------------------------------------------------------------
17;------------------------------------------------------------
18
19
20FUNCTION read2fromopa, unit, params, num
21;
22  compile_opt idl2, strictarrsubs
23;
24   offset=params.reclen*params.jpk*(num-1L)
25   a=assoc(unit,dblarr(params.jpiglo,params.jpjglo,/nozero),offset)
26   return, a[0]
27end
28;+
29; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
30;                      June 2002
31;-
32FUNCTION read3fromopa, unit, params, num
33;
34  compile_opt idl2, strictarrsubs
35;
36   offset=params.reclen*params.jpk*(num-1L)
37   a=assoc(unit,dblarr(params.jpiglo,params.jpjglo,params.jpk,/nozero),offset)
38   return, a[0]
39end
40
41;+
42; @file_comments
43; read the old restart files of OPA (before NetCDF)
44; based on the OPA subroutine dtrlec included at the end of the file.
45;
46; @categories for OPA before NetCDF
47;
48; @param filename {in}{required}
49; with the whole path if necessary
50;
51; @param jpiglo {in}{required}
52; @param jpjglo {in}{required}
53; @param jpk {in}{required}
54; dimensions of the opa grid
55;
56; @keyword IBLOC {default=4096L} ibloc size
57; @keyword JPBYT {default=8L} jpbyt size
58; @keyword NUMREC {default=19L*jpk} number of records in the file
59; @keyword UB
60; @keyword VB
61; @keyword TB
62; @keyword SB
63; @keyword ROTB
64; @keyword HDIVB
65; @keyword UN
66; @keyword VN
67; @keyword TN
68; @keyword SN
69; @keyword ROTN
70; @keyword HDIVN
71; @keyword GCX
72; @keyword GCXB
73; @keyword ETAB
74; @keyword ETAN
75; @keyword BSFB
76; @keyword BSFN
77; @keyword BSFD
78; @keyword EN
79; the variable we want to read.
80;
81; @returns according to the given keywords.
82; @restrictions bug for etab and etan written on the same record???
83;
84; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
85;                      June 2002
86; @version $Id$
87;-
88
89PRO readoldoparestart, filename, jpiglo, jpjglo, jpk, IBLOC = ibloc, JPBYT = jpbyt, NUMREC = numrec, ub = ub, vb = vb, tb = tb, sb = sb, rotb = rotb, hdivb = hdivb, un = un, vn = vn, tn = tn, sn = sn, rotn = rotn, hdivn = hdivn, gcx = gcx, gcxb = gcxb, etab = etab, etan = etan, bsfb = bsfb, bsfn = bsfn, bsfd = bsfd, en = en
90;
91;
92  compile_opt idl2, strictarrsubs
93;
94   iname_file = findfile(filename)
95   if iname_file[0] EQ '' then begin
96      print, 'Bad file name'
97      return
98   ENDIF ELSE iname_file = iname_file[0]
99; open the file
100   openr,numrst , iname_file, /get_lun, /swap_if_little_endian
101; check the size of the file
102   filepamameters = fstat(numrst)
103; parameter definition
104   IF keyword_set(ibloc) THEN ibloc = long(ibloc) ELSE ibloc = 4096L
105   jpiglo = long(jpiglo)
106   jpjglo = long(jpjglo)
107   jpk = long(jpk)
108   IF keyword_set(jpbyt) THEN jpbyt = long(jpbyt) ELSE jpbyt = 8L
109; record length computation
110   reclen = ibloc*((jpiglo*jpjglo*jpbyt-1 )/ibloc+1)
111   IF keyword_set(numrec) THEN numrec = long(numrec) ELSE numrec = 19L*jpk
112   toomuch = reclen-jpiglo*jpjglo*jpbyt
113; expected size computation
114   size = numrec*reclen-toomuch
115   if size NE filepamameters.size then begin
116      print, 'The size of the file is not the expected one!'
117      print, 'Check your file or the values of ibloc, jpiglo,'
118      print, 'jpjglo, jpk, jpbyt, numrec in this program'
119      return
120   endif
121; first record: six 64-bit integer to read.
122; default definition
123   ino1 = long64(9999)
124   it1 = long64(9999)
125   isor1 = long64(9999)
126   ipcg1 = long64(9999)
127   itke1 = long64(9999)
128   idast1 = long64(9999)
129; read
130   readu, numrst, ino1, it1, isor1, ipcg1, itke1, idast1
131   print, ino1, it1, isor1, ipcg1, itke1, idast1
132; other records
133   params = {jpiglo:jpiglo, jpjglo:jpjglo, jpk:jpk, reclen:reclen}
134;      CALL read3(numrst,ub   ,2 )
135   IF arg_present(ub) THEN ub = read3fromopa(numrst, params, 2)
136;      CALL read3(numrst,vb   ,3 )
137   IF arg_present(vb) THEN vb = read3fromopa(numrst, params, 3)
138;      CALL read3(numrst,tb   ,5 )
139   IF arg_present(tb) THEN tb = read3fromopa(numrst, params, 5)
140;      CALL read3(numrst,sb   ,6 )
141   IF arg_present(sb) THEN sb = read3fromopa(numrst, params, 6)
142;      CALL read3(numrst,rotb ,7 )
143   IF arg_present(rotb) THEN rotb = read3fromopa(numrst, params, 7)
144;      CALL read3(numrst,hdivb,8 )
145   IF arg_present(hdivb) THEN hdivb = read3fromopa(numrst, params, 8)
146;      CALL read3(numrst,un   ,9 )
147   IF arg_present(un) THEN un = read3fromopa(numrst, params, 9)
148;      CALL read3(numrst,vn   ,10)
149   IF arg_present(vn) THEN vn = read3fromopa(numrst, params, 10)
150;      CALL read3(numrst,tn   ,12)
151   IF arg_present(tn) THEN tn = read3fromopa(numrst, params, 12)
152;      CALL read3(numrst,sn   ,13)
153   IF arg_present(sn) THEN sn = read3fromopa(numrst, params, 13)
154;      CALL read3(numrst,rotn ,14)
155   IF arg_present(rotn) THEN rotn = read3fromopa(numrst, params, 14)
156;      CALL read3(numrst,hdivn,15)
157   IF arg_present(hdivn) THEN hdivn = read3fromopa(numrst, params, 15)
158;C
159;C ... Read elliptic solver arrays
160;C
161;      CALL read2(numrst,gcx ,jpk,17)
162   IF arg_present(gcx) THEN gcx = read2fromopa(numrst, params, 17)
163;      CALL read2(numrst,gcxb,jpk,18)
164   IF arg_present(gcxb) THEN gcxb = read2fromopa(numrst, params, 18)
165;C
166;#ifdef key_freesurf_cstvol
167;C
168;C ... free surface formulation (eta)
169;C
170;      CALL read2(numrst,etab ,jpk,4 )
171   IF arg_present(etab) THEN etab = read2fromopa(numrst, params, 4)
172;      CALL read2(numrst,etan ,jpk,4 )
173   IF arg_present(etan) THEN etan = read2fromopa(numrst, params, 4)
174;#  else
175;C
176;C ... Rigid-lid formulation (bsf)
177;C
178;      CALL read2(numrst,bsfb ,jpk,4 )
179   IF arg_present(bsfb) THEN bsfb = read2fromopa(numrst, params, 4)
180;      CALL read2(numrst,bsfn ,jpk,11)
181   IF arg_present(bsfn) THEN bsfn = read2fromopa(numrst, params, 11)
182;      CALL read2(numrst,bsfd ,jpk,16)
183   IF arg_present(bsfd) THEN bsfd  = read2fromopa(numrst, params, 16)
184;#endif
185;#ifdef key_zdftke
186;          CALL read3(numrst,en,19)
187   IF arg_present(en) THEN en = read3fromopa(numrst, params, 19)
188
189
190
191   close, numrst
192   free_lun, numrst
193
194   return
195end
196
197
198
199;CDIR$ LIST
200;      SUBROUTINE dtrlec
201;CCC---------------------------------------------------------------------
202;CCC
203;CCC                       ROUTINE dtrlec
204;CCC                     ******************
205;CCC
206;CCC  Purpose :
207;CCC  --------
208;CCC     Read files for restart
209;CCC
210;CC   Method :
211;CC   -------
212;CC      Read the previous fields on the file numrst
213;CC      the first record indicates previous characteristics
214;CC      after control with the present run, we read :
215;CC      - prognostic variables on the second record
216;CC      - elliptic solver arrays
217;CC     - barotropic stream function arrays (default option)
218;CC       or free surface arrays ("key_freesurf_cstvol" defined)
219;CC      - tke arrays ("key_zdftke" defined)
220;CC      for this last three records,  the previous characteristics
221;CC      could be different with those used in the present run.
222;CC
223;CC   Input :
224;CC   ------
225;CC      common
226;CC            /comrst/          : restart parameter
227;CC            /comctl/          : parameters for the control
228;CC
229;CC   Output :
230;CC   -------
231;CC      common
232;CC            /combef/          : previous fields (before)
233;CC            /comnow/          : present fields (now)
234;CC            /combsf/          : barotropic stream function
235;CC            /comspg/          : surface pressure
236;CC            /comsol/          : diagonal preconditioned conjugate
237;CC
238;CC   Modifications :
239;CC   --------------
240;CC      original  : 91-03 ()
241;CC      additions : 92-01 (M. Imbard)
242;CC                : 92-06 correction restart file (M. Imbard)
243;CC                : 98-02 (M. Guyon) FETI method
244;CC      addition  : 98-05 (G. Roullet) free surface
245;CC----------------------------------------------------------------------
246;CC parameters and commons
247;CC ======================
248;CDIR$ NOLIST
249;#include "parameter.h"
250;#include "common.h"
251;CDIR$ LIST
252;CC----------------------------------------------------------------------
253;CC local declarations
254;CC ==================
255;      INTEGER ji, jj, jk, jl
256;      INTEGER ino0, it0, ipcg0, isor0, itke0
257;      INTEGER ino1, it1, isor1, ipcg1, itke1, idast1
258;CC----------------------------------------------------------------------
259;CC statement functions
260;CC ===================
261;CDIR$ NOLIST
262;#include "stafun.h"
263;CDIR$ LIST
264;CCC---------------------------------------------------------------------
265;CCC  OPA8, LODYC (1997)
266;CCC---------------------------------------------------------------------
267;C
268;C
269;C 0. Initialisations
270;C ------------------
271;C
272;      ino0  = no
273;      it0   = nit000
274;      ipcg0 = 0
275;      isor0 = 0
276;      itke0 = 0
277;      isor0 = nsolv-1
278;      ipcg0 = 2-nsolv
279;#ifdef key_zdftke
280;      itke0 = 1
281;#endif
282;C FETI method
283;      IF (nsolv .EQ. 3) THEN
284;          isor0=2
285;          ipcg0=2
286;      ENDIF
287;C
288;      IF(lwp) THEN
289;          WRITE(numout,*) ' '
290;          WRITE(numout,*) ' *** dtrlec:  beginning of restart'
291;          WRITE(numout,*) ' '
292;          WRITE(numout,*) ' the present run :'
293;          WRITE(numout,*) '   job number : ', no
294;          WRITE(numout,*) '   with nit000 : ', nit000
295;          WRITE(numout,*) '   with pcg option ipcg0 : ', ipcg0
296;          WRITE(numout,*) '   with sor option isor0 : ', isor0
297;          WRITE(numout,*) '   with FETI solver option ipcg0 & isor0 : ',
298;     $        ipcg0,' & ',isor0
299;          WRITE(numout,*) '   with tke option itke0 : ', itke0
300;      ENDIF
301;C
302;C 1. Read numrst
303;C --------------
304;C
305;C ... First record
306;C
307;      READ(numrst,REC=1) ino1, it1, isor1, ipcg1, itke1, idast1
308;C
309;      IF(lwp) THEN
310;          WRITE(numout,*) ' '
311;          WRITE(numout,*) ' READ numrst with '
312;          WRITE(numout,*) '   job number : ', ino1
313;          WRITE(numout,*) '   with time step it : ', it1
314;          WRITE(numout,*) '   with pcg option ipcg1 : ', ipcg1
315;          WRITE(numout,*) '   with sor option isor1 : ', isor1
316;          WRITE(numout,*) '   with tke option itke1 : ', itke1
317;          WRITE(numout,*) '   with FETI solver option ipcg1 + isor1 : ',
318;     $        ipcg1 + isor1
319;          WRITE(numout,*) ' '
320;      ENDIF
321;C
322;C ... Control of date
323;C
324;      IF ( (it0-it1).NE.1 .AND. abs(nrstdt).EQ.1 ) THEN
325;          IF(lwp) THEN
326;              WRITE(numout,*) ' ===>>>> : problem with nit000 for the',
327;     $            ' restart'
328;              WRITE(numout,*) ' =======                              ',
329;     $            ' ======='
330;              WRITE(numout,*) ' we stop. verify the file'
331;              WRITE(numout,*) ' or rerun with the value  0 for the'
332;              WRITE(numout,*) ' control of time parameter  nrstdt'
333;              WRITE(numout,*) ' '
334;          ENDIF
335;          STOP 'dtrlec'
336;      ENDIF
337;      IF ( nrstdt.EQ.1 ) ndate0 = idast1
338;C
339;C ... Read prognostic variables
340;C
341;      CALL read3(numrst,ub   ,2 )
342;      CALL read3(numrst,vb   ,3 )
343;      CALL read3(numrst,tb   ,5 )
344;      CALL read3(numrst,sb   ,6 )
345;      CALL read3(numrst,rotb ,7 )
346;      CALL read3(numrst,hdivb,8 )
347;      CALL read3(numrst,un   ,9 )
348;      CALL read3(numrst,vn   ,10)
349;      CALL read3(numrst,tn   ,12)
350;      CALL read3(numrst,sn   ,13)
351;      CALL read3(numrst,rotn ,14)
352;      CALL read3(numrst,hdivn,15)
353;C
354;C ... Read elliptic solver arrays
355;C
356;      CALL read2(numrst,gcx ,jpk,17)
357;      CALL read2(numrst,gcxb,jpk,18)
358;C
359;#ifdef key_freesurf_cstvol
360;C
361;C ... free surface formulation (eta)
362;C
363;      CALL read2(numrst,etab ,jpk,4 )
364;      CALL read2(numrst,etan ,jpk,4 )
365;#  else
366;C
367;C ... Rigid-lid formulation (bsf)
368;C
369;      CALL read2(numrst,bsfb ,jpk,4 )
370;      CALL read2(numrst,bsfn ,jpk,11)
371;      CALL read2(numrst,bsfd ,jpk,16)
372;#endif
373;C
374;#ifdef key_zdftke
375;C
376;C ... Read tke arrays
377;C
378;      IF(itke1.eq.1) THEN
379;          CALL read3(numrst,en,19)
380;      ELSE
381;          IF(lwp) THEN
382;              WRITE(numout,*) ' ===>>>> : the previous restart file',
383;     $            ' didnt used  tke scheme'
384;              WRITE(numout,*) ' =======                ======='
385;          ENDIF
386;          nrstdt=2
387;      ENDIF
388;#endif
389;C
390;C
391;      RETURN
392;      END
Note: See TracBrowser for help on using the repository browser.