source: IOIPSL/trunk/src/getincom.f90 @ 441

Last change on this file since 441 was 386, checked in by bellier, 16 years ago

Added CeCILL License information

  • Property svn:keywords set to Id
File size: 55.0 KB
RevLine 
[386]1MODULE getincom
2!-
[11]3!$Id$
[4]4!-
[386]5! This software is governed by the CeCILL license
6! See IOIPSL/IOIPSL_License_CeCILL.txt
[4]7!---------------------------------------------------------------------
[11]8USE errioipsl, ONLY : ipslerr
9USE stringop, &
[125]10 &   ONLY : nocomma,cmpblank,strlowercase
[4]11!-
[11]12IMPLICIT NONE
[4]13!-
[11]14PRIVATE
15PUBLIC :: getin, getin_dump
[4]16!-
[11]17INTERFACE getin
[125]18!!--------------------------------------------------------------------
19!! The "getin" routines get a variable.
20!! We first check if we find it in the database
21!! and if not we get it from the run.def file.
22!!
23!! SUBROUTINE getin (target,ret_val)
24!!
25!! INPUT
26!!
27!! (C) target : Name of the variable
28!!
29!! OUTPUT
30!!
31!! (I/R/C/L) ret_val : scalar, vector or matrix that will contain
32!!                     that will contain the (standard)
33!!                     integer/real/character/logical values
34!!--------------------------------------------------------------------
[11]35  MODULE PROCEDURE getinrs, getinr1d, getinr2d, &
36 &                 getinis, getini1d, getini2d, &
37 &                 getincs, getinc1d, getinc2d, &
38 &                 getinls, getinl1d, getinl2d
39END INTERFACE
[4]40!-
[125]41!!--------------------------------------------------------------------
42!! The "getin_dump" routine will dump the content of the database
43!! into a file which has the same format as the run.def file.
44!! The idea is that the user can see which parameters were used
45!! and re-use the file for another run.
46!!
47!!  SUBROUTINE getin_dump (fileprefix)
48!!
49!! OPTIONAL INPUT argument
50!!
51!! (C) fileprefix : allows the user to change the name of the file
52!!                  in which the data will be archived
53!!--------------------------------------------------------------------
54!-
[4]55  INTEGER,PARAMETER :: max_files=100
56  CHARACTER(LEN=100),DIMENSION(max_files),SAVE :: filelist
57  INTEGER,SAVE      :: nbfiles
58!-
[11]59  INTEGER,PARAMETER :: max_lines=500,l_n=30
[4]60  INTEGER,SAVE :: nb_lines
61  CHARACTER(LEN=100),DIMENSION(max_lines),SAVE :: fichier
[125]62  INTEGER,DIMENSION(max_lines),SAVE :: fromfile,compline
63  CHARACTER(LEN=l_n),DIMENSION(max_lines),SAVE :: targetlist
[4]64!-
[11]65  INTEGER,PARAMETER :: n_d_fmt=5,max_msgs=15
66  CHARACTER(LEN=6),SAVE :: c_i_fmt = '(I5.5)'
67!-
[4]68! The data base of parameters
69!-
70  INTEGER,PARAMETER :: memslabs=200
[11]71  INTEGER,PARAMETER :: compress_lim=20
[4]72!-
73  INTEGER,SAVE :: nb_keys=0
74  INTEGER,SAVE :: keymemsize=0
75!-
[125]76! keystr definition
77! name of a key
78!-
[4]79! keystatus definition
80! keystatus = 1 : Value comes from run.def
81! keystatus = 2 : Default value is used
82! keystatus = 3 : Some vector elements were taken from default
83!-
84! keytype definition
[11]85! keytype = 1 : Integer
[4]86! keytype = 2 : Real
87! keytype = 3 : Character
88! keytype = 4 : Logical
89!-
[11]90  INTEGER,PARAMETER :: k_i=1, k_r=2, k_c=3, k_l=4
91!-
[4]92! Allow compression for keys (only for integer and real)
[125]93! keycompress < 0 : not compressed
[4]94! keycompress > 0 : number of repeat of the value
95!-
[125]96TYPE :: t_key
97  CHARACTER(LEN=l_n) :: keystr
98  INTEGER :: keystatus, keytype, keycompress, &
99 &           keyfromfile, keymemstart, keymemlen
100END TYPE t_key
[4]101!-
[125]102  TYPE(t_key),SAVE,ALLOCATABLE,DIMENSION(:) :: key_tab
[4]103!-
[11]104  INTEGER,SAVE,ALLOCATABLE :: i_mem(:)
105  INTEGER,SAVE             :: i_memsize=0, i_mempos=0
106  REAL,SAVE,ALLOCATABLE :: r_mem(:)
107  INTEGER,SAVE          :: r_memsize=0, r_mempos=0
108  CHARACTER(LEN=100),SAVE,ALLOCATABLE :: c_mem(:)
109  INTEGER,SAVE             :: c_memsize=0, c_mempos=0
110  LOGICAL,SAVE,ALLOCATABLE :: l_mem(:)
111  INTEGER,SAVE             :: l_memsize=0, l_mempos=0
[4]112!-
113CONTAINS
114!-
[11]115!=== INTEGER INTERFACE
[4]116!-
[11]117SUBROUTINE getinis (target,ret_val)
[4]118!---------------------------------------------------------------------
119  IMPLICIT NONE
120!-
[11]121  CHARACTER(LEN=*) :: target
122  INTEGER :: ret_val
[4]123!-
[11]124  INTEGER,DIMENSION(1) :: tmp_ret_val
[125]125  INTEGER :: pos,status=0,fileorig
[4]126!---------------------------------------------------------------------
127!-
128! Do we have this target in our database ?
129!-
[125]130  CALL get_findkey (1,target,pos)
[4]131!-
132  tmp_ret_val(1) = ret_val
133!-
134  IF (pos < 0) THEN
135!-- Get the information out of the file
[11]136    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
[4]137!-- Put the data into the database
[11]138    CALL get_wdb &
[125]139 &   (target,status,fileorig,1,i_val=tmp_ret_val)
[4]140  ELSE
141!-- Get the value out of the database
[11]142    CALL get_rdb (pos,1,target,i_val=tmp_ret_val)
[4]143  ENDIF
144  ret_val = tmp_ret_val(1)
145!---------------------
[11]146END SUBROUTINE getinis
[4]147!===
[11]148SUBROUTINE getini1d (target,ret_val)
[4]149!---------------------------------------------------------------------
150  IMPLICIT NONE
151!-
[11]152  CHARACTER(LEN=*) :: target
153  INTEGER,DIMENSION(:) :: ret_val
[4]154!-
[11]155  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
[4]156  INTEGER,SAVE :: tmp_ret_size = 0
[125]157  INTEGER :: pos,size_of_in,status=0,fileorig
[4]158!---------------------------------------------------------------------
159!-
160! Do we have this target in our database ?
161!-
[125]162  CALL get_findkey (1,target,pos)
[4]163!-
164  size_of_in = SIZE(ret_val)
165  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
166    ALLOCATE (tmp_ret_val(size_of_in))
167  ELSE IF (size_of_in > tmp_ret_size) THEN
168    DEALLOCATE (tmp_ret_val)
169    ALLOCATE (tmp_ret_val(size_of_in))
170    tmp_ret_size = size_of_in
171  ENDIF
172  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
173!-
174  IF (pos < 0) THEN
[11]175!-- Get the information out of the file
176    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
[4]177!-- Put the data into the database
[11]178    CALL get_wdb &
[125]179 &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
[4]180  ELSE
181!-- Get the value out of the database
[11]182    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
[4]183  ENDIF
184  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
185!----------------------
[11]186END SUBROUTINE getini1d
[4]187!===
[11]188SUBROUTINE getini2d (target,ret_val)
[4]189!---------------------------------------------------------------------
190  IMPLICIT NONE
191!-
[11]192  CHARACTER(LEN=*) :: target
193  INTEGER,DIMENSION(:,:) :: ret_val
[4]194!-
[11]195  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
[4]196  INTEGER,SAVE :: tmp_ret_size = 0
[125]197  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
[11]198  INTEGER :: jl,jj,ji
[4]199!---------------------------------------------------------------------
200!-
201! Do we have this target in our database ?
202!-
[125]203  CALL get_findkey (1,target,pos)
[4]204!-
205  size_of_in = SIZE(ret_val)
206  size_1 = SIZE(ret_val,1)
207  size_2 = SIZE(ret_val,2)
208  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
209    ALLOCATE (tmp_ret_val(size_of_in))
210  ELSE IF (size_of_in > tmp_ret_size) THEN
211    DEALLOCATE (tmp_ret_val)
212    ALLOCATE (tmp_ret_val(size_of_in))
213    tmp_ret_size = size_of_in
214  ENDIF
215!-
216  jl=0
217  DO jj=1,size_2
218    DO ji=1,size_1
219      jl=jl+1
220      tmp_ret_val(jl) = ret_val(ji,jj)
221    ENDDO
222  ENDDO
223!-
224  IF (pos < 0) THEN
[11]225!-- Get the information out of the file
226    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
[4]227!-- Put the data into the database
[11]228    CALL get_wdb &
[125]229 &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
[4]230  ELSE
231!-- Get the value out of the database
[11]232    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
[4]233  ENDIF
234!-
235  jl=0
236  DO jj=1,size_2
237    DO ji=1,size_1
238      jl=jl+1
239      ret_val(ji,jj) = tmp_ret_val(jl)
240    ENDDO
241  ENDDO
242!----------------------
[11]243END SUBROUTINE getini2d
[4]244!-
[11]245!=== REAL INTERFACE
[4]246!-
[11]247SUBROUTINE getinrs (target,ret_val)
[4]248!---------------------------------------------------------------------
249  IMPLICIT NONE
250!-
[11]251  CHARACTER(LEN=*) :: target
252  REAL :: ret_val
[4]253!-
[11]254  REAL,DIMENSION(1) :: tmp_ret_val
[125]255  INTEGER :: pos,status=0,fileorig
[4]256!---------------------------------------------------------------------
257!-
258! Do we have this target in our database ?
259!-
[125]260  CALL get_findkey (1,target,pos)
[4]261!-
262  tmp_ret_val(1) = ret_val
263!-
264  IF (pos < 0) THEN
[11]265!-- Get the information out of the file
266    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
[4]267!-- Put the data into the database
[11]268    CALL get_wdb &
[125]269 &   (target,status,fileorig,1,r_val=tmp_ret_val)
[11]270  ELSE
[4]271!-- Get the value out of the database
[11]272    CALL get_rdb (pos,1,target,r_val=tmp_ret_val)
[4]273  ENDIF
274  ret_val = tmp_ret_val(1)
275!---------------------
[11]276END SUBROUTINE getinrs
[4]277!===
[11]278SUBROUTINE getinr1d (target,ret_val)
[4]279!---------------------------------------------------------------------
280  IMPLICIT NONE
281!-
[11]282  CHARACTER(LEN=*) :: target
283  REAL,DIMENSION(:) :: ret_val
[4]284!-
[11]285  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
[4]286  INTEGER,SAVE :: tmp_ret_size = 0
[125]287  INTEGER :: pos,size_of_in,status=0,fileorig
[4]288!---------------------------------------------------------------------
289!-
290! Do we have this target in our database ?
291!-
[125]292  CALL get_findkey (1,target,pos)
[4]293!-
294  size_of_in = SIZE(ret_val)
295  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
296    ALLOCATE (tmp_ret_val(size_of_in))
297  ELSE IF (size_of_in > tmp_ret_size) THEN
298    DEALLOCATE (tmp_ret_val)
299    ALLOCATE (tmp_ret_val(size_of_in))
300    tmp_ret_size = size_of_in
301  ENDIF
302  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
303!-
304  IF (pos < 0) THEN
[11]305!-- Get the information out of the file
306    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
[4]307!-- Put the data into the database
[11]308    CALL get_wdb &
[125]309 &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
[4]310  ELSE
311!-- Get the value out of the database
[11]312    CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
[4]313  ENDIF
314  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
315!----------------------
[11]316END SUBROUTINE getinr1d
[4]317!===
[11]318SUBROUTINE getinr2d (target,ret_val)
[4]319!---------------------------------------------------------------------
320  IMPLICIT NONE
321!-
[11]322  CHARACTER(LEN=*) :: target
323  REAL,DIMENSION(:,:) :: ret_val
[4]324!-
[11]325  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
[4]326  INTEGER,SAVE :: tmp_ret_size = 0
[125]327  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
[11]328  INTEGER :: jl,jj,ji
[4]329!---------------------------------------------------------------------
330!-
331! Do we have this target in our database ?
332!-
[125]333  CALL get_findkey (1,target,pos)
[4]334!-
335  size_of_in = SIZE(ret_val)
336  size_1 = SIZE(ret_val,1)
337  size_2 = SIZE(ret_val,2)
338  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
339    ALLOCATE (tmp_ret_val(size_of_in))
340  ELSE IF (size_of_in > tmp_ret_size) THEN
341    DEALLOCATE (tmp_ret_val)
342    ALLOCATE (tmp_ret_val(size_of_in))
343    tmp_ret_size = size_of_in
344  ENDIF
345!-
346  jl=0
347  DO jj=1,size_2
348    DO ji=1,size_1
349      jl=jl+1
350      tmp_ret_val(jl) = ret_val(ji,jj)
351    ENDDO
352  ENDDO
353!-
354  IF (pos < 0) THEN
[11]355!-- Get the information out of the file
356    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
[4]357!-- Put the data into the database
[11]358    CALL get_wdb &
[125]359 &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
[4]360  ELSE
361!-- Get the value out of the database
[11]362    CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
[4]363  ENDIF
364!-
365  jl=0
366  DO jj=1,size_2
367    DO ji=1,size_1
368      jl=jl+1
369      ret_val(ji,jj) = tmp_ret_val(jl)
370    ENDDO
371  ENDDO
372!----------------------
[11]373END SUBROUTINE getinr2d
[4]374!-
[11]375!=== CHARACTER INTERFACE
[4]376!-
[11]377SUBROUTINE getincs (target,ret_val)
[4]378!---------------------------------------------------------------------
379  IMPLICIT NONE
380!-
[11]381  CHARACTER(LEN=*) :: target
[4]382  CHARACTER(LEN=*) :: ret_val
383!-
384  CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val
[125]385  INTEGER :: pos,status=0,fileorig
[4]386!---------------------------------------------------------------------
387!-
388! Do we have this target in our database ?
389!-
[125]390  CALL get_findkey (1,target,pos)
[4]391!-
392  tmp_ret_val(1) = ret_val
393!-
394  IF (pos < 0) THEN
[11]395!-- Get the information out of the file
396    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
[4]397!-- Put the data into the database
[11]398    CALL get_wdb &
[125]399 &   (target,status,fileorig,1,c_val=tmp_ret_val)
[4]400  ELSE
401!-- Get the value out of the database
[11]402    CALL get_rdb (pos,1,target,c_val=tmp_ret_val)
[4]403  ENDIF
404  ret_val = tmp_ret_val(1)
405!---------------------
406END SUBROUTINE getincs
407!===
[11]408SUBROUTINE getinc1d (target,ret_val)
[4]409!---------------------------------------------------------------------
410  IMPLICIT NONE
411!-
[11]412  CHARACTER(LEN=*) :: target
[4]413  CHARACTER(LEN=*),DIMENSION(:) :: ret_val
414!-
415  CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
416  INTEGER,SAVE :: tmp_ret_size = 0
[125]417  INTEGER :: pos,size_of_in,status=0,fileorig
[4]418!---------------------------------------------------------------------
419!-
420! Do we have this target in our database ?
421!-
[125]422  CALL get_findkey (1,target,pos)
[4]423!-
424  size_of_in = SIZE(ret_val)
425  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
426    ALLOCATE (tmp_ret_val(size_of_in))
427  ELSE IF (size_of_in > tmp_ret_size) THEN
428    DEALLOCATE (tmp_ret_val)
429    ALLOCATE (tmp_ret_val(size_of_in))
430    tmp_ret_size = size_of_in
431  ENDIF
432  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
433!-
434  IF (pos < 0) THEN
[11]435!-- Get the information out of the file
436    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
[4]437!-- Put the data into the database
[11]438    CALL get_wdb &
[125]439 &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
[4]440  ELSE
441!-- Get the value out of the database
[11]442    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
[4]443  ENDIF
444  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
445!----------------------
446END SUBROUTINE getinc1d
447!===
[11]448SUBROUTINE getinc2d (target,ret_val)
[4]449!---------------------------------------------------------------------
450  IMPLICIT NONE
451!-
[11]452  CHARACTER(LEN=*) :: target
[4]453  CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val
454!-
455  CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
456  INTEGER,SAVE :: tmp_ret_size = 0
[125]457  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
[4]458  INTEGER :: jl,jj,ji
459!---------------------------------------------------------------------
460!-
461! Do we have this target in our database ?
462!-
[125]463  CALL get_findkey (1,target,pos)
[4]464!-
465  size_of_in = SIZE(ret_val)
466  size_1 = SIZE(ret_val,1)
467  size_2 = SIZE(ret_val,2)
468  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
469    ALLOCATE (tmp_ret_val(size_of_in))
470  ELSE IF (size_of_in > tmp_ret_size) THEN
471    DEALLOCATE (tmp_ret_val)
472    ALLOCATE (tmp_ret_val(size_of_in))
473    tmp_ret_size = size_of_in
474  ENDIF
475!-
476  jl=0
477  DO jj=1,size_2
478    DO ji=1,size_1
479      jl=jl+1
480      tmp_ret_val(jl) = ret_val(ji,jj)
481    ENDDO
482  ENDDO
483!-
484  IF (pos < 0) THEN
[11]485!-- Get the information out of the file
486    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
[4]487!-- Put the data into the database
[11]488    CALL get_wdb &
[125]489 &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
[4]490  ELSE
491!-- Get the value out of the database
[11]492    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
[4]493  ENDIF
494!-
495  jl=0
496  DO jj=1,size_2
497    DO ji=1,size_1
498      jl=jl+1
499      ret_val(ji,jj) = tmp_ret_val(jl)
500    ENDDO
501  ENDDO
502!----------------------
503END SUBROUTINE getinc2d
504!-
[11]505!=== LOGICAL INTERFACE
[4]506!-
[11]507SUBROUTINE getinls (target,ret_val)
[4]508!---------------------------------------------------------------------
509  IMPLICIT NONE
510!-
[11]511  CHARACTER(LEN=*) :: target
[4]512  LOGICAL :: ret_val
513!-
514  LOGICAL,DIMENSION(1) :: tmp_ret_val
[125]515  INTEGER :: pos,status=0,fileorig
[4]516!---------------------------------------------------------------------
517!-
518! Do we have this target in our database ?
519!-
[125]520  CALL get_findkey (1,target,pos)
[4]521!-
522  tmp_ret_val(1) = ret_val
523!-
524  IF (pos < 0) THEN
[11]525!-- Get the information out of the file
526    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
[4]527!-- Put the data into the database
[11]528    CALL get_wdb &
[125]529 &   (target,status,fileorig,1,l_val=tmp_ret_val)
[4]530  ELSE
531!-- Get the value out of the database
[11]532    CALL get_rdb (pos,1,target,l_val=tmp_ret_val)
[4]533  ENDIF
534  ret_val = tmp_ret_val(1)
535!---------------------
536END SUBROUTINE getinls
537!===
[11]538SUBROUTINE getinl1d (target,ret_val)
[4]539!---------------------------------------------------------------------
540  IMPLICIT NONE
541!-
[11]542  CHARACTER(LEN=*) :: target
[4]543  LOGICAL,DIMENSION(:) :: ret_val
544!-
545  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
546  INTEGER,SAVE :: tmp_ret_size = 0
[125]547  INTEGER :: pos,size_of_in,status=0,fileorig
[4]548!---------------------------------------------------------------------
549!-
550! Do we have this target in our database ?
551!-
[125]552  CALL get_findkey (1,target,pos)
[4]553!-
554  size_of_in = SIZE(ret_val)
555  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
556    ALLOCATE (tmp_ret_val(size_of_in))
557  ELSE IF (size_of_in > tmp_ret_size) THEN
558    DEALLOCATE (tmp_ret_val)
559    ALLOCATE (tmp_ret_val(size_of_in))
560    tmp_ret_size = size_of_in
561  ENDIF
562  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
563!-
564  IF (pos < 0) THEN
[11]565!-- Get the information out of the file
566    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
[4]567!-- Put the data into the database
[11]568    CALL get_wdb &
[125]569 &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
[4]570  ELSE
571!-- Get the value out of the database
[11]572    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
[4]573  ENDIF
574  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
575!----------------------
576END SUBROUTINE getinl1d
577!===
[11]578SUBROUTINE getinl2d (target,ret_val)
[4]579!---------------------------------------------------------------------
580  IMPLICIT NONE
581!-
[11]582  CHARACTER(LEN=*) :: target
[4]583  LOGICAL,DIMENSION(:,:) :: ret_val
584!-
585  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
586  INTEGER,SAVE :: tmp_ret_size = 0
[125]587  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
[4]588  INTEGER :: jl,jj,ji
589!---------------------------------------------------------------------
590!-
591! Do we have this target in our database ?
592!-
[125]593  CALL get_findkey (1,target,pos)
[4]594!-
595  size_of_in = SIZE(ret_val)
596  size_1 = SIZE(ret_val,1)
597  size_2 = SIZE(ret_val,2)
598  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
599    ALLOCATE (tmp_ret_val(size_of_in))
600  ELSE IF (size_of_in > tmp_ret_size) THEN
601    DEALLOCATE (tmp_ret_val)
602    ALLOCATE (tmp_ret_val(size_of_in))
603    tmp_ret_size = size_of_in
604  ENDIF
605!-
606  jl=0
607  DO jj=1,size_2
608    DO ji=1,size_1
609      jl=jl+1
610      tmp_ret_val(jl) = ret_val(ji,jj)
611    ENDDO
612  ENDDO
613!-
614  IF (pos < 0) THEN
[11]615!-- Get the information out of the file
616    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
[4]617!-- Put the data into the database
[11]618    CALL get_wdb &
[125]619 &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
[4]620  ELSE
621!-- Get the value out of the database
[11]622    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
[4]623  ENDIF
624!-
625  jl=0
626  DO jj=1,size_2
627    DO ji=1,size_1
628      jl=jl+1
629      ret_val(ji,jj) = tmp_ret_val(jl)
630    ENDDO
631  ENDDO
632!----------------------
633END SUBROUTINE getinl2d
634!-
[11]635!=== Generic file/database INTERFACE
[4]636!-
[11]637SUBROUTINE get_fil (target,status,fileorig,i_val,r_val,c_val,l_val)
[4]638!---------------------------------------------------------------------
639!- Subroutine that will extract from the file the values
640!- attributed to the keyword target
641!-
[11]642!- (C) target    : target for which we will look in the file
643!- (I) status    : tells us from where we obtained the data
644!- (I) fileorig  : index of the file from which the key comes
645!- (I) i_val(:)  : INTEGER(nb_to_ret)   values
646!- (R) r_val(:)  : REAL(nb_to_ret)      values
647!- (L) l_val(:)  : LOGICAL(nb_to_ret)   values
648!- (C) c_val(:)  : CHARACTER(nb_to_ret) values
[4]649!---------------------------------------------------------------------
650  IMPLICIT NONE
651!-
[11]652  CHARACTER(LEN=*) :: target
653  INTEGER,INTENT(OUT) :: status,fileorig
654  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
655  REAL,DIMENSION(:),OPTIONAL             :: r_val
656  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
657  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
[4]658!-
[11]659  INTEGER :: k_typ,nb_to_ret,it,pos,len_str,status_cnt,io_err
660  CHARACTER(LEN=n_d_fmt)  :: cnt
661  CHARACTER(LEN=80) :: str_READ,str_READ_lower
662  CHARACTER(LEN=9)  :: c_vtyp
663  LOGICAL,DIMENSION(:),ALLOCATABLE :: found
664  LOGICAL :: def_beha,compressed
665  CHARACTER(LEN=10) :: c_fmt
666  INTEGER :: i_cmpval
667  REAL    :: r_cmpval
668  INTEGER :: ipos_tr,ipos_fl
669!---------------------------------------------------------------------
[4]670!-
[11]671! Get the type of the argument
672  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
673  SELECT CASE (k_typ)
674  CASE(k_i)
675    nb_to_ret = SIZE(i_val)
676  CASE(k_r)
677    nb_to_ret = SIZE(r_val)
678  CASE(k_c)
679    nb_to_ret = SIZE(c_val)
680  CASE(k_l)
681    nb_to_ret = SIZE(l_val)
682  CASE DEFAULT
683    CALL ipslerr (3,'get_fil', &
684 &   'Internal error','Unknown type of data',' ')
685  END SELECT
686!-
687! Read the file(s)
[4]688  CALL getin_read
689!-
[11]690! Allocate and initialize the memory we need
691  ALLOCATE(found(nb_to_ret))
[4]692  found(:) = .FALSE.
693!-
694! See what we find in the files read
695  DO it=1,nb_to_ret
696!---
697!-- First try the target as it is
[125]698    CALL get_findkey (2,target,pos)
[4]699!---
700!-- Another try
701!---
702    IF (pos < 0) THEN
[11]703      WRITE(UNIT=cnt,FMT=c_i_fmt) it
[125]704      CALL get_findkey (2,TRIM(target)//'__'//cnt,pos)
[4]705    ENDIF
706!---
[11]707!-- We dont know from which file the target could come.
[4]708!-- Thus by default we attribute it to the first file :
709    fileorig = 1
710!---
711    IF (pos > 0) THEN
712!-----
713      found(it) = .TRUE.
714      fileorig = fromfile(pos)
715!-----
716!---- DECODE
717!-----
[11]718      str_READ = ADJUSTL(fichier(pos))
[4]719      str_READ_lower = str_READ
720      CALL strlowercase (str_READ_lower)
721!-----
[11]722      IF (    (TRIM(str_READ_lower) == 'def')     &
723 &        .OR.(TRIM(str_READ_lower) == 'default') ) THEN
[4]724        def_beha = .TRUE.
725      ELSE
726        def_beha = .FALSE.
727        len_str = LEN_TRIM(str_READ)
[11]728        io_err = 0
729        SELECT CASE (k_typ)
730        CASE(k_i)
731          WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') len_str
732          READ (UNIT=str_READ(1:len_str), &
733 &              FMT=c_fmt,IOSTAT=io_err) i_val(it)
734        CASE(k_r)
735          READ (UNIT=str_READ(1:len_str), &
736 &              FMT=*,IOSTAT=io_err) r_val(it)
737        CASE(k_c)
738          c_val(it) = str_READ(1:len_str)
739        CASE(k_l)
740          ipos_tr = -1
741          ipos_fl = -1
742          ipos_tr = MAX(INDEX(str_READ_lower,'tru'), &
743 &                      INDEX(str_READ_lower,'y'))
744          ipos_fl = MAX(INDEX(str_READ_lower,'fal'), &
745 &                      INDEX(str_READ_lower,'n'))
746          IF (ipos_tr > 0) THEN
747            l_val(it) = .TRUE.
748          ELSE IF (ipos_fl > 0) THEN
749            l_val(it) = .FALSE.
750          ELSE
751            io_err = 100
752          ENDIF
753        END SELECT
754        IF (io_err /= 0) THEN
755          CALL ipslerr (3,'get_fil', &
756 &         'Target '//TRIM(target), &
757 &         'is not of '//TRIM(c_vtyp)//' type',' ')
[4]758        ENDIF
759      ENDIF
760!-----
[11]761      IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
762!-------
763!------ Is this the value of a compressed field ?
764        compressed = (compline(pos) > 0)
765        IF (compressed) THEN
766          IF (compline(pos) /= nb_to_ret) THEN
767            CALL ipslerr (2,'get_fil', &
768 &           'For key '//TRIM(target)//' we have a compressed field', &
769 &           'which does not have the right size.', &
770 &           'We will try to fix that.')
771          ENDIF
772          IF      (k_typ == k_i) THEN
773            i_cmpval = i_val(it)
774          ELSE IF (k_typ == k_r) THEN
775            r_cmpval = r_val(it)
776          ENDIF
777        ENDIF
778      ENDIF
[4]779    ELSE
780      found(it) = .FALSE.
[11]781      def_beha = .FALSE.
782      compressed = .FALSE.
[4]783    ENDIF
784  ENDDO
785!-
[11]786  IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
787!---
788!-- If this is a compressed field then we will uncompress it
789    IF (compressed) THEN
790      DO it=1,nb_to_ret
791        IF (.NOT.found(it)) THEN
792          IF      (k_typ == k_i) THEN
793            i_val(it) = i_cmpval
794          ELSE IF (k_typ == k_r) THEN
795          ENDIF
796          found(it) = .TRUE.
797        ENDIF
798      ENDDO
799    ENDIF
800  ENDIF
[4]801!-
[11]802! Now we set the status for what we found
[4]803  IF (def_beha) THEN
804    status = 2
[11]805    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(target)
[4]806  ELSE
807    status_cnt = 0
808    DO it=1,nb_to_ret
[11]809      IF (.NOT.found(it)) THEN
[4]810        status_cnt = status_cnt+1
[11]811        IF      (status_cnt <= max_msgs) THEN
812          WRITE (UNIT=*,FMT='(" USING DEFAULTS : ",A)', &
813 &               ADVANCE='NO') TRIM(target)
814          IF (nb_to_ret > 1) THEN
815            WRITE (UNIT=*,FMT='("__")',ADVANCE='NO')
816            WRITE (UNIT=*,FMT=c_i_fmt,ADVANCE='NO') it
817          ENDIF
818          SELECT CASE (k_typ)
819          CASE(k_i)
820            WRITE (UNIT=*,FMT=*) "=",i_val(it)
821          CASE(k_r)
822            WRITE (UNIT=*,FMT=*) "=",r_val(it)
823          CASE(k_c)
824            WRITE (UNIT=*,FMT=*) "=",c_val(it)
825          CASE(k_l)
826            WRITE (UNIT=*,FMT=*) "=",l_val(it)
827          END SELECT
828        ELSE IF (status_cnt == max_msgs+1) THEN
829          WRITE (UNIT=*,FMT='(" USING DEFAULTS ... ",A)')
[4]830        ENDIF
831      ENDIF
832    ENDDO
833!---
834    IF (status_cnt == 0) THEN
835      status = 1
836    ELSE IF (status_cnt == nb_to_ret) THEN
837      status = 2
838    ELSE
839      status = 3
840    ENDIF
841  ENDIF
[11]842! Deallocate the memory
843  DEALLOCATE(found)
[4]844!---------------------
[11]845END SUBROUTINE get_fil
846!===
847SUBROUTINE get_rdb (pos,size_of_in,target,i_val,r_val,c_val,l_val)
848!---------------------------------------------------------------------
849!- Read the required variable in the database
850!---------------------------------------------------------------------
851  IMPLICIT NONE
[4]852!-
[11]853  INTEGER :: pos,size_of_in
854  CHARACTER(LEN=*) :: target
855  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
856  REAL,DIMENSION(:),OPTIONAL             :: r_val
857  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
858  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
859!-
[125]860  INTEGER :: k_typ,k_beg,k_end
[11]861  CHARACTER(LEN=9) :: c_vtyp
862!---------------------------------------------------------------------
863!-
864! Get the type of the argument
865  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
866  IF (     (k_typ /= k_i).AND.(k_typ /= k_r) &
867 &    .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN
868    CALL ipslerr (3,'get_rdb', &
869 &   'Internal error','Unknown type of data',' ')
870  ENDIF
871!-
[125]872  IF (key_tab(pos)%keytype /= k_typ) THEN
[11]873    CALL ipslerr (3,'get_rdb', &
874 &   'Wrong data type for keyword '//TRIM(target), &
875 &   '(NOT '//TRIM(c_vtyp)//')',' ')
876  ENDIF
877!-
[125]878  IF (key_tab(pos)%keycompress > 0) THEN
879    IF (    (key_tab(pos)%keycompress /= size_of_in) &
880 &      .OR.(key_tab(pos)%keymemlen /= 1) ) THEN
[11]881      CALL ipslerr (3,'get_rdb', &
882 &     'Wrong compression length','for keyword '//TRIM(target),' ')
883    ELSE
884      SELECT CASE (k_typ)
885      CASE(k_i)
[125]886        i_val(1:size_of_in) = i_mem(key_tab(pos)%keymemstart)
[11]887      CASE(k_r)
[125]888        r_val(1:size_of_in) = r_mem(key_tab(pos)%keymemstart)
[11]889      END SELECT
890    ENDIF
891  ELSE
[125]892    IF (key_tab(pos)%keymemlen /= size_of_in) THEN
[11]893      CALL ipslerr (3,'get_rdb', &
894 &     'Wrong array length','for keyword '//TRIM(target),' ')
895    ELSE
[125]896      k_beg = key_tab(pos)%keymemstart
897      k_end = k_beg+key_tab(pos)%keymemlen-1
[11]898      SELECT CASE (k_typ)
899      CASE(k_i)
[125]900        i_val(1:size_of_in) = i_mem(k_beg:k_end)
[11]901      CASE(k_r)
[125]902        r_val(1:size_of_in) = r_mem(k_beg:k_end)
[11]903      CASE(k_c)
[125]904        c_val(1:size_of_in) = c_mem(k_beg:k_end)
[11]905      CASE(k_l)
[125]906        l_val(1:size_of_in) = l_mem(k_beg:k_end)
[11]907      END SELECT
908    ENDIF
909  ENDIF
910!---------------------
911END SUBROUTINE get_rdb
[4]912!===
[11]913SUBROUTINE get_wdb &
[125]914 &  (target,status,fileorig,size_of_in, &
[11]915 &   i_val,r_val,c_val,l_val)
916!---------------------------------------------------------------------
917!- Write data into the data base
918!---------------------------------------------------------------------
919  IMPLICIT NONE
[4]920!-
[11]921  CHARACTER(LEN=*) :: target
[125]922  INTEGER :: status,fileorig,size_of_in
[11]923  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
924  REAL,DIMENSION(:),OPTIONAL             :: r_val
925  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
926  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
927!-
928  INTEGER :: k_typ
929  CHARACTER(LEN=9) :: c_vtyp
[125]930  INTEGER :: k_mempos,k_memsize,k_beg,k_end
[11]931  LOGICAL :: l_cmp
932!---------------------------------------------------------------------
933!-
934! Get the type of the argument
935  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
936  IF (     (k_typ /= k_i).AND.(k_typ /= k_r) &
937 &    .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN
938    CALL ipslerr (3,'get_wdb', &
939 &   'Internal error','Unknown type of data',' ')
940  ENDIF
941!-
942! First check if we have sufficiant space for the new key
943  IF (nb_keys+1 > keymemsize) THEN
944    CALL getin_allockeys ()
945  ENDIF
946!-
947  SELECT CASE (k_typ)
948  CASE(k_i)
949    k_mempos = i_mempos; k_memsize = i_memsize;
950    l_cmp = (MINVAL(i_val) == MAXVAL(i_val)) &
951 &         .AND.(size_of_in > compress_lim)
952  CASE(k_r)
953    k_mempos = r_mempos; k_memsize = r_memsize;
954    l_cmp = (MINVAL(r_val) == MAXVAL(r_val)) &
955 &         .AND.(size_of_in > compress_lim)
956  CASE(k_c)
957    k_mempos = c_mempos; k_memsize = c_memsize;
958    l_cmp = .FALSE.
959  CASE(k_l)
960    k_mempos = l_mempos; k_memsize = l_memsize;
961    l_cmp = .FALSE.
962  END SELECT
963!-
964! Fill out the items of the data base
965  nb_keys = nb_keys+1
[125]966  key_tab(nb_keys)%keystr = target(1:MIN(LEN_TRIM(target),l_n))
967  key_tab(nb_keys)%keystatus = status
968  key_tab(nb_keys)%keytype = k_typ
969  key_tab(nb_keys)%keyfromfile = fileorig
970  key_tab(nb_keys)%keymemstart = k_mempos+1
[11]971  IF (l_cmp) THEN
[125]972    key_tab(nb_keys)%keycompress = size_of_in
973    key_tab(nb_keys)%keymemlen = 1
[11]974  ELSE
[125]975    key_tab(nb_keys)%keycompress = -1
976    key_tab(nb_keys)%keymemlen = size_of_in
[11]977  ENDIF
978!-
979! Before writing the actual size lets see if we have the space
[125]980  IF (key_tab(nb_keys)%keymemstart+key_tab(nb_keys)%keymemlen &
981 &    > k_memsize) THEN
982    CALL getin_allocmem (k_typ,key_tab(nb_keys)%keymemlen)
[11]983  ENDIF
984!-
[125]985  k_beg = key_tab(nb_keys)%keymemstart
986  k_end = k_beg+key_tab(nb_keys)%keymemlen-1
[11]987  SELECT CASE (k_typ)
988  CASE(k_i)
[125]989    i_mem(k_beg:k_end) = i_val(1:key_tab(nb_keys)%keymemlen)
990    i_mempos = k_end
[11]991  CASE(k_r)
[125]992    r_mem(k_beg:k_end) = r_val(1:key_tab(nb_keys)%keymemlen)
993    r_mempos = k_end
[11]994  CASE(k_c)
[125]995    c_mem(k_beg:k_end) = c_val(1:key_tab(nb_keys)%keymemlen)
996    c_mempos = k_end
[11]997  CASE(k_l)
[125]998    l_mem(k_beg:k_end) = l_val(1:key_tab(nb_keys)%keymemlen)
999    l_mempos = k_end
[11]1000  END SELECT
1001!---------------------
1002END SUBROUTINE get_wdb
1003!-
1004!===
1005!-
[4]1006SUBROUTINE getin_read
1007!---------------------------------------------------------------------
1008  IMPLICIT NONE
1009!-
1010  INTEGER,SAVE :: allread=0
[11]1011  INTEGER,SAVE :: current
[4]1012!---------------------------------------------------------------------
1013  IF (allread == 0) THEN
1014!-- Allocate a first set of memory.
1015    CALL getin_allockeys
[11]1016    CALL getin_allocmem (k_i,0)
1017    CALL getin_allocmem (k_r,0)
1018    CALL getin_allocmem (k_c,0)
1019    CALL getin_allocmem (k_l,0)
[4]1020!-- Start with reading the files
1021    nbfiles = 1
1022    filelist(1) = 'run.def'
1023    current = 1
1024    nb_lines = 0
1025!--
1026    DO WHILE (current <= nbfiles)
1027      CALL getin_readdef (current)
1028      current = current+1
1029    ENDDO
1030    allread = 1
1031    CALL getin_checkcohe ()
1032  ENDIF
1033!------------------------
1034END SUBROUTINE getin_read
1035!-
1036!===
1037!-
1038  SUBROUTINE getin_readdef(current)
1039!---------------------------------------------------------------------
1040!- This subroutine will read the files and only keep the
1041!- the relevant information. The information is kept as it
1042!- found in the file. The data will be analysed later.
1043!---------------------------------------------------------------------
1044  IMPLICIT NONE
1045!-
1046  INTEGER :: current
1047!-
[11]1048  CHARACTER(LEN=100) :: READ_str,NEW_str,last_key,key_str
1049  CHARACTER(LEN=n_d_fmt) :: cnt
1050  CHARACTER(LEN=10) :: c_fmt
[4]1051  INTEGER :: nb_lastkey
1052!-
[11]1053  INTEGER :: eof,ptn,len_str,i,it,iund,io_err
[4]1054  LOGICAL :: check = .FALSE.
1055!---------------------------------------------------------------------
1056  eof = 0
1057  ptn = 1
1058  nb_lastkey = 0
1059!-
1060  IF (check) THEN
1061    WRITE(*,*) 'getin_readdef : Open file ',TRIM(filelist(current))
1062  ENDIF
1063!-
[11]1064  OPEN (UNIT=22,FILE=filelist(current),STATUS="OLD",IOSTAT=io_err)
1065  IF (io_err /= 0) THEN
1066    CALL ipslerr (2,'getin_readdef', &
1067 &  'Could not open file '//TRIM(filelist(current)),' ',' ')
1068    RETURN
1069  ENDIF
[4]1070!-
1071  DO WHILE (eof /= 1)
1072!---
1073    CALL getin_skipafew (22,READ_str,eof,nb_lastkey)
1074    len_str = LEN_TRIM(READ_str)
1075    ptn = INDEX(READ_str,'=')
1076!---
1077    IF (ptn > 0) THEN
1078!---- Get the target
1079      key_str = TRIM(ADJUSTL(READ_str(1:ptn-1)))
[11]1080!---- Make sure that a vector keyword has the right length
1081      iund = INDEX(key_str,'__')
[4]1082      IF (iund > 0) THEN
[11]1083        WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') &
1084 &        LEN_TRIM(key_str)-iund-1
1085        READ(UNIT=key_str(iund+2:LEN_TRIM(key_str)), &
1086 &           FMT=c_fmt,IOSTAT=io_err) it
1087        IF ( (io_err == 0).AND.(it > 0) ) THEN
1088          WRITE(UNIT=cnt,FMT=c_i_fmt) it
[4]1089          key_str = key_str(1:iund+1)//cnt
1090        ELSE
[11]1091          CALL ipslerr (3,'getin_readdef', &
1092 &         'A very strange key has just been found :', &
1093 &         TRIM(key_str),' ')
[4]1094        ENDIF
1095      ENDIF
1096!---- Prepare the content
1097      NEW_str = TRIM(ADJUSTL(READ_str(ptn+1:len_str)))
1098      CALL nocomma (NEW_str)
1099      CALL cmpblank (NEW_str)
1100      NEW_str  = TRIM(ADJUSTL(NEW_str))
1101      IF (check) THEN
1102        WRITE(*,*) &
1103 &        '--> getin_readdef : ',TRIM(key_str),' :: ',TRIM(NEW_str)
1104      ENDIF
1105!---- Decypher the content of NEW_str
1106!-
1107!---- This has to be a new key word, thus :
1108      nb_lastkey = 0
1109!----
1110      CALL getin_decrypt (current,key_str,NEW_str,last_key,nb_lastkey)
1111!----
1112    ELSE IF (len_str > 0) THEN
1113!---- Prepare the key if we have an old one to which
1114!---- we will add the line just read
1115      IF (nb_lastkey > 0) THEN
1116        iund =  INDEX(last_key,'__')
1117        IF (iund > 0) THEN
1118!-------- We only continue a keyword, thus it is easy
1119          key_str = last_key(1:iund-1)
1120        ELSE
1121          IF (nb_lastkey /= 1) THEN
[11]1122            CALL ipslerr (3,'getin_readdef', &
1123 &           'We can not have a scalar keyword', &
1124 &           'and a vector content',' ')
[4]1125          ENDIF
1126!-------- The last keyword needs to be transformed into a vector.
[11]1127          WRITE(UNIT=cnt,FMT=c_i_fmt) 1
[4]1128          targetlist(nb_lines) = &
[11]1129 &         last_key(1:MIN(LEN_TRIM(last_key),l_n-n_d_fmt-2))//'__'//cnt
1130          key_str = last_key(1:LEN_TRIM(last_key))
[4]1131        ENDIF
1132      ENDIF
1133!---- Prepare the content
1134      NEW_str = TRIM(ADJUSTL(READ_str(1:len_str)))
1135      CALL getin_decrypt (current,key_str,NEW_str,last_key,nb_lastkey)
1136    ELSE
[11]1137!---- If we have an empty line then the keyword finishes
[4]1138      nb_lastkey = 0
1139      IF (check) THEN
1140        WRITE(*,*) 'getin_readdef : Have found an emtpy line '
1141      ENDIF
1142    ENDIF
1143  ENDDO
1144!-
[11]1145  CLOSE(UNIT=22)
[4]1146!-
1147  IF (check) THEN
[11]1148    OPEN (UNIT=22,file='run.def.test')
[4]1149    DO i=1,nb_lines
[11]1150      WRITE(UNIT=22,FMT=*) targetlist(i)," : ",fichier(i)
[4]1151    ENDDO
[11]1152    CLOSE(UNIT=22)
[4]1153  ENDIF
1154!---------------------------
1155END SUBROUTINE getin_readdef
1156!-
1157!===
1158!-
1159SUBROUTINE getin_decrypt(current,key_str,NEW_str,last_key,nb_lastkey)
1160!---------------------------------------------------------------------
1161!- This subroutine is going to decypher the line.
1162!- It essentialy checks how many items are included and
1163!- it they can be attached to a key.
1164!---------------------------------------------------------------------
1165  IMPLICIT NONE
1166!-
1167! ARGUMENTS
1168!-
[11]1169  INTEGER :: current,nb_lastkey
1170  CHARACTER(LEN=*) :: key_str,NEW_str,last_key
[4]1171!-
1172! LOCAL
1173!-
[11]1174  INTEGER :: len_str,blk,nbve,starpos
1175  CHARACTER(LEN=100) :: tmp_str,new_key,mult
1176  CHARACTER(LEN=n_d_fmt) :: cnt
1177  CHARACTER(LEN=10) :: c_fmt
[4]1178!---------------------------------------------------------------------
1179  len_str = LEN_TRIM(NEW_str)
1180  blk = INDEX(NEW_str(1:len_str),' ')
1181  tmp_str = NEW_str(1:len_str)
1182!-
1183! If the key is a new file then we take it up. Else
1184! we save the line and go on.
1185!-
1186  IF (INDEX(key_str,'INCLUDEDEF') > 0) THEN
1187    DO WHILE (blk > 0)
1188      IF (nbfiles+1 > max_files) THEN
[11]1189        CALL ipslerr (3,'getin_decrypt', &
1190 &       'Too many files to include',' ',' ')
[4]1191      ENDIF
1192!-----
1193      nbfiles = nbfiles+1
1194      filelist(nbfiles) = tmp_str(1:blk)
1195!-----
1196      tmp_str = TRIM(ADJUSTL(tmp_str(blk+1:LEN_TRIM(tmp_str))))
1197      blk = INDEX(tmp_str(1:LEN_TRIM(tmp_str)),' ')
1198    ENDDO
1199!---
1200    IF (nbfiles+1 > max_files) THEN
[11]1201      CALL ipslerr (3,'getin_decrypt', &
1202 &     'Too many files to include',' ',' ')
[4]1203    ENDIF
1204!---
1205    nbfiles =  nbfiles+1
1206    filelist(nbfiles) = TRIM(ADJUSTL(tmp_str))
1207!---
1208    last_key = 'INCLUDEDEF'
1209    nb_lastkey = 1
1210  ELSE
1211!-
1212!-- We are working on a new line of input
1213!-
1214    nb_lines = nb_lines+1
1215    IF (nb_lines > max_lines) THEN
[11]1216      CALL ipslerr (3,'getin_decrypt', &
1217 &     'Too many lines in the run.def files.', &
1218 &     'You need to increase', &
1219 &     'the parameter max_lines in the module getincom.')
[4]1220    ENDIF
1221!-
1222!-- First we solve the issue of conpressed information. Once
1223!-- this is done all line can be handled in the same way.
1224!-
1225    starpos = INDEX(NEW_str(1:len_str),'*')
1226    IF ( (starpos > 0).AND.(tmp_str(1:1) /= '"') &
1227 &                    .AND.(tmp_str(1:1) /= "'") ) THEN
1228!-----
[11]1229      IF (INDEX(key_str(1:LEN_TRIM(key_str)),'__') > 0) THEN
1230        CALL ipslerr (3,'getin_decrypt', &
1231 &       'We can not have a compressed field of values', &
1232 &       'in a vector notation (TARGET__n).', &
1233 &       'The key at fault : '//TRIM(key_str))
[4]1234      ENDIF
1235!-
1236!---- Read the multiplied
1237!-
1238      mult = TRIM(ADJUSTL(NEW_str(1:starpos-1)))
1239!---- Construct the new string and its parameters
1240      NEW_str = TRIM(ADJUSTL(NEW_str(starpos+1:len_str)))
1241      len_str = LEN_TRIM(NEW_str)
1242      blk = INDEX(NEW_str(1:len_str),' ')
1243      IF (blk > 1) THEN
[11]1244        CALL ipslerr (2,'getin_decrypt', &
1245 &       'This is a strange behavior','you could report',' ')
[4]1246      ENDIF
[11]1247      WRITE (UNIT=c_fmt,FMT='("(I",I5.5,")")') LEN_TRIM(mult)
1248      READ(UNIT=mult,FMT=c_fmt) compline(nb_lines)
[4]1249!---
1250    ELSE
1251      compline(nb_lines) = -1
1252    ENDIF
1253!-
1254!-- If there is no space wthin the line then the target is a scalar
1255!-- or the element of a properly written vector.
[11]1256!-- (ie of the type TARGET__00001)
[4]1257!-
1258    IF (    (blk <= 1) &
1259 &      .OR.(tmp_str(1:1) == '"') &
1260 &      .OR.(tmp_str(1:1) == "'") ) THEN
1261!-
1262      IF (nb_lastkey == 0) THEN
1263!------ Save info of current keyword as a scalar
1264!------ if it is not a continuation
[11]1265        targetlist(nb_lines) = key_str(1:MIN(LEN_TRIM(key_str),l_n))
1266        last_key = key_str(1:MIN(LEN_TRIM(key_str),l_n))
[4]1267        nb_lastkey = 1
1268      ELSE
1269!------ We are continuing a vector so the keyword needs
1270!------ to get the underscores
[11]1271        WRITE(UNIT=cnt,FMT=c_i_fmt) nb_lastkey+1
[4]1272        targetlist(nb_lines) = &
[11]1273 &        key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
1274        last_key = &
1275 &        key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
[4]1276        nb_lastkey = nb_lastkey+1
1277      ENDIF
1278!-----
1279      fichier(nb_lines) = NEW_str(1:len_str)
1280      fromfile(nb_lines) = current
1281    ELSE
1282!-
1283!---- If there are blanks whithin the line then we are dealing
1284!---- with a vector and we need to split it in many entries
[11]1285!---- with the TARGET__n notation.
[4]1286!----
1287!---- Test if the targer is not already a vector target !
1288!-
1289      IF (INDEX(TRIM(key_str),'__') > 0) THEN
[11]1290        CALL ipslerr (3,'getin_decrypt', &
1291 &       'We have found a mixed vector notation (TARGET__n).', &
1292 &       'The key at fault : '//TRIM(key_str),' ')
[4]1293      ENDIF
1294!-
1295      nbve = nb_lastkey
1296      nbve = nbve+1
[11]1297      WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
[4]1298!-
1299      DO WHILE (blk > 0)
1300!-
1301!------ Save the content of target__nbve
1302!-
1303        fichier(nb_lines) = tmp_str(1:blk)
[11]1304        new_key = &
1305 &       key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
1306        targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n))
[4]1307        fromfile(nb_lines) = current
1308!-
1309        tmp_str = TRIM(ADJUSTL(tmp_str(blk+1:LEN_TRIM(tmp_str))))
1310        blk = INDEX(TRIM(tmp_str),' ')
1311!-
1312        nb_lines = nb_lines+1
1313        IF (nb_lines > max_lines) THEN
[11]1314          CALL ipslerr (3,'getin_decrypt', &
1315 &         'Too many lines in the run.def files.', &
1316 &         'You need to increase', &
1317 &         'the parameter max_lines in the module getincom.')
[4]1318        ENDIF
1319        nbve = nbve+1
[11]1320        WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
[4]1321!-
1322      ENDDO
1323!-
1324!---- Save the content of the last target
1325!-
1326      fichier(nb_lines) = tmp_str(1:LEN_TRIM(tmp_str))
[11]1327      new_key = &
1328 &      key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
1329      targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n))
[4]1330      fromfile(nb_lines) = current
1331!-
[11]1332      last_key = &
1333 &      key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
[4]1334      nb_lastkey = nbve
1335!-
1336    ENDIF
1337!-
1338  ENDIF
1339!---------------------------
1340END SUBROUTINE getin_decrypt
1341!-
1342!===
1343!-
1344SUBROUTINE getin_checkcohe ()
1345!---------------------------------------------------------------------
1346!- This subroutine checks for redundancies.
1347!---------------------------------------------------------------------
1348  IMPLICIT NONE
1349!-
[125]1350  INTEGER :: line,n_k,k
[4]1351!---------------------------------------------------------------------
1352  DO line=1,nb_lines-1
1353!-
[125]1354    n_k = 0
1355    DO k=line+1,nb_lines
1356      IF (TRIM(targetlist(line)) == TRIM(targetlist(k))) THEN
1357        n_k = k
1358        EXIT
1359      ENDIF
1360    ENDDO
[4]1361!---
1362!-- IF we have found it we have a problem to solve.
1363!---
[125]1364    IF (n_k > 0) THEN
1365      WRITE(*,*) 'COUNT : ',n_k
[4]1366      WRITE(*,*) &
[125]1367 &  'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line))
[4]1368      WRITE(*,*) &
[125]1369 &  'getin_checkcohe : The following values were encoutered :'
[4]1370      WRITE(*,*) &
[125]1371 &  '                ',TRIM(targetlist(line)),' == ',fichier(line)
[4]1372      WRITE(*,*) &
[125]1373 &  '                ',TRIM(targetlist(k)),' == ',fichier(k)
[4]1374      WRITE(*,*) &
[125]1375 &  'getin_checkcohe : We will keep only the last value'
1376      targetlist(line) = ' '
[4]1377    ENDIF
1378  ENDDO
[11]1379!-----------------------------
[4]1380END SUBROUTINE getin_checkcohe
1381!-
1382!===
1383!-
1384SUBROUTINE getin_skipafew (unit,out_string,eof,nb_lastkey)
1385!---------------------------------------------------------------------
1386  IMPLICIT NONE
1387!-
[11]1388  INTEGER :: unit,eof,nb_lastkey
[4]1389  CHARACTER(LEN=100) :: dummy
1390  CHARACTER(LEN=100) :: out_string
1391  CHARACTER(LEN=1) :: first
1392!---------------------------------------------------------------------
1393  first="#"
1394  eof = 0
1395  out_string = "    "
1396!-
1397  DO WHILE (first == "#")
[11]1398    READ (UNIT=unit,FMT='(A)',ERR=9998,END=7778) dummy
[4]1399    dummy = TRIM(ADJUSTL(dummy))
1400    first=dummy(1:1)
1401    IF (first == "#") THEN
1402      nb_lastkey = 0
1403    ENDIF
1404  ENDDO
1405  out_string=dummy
1406!-
1407  RETURN
1408!-
[11]14099998 CONTINUE
1410  CALL ipslerr (3,'getin_skipafew','Error while reading file',' ',' ')
[4]1411!-
[11]14127778 CONTINUE
1413  eof = 1
[4]1414!----------------------------
1415END SUBROUTINE getin_skipafew
1416!-
1417!===
1418!-
1419SUBROUTINE getin_allockeys ()
1420!---------------------------------------------------------------------
1421  IMPLICIT NONE
1422!-
[125]1423  TYPE(t_key),ALLOCATABLE,DIMENSION(:) :: tmp_key_tab
[4]1424  INTEGER,ALLOCATABLE :: tmp_int(:)
1425  CHARACTER(LEN=100),ALLOCATABLE :: tmp_str(:)
1426!-
1427  INTEGER :: ier
[11]1428  CHARACTER(LEN=20) :: c_tmp
[4]1429!---------------------------------------------------------------------
1430  IF (keymemsize == 0) THEN
[11]1431!---
[125]1432!-- Nothing exists in memory arrays and it is easy to do.
1433!---
[11]1434    WRITE (UNIT=c_tmp,FMT=*) memslabs
[125]1435    ALLOCATE(key_tab(memslabs),stat=ier)
[4]1436    IF (ier /= 0) THEN
[11]1437      CALL ipslerr (3,'getin_allockeys', &
[125]1438 &     'Can not allocate key_tab', &
[11]1439 &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1440    ENDIF
1441    nb_keys = 0
1442    keymemsize = memslabs
[125]1443    key_tab(:)%keycompress = -1
[11]1444!---
[4]1445  ELSE
[11]1446!---
[4]1447!-- There is something already in the memory,
1448!-- we need to transfer and reallocate.
[11]1449!---
1450    WRITE (UNIT=c_tmp,FMT=*) keymemsize
[125]1451    ALLOCATE(tmp_key_tab(keymemsize),stat=ier)
[4]1452    IF (ier /= 0) THEN
[11]1453      CALL ipslerr (3,'getin_allockeys', &
[125]1454 &     'Can not allocate tmp_key_tab', &
[11]1455 &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1456    ENDIF
[11]1457    WRITE (UNIT=c_tmp,FMT=*) keymemsize+memslabs
[125]1458    tmp_key_tab(1:keymemsize) = key_tab(1:keymemsize)
1459    DEALLOCATE(key_tab)
1460    ALLOCATE(key_tab(keymemsize+memslabs),stat=ier)
[4]1461    IF (ier /= 0) THEN
[11]1462      CALL ipslerr (3,'getin_allockeys', &
[125]1463 &     'Can not allocate key_tab', &
[11]1464 &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1465    ENDIF
[125]1466    key_tab(:)%keycompress = -1
1467    key_tab(1:keymemsize) = tmp_key_tab(1:keymemsize)
1468    DEALLOCATE(tmp_key_tab)
[4]1469    keymemsize = keymemsize+memslabs
1470  ENDIF
1471!-----------------------------
1472END SUBROUTINE getin_allockeys
1473!-
1474!===
1475!-
1476SUBROUTINE getin_allocmem (type,len_wanted)
1477!---------------------------------------------------------------------
1478!- Allocate the memory of the data base for all 4 types of memory
[125]1479!- INTEGER / REAL / CHARACTER / LOGICAL
[4]1480!---------------------------------------------------------------------
1481  IMPLICIT NONE
1482!-
[11]1483  INTEGER :: type,len_wanted
[4]1484!-
1485  INTEGER,ALLOCATABLE :: tmp_int(:)
[125]1486  REAL,ALLOCATABLE :: tmp_real(:)
[4]1487  CHARACTER(LEN=100),ALLOCATABLE :: tmp_char(:)
1488  LOGICAL,ALLOCATABLE :: tmp_logic(:)
1489  INTEGER :: ier
[11]1490  CHARACTER(LEN=20) :: c_tmp
[4]1491!---------------------------------------------------------------------
1492  SELECT CASE (type)
[11]1493  CASE(k_i)
1494    IF (i_memsize == 0) THEN
1495      ALLOCATE(i_mem(memslabs),stat=ier)
[4]1496      IF (ier /= 0) THEN
[11]1497        WRITE (UNIT=c_tmp,FMT=*) memslabs
1498        CALL ipslerr (3,'getin_allocmem', &
1499 &       'Unable to allocate db-memory', &
1500 &       'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1501      ENDIF
[11]1502      i_memsize=memslabs
[4]1503    ELSE
[11]1504      ALLOCATE(tmp_int(i_memsize),stat=ier)
[4]1505      IF (ier /= 0) THEN
[11]1506        WRITE (UNIT=c_tmp,FMT=*) i_memsize
1507        CALL ipslerr (3,'getin_allocmem', &
1508 &       'Unable to allocate tmp_int', &
1509 &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1510      ENDIF
[11]1511      tmp_int(1:i_memsize) = i_mem(1:i_memsize)
1512      DEALLOCATE(i_mem)
1513      ALLOCATE(i_mem(i_memsize+MAX(memslabs,len_wanted)),stat=ier)
[4]1514      IF (ier /= 0) THEN
[11]1515        WRITE (UNIT=c_tmp,FMT=*) i_memsize+MAX(memslabs,len_wanted)
1516        CALL ipslerr (3,'getin_allocmem', &
1517 &       'Unable to re-allocate db-memory', &
1518 &       'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1519      ENDIF
[11]1520      i_mem(1:i_memsize) = tmp_int(1:i_memsize)
1521      i_memsize = i_memsize+MAX(memslabs,len_wanted)
[4]1522      DEALLOCATE(tmp_int)
1523    ENDIF
[11]1524  CASE(k_r)
1525    IF (r_memsize == 0) THEN
1526      ALLOCATE(r_mem(memslabs),stat=ier)
[4]1527      IF (ier /= 0) THEN
[11]1528        WRITE (UNIT=c_tmp,FMT=*) memslabs
1529        CALL ipslerr (3,'getin_allocmem', &
1530 &       'Unable to allocate db-memory', &
1531 &       'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1532      ENDIF
[11]1533      r_memsize =  memslabs
[4]1534    ELSE
[11]1535      ALLOCATE(tmp_real(r_memsize),stat=ier)
[4]1536      IF (ier /= 0) THEN
[11]1537        WRITE (UNIT=c_tmp,FMT=*) r_memsize
1538        CALL ipslerr (3,'getin_allocmem', &
1539 &       'Unable to allocate tmp_real', &
1540 &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1541      ENDIF
[11]1542      tmp_real(1:r_memsize) = r_mem(1:r_memsize)
1543      DEALLOCATE(r_mem)
1544      ALLOCATE(r_mem(r_memsize+MAX(memslabs,len_wanted)),stat=ier)
[4]1545      IF (ier /= 0) THEN
[11]1546        WRITE (UNIT=c_tmp,FMT=*) r_memsize+MAX(memslabs,len_wanted)
1547        CALL ipslerr (3,'getin_allocmem', &
1548 &       'Unable to re-allocate db-memory', &
1549 &       'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1550      ENDIF
[11]1551      r_mem(1:r_memsize) = tmp_real(1:r_memsize)
1552      r_memsize = r_memsize+MAX(memslabs,len_wanted)
[4]1553      DEALLOCATE(tmp_real)
1554    ENDIF
[11]1555  CASE(k_c)
1556    IF (c_memsize == 0) THEN
1557      ALLOCATE(c_mem(memslabs),stat=ier)
[4]1558      IF (ier /= 0) THEN
[11]1559        WRITE (UNIT=c_tmp,FMT=*) memslabs
1560        CALL ipslerr (3,'getin_allocmem', &
1561 &       'Unable to allocate db-memory', &
1562 &       'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1563      ENDIF
[11]1564      c_memsize = memslabs
[4]1565    ELSE
[11]1566      ALLOCATE(tmp_char(c_memsize),stat=ier)
[4]1567      IF (ier /= 0) THEN
[11]1568        WRITE (UNIT=c_tmp,FMT=*) c_memsize
1569        CALL ipslerr (3,'getin_allocmem', &
1570 &       'Unable to allocate tmp_char', &
1571 &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1572      ENDIF
[11]1573      tmp_char(1:c_memsize) = c_mem(1:c_memsize)
1574      DEALLOCATE(c_mem)
1575      ALLOCATE(c_mem(c_memsize+MAX(memslabs,len_wanted)),stat=ier)
[4]1576      IF (ier /= 0) THEN
[11]1577        WRITE (UNIT=c_tmp,FMT=*) c_memsize+MAX(memslabs,len_wanted)
1578        CALL ipslerr (3,'getin_allocmem', &
1579 &       'Unable to re-allocate db-memory', &
1580 &       'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1581      ENDIF
[11]1582      c_mem(1:c_memsize) = tmp_char(1:c_memsize)
1583      c_memsize = c_memsize+MAX(memslabs,len_wanted)
[4]1584      DEALLOCATE(tmp_char)
1585    ENDIF
[11]1586  CASE(k_l)
1587    IF (l_memsize == 0) THEN
1588      ALLOCATE(l_mem(memslabs),stat=ier)
[4]1589      IF (ier /= 0) THEN
[11]1590        WRITE (UNIT=c_tmp,FMT=*) memslabs
1591        CALL ipslerr (3,'getin_allocmem', &
1592 &       'Unable to allocate db-memory', &
1593 &       'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1594      ENDIF
[11]1595      l_memsize = memslabs
[4]1596    ELSE
[11]1597      ALLOCATE(tmp_logic(l_memsize),stat=ier)
[4]1598      IF (ier /= 0) THEN
[11]1599        WRITE (UNIT=c_tmp,FMT=*) l_memsize
1600        CALL ipslerr (3,'getin_allocmem', &
1601 &       'Unable to allocate tmp_logic', &
1602 &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1603      ENDIF
[11]1604      tmp_logic(1:l_memsize) = l_mem(1:l_memsize)
1605      DEALLOCATE(l_mem)
1606      ALLOCATE(l_mem(l_memsize+MAX(memslabs,len_wanted)),stat=ier)
[4]1607      IF (ier /= 0) THEN
[11]1608        WRITE (UNIT=c_tmp,FMT=*) l_memsize+MAX(memslabs,len_wanted)
1609        CALL ipslerr (3,'getin_allocmem', &
1610 &       'Unable to re-allocate db-memory', &
1611 &       'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
[4]1612      ENDIF
[11]1613      l_mem(1:l_memsize) = tmp_logic(1:l_memsize)
1614      l_memsize = l_memsize+MAX(memslabs,len_wanted)
[4]1615      DEALLOCATE(tmp_logic)
1616    ENDIF
1617  CASE DEFAULT
[11]1618    CALL ipslerr (3,'getin_allocmem','Unknown type of data',' ',' ')
[4]1619  END SELECT
1620!----------------------------
1621END SUBROUTINE getin_allocmem
1622!-
1623!===
1624!-
1625SUBROUTINE getin_dump (fileprefix)
1626!---------------------------------------------------------------------
1627  IMPLICIT NONE
1628!-
1629  CHARACTER(*),OPTIONAL :: fileprefix
1630!-
[11]1631  CHARACTER(LEN=80) :: usedfileprefix
[4]1632  INTEGER :: ikey,if,iff,iv
[11]1633  CHARACTER(LEN=20) :: c_tmp
1634  CHARACTER(LEN=100) :: tmp_str,used_filename
[4]1635  LOGICAL :: check = .FALSE.
1636!---------------------------------------------------------------------
1637  IF (PRESENT(fileprefix)) THEN
[11]1638    usedfileprefix = fileprefix(1:MIN(LEN_TRIM(fileprefix),80))
1639  ELSE
1640    usedfileprefix = "used"
[4]1641  ENDIF
1642!-
1643  DO if=1,nbfiles
1644!---
1645    used_filename = TRIM(usedfileprefix)//'_'//TRIM(filelist(if))
1646    IF (check) THEN
1647      WRITE(*,*) &
1648 &      'GETIN_DUMP : opens file : ',TRIM(used_filename),' if = ',if
1649      WRITE(*,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys
1650    ENDIF
[11]1651    OPEN (UNIT=22,FILE=used_filename)
1652!---
[4]1653!-- If this is the first file we need to add the list
1654!-- of file which belong to it
[11]1655    IF ( (if == 1).AND.(nbfiles > 1) ) THEN
1656      WRITE(22,*) '# '
1657      WRITE(22,*) '# This file is linked to the following files :'
1658      WRITE(22,*) '# '
[4]1659      DO iff=2,nbfiles
[11]1660        WRITE(22,*) 'INCLUDEDEF = ',TRIM(filelist(iff))
[4]1661      ENDDO
[11]1662      WRITE(22,*) '# '
[4]1663    ENDIF
1664!---
1665    DO ikey=1,nb_keys
[11]1666!-----
1667!---- Is this key from this file ?
[125]1668      IF (key_tab(ikey)%keyfromfile == if) THEN
[11]1669!-------
1670!------ Write some comments
1671        WRITE(22,*) '#'
[125]1672        SELECT CASE (key_tab(ikey)%keystatus)
[4]1673        CASE(1)
[11]1674          WRITE(22,*) '# Values of ', &
[125]1675 &          TRIM(key_tab(ikey)%keystr),' comes from the run.def.'
[4]1676        CASE(2)
[11]1677          WRITE(22,*) '# Values of ', &
[125]1678 &          TRIM(key_tab(ikey)%keystr),' are all defaults.'
[4]1679        CASE(3)
[11]1680          WRITE(22,*) '# Values of ', &
[125]1681 &          TRIM(key_tab(ikey)%keystr), &
1682 &          ' are a mix of run.def and defaults.'
[4]1683        CASE DEFAULT
[11]1684          WRITE(22,*) '# Dont know from where the value of ', &
[125]1685 &          TRIM(key_tab(ikey)%keystr),' comes.'
[4]1686        END SELECT
[11]1687        WRITE(22,*) '#'
1688!-------
1689!------ Write the values
[125]1690        SELECT CASE (key_tab(ikey)%keytype)
[11]1691        CASE(k_i)
[125]1692          IF (key_tab(ikey)%keymemlen == 1) THEN
1693            IF (key_tab(ikey)%keycompress < 0) THEN
[11]1694              WRITE(22,*) &
[125]1695 &              TRIM(key_tab(ikey)%keystr), &
1696 &              ' = ',i_mem(key_tab(ikey)%keymemstart)
[4]1697            ELSE
[11]1698              WRITE(22,*) &
[125]1699 &              TRIM(key_tab(ikey)%keystr), &
1700 &              ' = ',key_tab(ikey)%keycompress, &
1701 &              ' * ',i_mem(key_tab(ikey)%keymemstart)
[4]1702            ENDIF
1703          ELSE
[125]1704            DO iv=0,key_tab(ikey)%keymemlen-1
[11]1705              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
1706              WRITE(22,*) &
[125]1707 &              TRIM(key_tab(ikey)%keystr), &
1708 &              '__',TRIM(ADJUSTL(c_tmp)), &
1709 &              ' = ',i_mem(key_tab(ikey)%keymemstart+iv)
[4]1710            ENDDO
1711          ENDIF
[11]1712        CASE(k_r)
[125]1713          IF (key_tab(ikey)%keymemlen == 1) THEN
1714            IF (key_tab(ikey)%keycompress < 0) THEN
[11]1715              WRITE(22,*) &
[125]1716 &              TRIM(key_tab(ikey)%keystr), &
1717 &              ' = ',r_mem(key_tab(ikey)%keymemstart)
[4]1718            ELSE
[11]1719              WRITE(22,*) &
[125]1720 &              TRIM(key_tab(ikey)%keystr), &
1721 &              ' = ',key_tab(ikey)%keycompress, &
1722                   & ' * ',r_mem(key_tab(ikey)%keymemstart)
[4]1723            ENDIF
1724          ELSE
[125]1725            DO iv=0,key_tab(ikey)%keymemlen-1
[11]1726              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
1727              WRITE(22,*) &
[125]1728 &              TRIM(key_tab(ikey)%keystr),'__',TRIM(ADJUSTL(c_tmp)), &
1729 &              ' = ',r_mem(key_tab(ikey)%keymemstart+iv)
[4]1730            ENDDO
1731          ENDIF
[11]1732        CASE(k_c)
[125]1733          IF (key_tab(ikey)%keymemlen == 1) THEN
1734            tmp_str = c_mem(key_tab(ikey)%keymemstart)
1735            WRITE(22,*) TRIM(key_tab(ikey)%keystr), &
1736 &              ' = ',TRIM(tmp_str)
[4]1737          ELSE
[125]1738            DO iv=0,key_tab(ikey)%keymemlen-1
[11]1739              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
[125]1740              tmp_str = c_mem(key_tab(ikey)%keymemstart+iv)
[11]1741              WRITE(22,*) &
[125]1742 &              TRIM(key_tab(ikey)%keystr), &
1743 &              '__',TRIM(ADJUSTL(c_tmp)), &
[11]1744 &              ' = ',TRIM(tmp_str)
[4]1745            ENDDO
1746          ENDIF
[11]1747        CASE(k_l)
[125]1748          IF (key_tab(ikey)%keymemlen == 1) THEN
1749            IF (l_mem(key_tab(ikey)%keymemstart)) THEN
1750              WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = TRUE '
[4]1751            ELSE
[125]1752              WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = FALSE '
[4]1753            ENDIF
1754          ELSE
[125]1755            DO iv=0,key_tab(ikey)%keymemlen-1
[11]1756              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
[125]1757              IF (l_mem(key_tab(ikey)%keymemstart+iv)) THEN
1758                WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', &
[11]1759 &                          TRIM(ADJUSTL(c_tmp)),' = TRUE '
[4]1760              ELSE
[125]1761                WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', &
[11]1762 &                          TRIM(ADJUSTL(c_tmp)),' = FALSE '
[4]1763              ENDIF
1764            ENDDO
1765          ENDIF
1766        CASE DEFAULT
[11]1767          CALL ipslerr (3,'getin_dump', &
[125]1768 &         'Unknown type for variable '//TRIM(key_tab(ikey)%keystr), &
1769 &         ' ',' ')
[4]1770        END SELECT
1771      ENDIF
1772    ENDDO
1773!-
[11]1774    CLOSE(UNIT=22)
[4]1775!-
1776  ENDDO
1777!------------------------
1778END SUBROUTINE getin_dump
[11]1779!===
1780SUBROUTINE get_qtyp (k_typ,c_vtyp,i_v,r_v,c_v,l_v)
1781!---------------------------------------------------------------------
1782!- Returns the type of the argument (mutually exclusive)
1783!---------------------------------------------------------------------
1784  IMPLICIT NONE
[4]1785!-
[11]1786  INTEGER,INTENT(OUT) :: k_typ
1787  CHARACTER(LEN=*),INTENT(OUT) :: c_vtyp
1788  INTEGER,DIMENSION(:),OPTIONAL          :: i_v
1789  REAL,DIMENSION(:),OPTIONAL             :: r_v
1790  LOGICAL,DIMENSION(:),OPTIONAL          :: l_v
1791  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_v
1792!---------------------------------------------------------------------
1793  k_typ = 0
1794  IF (COUNT((/PRESENT(i_v),PRESENT(r_v),PRESENT(c_v),PRESENT(l_v)/)) &
1795 &    /= 1) THEN
1796    CALL ipslerr (3,'get_qtyp', &
1797 &   'Invalid number of optional arguments','(/= 1)',' ')
1798  ENDIF
1799!-
1800  IF     (PRESENT(i_v)) THEN
1801    k_typ = k_i
1802    c_vtyp = 'INTEGER'
1803  ELSEIF (PRESENT(r_v)) THEN
1804    k_typ = k_r
1805    c_vtyp = 'REAL'
1806  ELSEIF (PRESENT(c_v)) THEN
1807    k_typ = k_c
1808    c_vtyp = 'CHARACTER'
1809  ELSEIF (PRESENT(l_v)) THEN
1810    k_typ = k_l
1811    c_vtyp = 'LOGICAL'
1812  ENDIF
1813!----------------------
1814END SUBROUTINE get_qtyp
[4]1815!===
[125]1816SUBROUTINE get_findkey (i_tab,c_key,pos)
1817!---------------------------------------------------------------------
1818!- This subroutine looks for a key in a table
1819!---------------------------------------------------------------------
1820!- INPUT
1821!-   i_tab  : 1 -> search in key_tab(1:nb_keys)%keystr
1822!-            2 -> search in targetlist(1:nb_lines)
1823!-   c_key  : Name of the key we are looking for
1824!- OUTPUT
1825!-   pos    : -1 if key not found, else value in the table
1826!---------------------------------------------------------------------
1827  IMPLICIT NONE
1828!-
1829  INTEGER,INTENT(in) :: i_tab
1830  CHARACTER(LEN=*),INTENT(in) :: c_key
1831  INTEGER,INTENT(out) :: pos
1832!-
1833  INTEGER :: ikey_max,ikey
1834  CHARACTER(LEN=l_n) :: c_q_key
1835!---------------------------------------------------------------------
1836  pos = -1
1837  IF     (i_tab == 1) THEN
1838    ikey_max = nb_keys
1839  ELSEIF (i_tab == 2) THEN
1840    ikey_max = nb_lines
1841  ELSE
1842    ikey_max = 0
1843  ENDIF
1844  IF ( ikey_max > 0 ) THEN
1845    DO ikey=1,ikey_max
1846      IF (i_tab == 1) THEN
1847        c_q_key = key_tab(ikey)%keystr
1848      ELSE
1849        c_q_key = targetlist(ikey)
1850      ENDIF
1851      IF (TRIM(c_q_key) == TRIM(c_key)) THEN
1852        pos = ikey
1853        EXIT
1854      ENDIF
1855    ENDDO
1856  ENDIF
1857!-------------------------
1858END SUBROUTINE get_findkey
1859!===
[11]1860!------------------
[4]1861END MODULE getincom
Note: See TracBrowser for help on using the repository browser.