- Timestamp:
- Jun 18, 2009, 11:20:44 AM (15 years ago)
- Location:
- LMDZ4/branches/LMDZ4-dev/libf
- Files:
-
- 1 added
- 2 deleted
- 21 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ4/branches/LMDZ4-dev/libf/bibio/initdynav.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 c5 c6 4 subroutine initdynav(infile,day0,anne0,tstep,t_ops,t_wrt 7 5 . ,fileid) 8 6 7 #ifdef CPP_IOIPSL 9 8 USE IOIPSL 9 #endif 10 10 USE infotrac, ONLY : nqtot, ttext 11 11 … … 48 48 #include "description.h" 49 49 #include "serre.h" 50 #include "iniprint.h" 50 51 51 52 C Arguments … … 55 56 real tstep, t_ops, t_wrt 56 57 integer fileid 57 integer thoriid, zvertiid58 58 59 #ifdef CPP_IOIPSL 60 ! This routine needs IOIPSL to work 59 61 C Variables locales 60 62 C 63 integer thoriid, zvertiid 61 64 integer tau0 62 65 real zjulian … … 161 164 C 162 165 call histend(fileid) 166 #else 167 ! tell the user this routine should be run with ioipsl 168 write(lunout,*)"initdynav: Warning this routine should not be", 169 & " used without ioipsl" 170 #endif 171 ! of #ifdef CPP_IOIPSL 163 172 return 164 173 end -
LMDZ4/branches/LMDZ4-dev/libf/bibio/initfluxsto.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine initfluxsto … … 6 6 . fileid,filevid,filedid) 7 7 8 #ifdef CPP_IOIPSL 8 9 USE IOIPSL 9 10 #endif 10 11 implicit none 11 12 … … 47 48 #include "description.h" 48 49 #include "serre.h" 50 #include "iniprint.h" 49 51 50 52 C Arguments 51 53 C 52 54 character*(*) infile 53 integer*4 itau54 55 real tstep, t_ops, t_wrt 55 56 integer fileid, filevid,filedid 56 integer ndex(1) 57 58 #ifdef CPP_IOIPSL 59 ! This routine needs IOIPSL to work 60 C Variables locales 61 C 57 62 real nivd(1) 58 59 C Variables locales60 C61 63 integer tau0 62 64 real zjulian … … 222 224 endif 223 225 226 #else 227 ! tell the user this routine should be run with ioipsl 228 write(lunout,*)"initfluxsto: Warning this routine should not be", 229 & " used without ioipsl" 230 #endif 231 ! of #ifdef CPP_IOIPSL 224 232 return 225 233 end -
LMDZ4/branches/LMDZ4-dev/libf/bibio/inithist.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine inithist(infile,day0,anne0,tstep,t_ops,t_wrt,fileid, 5 5 . filevid) 6 6 7 #ifdef CPP_IOIPSL 7 8 USE IOIPSL 9 #endif 8 10 USE infotrac, ONLY : nqtot, ttext 9 11 … … 48 50 #include "description.h" 49 51 #include "serre.h" 52 #include "iniprint.h" 50 53 51 54 C Arguments … … 56 59 integer fileid, filevid 57 60 61 #ifdef CPP_IOIPSL 62 ! This routine needs IOIPSL to work 58 63 C Variables locales 59 64 C … … 181 186 call histend(fileid) 182 187 call histend(filevid) 188 #else 189 ! tell the user this routine should be run with ioipsl 190 write(lunout,*)"inithist: Warning this routine should not be", 191 & " used without ioipsl" 192 #endif 193 ! of #ifdef CPP_IOIPSL 183 194 return 184 195 end -
LMDZ4/branches/LMDZ4-dev/libf/bibio/ioipsl_getincom.F90
r1185 r1186 1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 ! Module and routines in this file are taken from IOIPSL 3 ! files getincom.f90 4 ! Module names has been changed to avoid problems 5 ! if compiling model with IOIPSL library 6 ! Ehouarn - March 2009 7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1 ! 2 ! $Id$ 3 ! 4 ! Module/Routines extracted from IOIPSL v2_1_8 5 ! 8 6 MODULE ioipsl_getincom 9 !--------------------------------------------------------------------- 10 USE ioipsl_stringop, & 11 & ONLY : findpos,nocomma,cmpblank,strlowercase,gensig,find_sig 12 !- 13 IMPLICIT NONE 14 !- 15 PRIVATE 16 PUBLIC :: getin, getin_dump 17 !- 18 INTERFACE getin 19 MODULE PROCEDURE getinrs, getinr1d, getinr2d, & 20 & getinis, getini1d, getini2d, & 21 & getincs, getinc1d, getinc2d, & 22 & getinls, getinl1d, getinl2d 23 END INTERFACE 7 !- 8 !$Id: getincom.f90 536 2009-01-30 11:46:27Z bellier $ 9 !- 10 ! This software is governed by the CeCILL license 11 ! See IOIPSL/IOIPSL_License_CeCILL.txt 12 !--------------------------------------------------------------------- 13 USE ioipsl_errioipsl, ONLY : ipslerr 14 USE ioipsl_stringop, & 15 & ONLY : nocomma,cmpblank,strlowercase 16 !- 17 IMPLICIT NONE 18 !- 19 PRIVATE 20 PUBLIC :: getin, getin_dump 21 !- 22 INTERFACE getin 23 !!-------------------------------------------------------------------- 24 !! The "getin" routines get a variable. 25 !! We first check if we find it in the database 26 !! and if not we get it from the run.def file. 27 !! 28 !! SUBROUTINE getin (target,ret_val) 29 !! 30 !! INPUT 31 !! 32 !! (C) target : Name of the variable 33 !! 34 !! OUTPUT 35 !! 36 !! (I/R/C/L) ret_val : scalar, vector or matrix that will contain 37 !! that will contain the (standard) 38 !! integer/real/character/logical values 39 !!-------------------------------------------------------------------- 40 MODULE PROCEDURE getinrs, getinr1d, getinr2d, & 41 & getinis, getini1d, getini2d, & 42 & getincs, getinc1d, getinc2d, & 43 & getinls, getinl1d, getinl2d 44 END INTERFACE 45 !- 46 !!-------------------------------------------------------------------- 47 !! The "getin_dump" routine will dump the content of the database 48 !! into a file which has the same format as the run.def file. 49 !! The idea is that the user can see which parameters were used 50 !! and re-use the file for another run. 51 !! 52 !! SUBROUTINE getin_dump (fileprefix) 53 !! 54 !! OPTIONAL INPUT argument 55 !! 56 !! (C) fileprefix : allows the user to change the name of the file 57 !! in which the data will be archived 58 !!-------------------------------------------------------------------- 24 59 !- 25 60 INTEGER,PARAMETER :: max_files=100 … … 27 62 INTEGER,SAVE :: nbfiles 28 63 !- 29 INTEGER,PARAMETER :: max_lines=4000 30 INTEGER,SAVE :: nb_lines 31 CHARACTER(LEN=100),DIMENSION(max_lines),SAVE :: fichier 32 INTEGER,DIMENSION(max_lines),SAVE :: targetsiglist,fromfile,compline 33 CHARACTER(LEN=30),DIMENSION(max_lines),SAVE :: targetlist 64 INTEGER,PARAMETER :: i_txtslab=1000,l_n=30 65 INTEGER,SAVE :: nb_lines,i_txtsize=0 66 CHARACTER(LEN=100),SAVE,ALLOCATABLE,DIMENSION(:) :: fichier 67 CHARACTER(LEN=l_n),SAVE,ALLOCATABLE,DIMENSION(:) :: targetlist 68 INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: fromfile,compline 69 !- 70 INTEGER,PARAMETER :: n_d_fmt=5,max_msgs=15 71 CHARACTER(LEN=6),SAVE :: c_i_fmt = '(I5.5)' 34 72 !- 35 73 ! The data base of parameters 36 74 !- 37 75 INTEGER,PARAMETER :: memslabs=200 38 INTEGER,PARAMETER :: compress_lim =2076 INTEGER,PARAMETER :: compress_lim=20 39 77 !- 40 78 INTEGER,SAVE :: nb_keys=0 41 79 INTEGER,SAVE :: keymemsize=0 42 INTEGER,SAVE,ALLOCATABLE :: keysig(:) 43 CHARACTER(LEN=30),SAVE,ALLOCATABLE :: keystr(:) 80 !- 81 ! keystr definition 82 ! name of a key 44 83 !- 45 84 ! keystatus definition … … 48 87 ! keystatus = 3 : Some vector elements were taken from default 49 88 !- 50 INTEGER,SAVE,ALLOCATABLE :: keystatus(:)51 !-52 89 ! keytype definition 53 ! keytype = 1 : Inte rger90 ! keytype = 1 : Integer 54 91 ! keytype = 2 : Real 55 92 ! keytype = 3 : Character 56 93 ! keytype = 4 : Logical 57 94 !- 58 INTEGER, SAVE,ALLOCATABLE :: keytype(:)95 INTEGER,PARAMETER :: k_i=1, k_r=2, k_c=3, k_l=4 59 96 !- 60 97 ! Allow compression for keys (only for integer and real) 61 ! keycompress < 0 : not compresse s98 ! keycompress < 0 : not compressed 62 99 ! keycompress > 0 : number of repeat of the value 63 100 !- 64 INTEGER,SAVE,ALLOCATABLE :: keycompress(:) 65 INTEGER,SAVE,ALLOCATABLE :: keyfromfile(:) 66 !- 67 INTEGER,SAVE,ALLOCATABLE :: keymemstart(:) 68 INTEGER,SAVE,ALLOCATABLE :: keymemlen(:) 69 !- 70 INTEGER,SAVE,ALLOCATABLE :: intmem(:) 71 INTEGER,SAVE :: intmemsize=0, intmempos=0 72 REAL,SAVE,ALLOCATABLE :: realmem(:) 73 INTEGER,SAVE :: realmemsize=0, realmempos=0 74 CHARACTER(LEN=100),SAVE,ALLOCATABLE :: charmem(:) 75 INTEGER,SAVE :: charmemsize=0, charmempos=0 76 LOGICAL,SAVE,ALLOCATABLE :: logicmem(:) 77 INTEGER,SAVE :: logicmemsize=0, logicmempos=0 101 TYPE :: t_key 102 CHARACTER(LEN=l_n) :: keystr 103 INTEGER :: keystatus, keytype, keycompress, & 104 & keyfromfile, keymemstart, keymemlen 105 END TYPE t_key 106 !- 107 TYPE(t_key),SAVE,ALLOCATABLE,DIMENSION(:) :: key_tab 108 !- 109 INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: i_mem 110 INTEGER,SAVE :: i_memsize=0, i_mempos=0 111 REAL,SAVE,ALLOCATABLE,DIMENSION(:) :: r_mem 112 INTEGER,SAVE :: r_memsize=0, r_mempos=0 113 CHARACTER(LEN=100),SAVE,ALLOCATABLE,DIMENSION(:) :: c_mem 114 INTEGER,SAVE :: c_memsize=0, c_mempos=0 115 LOGICAL,SAVE,ALLOCATABLE,DIMENSION(:) :: l_mem 116 INTEGER,SAVE :: l_memsize=0, l_mempos=0 78 117 !- 79 118 CONTAINS 80 119 !- 81 !=== REAL INTERFACES 82 !- 83 SUBROUTINE getinrs (TARGET,ret_val) 84 !--------------------------------------------------------------------- 85 !- Get a real scalar. We first check if we find it 86 !- in the database and if not we get it from the run.def 87 !- 88 !- getinr1d and getinr2d are written on the same pattern 89 !--------------------------------------------------------------------- 90 IMPLICIT NONE 91 !- 92 CHARACTER(LEN=*) :: TARGET 93 REAL :: ret_val 94 !- 95 REAL,DIMENSION(1) :: tmp_ret_val 96 INTEGER :: target_sig, pos, status=0, fileorig 97 !--------------------------------------------------------------------- 98 !- 99 ! Compute the signature of the target 100 !- 101 CALL gensig (TARGET,target_sig) 120 !=== INTEGER INTERFACE 121 !- 122 SUBROUTINE getinis (target,ret_val) 123 !--------------------------------------------------------------------- 124 IMPLICIT NONE 125 !- 126 CHARACTER(LEN=*) :: target 127 INTEGER :: ret_val 128 !- 129 INTEGER,DIMENSION(1) :: tmp_ret_val 130 INTEGER :: pos,status=0,fileorig 131 !--------------------------------------------------------------------- 102 132 !- 103 133 ! Do we have this target in our database ? 104 134 !- 105 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)135 CALL get_findkey (1,target,pos) 106 136 !- 107 137 tmp_ret_val(1) = ret_val … … 109 139 IF (pos < 0) THEN 110 140 !-- Get the information out of the file 111 CALL get filr (TARGET,status,fileorig,tmp_ret_val)141 CALL get_fil (target,status,fileorig,i_val=tmp_ret_val) 112 142 !-- Put the data into the database 113 CALL getdbwr (TARGET,target_sig,status,fileorig,1,tmp_ret_val) 143 CALL get_wdb & 144 & (target,status,fileorig,1,i_val=tmp_ret_val) 114 145 ELSE 115 146 !-- Get the value out of the database 116 CALL get dbrr (pos,1,TARGET,tmp_ret_val)147 CALL get_rdb (pos,1,target,i_val=tmp_ret_val) 117 148 ENDIF 118 149 ret_val = tmp_ret_val(1) 119 150 !--------------------- 120 END SUBROUTINE getinrs 121 !- 122 !=== 123 !- 124 SUBROUTINE getinr1d (TARGET,ret_val) 125 !--------------------------------------------------------------------- 126 !- See getinrs for details. It is the same thing but for a vector 127 !--------------------------------------------------------------------- 128 IMPLICIT NONE 129 !- 130 CHARACTER(LEN=*) :: TARGET 131 REAL,DIMENSION(:) :: ret_val 132 !- 133 REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 151 END SUBROUTINE getinis 152 !=== 153 SUBROUTINE getini1d (target,ret_val) 154 !--------------------------------------------------------------------- 155 IMPLICIT NONE 156 !- 157 CHARACTER(LEN=*) :: target 158 INTEGER,DIMENSION(:) :: ret_val 159 !- 160 INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 134 161 INTEGER,SAVE :: tmp_ret_size = 0 135 INTEGER :: target_sig, pos, size_of_in, status=0, fileorig 136 !--------------------------------------------------------------------- 137 !- 138 ! Compute the signature of the target 139 !- 140 CALL gensig (TARGET,target_sig) 162 INTEGER :: pos,size_of_in,status=0,fileorig 163 !--------------------------------------------------------------------- 141 164 !- 142 165 ! Do we have this target in our database ? 143 166 !- 144 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)167 CALL get_findkey (1,target,pos) 145 168 !- 146 169 size_of_in = SIZE(ret_val) … … 155 178 !- 156 179 IF (pos < 0) THEN 157 !-- Ge the information out of the file158 CALL get filr (TARGET,status,fileorig,tmp_ret_val)180 !-- Get the information out of the file 181 CALL get_fil (target,status,fileorig,i_val=tmp_ret_val) 159 182 !-- Put the data into the database 160 CALL get dbwr&161 & ( TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)183 CALL get_wdb & 184 & (target,status,fileorig,size_of_in,i_val=tmp_ret_val) 162 185 ELSE 163 186 !-- Get the value out of the database 164 CALL get dbrr (pos,size_of_in,TARGET,tmp_ret_val)187 CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val) 165 188 ENDIF 166 189 ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in) 167 190 !---------------------- 168 END SUBROUTINE getinr1d 169 !- 170 !=== 171 !- 172 SUBROUTINE getinr2d (TARGET,ret_val) 173 !--------------------------------------------------------------------- 174 !- See getinrs for details. It is the same thing but for a matrix 175 !--------------------------------------------------------------------- 176 IMPLICIT NONE 177 !- 178 CHARACTER(LEN=*) :: TARGET 179 REAL,DIMENSION(:,:) :: ret_val 180 !- 181 REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 191 END SUBROUTINE getini1d 192 !=== 193 SUBROUTINE getini2d (target,ret_val) 194 !--------------------------------------------------------------------- 195 IMPLICIT NONE 196 !- 197 CHARACTER(LEN=*) :: target 198 INTEGER,DIMENSION(:,:) :: ret_val 199 !- 200 INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 182 201 INTEGER,SAVE :: tmp_ret_size = 0 183 INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig 184 INTEGER :: jl, jj, ji 185 !--------------------------------------------------------------------- 186 !- 187 ! Compute the signature of the target 188 !- 189 CALL gensig (TARGET,target_sig) 202 INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig 203 INTEGER :: jl,jj,ji 204 !--------------------------------------------------------------------- 190 205 !- 191 206 ! Do we have this target in our database ? 192 207 !- 193 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)208 CALL get_findkey (1,target,pos) 194 209 !- 195 210 size_of_in = SIZE(ret_val) … … 213 228 !- 214 229 IF (pos < 0) THEN 215 !-- Ge the information out of the file216 CALL get filr (TARGET,status,fileorig,tmp_ret_val)230 !-- Get the information out of the file 231 CALL get_fil (target,status,fileorig,i_val=tmp_ret_val) 217 232 !-- Put the data into the database 218 CALL get dbwr&219 & ( TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)233 CALL get_wdb & 234 & (target,status,fileorig,size_of_in,i_val=tmp_ret_val) 220 235 ELSE 221 236 !-- Get the value out of the database 222 CALL getdbrr (pos,size_of_in,TARGET,tmp_ret_val) 237 CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val) 238 ENDIF 239 !- 240 jl=0 241 DO jj=1,size_2 242 DO ji=1,size_1 243 jl=jl+1 244 ret_val(ji,jj) = tmp_ret_val(jl) 245 ENDDO 246 ENDDO 247 !---------------------- 248 END SUBROUTINE getini2d 249 !- 250 !=== REAL INTERFACE 251 !- 252 SUBROUTINE getinrs (target,ret_val) 253 !--------------------------------------------------------------------- 254 IMPLICIT NONE 255 !- 256 CHARACTER(LEN=*) :: target 257 REAL :: ret_val 258 !- 259 REAL,DIMENSION(1) :: tmp_ret_val 260 INTEGER :: pos,status=0,fileorig 261 !--------------------------------------------------------------------- 262 !- 263 ! Do we have this target in our database ? 264 !- 265 CALL get_findkey (1,target,pos) 266 !- 267 tmp_ret_val(1) = ret_val 268 !- 269 IF (pos < 0) THEN 270 !-- Get the information out of the file 271 CALL get_fil (target,status,fileorig,r_val=tmp_ret_val) 272 !-- Put the data into the database 273 CALL get_wdb & 274 & (target,status,fileorig,1,r_val=tmp_ret_val) 275 ELSE 276 !-- Get the value out of the database 277 CALL get_rdb (pos,1,target,r_val=tmp_ret_val) 278 ENDIF 279 ret_val = tmp_ret_val(1) 280 !--------------------- 281 END SUBROUTINE getinrs 282 !=== 283 SUBROUTINE getinr1d (target,ret_val) 284 !--------------------------------------------------------------------- 285 IMPLICIT NONE 286 !- 287 CHARACTER(LEN=*) :: target 288 REAL,DIMENSION(:) :: ret_val 289 !- 290 REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 291 INTEGER,SAVE :: tmp_ret_size = 0 292 INTEGER :: pos,size_of_in,status=0,fileorig 293 !--------------------------------------------------------------------- 294 !- 295 ! Do we have this target in our database ? 296 !- 297 CALL get_findkey (1,target,pos) 298 !- 299 size_of_in = SIZE(ret_val) 300 IF (.NOT.ALLOCATED(tmp_ret_val)) THEN 301 ALLOCATE (tmp_ret_val(size_of_in)) 302 ELSE IF (size_of_in > tmp_ret_size) THEN 303 DEALLOCATE (tmp_ret_val) 304 ALLOCATE (tmp_ret_val(size_of_in)) 305 tmp_ret_size = size_of_in 306 ENDIF 307 tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in) 308 !- 309 IF (pos < 0) THEN 310 !-- Get the information out of the file 311 CALL get_fil (target,status,fileorig,r_val=tmp_ret_val) 312 !-- Put the data into the database 313 CALL get_wdb & 314 & (target,status,fileorig,size_of_in,r_val=tmp_ret_val) 315 ELSE 316 !-- Get the value out of the database 317 CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val) 318 ENDIF 319 ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in) 320 !---------------------- 321 END SUBROUTINE getinr1d 322 !=== 323 SUBROUTINE getinr2d (target,ret_val) 324 !--------------------------------------------------------------------- 325 IMPLICIT NONE 326 !- 327 CHARACTER(LEN=*) :: target 328 REAL,DIMENSION(:,:) :: ret_val 329 !- 330 REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 331 INTEGER,SAVE :: tmp_ret_size = 0 332 INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig 333 INTEGER :: jl,jj,ji 334 !--------------------------------------------------------------------- 335 !- 336 ! Do we have this target in our database ? 337 !- 338 CALL get_findkey (1,target,pos) 339 !- 340 size_of_in = SIZE(ret_val) 341 size_1 = SIZE(ret_val,1) 342 size_2 = SIZE(ret_val,2) 343 IF (.NOT.ALLOCATED(tmp_ret_val)) THEN 344 ALLOCATE (tmp_ret_val(size_of_in)) 345 ELSE IF (size_of_in > tmp_ret_size) THEN 346 DEALLOCATE (tmp_ret_val) 347 ALLOCATE (tmp_ret_val(size_of_in)) 348 tmp_ret_size = size_of_in 349 ENDIF 350 !- 351 jl=0 352 DO jj=1,size_2 353 DO ji=1,size_1 354 jl=jl+1 355 tmp_ret_val(jl) = ret_val(ji,jj) 356 ENDDO 357 ENDDO 358 !- 359 IF (pos < 0) THEN 360 !-- Get the information out of the file 361 CALL get_fil (target,status,fileorig,r_val=tmp_ret_val) 362 !-- Put the data into the database 363 CALL get_wdb & 364 & (target,status,fileorig,size_of_in,r_val=tmp_ret_val) 365 ELSE 366 !-- Get the value out of the database 367 CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val) 223 368 ENDIF 224 369 !- … … 233 378 END SUBROUTINE getinr2d 234 379 !- 235 !=== 236 !- 237 SUBROUTINE getfilr (TARGET,status,fileorig,ret_val) 238 !--------------------------------------------------------------------- 239 !- Subroutine that will extract from the file the values 240 !- attributed to the keyword target 241 !- 242 !- REALS 243 !- ----- 244 !- 245 !- target : in : CHARACTER(LEN=*) target for which we will 246 !- look in the file 247 !- status : out : INTEGER tells us from where we obtained the data 248 !- fileorig : out : The index of the file from which the key comes 249 !- ret_val : out : REAL(nb_to_ret) values read 250 !--------------------------------------------------------------------- 251 IMPLICIT NONE 252 !- 253 CHARACTER(LEN=*) :: TARGET 254 INTEGER :: status, fileorig 255 REAL,DIMENSION(:) :: ret_val 256 !- 257 INTEGER :: nb_to_ret 258 INTEGER :: it, pos, len_str, epos, ppos, int_tmp, status_cnt 259 CHARACTER(LEN=3) :: cnt, tl, dl 260 CHARACTER(LEN=10) :: fmt 261 CHARACTER(LEN=30) :: full_target 262 CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp 263 INTEGER :: full_target_sig 264 REAL :: compvalue 265 !- 266 INTEGER,SAVE :: max_len = 0 267 LOGICAL,SAVE,ALLOCATABLE :: found(:) 268 LOGICAL :: def_beha 269 LOGICAL :: compressed = .FALSE. 270 !--------------------------------------------------------------------- 271 nb_to_ret = SIZE(ret_val) 272 CALL getin_read 273 !- 274 ! Get the variables and memory we need 275 !- 276 IF (max_len == 0) THEN 277 ALLOCATE(found(nb_to_ret)) 278 max_len = nb_to_ret 279 ENDIF 280 IF (max_len < nb_to_ret) THEN 281 DEALLOCATE(found) 282 ALLOCATE(found(nb_to_ret)) 283 max_len = nb_to_ret 284 ENDIF 285 found(:) = .FALSE. 286 !- 287 ! See what we find in the files read 288 !- 289 DO it=1,nb_to_ret 290 !--- 291 !- 292 !-- First try the target as it is 293 !--- 294 full_target = TARGET(1:len_TRIM(target)) 295 CALL gensig (full_target,full_target_sig) 296 CALL find_sig (nb_lines,targetlist,full_target, & 297 & targetsiglist,full_target_sig,pos) 298 !--- 299 !-- Another try 300 !--- 301 IF (pos < 0) THEN 302 WRITE(cnt,'(I3.3)') it 303 full_target = TARGET(1:len_TRIM(target))//'__'//cnt 304 CALL gensig (full_target,full_target_sig) 305 CALL find_sig (nb_lines,targetlist,full_target, & 306 & targetsiglist,full_target_sig,pos) 307 ENDIF 308 !--- 309 !-- A priori we dont know from which file the target could come. 310 !-- Thus by default we attribute it to the first file : 311 !--- 312 fileorig = 1 313 !-- 314 IF (pos > 0) THEN 315 !---- 316 found(it) = .TRUE. 317 fileorig = fromfile(pos) 318 !----- 319 !---- DECODE 320 !----- 321 str_READ = TRIM(ADJUSTL(fichier(pos))) 322 str_READ_lower = str_READ 323 CALL strlowercase (str_READ_lower) 324 !---- 325 IF ( ( (INDEX(str_READ_lower,'def') == 1) & 326 & .AND.(LEN_TRIM(str_READ_lower) == 3) ) & 327 & .OR.( (INDEX(str_READ_lower,'default') == 1) & 328 & .AND.(LEN_TRIM(str_READ_lower) == 7) ) ) THEN 329 def_beha = .TRUE. 330 ELSE 331 def_beha = .FALSE. 332 len_str = LEN_TRIM(str_READ) 333 epos = INDEX(str_READ,'e') 334 ppos = INDEX(str_READ,'.') 335 !------ 336 IF (epos > 0) THEN 337 WRITE(tl,'(I3.3)') len_str 338 WRITE(dl,'(I3.3)') epos-ppos-1 339 fmt='(e'//tl//'.'//dl//')' 340 READ(str_READ,fmt) ret_val(it) 341 ELSE IF (ppos > 0) THEN 342 WRITE(tl,'(I3.3)') len_str 343 WRITE(dl,'(I3.3)') len_str-ppos 344 fmt='(f'//tl//'.'//dl//')' 345 READ(str_READ,fmt) ret_val(it) 346 ELSE 347 WRITE(tl,'(I3.3)') len_str 348 fmt = '(I'//tl//')' 349 READ(str_READ,fmt) int_tmp 350 ret_val(it) = REAL(int_tmp) 351 ENDIF 352 ENDIF 353 !---- 354 targetsiglist(pos) = -1 355 !----- 356 !---- Is this the value of a compressed field ? 357 !----- 358 IF (compline(pos) > 0) THEN 359 IF (compline(pos) == nb_to_ret) THEN 360 compressed = .TRUE. 361 compvalue = ret_val(it) 362 ELSE 363 WRITE(*,*) 'WARNING from getfilr' 364 WRITE(*,*) 'For key ',TRIM(TARGET), & 365 & ' we have a compressed field but which does not have the right size.' 366 WRITE(*,*) 'We will try to fix that ' 367 compressed = .TRUE. 368 compvalue = ret_val(it) 369 ENDIF 370 ENDIF 371 ELSE 372 found(it) = .FALSE. 373 ENDIF 374 ENDDO 375 !-- 376 ! If this is a compressed field then we will uncompress it 377 !-- 378 IF (compressed) THEN 379 DO it=1,nb_to_ret 380 IF (.NOT. found(it)) THEN 381 ret_val(it) = compvalue 382 found(it) = .TRUE. 383 ENDIF 384 ENDDO 385 ENDIF 386 !- 387 ! Now we get the status for what we found 388 !- 389 IF (def_beha) THEN 390 status = 2 391 WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET) 380 !=== CHARACTER INTERFACE 381 !- 382 SUBROUTINE getincs (target,ret_val) 383 !--------------------------------------------------------------------- 384 IMPLICIT NONE 385 !- 386 CHARACTER(LEN=*) :: target 387 CHARACTER(LEN=*) :: ret_val 388 !- 389 CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val 390 INTEGER :: pos,status=0,fileorig 391 !--------------------------------------------------------------------- 392 !- 393 ! Do we have this target in our database ? 394 !- 395 CALL get_findkey (1,target,pos) 396 !- 397 tmp_ret_val(1) = ret_val 398 !- 399 IF (pos < 0) THEN 400 !-- Get the information out of the file 401 CALL get_fil (target,status,fileorig,c_val=tmp_ret_val) 402 !-- Put the data into the database 403 CALL get_wdb & 404 & (target,status,fileorig,1,c_val=tmp_ret_val) 392 405 ELSE 393 status_cnt = 0394 DO it=1,nb_to_ret395 IF (.NOT. found(it)) THEN396 status_cnt = status_cnt+1397 IF (nb_to_ret > 1) THEN398 WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it399 ELSE400 str_tmp = TRIM(TARGET)401 ENDIF402 WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it)403 ENDIF404 ENDDO405 !---406 IF (status_cnt == 0) THEN407 status = 1408 ELSE IF (status_cnt == nb_to_ret) THEN409 status = 2410 ELSE411 status = 3412 ENDIF413 ENDIF414 !---------------------415 END SUBROUTINE getfilr416 !-417 !=== INTEGER INTERFACES418 !-419 SUBROUTINE getinis (TARGET,ret_val)420 !---------------------------------------------------------------------421 !- Get a interer scalar. We first check if we find it422 !- in the database and if not we get it from the run.def423 !-424 !- getini1d and getini2d are written on the same pattern425 !---------------------------------------------------------------------426 IMPLICIT NONE427 !-428 CHARACTER(LEN=*) :: TARGET429 INTEGER :: ret_val430 !-431 INTEGER,DIMENSION(1) :: tmp_ret_val432 INTEGER :: target_sig, pos, status=0, fileorig433 !---------------------------------------------------------------------434 !-435 ! Compute the signature of the target436 !-437 CALL gensig (TARGET,target_sig)438 !-439 ! Do we have this target in our database ?440 !-441 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)442 !-443 tmp_ret_val(1) = ret_val444 !-445 IF (pos < 0) THEN446 !-- Ge the information out of the file447 CALL getfili (TARGET,status,fileorig,tmp_ret_val)448 !-- Put the data into the database449 CALL getdbwi (TARGET,target_sig,status,fileorig,1,tmp_ret_val)450 ELSE451 406 !-- Get the value out of the database 452 CALL get dbri (pos,1,TARGET,tmp_ret_val)407 CALL get_rdb (pos,1,target,c_val=tmp_ret_val) 453 408 ENDIF 454 409 ret_val = tmp_ret_val(1) 455 410 !--------------------- 456 END SUBROUTINE getinis 457 !- 458 !=== 459 !- 460 SUBROUTINE getini1d (TARGET,ret_val) 461 !--------------------------------------------------------------------- 462 !- See getinis for details. It is the same thing but for a vector 463 !--------------------------------------------------------------------- 464 IMPLICIT NONE 465 !- 466 CHARACTER(LEN=*) :: TARGET 467 INTEGER,DIMENSION(:) :: ret_val 468 !- 469 INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 411 END SUBROUTINE getincs 412 !=== 413 SUBROUTINE getinc1d (target,ret_val) 414 !--------------------------------------------------------------------- 415 IMPLICIT NONE 416 !- 417 CHARACTER(LEN=*) :: target 418 CHARACTER(LEN=*),DIMENSION(:) :: ret_val 419 !- 420 CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 470 421 INTEGER,SAVE :: tmp_ret_size = 0 471 INTEGER :: target_sig, pos, size_of_in, status=0, fileorig 472 !--------------------------------------------------------------------- 473 !- 474 ! Compute the signature of the target 475 !- 476 CALL gensig (TARGET,target_sig) 422 INTEGER :: pos,size_of_in,status=0,fileorig 423 !--------------------------------------------------------------------- 477 424 !- 478 425 ! Do we have this target in our database ? 479 426 !- 480 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)427 CALL get_findkey (1,target,pos) 481 428 !- 482 429 size_of_in = SIZE(ret_val) … … 491 438 !- 492 439 IF (pos < 0) THEN 493 !-- Ge the information out of the file494 CALL get fili (TARGET,status,fileorig,tmp_ret_val)440 !-- Get the information out of the file 441 CALL get_fil (target,status,fileorig,c_val=tmp_ret_val) 495 442 !-- Put the data into the database 496 CALL get dbwi&497 & ( TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)443 CALL get_wdb & 444 & (target,status,fileorig,size_of_in,c_val=tmp_ret_val) 498 445 ELSE 499 446 !-- Get the value out of the database 500 CALL get dbri (pos,size_of_in,TARGET,tmp_ret_val)447 CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val) 501 448 ENDIF 502 449 ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in) 503 450 !---------------------- 504 END SUBROUTINE getini1d 505 !- 506 !=== 507 !- 508 SUBROUTINE getini2d (TARGET,ret_val) 509 !--------------------------------------------------------------------- 510 !- See getinis for details. It is the same thing but for a matrix 511 !--------------------------------------------------------------------- 512 IMPLICIT NONE 513 !- 514 CHARACTER(LEN=*) :: TARGET 515 INTEGER,DIMENSION(:,:) :: ret_val 516 !- 517 INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 451 END SUBROUTINE getinc1d 452 !=== 453 SUBROUTINE getinc2d (target,ret_val) 454 !--------------------------------------------------------------------- 455 IMPLICIT NONE 456 !- 457 CHARACTER(LEN=*) :: target 458 CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val 459 !- 460 CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 518 461 INTEGER,SAVE :: tmp_ret_size = 0 519 INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig 520 INTEGER :: jl, jj, ji 521 !--------------------------------------------------------------------- 522 !- 523 ! Compute the signature of the target 524 !- 525 CALL gensig (TARGET,target_sig) 462 INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig 463 INTEGER :: jl,jj,ji 464 !--------------------------------------------------------------------- 526 465 !- 527 466 ! Do we have this target in our database ? 528 467 !- 529 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)468 CALL get_findkey (1,target,pos) 530 469 !- 531 470 size_of_in = SIZE(ret_val) … … 549 488 !- 550 489 IF (pos < 0) THEN 551 !-- Ge the information out of the file552 CALL get fili (TARGET,status,fileorig,tmp_ret_val)490 !-- Get the information out of the file 491 CALL get_fil (target,status,fileorig,c_val=tmp_ret_val) 553 492 !-- Put the data into the database 554 CALL get dbwi&555 & ( TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)493 CALL get_wdb & 494 & (target,status,fileorig,size_of_in,c_val=tmp_ret_val) 556 495 ELSE 557 496 !-- Get the value out of the database 558 CALL get dbri (pos,size_of_in,TARGET,tmp_ret_val)497 CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val) 559 498 ENDIF 560 499 !- … … 567 506 ENDDO 568 507 !---------------------- 569 END SUBROUTINE getini2d 570 !- 571 !=== 572 !- 573 SUBROUTINE getfili (TARGET,status,fileorig,ret_val) 574 !--------------------------------------------------------------------- 575 !- Subroutine that will extract from the file the values 576 !- attributed to the keyword target 577 !- 578 !- INTEGER 579 !- ------- 580 !- 581 !- target : in : CHARACTER(LEN=*) target for which we will 582 !- look in the file 583 !- status : out : INTEGER tells us from where we obtained the data 584 !- fileorig : out : The index of the file from which the key comes 585 !- ret_val : out : INTEGER(nb_to_ret) values read 586 !--------------------------------------------------------------------- 587 IMPLICIT NONE 588 !- 589 CHARACTER(LEN=*) :: TARGET 590 INTEGER :: status, fileorig 591 INTEGER :: ret_val(:) 592 !- 593 INTEGER :: nb_to_ret 594 INTEGER :: it, pos, len_str, status_cnt 595 CHARACTER(LEN=3) :: cnt, chlen 596 CHARACTER(LEN=10) :: fmt 597 CHARACTER(LEN=30) :: full_target 598 CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp 599 INTEGER :: full_target_sig 600 INTEGER :: compvalue 601 !- 602 INTEGER,SAVE :: max_len = 0 603 LOGICAL,SAVE,ALLOCATABLE :: found(:) 604 LOGICAL :: def_beha 605 LOGICAL :: compressed = .FALSE. 606 !--------------------------------------------------------------------- 607 nb_to_ret = SIZE(ret_val) 608 CALL getin_read 609 !- 610 ! Get the variables and memory we need 611 !- 612 IF (max_len == 0) THEN 613 ALLOCATE(found(nb_to_ret)) 614 max_len = nb_to_ret 615 ENDIF 616 IF (max_len < nb_to_ret) THEN 617 DEALLOCATE(found) 618 ALLOCATE(found(nb_to_ret)) 619 max_len = nb_to_ret 620 ENDIF 621 found(:) = .FALSE. 622 !- 623 ! See what we find in the files read 624 !- 625 DO it=1,nb_to_ret 626 !--- 627 !-- First try the target as it is 628 !--- 629 full_target = TARGET(1:len_TRIM(target)) 630 CALL gensig (full_target,full_target_sig) 631 CALL find_sig (nb_lines,targetlist,full_target, & 632 & targetsiglist,full_target_sig,pos) 633 !--- 634 !-- Another try 635 !--- 636 IF (pos < 0) THEN 637 WRITE(cnt,'(I3.3)') it 638 full_target = TARGET(1:len_TRIM(target))//'__'//cnt 639 CALL gensig (full_target,full_target_sig) 640 CALL find_sig (nb_lines,targetlist,full_target, & 641 & targetsiglist,full_target_sig,pos) 642 ENDIF 643 !--- 644 !-- A priori we dont know from which file the target could come. 645 !-- Thus by default we attribute it to the first file : 646 !--- 647 fileorig = 1 648 !- 649 IF (pos > 0) THEN 650 !----- 651 found(it) = .TRUE. 652 fileorig = fromfile(pos) 653 !----- 654 !---- DECODE 655 !---- 656 str_READ = TRIM(ADJUSTL(fichier(pos))) 657 str_READ_lower = str_READ 658 CALL strlowercase (str_READ_lower) 659 !----- 660 IF ( ( (INDEX(str_READ_lower,'def') == 1) & 661 & .AND.(LEN_TRIM(str_READ_lower) == 3) ) & 662 & .OR.( (INDEX(str_READ_lower,'default') == 1) & 663 & .AND.(LEN_TRIM(str_READ_lower) == 7) ) ) THEN 664 def_beha = .TRUE. 665 ELSE 666 def_beha = .FALSE. 667 len_str = LEN_TRIM(str_READ) 668 WRITE(chlen,'(I3.3)') len_str 669 fmt = '(I'//chlen//')' 670 READ(str_READ,fmt) ret_val(it) 671 ENDIF 672 !----- 673 targetsiglist(pos) = -1 674 !----- 675 !---- Is this the value of a compressed field ? 676 !----- 677 IF (compline(pos) > 0) THEN 678 IF (compline(pos) == nb_to_ret) THEN 679 compressed = .TRUE. 680 compvalue = ret_val(it) 681 ELSE 682 WRITE(*,*) 'WARNING from getfilr' 683 WRITE(*,*) 'For key ',TRIM(TARGET), & 684 & ' we have a compressed field but which does not have the right size.' 685 WRITE(*,*) 'We will try to fix that ' 686 compressed = .TRUE. 687 compvalue = ret_val(it) 688 ENDIF 689 ENDIF 690 ELSE 691 found(it) = .FALSE. 692 ENDIF 693 ENDDO 694 !- 695 ! If this is a compressed field then we will uncompress it 696 !- 697 IF (compressed) THEN 698 DO it=1,nb_to_ret 699 IF (.NOT. found(it)) THEN 700 ret_val(it) = compvalue 701 found(it) = .TRUE. 702 ENDIF 703 ENDDO 704 ENDIF 705 !- 706 ! Now we get the status for what we found 707 !- 708 IF (def_beha) THEN 709 status = 2 710 WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET) 711 ELSE 712 status_cnt = 0 713 DO it=1,nb_to_ret 714 IF (.NOT. found(it)) THEN 715 status_cnt = status_cnt+1 716 IF (nb_to_ret > 1) THEN 717 WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it 718 ELSE 719 str_tmp = TRIM(TARGET) 720 ENDIF 721 WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it) 722 ENDIF 723 ENDDO 724 !--- 725 IF (status_cnt == 0) THEN 726 status = 1 727 ELSE IF (status_cnt == nb_to_ret) THEN 728 status = 2 729 ELSE 730 status = 3 731 ENDIF 732 ENDIF 733 !--------------------- 734 END SUBROUTINE getfili 735 !- 736 !=== CHARACTER INTERFACES 737 !- 738 SUBROUTINE getincs (TARGET,ret_val) 739 !--------------------------------------------------------------------- 740 !- Get a CHARACTER scalar. We first check if we find it 741 !- in the database and if not we get it from the run.def 742 !- 743 !- getinc1d and getinc2d are written on the same pattern 744 !--------------------------------------------------------------------- 745 IMPLICIT NONE 746 !- 747 CHARACTER(LEN=*) :: TARGET 748 CHARACTER(LEN=*) :: ret_val 749 !- 750 CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val 751 INTEGER :: target_sig, pos, status=0, fileorig 752 !--------------------------------------------------------------------- 753 !- 754 ! Compute the signature of the target 755 !- 756 CALL gensig (TARGET,target_sig) 508 END SUBROUTINE getinc2d 509 !- 510 !=== LOGICAL INTERFACE 511 !- 512 SUBROUTINE getinls (target,ret_val) 513 !--------------------------------------------------------------------- 514 IMPLICIT NONE 515 !- 516 CHARACTER(LEN=*) :: target 517 LOGICAL :: ret_val 518 !- 519 LOGICAL,DIMENSION(1) :: tmp_ret_val 520 INTEGER :: pos,status=0,fileorig 521 !--------------------------------------------------------------------- 757 522 !- 758 523 ! Do we have this target in our database ? 759 524 !- 760 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)525 CALL get_findkey (1,target,pos) 761 526 !- 762 527 tmp_ret_val(1) = ret_val 763 528 !- 764 529 IF (pos < 0) THEN 765 !-- Ge the information out of the file766 CALL get filc (TARGET,status,fileorig,tmp_ret_val)530 !-- Get the information out of the file 531 CALL get_fil (target,status,fileorig,l_val=tmp_ret_val) 767 532 !-- Put the data into the database 768 CALL getdbwc (TARGET,target_sig,status,fileorig,1,tmp_ret_val) 533 CALL get_wdb & 534 & (target,status,fileorig,1,l_val=tmp_ret_val) 769 535 ELSE 770 536 !-- Get the value out of the database 771 CALL get dbrc (pos,1,TARGET,tmp_ret_val)537 CALL get_rdb (pos,1,target,l_val=tmp_ret_val) 772 538 ENDIF 773 539 ret_val = tmp_ret_val(1) 774 540 !--------------------- 775 END SUBROUTINE getincs 776 !- 777 !=== 778 !- 779 SUBROUTINE getinc1d (TARGET,ret_val) 780 !--------------------------------------------------------------------- 781 !- See getincs for details. It is the same thing but for a vector 782 !--------------------------------------------------------------------- 783 IMPLICIT NONE 784 !- 785 CHARACTER(LEN=*) :: TARGET 786 CHARACTER(LEN=*),DIMENSION(:) :: ret_val 787 !- 788 CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 541 END SUBROUTINE getinls 542 !=== 543 SUBROUTINE getinl1d (target,ret_val) 544 !--------------------------------------------------------------------- 545 IMPLICIT NONE 546 !- 547 CHARACTER(LEN=*) :: target 548 LOGICAL,DIMENSION(:) :: ret_val 549 !- 550 LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 789 551 INTEGER,SAVE :: tmp_ret_size = 0 790 INTEGER :: target_sig, pos, size_of_in, status=0, fileorig 791 !--------------------------------------------------------------------- 792 !- 793 ! Compute the signature of the target 794 !- 795 CALL gensig (TARGET,target_sig) 552 INTEGER :: pos,size_of_in,status=0,fileorig 553 !--------------------------------------------------------------------- 796 554 !- 797 555 ! Do we have this target in our database ? 798 556 !- 799 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)557 CALL get_findkey (1,target,pos) 800 558 !- 801 559 size_of_in = SIZE(ret_val) … … 810 568 !- 811 569 IF (pos < 0) THEN 812 !-- Ge the information out of the file813 CALL get filc (TARGET,status,fileorig,tmp_ret_val)570 !-- Get the information out of the file 571 CALL get_fil (target,status,fileorig,l_val=tmp_ret_val) 814 572 !-- Put the data into the database 815 CALL get dbwc&816 & ( TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)573 CALL get_wdb & 574 & (target,status,fileorig,size_of_in,l_val=tmp_ret_val) 817 575 ELSE 818 576 !-- Get the value out of the database 819 CALL get dbrc (pos,size_of_in,TARGET,tmp_ret_val)577 CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val) 820 578 ENDIF 821 579 ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in) 822 580 !---------------------- 823 END SUBROUTINE getinc1d 824 !- 825 !=== 826 !- 827 SUBROUTINE getinc2d (TARGET,ret_val) 828 !--------------------------------------------------------------------- 829 !- See getincs for details. It is the same thing but for a matrix 830 !--------------------------------------------------------------------- 831 IMPLICIT NONE 832 !- 833 CHARACTER(LEN=*) :: TARGET 834 CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val 835 !- 836 CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 581 END SUBROUTINE getinl1d 582 !=== 583 SUBROUTINE getinl2d (target,ret_val) 584 !--------------------------------------------------------------------- 585 IMPLICIT NONE 586 !- 587 CHARACTER(LEN=*) :: target 588 LOGICAL,DIMENSION(:,:) :: ret_val 589 !- 590 LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 837 591 INTEGER,SAVE :: tmp_ret_size = 0 838 INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig592 INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig 839 593 INTEGER :: jl,jj,ji 840 594 !--------------------------------------------------------------------- 841 595 !- 842 ! Compute the signature of the target843 !-844 CALL gensig (TARGET,target_sig)845 !-846 596 ! Do we have this target in our database ? 847 597 !- 848 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)598 CALL get_findkey (1,target,pos) 849 599 !- 850 600 size_of_in = SIZE(ret_val) … … 868 618 !- 869 619 IF (pos < 0) THEN 870 !-- Ge the information out of the file871 CALL get filc (TARGET,status,fileorig,tmp_ret_val)620 !-- Get the information out of the file 621 CALL get_fil (target,status,fileorig,l_val=tmp_ret_val) 872 622 !-- Put the data into the database 873 CALL get dbwc&874 & ( TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)623 CALL get_wdb & 624 & (target,status,fileorig,size_of_in,l_val=tmp_ret_val) 875 625 ELSE 876 626 !-- Get the value out of the database 877 CALL getdbrc (pos,size_of_in,TARGET,tmp_ret_val) 878 ENDIF 879 !- 880 jl=0 881 DO jj=1,size_2 882 DO ji=1,size_1 883 jl=jl+1 884 ret_val(ji,jj) = tmp_ret_val(jl) 885 ENDDO 886 ENDDO 887 !---------------------- 888 END SUBROUTINE getinc2d 889 !- 890 !=== 891 !- 892 SUBROUTINE getfilc (TARGET,status,fileorig,ret_val) 893 !--------------------------------------------------------------------- 894 !- Subroutine that will extract from the file the values 895 !- attributed to the keyword target 896 !- 897 !- CHARACTER 898 !- --------- 899 !- 900 !- target : in : CHARACTER(LEN=*) target for which we will 901 !- look in the file 902 !- status : out : INTEGER tells us from where we obtained the data 903 !- fileorig : out : The index of the file from which the key comes 904 !- ret_val : out : CHARACTER(nb_to_ret) values read 905 !--------------------------------------------------------------------- 906 IMPLICIT NONE 907 !- 908 !- 909 CHARACTER(LEN=*) :: TARGET 910 INTEGER :: status, fileorig 911 CHARACTER(LEN=*),DIMENSION(:) :: ret_val 912 !- 913 INTEGER :: nb_to_ret 914 INTEGER :: it, pos, len_str, status_cnt 915 CHARACTER(LEN=3) :: cnt 916 CHARACTER(LEN=30) :: full_target 917 CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp 918 INTEGER :: full_target_sig 919 !- 920 INTEGER,SAVE :: max_len = 0 921 LOGICAL,DIMENSION(:),SAVE,ALLOCATABLE :: found 922 LOGICAL :: def_beha 923 !--------------------------------------------------------------------- 924 nb_to_ret = SIZE(ret_val) 925 CALL getin_read 926 !- 927 ! Get the variables and memory we need 928 !- 929 IF (max_len == 0) THEN 930 ALLOCATE(found(nb_to_ret)) 931 max_len = nb_to_ret 932 ENDIF 933 IF (max_len < nb_to_ret) THEN 934 DEALLOCATE(found) 935 ALLOCATE(found(nb_to_ret)) 936 max_len = nb_to_ret 937 ENDIF 938 found(:) = .FALSE. 939 !- 940 ! See what we find in the files read 941 !- 942 DO it=1,nb_to_ret 943 !--- 944 !-- First try the target as it is 945 full_target = TARGET(1:len_TRIM(target)) 946 CALL gensig (full_target,full_target_sig) 947 CALL find_sig (nb_lines,targetlist,full_target, & 948 & targetsiglist,full_target_sig,pos) 949 !--- 950 !-- Another try 951 !--- 952 IF (pos < 0) THEN 953 WRITE(cnt,'(I3.3)') it 954 full_target = TARGET(1:len_TRIM(target))//'__'//cnt 955 CALL gensig (full_target,full_target_sig) 956 CALL find_sig (nb_lines,targetlist,full_target, & 957 & targetsiglist,full_target_sig,pos) 958 ENDIF 959 !--- 960 !-- A priori we dont know from which file the target could come. 961 !-- Thus by default we attribute it to the first file : 962 !--- 963 fileorig = 1 964 !--- 965 IF (pos > 0) THEN 966 !----- 967 found(it) = .TRUE. 968 fileorig = fromfile(pos) 969 !----- 970 !---- DECODE 971 !----- 972 str_READ = TRIM(ADJUSTL(fichier(pos))) 973 str_READ_lower = str_READ 974 CALL strlowercase (str_READ_lower) 975 !----- 976 IF ( ( (INDEX(str_READ_lower,'def') == 1) & 977 & .AND.(LEN_TRIM(str_READ_lower) == 3) ) & 978 & .OR.( (INDEX(str_READ_lower,'default') == 1) & 979 & .AND.(LEN_TRIM(str_READ_lower) == 7) ) ) THEN 980 def_beha = .TRUE. 981 ELSE 982 def_beha = .FALSE. 983 len_str = LEN_TRIM(str_READ) 984 ret_val(it) = str_READ(1:len_str) 985 ENDIF 986 !----- 987 targetsiglist(pos) = -1 988 !----- 989 ELSE 990 found(it) = .FALSE. 991 ENDIF 992 ENDDO 993 !- 994 ! Now we get the status for what we found 995 !- 996 IF (def_beha) THEN 997 status = 2 998 WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET) 999 ELSE 1000 status_cnt = 0 1001 DO it=1,nb_to_ret 1002 IF (.NOT. found(it)) THEN 1003 status_cnt = status_cnt+1 1004 IF (nb_to_ret > 1) THEN 1005 WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it 1006 ELSE 1007 str_tmp = TARGET(1:len_TRIM(target)) 1008 ENDIF 1009 WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it) 1010 ENDIF 1011 ENDDO 1012 !- 1013 IF (status_cnt == 0) THEN 1014 status = 1 1015 ELSE IF (status_cnt == nb_to_ret) THEN 1016 status = 2 1017 ELSE 1018 status = 3 1019 ENDIF 1020 ENDIF 1021 !--------------------- 1022 END SUBROUTINE getfilc 1023 !- 1024 !=== LOGICAL INTERFACES 1025 !- 1026 SUBROUTINE getinls (TARGET,ret_val) 1027 !--------------------------------------------------------------------- 1028 !- Get a logical scalar. We first check if we find it 1029 !- in the database and if not we get it from the run.def 1030 !- 1031 !- getinl1d and getinl2d are written on the same pattern 1032 !--------------------------------------------------------------------- 1033 IMPLICIT NONE 1034 !- 1035 CHARACTER(LEN=*) :: TARGET 1036 LOGICAL :: ret_val 1037 !- 1038 LOGICAL,DIMENSION(1) :: tmp_ret_val 1039 INTEGER :: target_sig, pos, status=0, fileorig 1040 !--------------------------------------------------------------------- 1041 !- 1042 ! Compute the signature of the target 1043 !- 1044 CALL gensig (TARGET,target_sig) 1045 !- 1046 ! Do we have this target in our database ? 1047 !- 1048 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos) 1049 !- 1050 tmp_ret_val(1) = ret_val 1051 !- 1052 IF (pos < 0) THEN 1053 !-- Ge the information out of the file 1054 CALL getfill (TARGET,status,fileorig,tmp_ret_val) 1055 !-- Put the data into the database 1056 CALL getdbwl (TARGET,target_sig,status,fileorig,1,tmp_ret_val) 1057 ELSE 1058 !-- Get the value out of the database 1059 CALL getdbrl (pos,1,TARGET,tmp_ret_val) 1060 ENDIF 1061 ret_val = tmp_ret_val(1) 1062 !--------------------- 1063 END SUBROUTINE getinls 1064 !- 1065 !=== 1066 !- 1067 SUBROUTINE getinl1d (TARGET,ret_val) 1068 !--------------------------------------------------------------------- 1069 !- See getinls for details. It is the same thing but for a vector 1070 !--------------------------------------------------------------------- 1071 IMPLICIT NONE 1072 !- 1073 CHARACTER(LEN=*) :: TARGET 1074 LOGICAL,DIMENSION(:) :: ret_val 1075 !- 1076 LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 1077 INTEGER,SAVE :: tmp_ret_size = 0 1078 INTEGER :: target_sig, pos, size_of_in, status=0, fileorig 1079 !--------------------------------------------------------------------- 1080 !- 1081 ! Compute the signature of the target 1082 !- 1083 CALL gensig (TARGET,target_sig) 1084 !- 1085 ! Do we have this target in our database ? 1086 !- 1087 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos) 1088 !- 1089 size_of_in = SIZE(ret_val) 1090 IF (.NOT.ALLOCATED(tmp_ret_val)) THEN 1091 ALLOCATE (tmp_ret_val(size_of_in)) 1092 ELSE IF (size_of_in > tmp_ret_size) THEN 1093 DEALLOCATE (tmp_ret_val) 1094 ALLOCATE (tmp_ret_val(size_of_in)) 1095 tmp_ret_size = size_of_in 1096 ENDIF 1097 tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in) 1098 !- 1099 IF (pos < 0) THEN 1100 !-- Ge the information out of the file 1101 CALL getfill (TARGET,status,fileorig,tmp_ret_val) 1102 !-- Put the data into the database 1103 CALL getdbwl & 1104 & (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val) 1105 ELSE 1106 !-- Get the value out of the database 1107 CALL getdbrl (pos,size_of_in,TARGET,tmp_ret_val) 1108 ENDIF 1109 ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in) 1110 !---------------------- 1111 END SUBROUTINE getinl1d 1112 !- 1113 !=== 1114 !- 1115 SUBROUTINE getinl2d (TARGET,ret_val) 1116 !--------------------------------------------------------------------- 1117 !- See getinls for details. It is the same thing but for a matrix 1118 !--------------------------------------------------------------------- 1119 IMPLICIT NONE 1120 !- 1121 CHARACTER(LEN=*) :: TARGET 1122 LOGICAL,DIMENSION(:,:) :: ret_val 1123 !- 1124 LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val 1125 INTEGER,SAVE :: tmp_ret_size = 0 1126 INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig 1127 INTEGER :: jl,jj,ji 1128 !--------------------------------------------------------------------- 1129 !- 1130 ! Compute the signature of the target 1131 !- 1132 CALL gensig (TARGET,target_sig) 1133 !- 1134 ! Do we have this target in our database ? 1135 !- 1136 CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos) 1137 !- 1138 size_of_in = SIZE(ret_val) 1139 size_1 = SIZE(ret_val,1) 1140 size_2 = SIZE(ret_val,2) 1141 IF (.NOT.ALLOCATED(tmp_ret_val)) THEN 1142 ALLOCATE (tmp_ret_val(size_of_in)) 1143 ELSE IF (size_of_in > tmp_ret_size) THEN 1144 DEALLOCATE (tmp_ret_val) 1145 ALLOCATE (tmp_ret_val(size_of_in)) 1146 tmp_ret_size = size_of_in 1147 ENDIF 1148 !- 1149 jl=0 1150 DO jj=1,size_2 1151 DO ji=1,size_1 1152 jl=jl+1 1153 tmp_ret_val(jl) = ret_val(ji,jj) 1154 ENDDO 1155 ENDDO 1156 !- 1157 IF (pos < 0) THEN 1158 !-- Ge the information out of the file 1159 CALL getfill (TARGET,status,fileorig,tmp_ret_val) 1160 !-- Put the data into the database 1161 CALL getdbwl & 1162 & (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val) 1163 ELSE 1164 !-- Get the value out of the database 1165 CALL getdbrl (pos,size_of_in,TARGET,tmp_ret_val) 627 CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val) 1166 628 ENDIF 1167 629 !- … … 1176 638 END SUBROUTINE getinl2d 1177 639 !- 1178 !=== 1179 !- 1180 SUBROUTINE get fill (TARGET,status,fileorig,ret_val)640 !=== Generic file/database INTERFACE 641 !- 642 SUBROUTINE get_fil (target,status,fileorig,i_val,r_val,c_val,l_val) 1181 643 !--------------------------------------------------------------------- 1182 644 !- Subroutine that will extract from the file the values 1183 645 !- attributed to the keyword target 1184 646 !- 1185 !- LOGICAL 1186 !- ------- 1187 !- 1188 !- target : in : CHARACTER(LEN=*) target for which we will 1189 !- look in the file 1190 !- status : out : INTEGER tells us from where we obtained the data 1191 !- fileorig : out : The index of the file from which the key comes 1192 !- ret_val : out : LOGICAL(nb_to_ret) values read 1193 !--------------------------------------------------------------------- 1194 IMPLICIT NONE 1195 !- 1196 CHARACTER(LEN=*) :: TARGET 1197 INTEGER :: status, fileorig 1198 LOGICAL,DIMENSION(:) :: ret_val 1199 !- 1200 INTEGER :: nb_to_ret 1201 INTEGER :: it, pos, len_str, ipos_tr, ipos_fl, status_cnt 1202 CHARACTER(LEN=3) :: cnt 1203 CHARACTER(LEN=30) :: full_target 1204 CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp 1205 INTEGER :: full_target_sig 1206 !- 1207 INTEGER,SAVE :: max_len = 0 1208 LOGICAL,DIMENSION(:),SAVE,ALLOCATABLE :: found 1209 LOGICAL :: def_beha 1210 !--------------------------------------------------------------------- 1211 nb_to_ret = SIZE(ret_val) 647 !- (C) target : target for which we will look in the file 648 !- (I) status : tells us from where we obtained the data 649 !- (I) fileorig : index of the file from which the key comes 650 !- (I) i_val(:) : INTEGER(nb_to_ret) values 651 !- (R) r_val(:) : REAL(nb_to_ret) values 652 !- (L) l_val(:) : LOGICAL(nb_to_ret) values 653 !- (C) c_val(:) : CHARACTER(nb_to_ret) values 654 !--------------------------------------------------------------------- 655 IMPLICIT NONE 656 !- 657 CHARACTER(LEN=*) :: target 658 INTEGER,INTENT(OUT) :: status,fileorig 659 INTEGER,DIMENSION(:),OPTIONAL :: i_val 660 REAL,DIMENSION(:),OPTIONAL :: r_val 661 LOGICAL,DIMENSION(:),OPTIONAL :: l_val 662 CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val 663 !- 664 INTEGER :: k_typ,nb_to_ret,it,pos,len_str,status_cnt,io_err 665 CHARACTER(LEN=n_d_fmt) :: cnt 666 CHARACTER(LEN=80) :: str_READ,str_READ_lower 667 CHARACTER(LEN=9) :: c_vtyp 668 LOGICAL,DIMENSION(:),ALLOCATABLE :: found 669 LOGICAL :: def_beha,compressed 670 CHARACTER(LEN=10) :: c_fmt 671 INTEGER :: i_cmpval 672 REAL :: r_cmpval 673 INTEGER :: ipos_tr,ipos_fl 674 !--------------------------------------------------------------------- 675 !- 676 ! Get the type of the argument 677 CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val) 678 SELECT CASE (k_typ) 679 CASE(k_i) 680 nb_to_ret = SIZE(i_val) 681 CASE(k_r) 682 nb_to_ret = SIZE(r_val) 683 CASE(k_c) 684 nb_to_ret = SIZE(c_val) 685 CASE(k_l) 686 nb_to_ret = SIZE(l_val) 687 CASE DEFAULT 688 CALL ipslerr (3,'get_fil', & 689 & 'Internal error','Unknown type of data',' ') 690 END SELECT 691 !- 692 ! Read the file(s) 1212 693 CALL getin_read 1213 694 !- 1214 ! Get the variables and memory we need 1215 !- 1216 IF (max_len == 0) THEN 1217 ALLOCATE(found(nb_to_ret)) 1218 max_len = nb_to_ret 1219 ENDIF 1220 IF (max_len < nb_to_ret) THEN 1221 DEALLOCATE(found) 1222 ALLOCATE(found(nb_to_ret)) 1223 max_len = nb_to_ret 1224 ENDIF 695 ! Allocate and initialize the memory we need 696 ALLOCATE(found(nb_to_ret)) 1225 697 found(:) = .FALSE. 1226 698 !- 1227 699 ! See what we find in the files read 1228 !-1229 700 DO it=1,nb_to_ret 1230 701 !--- 1231 702 !-- First try the target as it is 1232 !--- 1233 full_target = TARGET(1:len_TRIM(target)) 1234 CALL gensig (full_target,full_target_sig) 1235 CALL find_sig (nb_lines,targetlist,full_target, & 1236 & targetsiglist,full_target_sig,pos) 703 CALL get_findkey (2,target,pos) 1237 704 !--- 1238 705 !-- Another try 1239 706 !--- 1240 707 IF (pos < 0) THEN 1241 WRITE(cnt,'(I3.3)') it 1242 full_target = TARGET(1:len_TRIM(target))//'__'//cnt 1243 CALL gensig (full_target,full_target_sig) 1244 CALL find_sig (nb_lines,targetlist,full_target, & 1245 & targetsiglist,full_target_sig,pos) 1246 ENDIF 1247 !--- 1248 !-- A priori we dont know from which file the target could come. 708 WRITE(UNIT=cnt,FMT=c_i_fmt) it 709 CALL get_findkey (2,TRIM(target)//'__'//cnt,pos) 710 ENDIF 711 !--- 712 !-- We dont know from which file the target could come. 1249 713 !-- Thus by default we attribute it to the first file : 1250 !---1251 714 fileorig = 1 1252 715 !--- … … 1258 721 !---- DECODE 1259 722 !----- 1260 str_READ = TRIM(ADJUSTL(fichier(pos)))723 str_READ = ADJUSTL(fichier(pos)) 1261 724 str_READ_lower = str_READ 1262 725 CALL strlowercase (str_READ_lower) 1263 726 !----- 1264 IF ( ( (INDEX(str_READ_lower,'def') == 1) & 1265 & .AND.(LEN_TRIM(str_READ_lower) == 3) ) & 1266 & .OR.( (INDEX(str_READ_lower,'default') == 1) & 1267 & .AND.(LEN_TRIM(str_READ_lower) == 7) ) ) THEN 727 IF ( (TRIM(str_READ_lower) == 'def') & 728 & .OR.(TRIM(str_READ_lower) == 'default') ) THEN 1268 729 def_beha = .TRUE. 1269 730 ELSE 1270 731 def_beha = .FALSE. 1271 732 len_str = LEN_TRIM(str_READ) 1272 ipos_tr = -1 1273 ipos_fl = -1 733 io_err = 0 734 SELECT CASE (k_typ) 735 CASE(k_i) 736 WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') len_str 737 READ (UNIT=str_READ(1:len_str), & 738 & FMT=c_fmt,IOSTAT=io_err) i_val(it) 739 CASE(k_r) 740 READ (UNIT=str_READ(1:len_str), & 741 & FMT=*,IOSTAT=io_err) r_val(it) 742 CASE(k_c) 743 c_val(it) = str_READ(1:len_str) 744 CASE(k_l) 745 ipos_tr = -1 746 ipos_fl = -1 747 ipos_tr = MAX(INDEX(str_READ_lower,'tru'), & 748 & INDEX(str_READ_lower,'y')) 749 ipos_fl = MAX(INDEX(str_READ_lower,'fal'), & 750 & INDEX(str_READ_lower,'n')) 751 IF (ipos_tr > 0) THEN 752 l_val(it) = .TRUE. 753 ELSE IF (ipos_fl > 0) THEN 754 l_val(it) = .FALSE. 755 ELSE 756 io_err = 100 757 ENDIF 758 END SELECT 759 IF (io_err /= 0) THEN 760 CALL ipslerr (3,'get_fil', & 761 & 'Target '//TRIM(target), & 762 & 'is not of '//TRIM(c_vtyp)//' type',' ') 763 ENDIF 764 ENDIF 765 !----- 766 IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN 1274 767 !------- 1275 ipos_tr = MAX(INDEX(str_READ,'tru'),INDEX(str_READ,'TRU'), & 1276 & INDEX(str_READ,'y'),INDEX(str_READ,'Y')) 1277 ipos_fl = MAX(INDEX(str_READ,'fal'),INDEX(str_READ,'FAL'), & 1278 & INDEX(str_READ,'n'),INDEX(str_READ,'N')) 1279 !------- 1280 IF (ipos_tr > 0) THEN 1281 ret_val(it) = .TRUE. 1282 ELSE IF (ipos_fl > 0) THEN 1283 ret_val(it) = .FALSE. 1284 ELSE 1285 WRITE(*,*) "ERROR : getfill : TARGET ", & 1286 & TRIM(TARGET)," is not of logical value" 1287 STOP 'getinl' 768 !------ Is this the value of a compressed field ? 769 compressed = (compline(pos) > 0) 770 IF (compressed) THEN 771 IF (compline(pos) /= nb_to_ret) THEN 772 CALL ipslerr (2,'get_fil', & 773 & 'For key '//TRIM(target)//' we have a compressed field', & 774 & 'which does not have the right size.', & 775 & 'We will try to fix that.') 776 ENDIF 777 IF (k_typ == k_i) THEN 778 i_cmpval = i_val(it) 779 ELSE IF (k_typ == k_r) THEN 780 r_cmpval = r_val(it) 781 ENDIF 1288 782 ENDIF 1289 783 ENDIF 1290 !-----1291 targetsiglist(pos) = -11292 !-----1293 784 ELSE 1294 !-1295 785 found(it) = .FALSE. 1296 !- 1297 ENDIF1298 !- 786 def_beha = .FALSE. 787 compressed = .FALSE. 788 ENDIF 1299 789 ENDDO 1300 790 !- 1301 ! Now we get the status for what we found 1302 !- 791 IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN 792 !--- 793 !-- If this is a compressed field then we will uncompress it 794 IF (compressed) THEN 795 DO it=1,nb_to_ret 796 IF (.NOT.found(it)) THEN 797 IF (k_typ == k_i) THEN 798 i_val(it) = i_cmpval 799 ELSE IF (k_typ == k_r) THEN 800 ENDIF 801 found(it) = .TRUE. 802 ENDIF 803 ENDDO 804 ENDIF 805 ENDIF 806 !- 807 ! Now we set the status for what we found 1303 808 IF (def_beha) THEN 1304 809 status = 2 1305 WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM( TARGET)810 WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(target) 1306 811 ELSE 1307 812 status_cnt = 0 1308 813 DO it=1,nb_to_ret 1309 IF (.NOT. 814 IF (.NOT.found(it)) THEN 1310 815 status_cnt = status_cnt+1 1311 IF (nb_to_ret > 1) THEN 1312 WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it 1313 ELSE 1314 str_tmp = TRIM(TARGET) 816 IF (status_cnt <= max_msgs) THEN 817 WRITE (UNIT=*,FMT='(" USING DEFAULTS : ",A)', & 818 & ADVANCE='NO') TRIM(target) 819 IF (nb_to_ret > 1) THEN 820 WRITE (UNIT=*,FMT='("__")',ADVANCE='NO') 821 WRITE (UNIT=*,FMT=c_i_fmt,ADVANCE='NO') it 822 ENDIF 823 SELECT CASE (k_typ) 824 CASE(k_i) 825 WRITE (UNIT=*,FMT=*) "=",i_val(it) 826 CASE(k_r) 827 WRITE (UNIT=*,FMT=*) "=",r_val(it) 828 CASE(k_c) 829 WRITE (UNIT=*,FMT=*) "=",c_val(it) 830 CASE(k_l) 831 WRITE (UNIT=*,FMT=*) "=",l_val(it) 832 END SELECT 833 ELSE IF (status_cnt == max_msgs+1) THEN 834 WRITE (UNIT=*,FMT='(" USING DEFAULTS ... ",A)') 1315 835 ENDIF 1316 WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it)1317 836 ENDIF 1318 837 ENDDO … … 1326 845 ENDIF 1327 846 ENDIF 847 ! Deallocate the memory 848 DEALLOCATE(found) 1328 849 !--------------------- 1329 END SUBROUTINE getfill 850 END SUBROUTINE get_fil 851 !=== 852 SUBROUTINE get_rdb (pos,size_of_in,target,i_val,r_val,c_val,l_val) 853 !--------------------------------------------------------------------- 854 !- Read the required variable in the database 855 !--------------------------------------------------------------------- 856 IMPLICIT NONE 857 !- 858 INTEGER :: pos,size_of_in 859 CHARACTER(LEN=*) :: target 860 INTEGER,DIMENSION(:),OPTIONAL :: i_val 861 REAL,DIMENSION(:),OPTIONAL :: r_val 862 LOGICAL,DIMENSION(:),OPTIONAL :: l_val 863 CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val 864 !- 865 INTEGER :: k_typ,k_beg,k_end 866 CHARACTER(LEN=9) :: c_vtyp 867 !--------------------------------------------------------------------- 868 !- 869 ! Get the type of the argument 870 CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val) 871 IF ( (k_typ /= k_i).AND.(k_typ /= k_r) & 872 & .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN 873 CALL ipslerr (3,'get_rdb', & 874 & 'Internal error','Unknown type of data',' ') 875 ENDIF 876 !- 877 IF (key_tab(pos)%keytype /= k_typ) THEN 878 CALL ipslerr (3,'get_rdb', & 879 & 'Wrong data type for keyword '//TRIM(target), & 880 & '(NOT '//TRIM(c_vtyp)//')',' ') 881 ENDIF 882 !- 883 IF (key_tab(pos)%keycompress > 0) THEN 884 IF ( (key_tab(pos)%keycompress /= size_of_in) & 885 & .OR.(key_tab(pos)%keymemlen /= 1) ) THEN 886 CALL ipslerr (3,'get_rdb', & 887 & 'Wrong compression length','for keyword '//TRIM(target),' ') 888 ELSE 889 SELECT CASE (k_typ) 890 CASE(k_i) 891 i_val(1:size_of_in) = i_mem(key_tab(pos)%keymemstart) 892 CASE(k_r) 893 r_val(1:size_of_in) = r_mem(key_tab(pos)%keymemstart) 894 END SELECT 895 ENDIF 896 ELSE 897 IF (key_tab(pos)%keymemlen /= size_of_in) THEN 898 CALL ipslerr (3,'get_rdb', & 899 & 'Wrong array length','for keyword '//TRIM(target),' ') 900 ELSE 901 k_beg = key_tab(pos)%keymemstart 902 k_end = k_beg+key_tab(pos)%keymemlen-1 903 SELECT CASE (k_typ) 904 CASE(k_i) 905 i_val(1:size_of_in) = i_mem(k_beg:k_end) 906 CASE(k_r) 907 r_val(1:size_of_in) = r_mem(k_beg:k_end) 908 CASE(k_c) 909 c_val(1:size_of_in) = c_mem(k_beg:k_end) 910 CASE(k_l) 911 l_val(1:size_of_in) = l_mem(k_beg:k_end) 912 END SELECT 913 ENDIF 914 ENDIF 915 !--------------------- 916 END SUBROUTINE get_rdb 917 !=== 918 SUBROUTINE get_wdb & 919 & (target,status,fileorig,size_of_in, & 920 & i_val,r_val,c_val,l_val) 921 !--------------------------------------------------------------------- 922 !- Write data into the data base 923 !--------------------------------------------------------------------- 924 IMPLICIT NONE 925 !- 926 CHARACTER(LEN=*) :: target 927 INTEGER :: status,fileorig,size_of_in 928 INTEGER,DIMENSION(:),OPTIONAL :: i_val 929 REAL,DIMENSION(:),OPTIONAL :: r_val 930 LOGICAL,DIMENSION(:),OPTIONAL :: l_val 931 CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val 932 !- 933 INTEGER :: k_typ 934 CHARACTER(LEN=9) :: c_vtyp 935 INTEGER :: k_mempos,k_memsize,k_beg,k_end 936 LOGICAL :: l_cmp 937 !--------------------------------------------------------------------- 938 !- 939 ! Get the type of the argument 940 CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val) 941 IF ( (k_typ /= k_i).AND.(k_typ /= k_r) & 942 & .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN 943 CALL ipslerr (3,'get_wdb', & 944 & 'Internal error','Unknown type of data',' ') 945 ENDIF 946 !- 947 ! First check if we have sufficiant space for the new key 948 IF (nb_keys+1 > keymemsize) THEN 949 CALL getin_allockeys () 950 ENDIF 951 !- 952 SELECT CASE (k_typ) 953 CASE(k_i) 954 k_mempos = i_mempos; k_memsize = i_memsize; 955 l_cmp = (MINVAL(i_val) == MAXVAL(i_val)) & 956 & .AND.(size_of_in > compress_lim) 957 CASE(k_r) 958 k_mempos = r_mempos; k_memsize = r_memsize; 959 l_cmp = (MINVAL(r_val) == MAXVAL(r_val)) & 960 & .AND.(size_of_in > compress_lim) 961 CASE(k_c) 962 k_mempos = c_mempos; k_memsize = c_memsize; 963 l_cmp = .FALSE. 964 CASE(k_l) 965 k_mempos = l_mempos; k_memsize = l_memsize; 966 l_cmp = .FALSE. 967 END SELECT 968 !- 969 ! Fill out the items of the data base 970 nb_keys = nb_keys+1 971 key_tab(nb_keys)%keystr = target(1:MIN(LEN_TRIM(target),l_n)) 972 key_tab(nb_keys)%keystatus = status 973 key_tab(nb_keys)%keytype = k_typ 974 key_tab(nb_keys)%keyfromfile = fileorig 975 key_tab(nb_keys)%keymemstart = k_mempos+1 976 IF (l_cmp) THEN 977 key_tab(nb_keys)%keycompress = size_of_in 978 key_tab(nb_keys)%keymemlen = 1 979 ELSE 980 key_tab(nb_keys)%keycompress = -1 981 key_tab(nb_keys)%keymemlen = size_of_in 982 ENDIF 983 !- 984 ! Before writing the actual size lets see if we have the space 985 IF (key_tab(nb_keys)%keymemstart+key_tab(nb_keys)%keymemlen & 986 & > k_memsize) THEN 987 CALL getin_allocmem (k_typ,key_tab(nb_keys)%keymemlen) 988 ENDIF 989 !- 990 k_beg = key_tab(nb_keys)%keymemstart 991 k_end = k_beg+key_tab(nb_keys)%keymemlen-1 992 SELECT CASE (k_typ) 993 CASE(k_i) 994 i_mem(k_beg:k_end) = i_val(1:key_tab(nb_keys)%keymemlen) 995 i_mempos = k_end 996 CASE(k_r) 997 r_mem(k_beg:k_end) = r_val(1:key_tab(nb_keys)%keymemlen) 998 r_mempos = k_end 999 CASE(k_c) 1000 c_mem(k_beg:k_end) = c_val(1:key_tab(nb_keys)%keymemlen) 1001 c_mempos = k_end 1002 CASE(k_l) 1003 l_mem(k_beg:k_end) = l_val(1:key_tab(nb_keys)%keymemlen) 1004 l_mempos = k_end 1005 END SELECT 1006 !--------------------- 1007 END SUBROUTINE get_wdb 1330 1008 !- 1331 1009 !=== … … 1336 1014 !- 1337 1015 INTEGER,SAVE :: allread=0 1338 INTEGER,SAVE :: current ,i1016 INTEGER,SAVE :: current 1339 1017 !--------------------------------------------------------------------- 1340 1018 IF (allread == 0) THEN 1341 1019 !-- Allocate a first set of memory. 1342 CALL getin_allockeys 1343 CALL getin_allocmem (1,0) 1344 CALL getin_allocmem (2,0) 1345 CALL getin_allocmem (3,0) 1346 CALL getin_allocmem (4,0) 1020 CALL getin_alloctxt () 1021 CALL getin_allockeys () 1022 CALL getin_allocmem (k_i,0) 1023 CALL getin_allocmem (k_r,0) 1024 CALL getin_allocmem (k_c,0) 1025 CALL getin_allocmem (k_l,0) 1347 1026 !-- Start with reading the files 1348 1027 nbfiles = 1 1349 1028 filelist(1) = 'run.def' 1350 1029 current = 1 1351 nb_lines = 01352 1030 !-- 1353 1031 DO WHILE (current <= nbfiles) … … 1373 1051 INTEGER :: current 1374 1052 !- 1375 CHARACTER(LEN=100) :: READ_str, NEW_str, new_key, last_key, key_str 1376 CHARACTER(LEN=3) :: cnt 1053 CHARACTER(LEN=100) :: READ_str,NEW_str,last_key,key_str 1054 CHARACTER(LEN=n_d_fmt) :: cnt 1055 CHARACTER(LEN=10) :: c_fmt 1377 1056 INTEGER :: nb_lastkey 1378 1057 !- 1379 INTEGER :: eof, ptn, len_str, i, it, iund1058 INTEGER :: eof,ptn,len_str,i,it,iund,io_err 1380 1059 LOGICAL :: check = .FALSE. 1381 1060 !--------------------------------------------------------------------- … … 1388 1067 ENDIF 1389 1068 !- 1390 OPEN (22,file=filelist(current),ERR=9997,STATUS="OLD") 1069 OPEN (UNIT=22,FILE=filelist(current),STATUS="OLD",IOSTAT=io_err) 1070 IF (io_err /= 0) THEN 1071 CALL ipslerr (2,'getin_readdef', & 1072 & 'Could not open file '//TRIM(filelist(current)),' ',' ') 1073 RETURN 1074 ENDIF 1391 1075 !- 1392 1076 DO WHILE (eof /= 1) … … 1399 1083 !---- Get the target 1400 1084 key_str = TRIM(ADJUSTL(READ_str(1:ptn-1))) 1401 !---- Make sure that ifa vector keyword has the right length1402 iund = 1085 !---- Make sure that a vector keyword has the right length 1086 iund = INDEX(key_str,'__') 1403 1087 IF (iund > 0) THEN 1404 SELECTCASE( len_trim(key_str)-iund ) 1405 CASE(2) 1406 READ(key_str(iund+2:len_trim(key_str)),'(I1)') it 1407 CASE(3) 1408 READ(key_str(iund+2:len_trim(key_str)),'(I2)') it 1409 CASE(4) 1410 READ(key_str(iund+2:len_trim(key_str)),'(I3)') it 1411 CASE DEFAULT 1412 it = -1 1413 END SELECT 1414 IF (it > 0) THEN 1415 WRITE(cnt,'(I3.3)') it 1088 WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') & 1089 & LEN_TRIM(key_str)-iund-1 1090 READ(UNIT=key_str(iund+2:LEN_TRIM(key_str)), & 1091 & FMT=c_fmt,IOSTAT=io_err) it 1092 IF ( (io_err == 0).AND.(it > 0) ) THEN 1093 WRITE(UNIT=cnt,FMT=c_i_fmt) it 1416 1094 key_str = key_str(1:iund+1)//cnt 1417 1095 ELSE 1418 WRITE(*,*) & 1419 & 'getin_readdef : A very strange key has just been found' 1420 WRITE(*,*) 'getin_readdef : ',key_str(1:len_TRIM(key_str)) 1421 STOP 'getin_readdef' 1096 CALL ipslerr (3,'getin_readdef', & 1097 & 'A very strange key has just been found :', & 1098 & TRIM(key_str),' ') 1422 1099 ENDIF 1423 1100 ENDIF … … 1448 1125 ELSE 1449 1126 IF (nb_lastkey /= 1) THEN 1450 WRITE(*,*) & 1451 & 'getin_readdef : An error has occured. We can not have a scalar' 1452 WRITE(*,*) 'getin_readdef : keywod and a vector content' 1453 STOP 'getin_readdef' 1127 CALL ipslerr (3,'getin_readdef', & 1128 & 'We can not have a scalar keyword', & 1129 & 'and a vector content',' ') 1454 1130 ENDIF 1455 1131 !-------- The last keyword needs to be transformed into a vector. 1132 WRITE(UNIT=cnt,FMT=c_i_fmt) 1 1456 1133 targetlist(nb_lines) = & 1457 & last_key(1:MIN(len_trim(last_key),30))//'__001' 1458 CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines)) 1459 key_str = last_key(1:len_TRIM(last_key)) 1134 & last_key(1:MIN(LEN_TRIM(last_key),l_n-n_d_fmt-2))//'__'//cnt 1135 key_str = last_key(1:LEN_TRIM(last_key)) 1460 1136 ENDIF 1461 1137 ENDIF … … 1464 1140 CALL getin_decrypt (current,key_str,NEW_str,last_key,nb_lastkey) 1465 1141 ELSE 1466 !---- If we have an empty line the the keyword finishes1142 !---- If we have an empty line then the keyword finishes 1467 1143 nb_lastkey = 0 1468 1144 IF (check) THEN … … 1472 1148 ENDDO 1473 1149 !- 1474 CLOSE( 22)1150 CLOSE(UNIT=22) 1475 1151 !- 1476 1152 IF (check) THEN 1477 OPEN ( 22,file='run.def.test')1153 OPEN (UNIT=22,file='run.def.test') 1478 1154 DO i=1,nb_lines 1479 WRITE( 22,*) targetlist(i)," : ",fichier(i)1155 WRITE(UNIT=22,FMT=*) targetlist(i)," : ",fichier(i) 1480 1156 ENDDO 1481 CLOSE(22) 1482 ENDIF 1483 !- 1484 RETURN 1485 !- 1486 9997 WRITE(*,*) "getin_readdef : Could not open file ", & 1487 & TRIM(filelist(current)) 1157 CLOSE(UNIT=22) 1158 ENDIF 1488 1159 !--------------------------- 1489 1160 END SUBROUTINE getin_readdef … … 1501 1172 ! ARGUMENTS 1502 1173 !- 1503 INTEGER :: current, 1504 CHARACTER(LEN=*) :: key_str, NEW_str,last_key1174 INTEGER :: current,nb_lastkey 1175 CHARACTER(LEN=*) :: key_str,NEW_str,last_key 1505 1176 !- 1506 1177 ! LOCAL 1507 1178 !- 1508 INTEGER :: len_str, blk, nbve,starpos1509 CHARACTER(LEN=100) :: tmp_str, new_key,mult1510 CHARACTER(LEN= 3) :: cnt, chlen1511 CHARACTER(LEN=10) ::fmt1179 INTEGER :: len_str,blk,nbve,starpos 1180 CHARACTER(LEN=100) :: tmp_str,new_key,mult 1181 CHARACTER(LEN=n_d_fmt) :: cnt 1182 CHARACTER(LEN=10) :: c_fmt 1512 1183 !--------------------------------------------------------------------- 1513 1184 len_str = LEN_TRIM(NEW_str) … … 1521 1192 DO WHILE (blk > 0) 1522 1193 IF (nbfiles+1 > max_files) THEN 1523 WRITE(*,*) 'FATAL ERROR : Too many files to include'1524 STOP 'getin_readdef'1194 CALL ipslerr (3,'getin_decrypt', & 1195 & 'Too many files to include',' ',' ') 1525 1196 ENDIF 1526 1197 !----- … … 1533 1204 !--- 1534 1205 IF (nbfiles+1 > max_files) THEN 1535 WRITE(*,*) 'FATAL ERROR : Too many files to include'1536 STOP 'getin_readdef'1206 CALL ipslerr (3,'getin_decrypt', & 1207 & 'Too many files to include',' ',' ') 1537 1208 ENDIF 1538 1209 !--- … … 1546 1217 !-- We are working on a new line of input 1547 1218 !- 1219 IF (nb_lines+1 > i_txtsize) THEN 1220 CALL getin_alloctxt () 1221 ENDIF 1548 1222 nb_lines = nb_lines+1 1549 IF (nb_lines > max_lines) THEN1550 WRITE(*,*) &1551 & 'Too many line in the run.def files. You need to increase'1552 WRITE(*,*) 'the parameter max_lines in the module getincom.'1553 STOP 'getin_decrypt'1554 ENDIF1555 1223 !- 1556 1224 !-- First we solve the issue of conpressed information. Once … … 1561 1229 & .AND.(tmp_str(1:1) /= "'") ) THEN 1562 1230 !----- 1563 IF (INDEX(key_str(1:len_TRIM(key_str)),'__') > 0) THEN 1564 WRITE(*,*) 'ERROR : getin_decrypt' 1565 WRITE(*,*) & 1566 & 'We can not have a compressed field of values for in a' 1567 WRITE(*,*) & 1568 & 'vector notation. If a target is of the type TARGET__1' 1569 WRITE(*,*) 'then only a scalar value is allowed' 1570 WRITE(*,*) 'The key at fault : ',key_str(1:len_TRIM(key_str)) 1571 STOP 'getin_decrypt' 1231 IF (INDEX(key_str(1:LEN_TRIM(key_str)),'__') > 0) THEN 1232 CALL ipslerr (3,'getin_decrypt', & 1233 & 'We can not have a compressed field of values', & 1234 & 'in a vector notation (TARGET__n).', & 1235 & 'The key at fault : '//TRIM(key_str)) 1572 1236 ENDIF 1573 1237 !- … … 1580 1244 blk = INDEX(NEW_str(1:len_str),' ') 1581 1245 IF (blk > 1) THEN 1582 WRITE(*,*) & 1583 & 'This is a strange behavior of getin_decrypt you could report' 1584 ENDIF 1585 WRITE(chlen,'(I3.3)') LEN_TRIM(mult) 1586 fmt = '(I'//chlen//')' 1587 READ(mult,fmt) compline(nb_lines) 1246 CALL ipslerr (2,'getin_decrypt', & 1247 & 'This is a strange behavior','you could report',' ') 1248 ENDIF 1249 WRITE (UNIT=c_fmt,FMT='("(I",I5.5,")")') LEN_TRIM(mult) 1250 READ(UNIT=mult,FMT=c_fmt) compline(nb_lines) 1588 1251 !--- 1589 1252 ELSE … … 1593 1256 !-- If there is no space wthin the line then the target is a scalar 1594 1257 !-- or the element of a properly written vector. 1595 !-- (ie of the type TARGET__ 1)1258 !-- (ie of the type TARGET__00001) 1596 1259 !- 1597 1260 IF ( (blk <= 1) & … … 1602 1265 !------ Save info of current keyword as a scalar 1603 1266 !------ if it is not a continuation 1604 targetlist(nb_lines) = key_str(1:MIN( len_trim(key_str),30))1605 last_key = key_str(1:MIN( len_trim(key_str),30))1267 targetlist(nb_lines) = key_str(1:MIN(LEN_TRIM(key_str),l_n)) 1268 last_key = key_str(1:MIN(LEN_TRIM(key_str),l_n)) 1606 1269 nb_lastkey = 1 1607 1270 ELSE 1608 1271 !------ We are continuing a vector so the keyword needs 1609 1272 !------ to get the underscores 1610 WRITE( cnt,'(I3.3)') nb_lastkey+11273 WRITE(UNIT=cnt,FMT=c_i_fmt) nb_lastkey+1 1611 1274 targetlist(nb_lines) = & 1612 & key_str(1:MIN(len_trim(key_str),25))//'__'//cnt 1613 last_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt 1275 & key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt 1276 last_key = & 1277 & key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt 1614 1278 nb_lastkey = nb_lastkey+1 1615 1279 ENDIF 1616 1280 !----- 1617 CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))1618 1281 fichier(nb_lines) = NEW_str(1:len_str) 1619 1282 fromfile(nb_lines) = current … … 1622 1285 !---- If there are blanks whithin the line then we are dealing 1623 1286 !---- with a vector and we need to split it in many entries 1624 !---- with the T RAGET__1notation.1287 !---- with the TARGET__n notation. 1625 1288 !---- 1626 1289 !---- Test if the targer is not already a vector target ! 1627 1290 !- 1628 1291 IF (INDEX(TRIM(key_str),'__') > 0) THEN 1629 WRITE(*,*) 'ERROR : getin_decrypt' 1630 WRITE(*,*) 'We have found a mixed vector notation' 1631 WRITE(*,*) 'If a target is of the type TARGET__1' 1632 WRITE(*,*) 'then only a scalar value is allowed' 1633 WRITE(*,*) 'The key at fault : ',key_str(1:len_TRIM(key_str)) 1634 STOP 'getin_decrypt' 1292 CALL ipslerr (3,'getin_decrypt', & 1293 & 'We have found a mixed vector notation (TARGET__n).', & 1294 & 'The key at fault : '//TRIM(key_str),' ') 1635 1295 ENDIF 1636 1296 !- 1637 1297 nbve = nb_lastkey 1638 1298 nbve = nbve+1 1639 WRITE( cnt,'(I3.3)') nbve1299 WRITE(UNIT=cnt,FMT=c_i_fmt) nbve 1640 1300 !- 1641 1301 DO WHILE (blk > 0) … … 1644 1304 !- 1645 1305 fichier(nb_lines) = tmp_str(1:blk) 1646 new_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt1647 targetlist(nb_lines) = new_key(1:MIN(len_trim(new_key),30))1648 CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))1306 new_key = & 1307 & key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt 1308 targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n)) 1649 1309 fromfile(nb_lines) = current 1650 1310 !- … … 1652 1312 blk = INDEX(TRIM(tmp_str),' ') 1653 1313 !- 1314 IF (nb_lines+1 > i_txtsize) THEN 1315 CALL getin_alloctxt () 1316 ENDIF 1654 1317 nb_lines = nb_lines+1 1655 IF (nb_lines > max_lines) THEN1656 WRITE(*,*) &1657 & 'Too many line in the run.def files. You need to increase'1658 WRITE(*,*) 'the parameter max_lines in the module getincom.'1659 STOP 'getin_decrypt'1660 ENDIF1661 1318 nbve = nbve+1 1662 WRITE( cnt,'(I3.3)') nbve1319 WRITE(UNIT=cnt,FMT=c_i_fmt) nbve 1663 1320 !- 1664 1321 ENDDO … … 1667 1324 !- 1668 1325 fichier(nb_lines) = tmp_str(1:LEN_TRIM(tmp_str)) 1669 new_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt1670 targetlist(nb_lines) = new_key(1:MIN(len_trim(new_key),30))1671 CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))1326 new_key = & 1327 & key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt 1328 targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n)) 1672 1329 fromfile(nb_lines) = current 1673 1330 !- 1674 last_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt 1331 last_key = & 1332 & key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt 1675 1333 nb_lastkey = nbve 1676 1334 !- … … 1689 1347 IMPLICIT NONE 1690 1348 !- 1691 ! Arguments 1692 !- 1693 !- 1694 ! LOCAL 1695 !- 1696 INTEGER :: line,i,sig 1697 INTEGER :: found 1698 CHARACTER(LEN=30) :: str 1349 INTEGER :: line,n_k,k 1699 1350 !--------------------------------------------------------------------- 1700 1351 DO line=1,nb_lines-1 1701 1352 !- 1702 CALL find_sig & 1703 & (nb_lines-line,targetlist(line+1:nb_lines),targetlist(line), & 1704 & targetsiglist(line+1:nb_lines),targetsiglist(line),found) 1353 n_k = 0 1354 DO k=line+1,nb_lines 1355 IF (TRIM(targetlist(line)) == TRIM(targetlist(k))) THEN 1356 n_k = k 1357 EXIT 1358 ENDIF 1359 ENDDO 1705 1360 !--- 1706 1361 !-- IF we have found it we have a problem to solve. 1707 1362 !--- 1708 IF (found > 0) THEN 1709 WRITE(*,*) 'COUNT : ', & 1710 & COUNT(ABS(targetsiglist(line+1:nb_lines)-targetsiglist(line)) < 1) 1711 !----- 1363 IF (n_k > 0) THEN 1364 WRITE(*,*) 'COUNT : ',n_k 1712 1365 WRITE(*,*) & 1713 & 'getin_checkcohe : Found a problem on key ',targetlist(line)1366 & 'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line)) 1714 1367 WRITE(*,*) & 1715 & 'getin_checkcohe : The following values were encoutered :'1368 & 'getin_checkcohe : The following values were encoutered :' 1716 1369 WRITE(*,*) & 1717 & ' ',TRIM(targetlist(line)), & 1718 & targetsiglist(line),' == ',fichier(line) 1370 & ' ',TRIM(targetlist(line)),' == ',fichier(line) 1719 1371 WRITE(*,*) & 1720 & ' ',TRIM(targetlist(line+found)), & 1721 & targetsiglist(line+found),' == ',fichier(line+found) 1372 & ' ',TRIM(targetlist(k)),' == ',fichier(k) 1722 1373 WRITE(*,*) & 1723 & 'getin_checkcohe : We will keep only the last value' 1724 !----- 1725 targetsiglist(line) = 1 1374 & 'getin_checkcohe : We will keep only the last value' 1375 targetlist(line) = ' ' 1726 1376 ENDIF 1727 1377 ENDDO 1728 !- 1378 !----------------------------- 1729 1379 END SUBROUTINE getin_checkcohe 1730 1380 !- … … 1735 1385 IMPLICIT NONE 1736 1386 !- 1737 INTEGER :: unit, eof,nb_lastkey1387 INTEGER :: unit,eof,nb_lastkey 1738 1388 CHARACTER(LEN=100) :: dummy 1739 1389 CHARACTER(LEN=100) :: out_string … … 1745 1395 !- 1746 1396 DO WHILE (first == "#") 1747 READ ( unit,'(a100)',ERR=9998,END=7778) dummy1397 READ (UNIT=unit,FMT='(A)',ERR=9998,END=7778) dummy 1748 1398 dummy = TRIM(ADJUSTL(dummy)) 1749 1399 first=dummy(1:1) … … 1756 1406 RETURN 1757 1407 !- 1758 9998 WRITE(*,*) " GETIN_SKIPAFEW : Error while reading file " 1759 STOP 'getin_skipafew' 1760 !- 1761 7778 eof = 1 1408 9998 CONTINUE 1409 CALL ipslerr (3,'getin_skipafew','Error while reading file',' ',' ') 1410 !- 1411 7778 CONTINUE 1412 eof = 1 1762 1413 !---------------------------- 1763 1414 END SUBROUTINE getin_skipafew 1764 1415 !- 1765 !=== INTEGER database INTERFACE1766 !-1767 SUBROUTINE getdbwi &1768 & (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)1769 !---------------------------------------------------------------------1770 !- Write the INTEGER data into the data base1771 !---------------------------------------------------------------------1772 IMPLICIT NONE1773 !-1774 CHARACTER(LEN=*) :: target1775 INTEGER :: target_sig, status, fileorig, size_of_in1776 INTEGER,DIMENSION(:) :: tmp_ret_val1777 !---------------------------------------------------------------------1778 !-1779 ! First check if we have sufficiant space for the new key1780 !-1781 IF (nb_keys+1 > keymemsize) THEN1782 CALL getin_allockeys ()1783 ENDIF1784 !-1785 ! Fill out the items of the data base1786 !-1787 nb_keys = nb_keys+11788 keysig(nb_keys) = target_sig1789 keystr(nb_keys) = target(1:MIN(len_trim(target),30))1790 keystatus(nb_keys) = status1791 keytype(nb_keys) = 11792 keyfromfile(nb_keys) = fileorig1793 !-1794 ! Can we compress the data base entry ?1795 !-1796 IF ( (MINVAL(tmp_ret_val) == MAXVAL(tmp_ret_val)) &1797 & .AND.(size_of_in > compress_lim)) THEN1798 keymemstart(nb_keys) = intmempos+11799 keycompress(nb_keys) = size_of_in1800 keymemlen(nb_keys) = 11801 ELSE1802 keymemstart(nb_keys) = intmempos+11803 keycompress(nb_keys) = -11804 keymemlen(nb_keys) = size_of_in1805 ENDIF1806 !-1807 ! Before writing the actual size lets see if we have the space1808 !-1809 IF (keymemstart(nb_keys)+keymemlen(nb_keys) > intmemsize) THEN1810 CALL getin_allocmem (1,keymemlen(nb_keys))1811 ENDIF1812 !-1813 intmem(keymemstart(nb_keys): &1814 & keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &1815 & tmp_ret_val(1:keymemlen(nb_keys))1816 intmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-11817 !---------------------1818 END SUBROUTINE getdbwi1819 !-1820 !===1821 !-1822 SUBROUTINE getdbri (pos,size_of_in,target,tmp_ret_val)1823 !---------------------------------------------------------------------1824 !- Read the required variables in the database for INTEGERS1825 !---------------------------------------------------------------------1826 IMPLICIT NONE1827 !-1828 INTEGER :: pos, size_of_in1829 CHARACTER(LEN=*) :: target1830 INTEGER,DIMENSION(:) :: tmp_ret_val1831 !---------------------------------------------------------------------1832 IF (keytype(pos) /= 1) THEN1833 WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target1834 STOP 'getdbri'1835 ENDIF1836 !-1837 IF (keycompress(pos) > 0) THEN1838 IF ( keycompress(pos) /= size_of_in .OR. keymemlen(pos) /= 1 ) THEN1839 WRITE(*,*) &1840 & 'FATAL ERROR : Wrong compression length for keyword ',target1841 STOP 'getdbri'1842 ELSE1843 tmp_ret_val(1:size_of_in) = intmem(keymemstart(pos))1844 ENDIF1845 ELSE1846 IF (keymemlen(pos) /= size_of_in) THEN1847 WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target1848 STOP 'getdbri'1849 ELSE1850 tmp_ret_val(1:size_of_in) = &1851 & intmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)1852 ENDIF1853 ENDIF1854 !---------------------1855 END SUBROUTINE getdbri1856 !-1857 !=== REAL database INTERFACE1858 !-1859 SUBROUTINE getdbwr &1860 & (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)1861 !---------------------------------------------------------------------1862 !- Write the REAL data into the data base1863 !---------------------------------------------------------------------1864 IMPLICIT NONE1865 !-1866 CHARACTER(LEN=*) :: target1867 INTEGER :: target_sig, status, fileorig, size_of_in1868 REAL,DIMENSION(:) :: tmp_ret_val1869 !---------------------------------------------------------------------1870 !-1871 ! First check if we have sufficiant space for the new key1872 !-1873 IF (nb_keys+1 > keymemsize) THEN1874 CALL getin_allockeys ()1875 ENDIF1876 !-1877 ! Fill out the items of the data base1878 !-1879 nb_keys = nb_keys+11880 keysig(nb_keys) = target_sig1881 keystr(nb_keys) = target(1:MIN(len_trim(target),30))1882 keystatus(nb_keys) = status1883 keytype(nb_keys) = 21884 keyfromfile(nb_keys) = fileorig1885 !-1886 ! Can we compress the data base entry ?1887 !-1888 IF ( (MINVAL(tmp_ret_val) == MAXVAL(tmp_ret_val)) &1889 & .AND.(size_of_in > compress_lim)) THEN1890 keymemstart(nb_keys) = realmempos+11891 keycompress(nb_keys) = size_of_in1892 keymemlen(nb_keys) = 11893 ELSE1894 keymemstart(nb_keys) = realmempos+11895 keycompress(nb_keys) = -11896 keymemlen(nb_keys) = size_of_in1897 ENDIF1898 !-1899 ! Before writing the actual size lets see if we have the space1900 !-1901 IF (keymemstart(nb_keys)+keymemlen(nb_keys) > realmemsize) THEN1902 CALL getin_allocmem (2,keymemlen(nb_keys))1903 ENDIF1904 !-1905 realmem(keymemstart(nb_keys): &1906 & keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &1907 & tmp_ret_val(1:keymemlen(nb_keys))1908 realmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-11909 !---------------------1910 END SUBROUTINE getdbwr1911 !-1912 !===1913 !-1914 SUBROUTINE getdbrr (pos,size_of_in,target,tmp_ret_val)1915 !---------------------------------------------------------------------1916 !- Read the required variables in the database for REALS1917 !---------------------------------------------------------------------1918 IMPLICIT NONE1919 !-1920 INTEGER :: pos, size_of_in1921 CHARACTER(LEN=*) :: target1922 REAL,DIMENSION(:) :: tmp_ret_val1923 !---------------------------------------------------------------------1924 IF (keytype(pos) /= 2) THEN1925 WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target1926 STOP 'getdbrr'1927 ENDIF1928 !-1929 IF (keycompress(pos) > 0) THEN1930 IF ( (keycompress(pos) /= size_of_in) &1931 & .OR.(keymemlen(pos) /= 1) ) THEN1932 WRITE(*,*) &1933 & 'FATAL ERROR : Wrong compression length for keyword ',target1934 STOP 'getdbrr'1935 ELSE1936 tmp_ret_val(1:size_of_in) = realmem(keymemstart(pos))1937 ENDIF1938 ELSE1939 IF (keymemlen(pos) /= size_of_in) THEN1940 WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target1941 STOP 'getdbrr'1942 ELSE1943 tmp_ret_val(1:size_of_in) = &1944 & realmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)1945 ENDIF1946 ENDIF1947 !---------------------1948 END SUBROUTINE getdbrr1949 !-1950 !=== CHARACTER database INTERFACE1951 !-1952 SUBROUTINE getdbwc &1953 & (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)1954 !---------------------------------------------------------------------1955 !- Write the CHARACTER data into the data base1956 !---------------------------------------------------------------------1957 IMPLICIT NONE1958 !-1959 CHARACTER(LEN=*) :: target1960 INTEGER :: target_sig,status,fileorig,size_of_in1961 CHARACTER(LEN=*),DIMENSION(:) :: tmp_ret_val1962 !---------------------------------------------------------------------1963 !-1964 ! First check if we have sufficiant space for the new key1965 !-1966 IF (nb_keys+1 > keymemsize) THEN1967 CALL getin_allockeys ()1968 ENDIF1969 !-1970 ! Fill out the items of the data base1971 !-1972 nb_keys = nb_keys+11973 keysig(nb_keys) = target_sig1974 keystr(nb_keys) = target(1:MIN(len_trim(target),30))1975 keystatus(nb_keys) = status1976 keytype(nb_keys) = 31977 keyfromfile(nb_keys) = fileorig1978 keymemstart(nb_keys) = charmempos+11979 keymemlen(nb_keys) = size_of_in1980 !-1981 ! Before writing the actual size lets see if we have the space1982 !-1983 IF (keymemstart(nb_keys)+keymemlen(nb_keys) > realmemsize) THEN1984 CALL getin_allocmem (3,keymemlen(nb_keys))1985 ENDIF1986 !-1987 charmem(keymemstart(nb_keys): &1988 & keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &1989 & tmp_ret_val(1:keymemlen(nb_keys))1990 charmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-11991 !---------------------1992 END SUBROUTINE getdbwc1993 !-1994 !===1995 !-1996 SUBROUTINE getdbrc(pos,size_of_in,target,tmp_ret_val)1997 !---------------------------------------------------------------------1998 !- Read the required variables in the database for CHARACTER1999 !---------------------------------------------------------------------2000 IMPLICIT NONE2001 !-2002 INTEGER :: pos, size_of_in2003 CHARACTER(LEN=*) :: target2004 CHARACTER(LEN=*),DIMENSION(:) :: tmp_ret_val2005 !---------------------------------------------------------------------2006 IF (keytype(pos) /= 3) THEN2007 WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target2008 STOP 'getdbrc'2009 ENDIF2010 !-2011 IF (keymemlen(pos) /= size_of_in) THEN2012 WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target2013 STOP 'getdbrc'2014 ELSE2015 tmp_ret_val(1:size_of_in) = &2016 & charmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)2017 ENDIF2018 !---------------------2019 END SUBROUTINE getdbrc2020 !-2021 !=== LOGICAL database INTERFACE2022 !-2023 SUBROUTINE getdbwl &2024 & (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)2025 !---------------------------------------------------------------------2026 !- Write the LOGICAL data into the data base2027 !---------------------------------------------------------------------2028 IMPLICIT NONE2029 !-2030 CHARACTER(LEN=*) :: target2031 INTEGER :: target_sig, status, fileorig, size_of_in2032 LOGICAL,DIMENSION(:) :: tmp_ret_val2033 !---------------------------------------------------------------------2034 !-2035 ! First check if we have sufficiant space for the new key2036 !-2037 IF (nb_keys+1 > keymemsize) THEN2038 CALL getin_allockeys ()2039 ENDIF2040 !-2041 ! Fill out the items of the data base2042 !-2043 nb_keys = nb_keys+12044 keysig(nb_keys) = target_sig2045 keystr(nb_keys) = target(1:MIN(len_trim(target),30))2046 keystatus(nb_keys) = status2047 keytype(nb_keys) = 42048 keyfromfile(nb_keys) = fileorig2049 keymemstart(nb_keys) = logicmempos+12050 keymemlen(nb_keys) = size_of_in2051 !-2052 ! Before writing the actual size lets see if we have the space2053 !-2054 IF (keymemstart(nb_keys)+keymemlen(nb_keys) > logicmemsize) THEN2055 CALL getin_allocmem (4,keymemlen(nb_keys))2056 ENDIF2057 !-2058 logicmem(keymemstart(nb_keys): &2059 & keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &2060 & tmp_ret_val(1:keymemlen(nb_keys))2061 logicmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-12062 !---------------------2063 END SUBROUTINE getdbwl2064 !-2065 !===2066 !-2067 SUBROUTINE getdbrl(pos,size_of_in,target,tmp_ret_val)2068 !---------------------------------------------------------------------2069 !- Read the required variables in the database for LOGICALS2070 !---------------------------------------------------------------------2071 IMPLICIT NONE2072 !-2073 INTEGER :: pos, size_of_in2074 CHARACTER(LEN=*) :: target2075 LOGICAL,DIMENSION(:) :: tmp_ret_val2076 !---------------------------------------------------------------------2077 IF (keytype(pos) /= 4) THEN2078 WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target2079 STOP 'getdbrl'2080 ENDIF2081 !-2082 IF (keymemlen(pos) /= size_of_in) THEN2083 WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target2084 STOP 'getdbrl'2085 ELSE2086 tmp_ret_val(1:size_of_in) = &2087 & logicmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)2088 ENDIF2089 !---------------------2090 END SUBROUTINE getdbrl2091 !-2092 1416 !=== 2093 1417 !- … … 2096 1420 IMPLICIT NONE 2097 1421 !- 2098 INTEGER,ALLOCATABLE :: tmp_int(:)1422 TYPE(t_key),ALLOCATABLE,DIMENSION(:) :: tmp_key_tab 2099 1423 CHARACTER(LEN=100),ALLOCATABLE :: tmp_str(:) 2100 1424 !- 2101 1425 INTEGER :: ier 2102 !--------------------------------------------------------------------- 2103 !- 2104 ! Either nothing exists in these arrays and it is easy to do 2105 !- 1426 CHARACTER(LEN=20) :: c_tmp 1427 !--------------------------------------------------------------------- 2106 1428 IF (keymemsize == 0) THEN 2107 !- 2108 ALLOCATE(keysig(memslabs),stat=ier) 1429 !--- 1430 !-- Nothing exists in memory arrays and it is easy to do. 1431 !--- 1432 WRITE (UNIT=c_tmp,FMT=*) memslabs 1433 ALLOCATE(key_tab(memslabs),stat=ier) 2109 1434 IF (ier /= 0) THEN 2110 WRITE(*,*) & 2111 & 'getin_allockeys : Can not allocate keysig to size ', & 2112 & memslabs 2113 STOP 2114 ENDIF 2115 !- 2116 ALLOCATE(keystr(memslabs),stat=ier) 2117 IF (ier /= 0) THEN 2118 WRITE(*,*) & 2119 & 'getin_allockeys : Can not allocate keystr to size ', & 2120 & memslabs 2121 STOP 2122 ENDIF 2123 !- 2124 ALLOCATE(keystatus(memslabs),stat=ier) 2125 IF (ier /= 0) THEN 2126 WRITE(*,*) & 2127 & 'getin_allockeys : Can not allocate keystatus to size ', & 2128 & memslabs 2129 STOP 2130 ENDIF 2131 !- 2132 ALLOCATE(keytype(memslabs),stat=ier) 2133 IF (ier /= 0) THEN 2134 WRITE(*,*) & 2135 & 'getin_allockeys : Can not allocate keytype to size ', & 2136 & memslabs 2137 STOP 2138 ENDIF 2139 !- 2140 ALLOCATE(keycompress(memslabs),stat=ier) 2141 IF (ier /= 0) THEN 2142 WRITE(*,*) & 2143 & 'getin_allockeys : Can not allocate keycompress to size ', & 2144 & memslabs 2145 STOP 2146 ENDIF 2147 !- 2148 ALLOCATE(keyfromfile(memslabs),stat=ier) 2149 IF (ier /= 0) THEN 2150 WRITE(*,*) & 2151 & 'getin_allockeys : Can not allocate keyfromfile to size ', & 2152 & memslabs 2153 STOP 2154 ENDIF 2155 !- 2156 ALLOCATE(keymemstart(memslabs),stat=ier) 2157 IF (ier /= 0) THEN 2158 WRITE(*,*) & 2159 & 'getin_allockeys : Can not allocate keymemstart to size ', & 2160 & memslabs 2161 STOP 2162 ENDIF 2163 !- 2164 ALLOCATE(keymemlen(memslabs),stat=ier) 2165 IF (ier /= 0) THEN 2166 WRITE(*,*) & 2167 & 'getin_allockeys : Can not allocate keymemlen to size ', & 2168 & memslabs 2169 STOP 2170 ENDIF 2171 !- 1435 CALL ipslerr (3,'getin_allockeys', & 1436 & 'Can not allocate key_tab', & 1437 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1438 ENDIF 2172 1439 nb_keys = 0 2173 1440 keymemsize = memslabs 2174 key compress(:)= -12175 !- 1441 key_tab(:)%keycompress = -1 1442 !--- 2176 1443 ELSE 2177 !- 1444 !--- 2178 1445 !-- There is something already in the memory, 2179 1446 !-- we need to transfer and reallocate. 2180 !- 2181 ALLOCATE(tmp_str(keymemsize),stat=ier) 1447 !--- 1448 WRITE (UNIT=c_tmp,FMT=*) keymemsize 1449 ALLOCATE(tmp_key_tab(keymemsize),stat=ier) 2182 1450 IF (ier /= 0) THEN 2183 WRITE(*,*) & 2184 & 'getin_allockeys : Can not allocate tmp_str to size ', & 2185 & keymemsize 2186 STOP 2187 ENDIF 2188 !- 2189 ALLOCATE(tmp_int(keymemsize),stat=ier) 1451 CALL ipslerr (3,'getin_allockeys', & 1452 & 'Can not allocate tmp_key_tab', & 1453 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1454 ENDIF 1455 WRITE (UNIT=c_tmp,FMT=*) keymemsize+memslabs 1456 tmp_key_tab(1:keymemsize) = key_tab(1:keymemsize) 1457 DEALLOCATE(key_tab) 1458 ALLOCATE(key_tab(keymemsize+memslabs),stat=ier) 2190 1459 IF (ier /= 0) THEN 2191 WRITE(*,*) & 2192 & 'getin_allockeys : Can not allocate tmp_int to size ', & 2193 & keymemsize 2194 STOP 2195 ENDIF 2196 !- 2197 tmp_int(1:keymemsize) = keysig(1:keymemsize) 2198 DEALLOCATE(keysig) 2199 ALLOCATE(keysig(keymemsize+memslabs),stat=ier) 2200 IF (ier /= 0) THEN 2201 WRITE(*,*) & 2202 & 'getin_allockeys : Can not allocate keysig to size ', & 2203 & keymemsize+memslabs 2204 STOP 2205 ENDIF 2206 keysig(1:keymemsize) = tmp_int(1:keymemsize) 2207 !- 2208 tmp_str(1:keymemsize) = keystr(1:keymemsize) 2209 DEALLOCATE(keystr) 2210 ALLOCATE(keystr(keymemsize+memslabs),stat=ier) 2211 IF (ier /= 0) THEN 2212 WRITE(*,*) & 2213 & 'getin_allockeys : Can not allocate keystr to size ', & 2214 & keymemsize+memslabs 2215 STOP 2216 ENDIF 2217 keystr(1:keymemsize) = tmp_str(1:keymemsize) 2218 !- 2219 tmp_int(1:keymemsize) = keystatus(1:keymemsize) 2220 DEALLOCATE(keystatus) 2221 ALLOCATE(keystatus(keymemsize+memslabs),stat=ier) 2222 IF (ier /= 0) THEN 2223 WRITE(*,*) & 2224 & 'getin_allockeys : Can not allocate keystatus to size ', & 2225 & keymemsize+memslabs 2226 STOP 2227 ENDIF 2228 keystatus(1:keymemsize) = tmp_int(1:keymemsize) 2229 !- 2230 tmp_int(1:keymemsize) = keytype(1:keymemsize) 2231 DEALLOCATE(keytype) 2232 ALLOCATE(keytype(keymemsize+memslabs),stat=ier) 2233 IF (ier /= 0) THEN 2234 WRITE(*,*) & 2235 & 'getin_allockeys : Can not allocate keytype to size ', & 2236 & keymemsize+memslabs 2237 STOP 2238 ENDIF 2239 keytype(1:keymemsize) = tmp_int(1:keymemsize) 2240 !- 2241 tmp_int(1:keymemsize) = keycompress(1:keymemsize) 2242 DEALLOCATE(keycompress) 2243 ALLOCATE(keycompress(keymemsize+memslabs),stat=ier) 2244 IF (ier /= 0) THEN 2245 WRITE(*,*) & 2246 & 'getin_allockeys : Can not allocate keycompress to size ', & 2247 & keymemsize+memslabs 2248 STOP 2249 ENDIF 2250 keycompress(:) = -1 2251 keycompress(1:keymemsize) = tmp_int(1:keymemsize) 2252 !- 2253 tmp_int(1:keymemsize) = keyfromfile(1:keymemsize) 2254 DEALLOCATE(keyfromfile) 2255 ALLOCATE(keyfromfile(keymemsize+memslabs),stat=ier) 2256 IF (ier /= 0) THEN 2257 WRITE(*,*) & 2258 & 'getin_allockeys : Can not allocate keyfromfile to size ', & 2259 & keymemsize+memslabs 2260 STOP 2261 ENDIF 2262 keyfromfile(1:keymemsize) = tmp_int(1:keymemsize) 2263 !- 2264 tmp_int(1:keymemsize) = keymemstart(1:keymemsize) 2265 DEALLOCATE(keymemstart) 2266 ALLOCATE(keymemstart(keymemsize+memslabs),stat=ier) 2267 IF (ier /= 0) THEN 2268 WRITE(*,*) & 2269 & 'getin_allockeys : Can not allocate keymemstart to size ', & 2270 & keymemsize+memslabs 2271 STOP 2272 ENDIF 2273 keymemstart(1:keymemsize) = tmp_int(1:keymemsize) 2274 !- 2275 tmp_int(1:keymemsize) = keymemlen(1:keymemsize) 2276 DEALLOCATE(keymemlen) 2277 ALLOCATE(keymemlen(keymemsize+memslabs),stat=ier) 2278 IF (ier /= 0) THEN 2279 WRITE(*,*) & 2280 & 'getin_allockeys : Can not allocate keymemlen to size ', & 2281 & keymemsize+memslabs 2282 STOP 2283 ENDIF 2284 keymemlen(1:keymemsize) = tmp_int(1:keymemsize) 2285 !- 1460 CALL ipslerr (3,'getin_allockeys', & 1461 & 'Can not allocate key_tab', & 1462 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1463 ENDIF 1464 key_tab(:)%keycompress = -1 1465 key_tab(1:keymemsize) = tmp_key_tab(1:keymemsize) 1466 DEALLOCATE(tmp_key_tab) 2286 1467 keymemsize = keymemsize+memslabs 2287 !-2288 DEALLOCATE(tmp_int)2289 DEALLOCATE(tmp_str)2290 1468 ENDIF 2291 1469 !----------------------------- … … 2297 1475 !--------------------------------------------------------------------- 2298 1476 !- Allocate the memory of the data base for all 4 types of memory 2299 !- 2300 !- 1 = INTEGER 2301 !- 2 = REAL 2302 !- 3 = CHAR 2303 !- 4 = LOGICAL 2304 !--------------------------------------------------------------------- 2305 IMPLICIT NONE 2306 !- 2307 INTEGER :: type, len_wanted 1477 !- INTEGER / REAL / CHARACTER / LOGICAL 1478 !--------------------------------------------------------------------- 1479 IMPLICIT NONE 1480 !- 1481 INTEGER :: type,len_wanted 2308 1482 !- 2309 1483 INTEGER,ALLOCATABLE :: tmp_int(:) 1484 REAL,ALLOCATABLE :: tmp_real(:) 2310 1485 CHARACTER(LEN=100),ALLOCATABLE :: tmp_char(:) 2311 REAL,ALLOCATABLE :: tmp_real(:)2312 1486 LOGICAL,ALLOCATABLE :: tmp_logic(:) 2313 1487 INTEGER :: ier 1488 CHARACTER(LEN=20) :: c_tmp 2314 1489 !--------------------------------------------------------------------- 2315 1490 SELECT CASE (type) 2316 CASE( 1)2317 IF (i ntmemsize == 0) THEN2318 ALLOCATE(i ntmem(memslabs),stat=ier)1491 CASE(k_i) 1492 IF (i_memsize == 0) THEN 1493 ALLOCATE(i_mem(memslabs),stat=ier) 2319 1494 IF (ier /= 0) THEN 2320 WRITE (*,*) &2321 & 'getin_allocmem : Unable to allocate db-memory intmem to', &2322 & memslabs2323 STOP2324 ENDIF 2325 i ntmemsize=memslabs1495 WRITE (UNIT=c_tmp,FMT=*) memslabs 1496 CALL ipslerr (3,'getin_allocmem', & 1497 & 'Unable to allocate db-memory', & 1498 & 'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1499 ENDIF 1500 i_memsize=memslabs 2326 1501 ELSE 2327 ALLOCATE(tmp_int(i ntmemsize),stat=ier)1502 ALLOCATE(tmp_int(i_memsize),stat=ier) 2328 1503 IF (ier /= 0) THEN 2329 WRITE (*,*) &2330 & 'getin_allocmem : Unable to allocate tmp_int to', &2331 & intmemsize2332 STOP2333 ENDIF 2334 tmp_int(1:i ntmemsize) = intmem(1:intmemsize)2335 DEALLOCATE(i ntmem)2336 ALLOCATE(i ntmem(intmemsize+MAX(memslabs,len_wanted)),stat=ier)1504 WRITE (UNIT=c_tmp,FMT=*) i_memsize 1505 CALL ipslerr (3,'getin_allocmem', & 1506 & 'Unable to allocate tmp_int', & 1507 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1508 ENDIF 1509 tmp_int(1:i_memsize) = i_mem(1:i_memsize) 1510 DEALLOCATE(i_mem) 1511 ALLOCATE(i_mem(i_memsize+MAX(memslabs,len_wanted)),stat=ier) 2337 1512 IF (ier /= 0) THEN 2338 WRITE (*,*) &2339 & 'getin_allocmem : Unable to re-allocate db-memory intmem to', &2340 & intmemsize+MAX(memslabs,len_wanted)2341 STOP2342 ENDIF 2343 i ntmem(1:intmemsize) = tmp_int(1:intmemsize)2344 i ntmemsize = intmemsize+MAX(memslabs,len_wanted)1513 WRITE (UNIT=c_tmp,FMT=*) i_memsize+MAX(memslabs,len_wanted) 1514 CALL ipslerr (3,'getin_allocmem', & 1515 & 'Unable to re-allocate db-memory', & 1516 & 'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1517 ENDIF 1518 i_mem(1:i_memsize) = tmp_int(1:i_memsize) 1519 i_memsize = i_memsize+MAX(memslabs,len_wanted) 2345 1520 DEALLOCATE(tmp_int) 2346 1521 ENDIF 2347 CASE( 2)2348 IF (r ealmemsize == 0) THEN2349 ALLOCATE(r ealmem(memslabs),stat=ier)1522 CASE(k_r) 1523 IF (r_memsize == 0) THEN 1524 ALLOCATE(r_mem(memslabs),stat=ier) 2350 1525 IF (ier /= 0) THEN 2351 WRITE (*,*) &2352 & 'getin_allocmem : Unable to allocate db-memory realmem to', &2353 & memslabs2354 STOP2355 ENDIF 2356 r ealmemsize = memslabs1526 WRITE (UNIT=c_tmp,FMT=*) memslabs 1527 CALL ipslerr (3,'getin_allocmem', & 1528 & 'Unable to allocate db-memory', & 1529 & 'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1530 ENDIF 1531 r_memsize = memslabs 2357 1532 ELSE 2358 ALLOCATE(tmp_real(r ealmemsize),stat=ier)1533 ALLOCATE(tmp_real(r_memsize),stat=ier) 2359 1534 IF (ier /= 0) THEN 2360 WRITE (*,*) &2361 & 'getin_allocmem : Unable to allocate tmp_real to', &2362 & realmemsize2363 STOP2364 ENDIF 2365 tmp_real(1:r ealmemsize) = realmem(1:realmemsize)2366 DEALLOCATE(r ealmem)2367 ALLOCATE(r ealmem(realmemsize+MAX(memslabs,len_wanted)),stat=ier)1535 WRITE (UNIT=c_tmp,FMT=*) r_memsize 1536 CALL ipslerr (3,'getin_allocmem', & 1537 & 'Unable to allocate tmp_real', & 1538 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1539 ENDIF 1540 tmp_real(1:r_memsize) = r_mem(1:r_memsize) 1541 DEALLOCATE(r_mem) 1542 ALLOCATE(r_mem(r_memsize+MAX(memslabs,len_wanted)),stat=ier) 2368 1543 IF (ier /= 0) THEN 2369 WRITE (*,*) &2370 & 'getin_allocmem : Unable to re-allocate db-memory realmem to', &2371 & realmemsize+MAX(memslabs,len_wanted)2372 STOP2373 ENDIF 2374 r ealmem(1:realmemsize) = tmp_real(1:realmemsize)2375 r ealmemsize = realmemsize+MAX(memslabs,len_wanted)1544 WRITE (UNIT=c_tmp,FMT=*) r_memsize+MAX(memslabs,len_wanted) 1545 CALL ipslerr (3,'getin_allocmem', & 1546 & 'Unable to re-allocate db-memory', & 1547 & 'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1548 ENDIF 1549 r_mem(1:r_memsize) = tmp_real(1:r_memsize) 1550 r_memsize = r_memsize+MAX(memslabs,len_wanted) 2376 1551 DEALLOCATE(tmp_real) 2377 1552 ENDIF 2378 CASE( 3)2379 IF (c harmemsize == 0) THEN2380 ALLOCATE(c harmem(memslabs),stat=ier)1553 CASE(k_c) 1554 IF (c_memsize == 0) THEN 1555 ALLOCATE(c_mem(memslabs),stat=ier) 2381 1556 IF (ier /= 0) THEN 2382 WRITE (*,*) &2383 & 'getin_allocmem : Unable to allocate db-memory charmem to', &2384 & memslabs2385 STOP2386 ENDIF 2387 c harmemsize = memslabs1557 WRITE (UNIT=c_tmp,FMT=*) memslabs 1558 CALL ipslerr (3,'getin_allocmem', & 1559 & 'Unable to allocate db-memory', & 1560 & 'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1561 ENDIF 1562 c_memsize = memslabs 2388 1563 ELSE 2389 ALLOCATE(tmp_char(c harmemsize),stat=ier)1564 ALLOCATE(tmp_char(c_memsize),stat=ier) 2390 1565 IF (ier /= 0) THEN 2391 WRITE (*,*) &2392 & 'getin_allocmem : Unable to allocate tmp_char to', &2393 & charmemsize2394 STOP2395 ENDIF 2396 tmp_char(1:c harmemsize) = charmem(1:charmemsize)2397 DEALLOCATE(c harmem)2398 ALLOCATE(c harmem(charmemsize+MAX(memslabs,len_wanted)),stat=ier)1566 WRITE (UNIT=c_tmp,FMT=*) c_memsize 1567 CALL ipslerr (3,'getin_allocmem', & 1568 & 'Unable to allocate tmp_char', & 1569 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1570 ENDIF 1571 tmp_char(1:c_memsize) = c_mem(1:c_memsize) 1572 DEALLOCATE(c_mem) 1573 ALLOCATE(c_mem(c_memsize+MAX(memslabs,len_wanted)),stat=ier) 2399 1574 IF (ier /= 0) THEN 2400 WRITE (*,*) &2401 & 'getin_allocmem : Unable to re-allocate db-memory charmem to', &2402 & charmemsize+MAX(memslabs,len_wanted)2403 STOP2404 ENDIF 2405 c harmem(1:charmemsize) = tmp_char(1:charmemsize)2406 c harmemsize = charmemsize+MAX(memslabs,len_wanted)1575 WRITE (UNIT=c_tmp,FMT=*) c_memsize+MAX(memslabs,len_wanted) 1576 CALL ipslerr (3,'getin_allocmem', & 1577 & 'Unable to re-allocate db-memory', & 1578 & 'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1579 ENDIF 1580 c_mem(1:c_memsize) = tmp_char(1:c_memsize) 1581 c_memsize = c_memsize+MAX(memslabs,len_wanted) 2407 1582 DEALLOCATE(tmp_char) 2408 1583 ENDIF 2409 CASE( 4)2410 IF (l ogicmemsize == 0) THEN2411 ALLOCATE(l ogicmem(memslabs),stat=ier)1584 CASE(k_l) 1585 IF (l_memsize == 0) THEN 1586 ALLOCATE(l_mem(memslabs),stat=ier) 2412 1587 IF (ier /= 0) THEN 2413 WRITE (*,*) &2414 & 'getin_allocmem : Unable to allocate db-memory logicmem to', &2415 & memslabs2416 STOP2417 ENDIF 2418 l ogicmemsize = memslabs1588 WRITE (UNIT=c_tmp,FMT=*) memslabs 1589 CALL ipslerr (3,'getin_allocmem', & 1590 & 'Unable to allocate db-memory', & 1591 & 'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1592 ENDIF 1593 l_memsize = memslabs 2419 1594 ELSE 2420 ALLOCATE(tmp_logic(l ogicmemsize),stat=ier)1595 ALLOCATE(tmp_logic(l_memsize),stat=ier) 2421 1596 IF (ier /= 0) THEN 2422 WRITE (*,*) &2423 & 'getin_allocmem : Unable to allocate tmp_logic to', &2424 & logicmemsize2425 STOP2426 ENDIF 2427 tmp_logic(1:l ogicmemsize) = logicmem(1:logicmemsize)2428 DEALLOCATE(l ogicmem)2429 ALLOCATE(l ogicmem(logicmemsize+MAX(memslabs,len_wanted)),stat=ier)1597 WRITE (UNIT=c_tmp,FMT=*) l_memsize 1598 CALL ipslerr (3,'getin_allocmem', & 1599 & 'Unable to allocate tmp_logic', & 1600 & 'to size '//TRIM(ADJUSTL(c_tmp)),' ') 1601 ENDIF 1602 tmp_logic(1:l_memsize) = l_mem(1:l_memsize) 1603 DEALLOCATE(l_mem) 1604 ALLOCATE(l_mem(l_memsize+MAX(memslabs,len_wanted)),stat=ier) 2430 1605 IF (ier /= 0) THEN 2431 WRITE (*,*) &2432 & 'getin_allocmem : Unable to re-allocate db-memory logicmem to', &2433 & logicmemsize+MAX(memslabs,len_wanted)2434 STOP2435 ENDIF 2436 l ogicmem(1:logicmemsize) = tmp_logic(1:logicmemsize)2437 l ogicmemsize = logicmemsize+MAX(memslabs,len_wanted)1606 WRITE (UNIT=c_tmp,FMT=*) l_memsize+MAX(memslabs,len_wanted) 1607 CALL ipslerr (3,'getin_allocmem', & 1608 & 'Unable to re-allocate db-memory', & 1609 & 'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ') 1610 ENDIF 1611 l_mem(1:l_memsize) = tmp_logic(1:l_memsize) 1612 l_memsize = l_memsize+MAX(memslabs,len_wanted) 2438 1613 DEALLOCATE(tmp_logic) 2439 1614 ENDIF 2440 1615 CASE DEFAULT 2441 WRITE(*,*) 'getin_allocmem : Unknown type : ',type 2442 STOP 1616 CALL ipslerr (3,'getin_allocmem','Unknown type of data',' ',' ') 2443 1617 END SELECT 2444 1618 !---------------------------- … … 2447 1621 !=== 2448 1622 !- 1623 SUBROUTINE getin_alloctxt () 1624 !--------------------------------------------------------------------- 1625 IMPLICIT NONE 1626 !- 1627 CHARACTER(LEN=100),ALLOCATABLE :: tmp_fic(:) 1628 CHARACTER(LEN=l_n),ALLOCATABLE :: tmp_tgl(:) 1629 INTEGER,ALLOCATABLE :: tmp_int(:) 1630 !- 1631 INTEGER :: ier 1632 CHARACTER(LEN=20) :: c_tmp1,c_tmp2 1633 !--------------------------------------------------------------------- 1634 IF (i_txtsize == 0) THEN 1635 !--- 1636 !-- Nothing exists in memory arrays and it is easy to do. 1637 !--- 1638 WRITE (UNIT=c_tmp1,FMT=*) i_txtslab 1639 ALLOCATE(fichier(i_txtslab),stat=ier) 1640 IF (ier /= 0) THEN 1641 CALL ipslerr (3,'getin_alloctxt', & 1642 & 'Can not allocate fichier', & 1643 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1644 ENDIF 1645 !--- 1646 ALLOCATE(targetlist(i_txtslab),stat=ier) 1647 IF (ier /= 0) THEN 1648 CALL ipslerr (3,'getin_alloctxt', & 1649 & 'Can not allocate targetlist', & 1650 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1651 ENDIF 1652 !--- 1653 ALLOCATE(fromfile(i_txtslab),stat=ier) 1654 IF (ier /= 0) THEN 1655 CALL ipslerr (3,'getin_alloctxt', & 1656 & 'Can not allocate fromfile', & 1657 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1658 ENDIF 1659 !--- 1660 ALLOCATE(compline(i_txtslab),stat=ier) 1661 IF (ier /= 0) THEN 1662 CALL ipslerr (3,'getin_alloctxt', & 1663 & 'Can not allocate compline', & 1664 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1665 ENDIF 1666 !--- 1667 nb_lines = 0 1668 i_txtsize = i_txtslab 1669 ELSE 1670 !--- 1671 !-- There is something already in the memory, 1672 !-- we need to transfer and reallocate. 1673 !--- 1674 WRITE (UNIT=c_tmp1,FMT=*) i_txtsize 1675 WRITE (UNIT=c_tmp2,FMT=*) i_txtsize+i_txtslab 1676 ALLOCATE(tmp_fic(i_txtsize),stat=ier) 1677 IF (ier /= 0) THEN 1678 CALL ipslerr (3,'getin_alloctxt', & 1679 & 'Can not allocate tmp_fic', & 1680 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1681 ENDIF 1682 tmp_fic(1:i_txtsize) = fichier(1:i_txtsize) 1683 DEALLOCATE(fichier) 1684 ALLOCATE(fichier(i_txtsize+i_txtslab),stat=ier) 1685 IF (ier /= 0) THEN 1686 CALL ipslerr (3,'getin_alloctxt', & 1687 & 'Can not allocate fichier', & 1688 & 'to size '//TRIM(ADJUSTL(c_tmp2)),' ') 1689 ENDIF 1690 fichier(1:i_txtsize) = tmp_fic(1:i_txtsize) 1691 DEALLOCATE(tmp_fic) 1692 !--- 1693 ALLOCATE(tmp_tgl(i_txtsize),stat=ier) 1694 IF (ier /= 0) THEN 1695 CALL ipslerr (3,'getin_alloctxt', & 1696 & 'Can not allocate tmp_tgl', & 1697 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1698 ENDIF 1699 tmp_tgl(1:i_txtsize) = targetlist(1:i_txtsize) 1700 DEALLOCATE(targetlist) 1701 ALLOCATE(targetlist(i_txtsize+i_txtslab),stat=ier) 1702 IF (ier /= 0) THEN 1703 CALL ipslerr (3,'getin_alloctxt', & 1704 & 'Can not allocate targetlist', & 1705 & 'to size '//TRIM(ADJUSTL(c_tmp2)),' ') 1706 ENDIF 1707 targetlist(1:i_txtsize) = tmp_tgl(1:i_txtsize) 1708 DEALLOCATE(tmp_tgl) 1709 !--- 1710 ALLOCATE(tmp_int(i_txtsize),stat=ier) 1711 IF (ier /= 0) THEN 1712 CALL ipslerr (3,'getin_alloctxt', & 1713 & 'Can not allocate tmp_int', & 1714 & 'to size '//TRIM(ADJUSTL(c_tmp1)),' ') 1715 ENDIF 1716 tmp_int(1:i_txtsize) = fromfile(1:i_txtsize) 1717 DEALLOCATE(fromfile) 1718 ALLOCATE(fromfile(i_txtsize+i_txtslab),stat=ier) 1719 IF (ier /= 0) THEN 1720 CALL ipslerr (3,'getin_alloctxt', & 1721 & 'Can not allocate fromfile', & 1722 & 'to size '//TRIM(ADJUSTL(c_tmp2)),' ') 1723 ENDIF 1724 fromfile(1:i_txtsize) = tmp_int(1:i_txtsize) 1725 !--- 1726 tmp_int(1:i_txtsize) = compline(1:i_txtsize) 1727 DEALLOCATE(compline) 1728 ALLOCATE(compline(i_txtsize+i_txtslab),stat=ier) 1729 IF (ier /= 0) THEN 1730 CALL ipslerr (3,'getin_alloctxt', & 1731 & 'Can not allocate compline', & 1732 & 'to size '//TRIM(ADJUSTL(c_tmp2)),' ') 1733 ENDIF 1734 compline(1:i_txtsize) = tmp_int(1:i_txtsize) 1735 DEALLOCATE(tmp_int) 1736 !--- 1737 i_txtsize = i_txtsize+i_txtslab 1738 ENDIF 1739 !---------------------------- 1740 END SUBROUTINE getin_alloctxt 1741 !- 1742 !=== 1743 !- 2449 1744 SUBROUTINE getin_dump (fileprefix) 2450 1745 !--------------------------------------------------------------------- 2451 !- This subroutine will dump the content of the database into file2452 !- which has the same format as the run.def. The idea is that the user2453 !- can see which parameters were used and re-use the file for another2454 !- run.2455 !-2456 !- The argument file allows the user to change the name of the file2457 !- in which the data will be archived2458 !---------------------------------------------------------------------2459 1746 IMPLICIT NONE 2460 1747 !- 2461 1748 CHARACTER(*),OPTIONAL :: fileprefix 2462 1749 !- 2463 CHARACTER(LEN=80) :: usedfileprefix = "used"1750 CHARACTER(LEN=80) :: usedfileprefix 2464 1751 INTEGER :: ikey,if,iff,iv 2465 CHARACTER(LEN= 3) :: tmp32466 CHARACTER(LEN=100) :: tmp_str, 1752 CHARACTER(LEN=20) :: c_tmp 1753 CHARACTER(LEN=100) :: tmp_str,used_filename 2467 1754 LOGICAL :: check = .FALSE. 2468 1755 !--------------------------------------------------------------------- 2469 1756 IF (PRESENT(fileprefix)) THEN 2470 usedfileprefix = fileprefix(1:MIN(len_trim(fileprefix),80)) 1757 usedfileprefix = fileprefix(1:MIN(LEN_TRIM(fileprefix),80)) 1758 ELSE 1759 usedfileprefix = "used" 2471 1760 ENDIF 2472 1761 !- … … 2479 1768 WRITE(*,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys 2480 1769 ENDIF 2481 OPEN (unit=76,file=used_filename)2482 !- 1770 OPEN (UNIT=22,FILE=used_filename) 1771 !--- 2483 1772 !-- If this is the first file we need to add the list 2484 1773 !-- of file which belong to it 2485 !- 2486 IF ( (if == 1) .AND. (nbfiles > 1) ) THEN 2487 WRITE(76,*) '# ' 2488 WRITE(76,*) '# This file is linked to the following files :' 2489 WRITE(76,*) '# ' 1774 IF ( (if == 1).AND.(nbfiles > 1) ) THEN 1775 WRITE(22,*) '# ' 1776 WRITE(22,*) '# This file is linked to the following files :' 1777 WRITE(22,*) '# ' 2490 1778 DO iff=2,nbfiles 2491 WRITE( 76,*) 'INCLUDEDEF = ',TRIM(filelist(iff))1779 WRITE(22,*) 'INCLUDEDEF = ',TRIM(filelist(iff)) 2492 1780 ENDDO 2493 WRITE( 76,*) '# '1781 WRITE(22,*) '# ' 2494 1782 ENDIF 2495 1783 !--- 2496 1784 DO ikey=1,nb_keys 2497 !- 2498 !---- Is this key form this file ? 2499 !- 2500 IF (keyfromfile(ikey) == if) THEN 2501 !- 2502 !---- Write some comments 2503 !- 2504 WRITE(76,*) '#' 2505 SELECT CASE (keystatus(ikey)) 1785 !----- 1786 !---- Is this key from this file ? 1787 IF (key_tab(ikey)%keyfromfile == if) THEN 1788 !------- 1789 !------ Write some comments 1790 WRITE(22,*) '#' 1791 SELECT CASE (key_tab(ikey)%keystatus) 2506 1792 CASE(1) 2507 WRITE( 76,*) '# Values of ', &2508 & TRIM(key str(ikey)),' comes from the run.def.'1793 WRITE(22,*) '# Values of ', & 1794 & TRIM(key_tab(ikey)%keystr),' comes from the run.def.' 2509 1795 CASE(2) 2510 WRITE( 76,*) '# Values of ', &2511 & TRIM(key str(ikey)),' are all defaults.'1796 WRITE(22,*) '# Values of ', & 1797 & TRIM(key_tab(ikey)%keystr),' are all defaults.' 2512 1798 CASE(3) 2513 WRITE(76,*) '# Values of ', & 2514 & TRIM(keystr(ikey)),' are a mix of run.def and defaults.' 1799 WRITE(22,*) '# Values of ', & 1800 & TRIM(key_tab(ikey)%keystr), & 1801 & ' are a mix of run.def and defaults.' 2515 1802 CASE DEFAULT 2516 WRITE( 76,*) '# Dont know from where the value of ', &2517 & TRIM(key str(ikey)),' comes.'1803 WRITE(22,*) '# Dont know from where the value of ', & 1804 & TRIM(key_tab(ikey)%keystr),' comes.' 2518 1805 END SELECT 2519 WRITE(76,*) '#' 2520 !- 2521 !---- Write the values 2522 !- 2523 SELECT CASE (keytype(ikey)) 2524 !- 2525 CASE(1) 2526 IF (keymemlen(ikey) == 1) THEN 2527 IF (keycompress(ikey) < 0) THEN 2528 WRITE(76,*) & 2529 & TRIM(keystr(ikey)),' = ',intmem(keymemstart(ikey)) 1806 WRITE(22,*) '#' 1807 !------- 1808 !------ Write the values 1809 SELECT CASE (key_tab(ikey)%keytype) 1810 CASE(k_i) 1811 IF (key_tab(ikey)%keymemlen == 1) THEN 1812 IF (key_tab(ikey)%keycompress < 0) THEN 1813 WRITE(22,*) & 1814 & TRIM(key_tab(ikey)%keystr), & 1815 & ' = ',i_mem(key_tab(ikey)%keymemstart) 2530 1816 ELSE 2531 WRITE(76,*) & 2532 & TRIM(keystr(ikey)),' = ',keycompress(ikey), & 2533 & ' * ',intmem(keymemstart(ikey)) 1817 WRITE(22,*) & 1818 & TRIM(key_tab(ikey)%keystr), & 1819 & ' = ',key_tab(ikey)%keycompress, & 1820 & ' * ',i_mem(key_tab(ikey)%keymemstart) 2534 1821 ENDIF 2535 1822 ELSE 2536 DO iv=0,keymemlen(ikey)-1 2537 WRITE(tmp3,'(I3.3)') iv+1 2538 WRITE(76,*) & 2539 & TRIM(keystr(ikey)),'__',tmp3, & 2540 & ' = ',intmem(keymemstart(ikey)+iv) 1823 DO iv=0,key_tab(ikey)%keymemlen-1 1824 WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1 1825 WRITE(22,*) & 1826 & TRIM(key_tab(ikey)%keystr), & 1827 & '__',TRIM(ADJUSTL(c_tmp)), & 1828 & ' = ',i_mem(key_tab(ikey)%keymemstart+iv) 2541 1829 ENDDO 2542 1830 ENDIF 2543 !- 2544 CASE(2)2545 IF (keymemlen(ikey) == 1) THEN2546 IF (keycompress(ikey) < 0) THEN2547 WRITE(76,*)&2548 & TRIM(keystr(ikey)),' = ',realmem(keymemstart(ikey))1831 CASE(k_r) 1832 IF (key_tab(ikey)%keymemlen == 1) THEN 1833 IF (key_tab(ikey)%keycompress < 0) THEN 1834 WRITE(22,*) & 1835 & TRIM(key_tab(ikey)%keystr), & 1836 & ' = ',r_mem(key_tab(ikey)%keymemstart) 2549 1837 ELSE 2550 WRITE(76,*) & 2551 & TRIM(keystr(ikey)),' = ',keycompress(ikey),& 2552 & ' * ',realmem(keymemstart(ikey)) 1838 WRITE(22,*) & 1839 & TRIM(key_tab(ikey)%keystr), & 1840 & ' = ',key_tab(ikey)%keycompress, & 1841 & ' * ',r_mem(key_tab(ikey)%keymemstart) 2553 1842 ENDIF 2554 1843 ELSE 2555 DO iv=0,key memlen(ikey)-12556 WRITE( tmp3,'(I3.3)') iv+12557 WRITE( 76,*) &2558 & TRIM(key str(ikey)),'__',tmp3, &2559 & ' = ',r ealmem(keymemstart(ikey)+iv)1844 DO iv=0,key_tab(ikey)%keymemlen-1 1845 WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1 1846 WRITE(22,*) & 1847 & TRIM(key_tab(ikey)%keystr),'__',TRIM(ADJUSTL(c_tmp)), & 1848 & ' = ',r_mem(key_tab(ikey)%keymemstart+iv) 2560 1849 ENDDO 2561 1850 ENDIF 2562 CASE(3) 2563 IF (keymemlen(ikey) == 1) THEN 2564 tmp_str = charmem(keymemstart(ikey)) 2565 WRITE(76,*) TRIM(keystr(ikey)),' = ',TRIM(tmp_str) 1851 CASE(k_c) 1852 IF (key_tab(ikey)%keymemlen == 1) THEN 1853 tmp_str = c_mem(key_tab(ikey)%keymemstart) 1854 WRITE(22,*) TRIM(key_tab(ikey)%keystr), & 1855 & ' = ',TRIM(tmp_str) 2566 1856 ELSE 2567 DO iv=0,keymemlen(ikey)-1 2568 WRITE(tmp3,'(I3.3)') iv+1 2569 tmp_str = charmem(keymemstart(ikey)+iv) 2570 WRITE(76,*) & 2571 & TRIM(keystr(ikey)),'__',tmp3,' = ',TRIM(tmp_str) 1857 DO iv=0,key_tab(ikey)%keymemlen-1 1858 WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1 1859 tmp_str = c_mem(key_tab(ikey)%keymemstart+iv) 1860 WRITE(22,*) & 1861 & TRIM(key_tab(ikey)%keystr), & 1862 & '__',TRIM(ADJUSTL(c_tmp)), & 1863 & ' = ',TRIM(tmp_str) 2572 1864 ENDDO 2573 1865 ENDIF 2574 CASE( 4)2575 IF (key memlen(ikey)== 1) THEN2576 IF (l ogicmem(keymemstart(ikey))) THEN2577 WRITE( 76,*) TRIM(keystr(ikey)),' = TRUE '1866 CASE(k_l) 1867 IF (key_tab(ikey)%keymemlen == 1) THEN 1868 IF (l_mem(key_tab(ikey)%keymemstart)) THEN 1869 WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = TRUE ' 2578 1870 ELSE 2579 WRITE( 76,*) TRIM(keystr(ikey)),' = FALSE '1871 WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = FALSE ' 2580 1872 ENDIF 2581 1873 ELSE 2582 DO iv=0,keymemlen(ikey)-1 2583 WRITE(tmp3,'(I3.3)') iv+1 2584 IF (logicmem(keymemstart(ikey)+iv)) THEN 2585 WRITE(76,*) TRIM(keystr(ikey)),'__',tmp3,' = TRUE ' 1874 DO iv=0,key_tab(ikey)%keymemlen-1 1875 WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1 1876 IF (l_mem(key_tab(ikey)%keymemstart+iv)) THEN 1877 WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', & 1878 & TRIM(ADJUSTL(c_tmp)),' = TRUE ' 2586 1879 ELSE 2587 WRITE(76,*) TRIM(keystr(ikey)),'__',tmp3,' = FALSE ' 1880 WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', & 1881 & TRIM(ADJUSTL(c_tmp)),' = FALSE ' 2588 1882 ENDIF 2589 1883 ENDDO 2590 1884 ENDIF 2591 !-2592 1885 CASE DEFAULT 2593 WRITE(*,*) & 2594 & 'FATAL ERROR : Unknown type for variable ', & 2595 & TRIM(keystr(ikey)) 2596 STOP 'getin_dump' 1886 CALL ipslerr (3,'getin_dump', & 1887 & 'Unknown type for variable '//TRIM(key_tab(ikey)%keystr), & 1888 & ' ',' ') 2597 1889 END SELECT 2598 1890 ENDIF 2599 1891 ENDDO 2600 1892 !- 2601 CLOSE( unit=76)1893 CLOSE(UNIT=22) 2602 1894 !- 2603 1895 ENDDO 2604 1896 !------------------------ 2605 1897 END SUBROUTINE getin_dump 2606 !- 2607 !=== 2608 !- 1898 !=== 1899 SUBROUTINE get_qtyp (k_typ,c_vtyp,i_v,r_v,c_v,l_v) 1900 !--------------------------------------------------------------------- 1901 !- Returns the type of the argument (mutually exclusive) 1902 !--------------------------------------------------------------------- 1903 IMPLICIT NONE 1904 !- 1905 INTEGER,INTENT(OUT) :: k_typ 1906 CHARACTER(LEN=*),INTENT(OUT) :: c_vtyp 1907 INTEGER,DIMENSION(:),OPTIONAL :: i_v 1908 REAL,DIMENSION(:),OPTIONAL :: r_v 1909 LOGICAL,DIMENSION(:),OPTIONAL :: l_v 1910 CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_v 1911 !--------------------------------------------------------------------- 1912 k_typ = 0 1913 IF (COUNT((/PRESENT(i_v),PRESENT(r_v),PRESENT(c_v),PRESENT(l_v)/)) & 1914 & /= 1) THEN 1915 CALL ipslerr (3,'get_qtyp', & 1916 & 'Invalid number of optional arguments','(/= 1)',' ') 1917 ENDIF 1918 !- 1919 IF (PRESENT(i_v)) THEN 1920 k_typ = k_i 1921 c_vtyp = 'INTEGER' 1922 ELSEIF (PRESENT(r_v)) THEN 1923 k_typ = k_r 1924 c_vtyp = 'REAL' 1925 ELSEIF (PRESENT(c_v)) THEN 1926 k_typ = k_c 1927 c_vtyp = 'CHARACTER' 1928 ELSEIF (PRESENT(l_v)) THEN 1929 k_typ = k_l 1930 c_vtyp = 'LOGICAL' 1931 ENDIF 1932 !---------------------- 1933 END SUBROUTINE get_qtyp 1934 !=== 1935 SUBROUTINE get_findkey (i_tab,c_key,pos) 1936 !--------------------------------------------------------------------- 1937 !- This subroutine looks for a key in a table 1938 !--------------------------------------------------------------------- 1939 !- INPUT 1940 !- i_tab : 1 -> search in key_tab(1:nb_keys)%keystr 1941 !- 2 -> search in targetlist(1:nb_lines) 1942 !- c_key : Name of the key we are looking for 1943 !- OUTPUT 1944 !- pos : -1 if key not found, else value in the table 1945 !--------------------------------------------------------------------- 1946 IMPLICIT NONE 1947 !- 1948 INTEGER,INTENT(in) :: i_tab 1949 CHARACTER(LEN=*),INTENT(in) :: c_key 1950 INTEGER,INTENT(out) :: pos 1951 !- 1952 INTEGER :: ikey_max,ikey 1953 CHARACTER(LEN=l_n) :: c_q_key 1954 !--------------------------------------------------------------------- 1955 pos = -1 1956 IF (i_tab == 1) THEN 1957 ikey_max = nb_keys 1958 ELSEIF (i_tab == 2) THEN 1959 ikey_max = nb_lines 1960 ELSE 1961 ikey_max = 0 1962 ENDIF 1963 IF ( ikey_max > 0 ) THEN 1964 DO ikey=1,ikey_max 1965 IF (i_tab == 1) THEN 1966 c_q_key = key_tab(ikey)%keystr 1967 ELSE 1968 c_q_key = targetlist(ikey) 1969 ENDIF 1970 IF (TRIM(c_q_key) == TRIM(c_key)) THEN 1971 pos = ikey 1972 EXIT 1973 ENDIF 1974 ENDDO 1975 ENDIF 1976 !------------------------- 1977 END SUBROUTINE get_findkey 1978 !=== 1979 !------------------ 2609 1980 END MODULE ioipsl_getincom -
LMDZ4/branches/LMDZ4-dev/libf/bibio/ioipsl_stringop.F90
r1185 r1186 1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 ! Module and routines in this file are taken from IOIPSL 3 ! files stringop.f90 4 ! Module names has been changed to avoid problems 5 ! if compiling model with IOIPSL library 6 ! Ehouarn - March 2009 7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1 ! 2 ! $Id$ 3 ! 4 ! Module/Routines extracted from IOIPSL v2_1_8 8 5 ! 9 6 MODULE ioipsl_stringop 10 !--------------------------------------------------------------------- 11 !- 12 INTEGER, DIMENSION(30) :: & 13 & prime=(/1,2,3,5,7,11,13,17,19,23,29,31,37,41,43, & 14 & 47,53,59,61,67,71,73,79,83,89,97,101,103,107,109/) 7 !- 8 !$Id: stringop.f90 386 2008-09-04 08:38:48Z bellier $ 9 !- 10 ! This software is governed by the CeCILL license 11 ! See IOIPSL/IOIPSL_License_CeCILL.txt 12 !--------------------------------------------------------------------- 13 !- 14 INTEGER,DIMENSION(30) :: & 15 & prime=(/1,2,3,5,7,11,13,17,19,23,29,31,37,41,43, & 16 & 47,53,59,61,67,71,73,79,83,89,97,101,103,107,109/) 15 17 !- 16 18 !--------------------------------------------------------------------- 17 19 CONTAINS 18 20 != 19 20 !--------------------------------------------------------------------- 21 !- 22 !--------------------------------------------------------------------- 23 24 !- 25 26 !--------------------------------------------------------------------- 27 28 29 30 31 32 33 34 35 36 37 38 !---------------------- ---39 40 != 41 21 SUBROUTINE cmpblank (str) 22 !--------------------------------------------------------------------- 23 !- Compact blanks 24 !--------------------------------------------------------------------- 25 CHARACTER(LEN=*),INTENT(inout) :: str 26 !- 27 INTEGER :: lcc,ipb 28 !--------------------------------------------------------------------- 29 lcc = LEN_TRIM(str) 30 ipb = 1 31 DO 32 IF (ipb >= lcc) EXIT 33 IF (str(ipb:ipb+1) == ' ') THEN 34 str(ipb+1:) = str(ipb+2:lcc) 35 lcc = lcc-1 36 ELSE 37 ipb = ipb+1 38 ENDIF 39 ENDDO 40 !---------------------- 41 END SUBROUTINE cmpblank 42 !=== 43 INTEGER FUNCTION cntpos (c_c,l_c,c_r,l_r) 42 44 !--------------------------------------------------------------------- 43 45 !- Finds number of occurences of c_r in c_c 44 46 !--------------------------------------------------------------------- 45 IMPLICIT NONE 46 !- 47 CHARACTER(LEN=*),INTENT(in) :: c_c 48 INTEGER,INTENT(IN) :: l_c 49 CHARACTER(LEN=*),INTENT(in) :: c_r 50 INTEGER,INTENT(IN) :: l_r 51 !- 52 INTEGER :: ipos,indx,ires 53 !--------------------------------------------------------------------- 54 cntpos = 0 55 ipos = 1 56 DO 57 indx = INDEX(c_c(ipos:l_c),c_r(1:l_r)) 58 IF (indx > 0) THEN 59 cntpos = cntpos+1 60 ipos = ipos+indx+l_r-1 61 ELSE 62 EXIT 63 ENDIF 64 ENDDO 47 IMPLICIT NONE 48 !- 49 CHARACTER(LEN=*),INTENT(in) :: c_c 50 INTEGER,INTENT(IN) :: l_c 51 CHARACTER(LEN=*),INTENT(in) :: c_r 52 INTEGER,INTENT(IN) :: l_r 53 !- 54 INTEGER :: ipos,indx 55 !--------------------------------------------------------------------- 56 cntpos = 0 57 ipos = 1 58 DO 59 indx = INDEX(c_c(ipos:l_c),c_r(1:l_r)) 60 IF (indx > 0) THEN 61 cntpos = cntpos+1 62 ipos = ipos+indx+l_r-1 63 ELSE 64 EXIT 65 ENDIF 66 ENDDO 67 !------------------ 68 END FUNCTION cntpos 69 !=== 70 INTEGER FUNCTION findpos (c_c,l_c,c_r,l_r) 71 !--------------------------------------------------------------------- 72 !- Finds position of c_r in c_c 73 !--------------------------------------------------------------------- 74 IMPLICIT NONE 75 !- 76 CHARACTER(LEN=*),INTENT(in) :: c_c 77 INTEGER,INTENT(IN) :: l_c 78 CHARACTER(LEN=*),INTENT(in) :: c_r 79 INTEGER,INTENT(IN) :: l_r 80 !--------------------------------------------------------------------- 81 findpos = INDEX(c_c(1:l_c),c_r(1:l_r)) 82 IF (findpos == 0) findpos=-1 83 !------------------- 84 END FUNCTION findpos 85 !=== 86 SUBROUTINE find_str (str_tab,str,pos) 87 !--------------------------------------------------------------------- 88 !- This subroutine looks for a string in a table 89 !--------------------------------------------------------------------- 90 !- INPUT 91 !- str_tab : Table of strings 92 !- str : Target we are looking for 93 !- OUTPUT 94 !- pos : -1 if str not found, else value in the table 95 !--------------------------------------------------------------------- 96 IMPLICIT NONE 97 !- 98 CHARACTER(LEN=*),DIMENSION(:),INTENT(in) :: str_tab 99 CHARACTER(LEN=*),INTENT(in) :: str 100 INTEGER,INTENT(out) :: pos 101 !- 102 INTEGER :: nb_str,i 103 !--------------------------------------------------------------------- 104 pos = -1 105 nb_str=SIZE(str_tab) 106 IF ( nb_str > 0 ) THEN 107 DO i=1,nb_str 108 IF ( TRIM(str_tab(i)) == TRIM(str) ) THEN 109 pos = i 110 EXIT 111 ENDIF 112 ENDDO 113 ENDIF 114 !---------------------- 115 END SUBROUTINE find_str 116 !=== 117 SUBROUTINE nocomma (str) 118 !--------------------------------------------------------------------- 119 !- Replace commas with blanks 120 !--------------------------------------------------------------------- 121 IMPLICIT NONE 122 !- 123 CHARACTER(LEN=*) :: str 124 !- 125 INTEGER :: i 126 !--------------------------------------------------------------------- 127 DO i=1,LEN_TRIM(str) 128 IF (str(i:i) == ',') str(i:i) = ' ' 129 ENDDO 65 130 !--------------------- 66 END FUNCTION cntpos 67 != 68 INTEGER FUNCTION findpos (c_c,l_c,c_r,l_r) 69 !--------------------------------------------------------------------- 70 !- Finds position of c_r in c_c 71 !--------------------------------------------------------------------- 72 IMPLICIT NONE 73 !- 74 CHARACTER(LEN=*),INTENT(in) :: c_c 75 INTEGER,INTENT(IN) :: l_c 76 CHARACTER(LEN=*),INTENT(in) :: c_r 77 INTEGER,INTENT(IN) :: l_r 78 !--------------------------------------------------------------------- 79 findpos = INDEX(c_c(1:l_c),c_r(1:l_r)) 80 IF (findpos == 0) findpos=-1 81 !---------------------- 82 END FUNCTION findpos 83 != 84 SUBROUTINE find_str (nb_str,str_tab,str_len_tab,str,pos) 85 !--------------------------------------------------------------------- 86 !- This subroutine looks for a string in a table 87 !--------------------------------------------------------------------- 88 !- INPUT 89 !- nb_str : length of table 90 !- str_tab : Table of strings 91 !- str_len_tab : Table of string-length 92 !- str : Target we are looking for 93 !- OUTPUT 94 !- pos : -1 if str not found, else value in the table 95 !--------------------------------------------------------------------- 96 IMPLICIT NONE 97 !- 98 INTEGER :: nb_str 99 CHARACTER(LEN=*),DIMENSION(nb_str) :: str_tab 100 INTEGER,DIMENSION(nb_str) :: str_len_tab 101 CHARACTER(LEN=*) :: str 102 INTEGER :: pos 103 !- 104 INTEGER :: i,il 105 !--------------------------------------------------------------------- 106 pos = -1 107 il = LEN_TRIM(str) 108 IF ( nb_str > 0 ) THEN 109 DO i=1,nb_str 110 IF ( (INDEX(str_tab(i),str(1:il)) > 0) & 111 .AND.(str_len_tab(i) == il) ) THEN 112 pos = i 113 EXIT 114 ENDIF 115 ENDDO 116 ENDIF 117 !------------------------- 118 END SUBROUTINE find_str 119 != 120 SUBROUTINE nocomma (str) 121 !--------------------------------------------------------------------- 122 !- 123 !--------------------------------------------------------------------- 124 IMPLICIT NONE 125 !- 126 CHARACTER(LEN=*) :: str 127 !- 128 INTEGER :: i 129 !--------------------------------------------------------------------- 130 DO i=1,LEN_TRIM(str) 131 IF (str(i:i) == ',') str(i:i) = ' ' 132 ENDDO 133 !------------------------ 134 END SUBROUTINE nocomma 135 != 136 SUBROUTINE strlowercase (str) 131 END SUBROUTINE nocomma 132 !=== 133 SUBROUTINE strlowercase (str) 137 134 !--------------------------------------------------------------------- 138 135 !- Converts a string into lowercase 139 136 !--------------------------------------------------------------------- 140 141 !- 142 143 !- 144 145 !--------------------------------------------------------------------- 146 147 148 IF ( (ic >= 65) .AND. (ic <= 90) )str(i:i) = ACHAR(ic+32)149 150 !-------------------------- ---151 152 != 153 137 IMPLICIT NONE 138 !- 139 CHARACTER(LEN=*) :: str 140 !- 141 INTEGER :: i,ic 142 !--------------------------------------------------------------------- 143 DO i=1,LEN_TRIM(str) 144 ic = IACHAR(str(i:i)) 145 IF ( (ic >= 65).AND.(ic <= 90) ) str(i:i) = ACHAR(ic+32) 146 ENDDO 147 !-------------------------- 148 END SUBROUTINE strlowercase 149 !=== 150 SUBROUTINE struppercase (str) 154 151 !--------------------------------------------------------------------- 155 152 !- Converts a string into uppercase 156 153 !--------------------------------------------------------------------- 157 IMPLICIT NONE 158 !- 159 CHARACTER(LEN=*) :: str 160 !- 161 INTEGER :: i,ic 162 !--------------------------------------------------------------------- 163 DO i=1,LEN_TRIM(str) 164 ic = IACHAR(str(i:i)) 165 IF ( (ic >= 97) .AND. (ic <= 122) ) str(i:i) = ACHAR(ic-32) 166 ENDDO 167 !----------------------------- 168 END SUBROUTINE struppercase 169 != 170 !------------------ 171 SUBROUTINE gensig (str, sig) 154 IMPLICIT NONE 155 !- 156 CHARACTER(LEN=*) :: str 157 !- 158 INTEGER :: i,ic 159 !--------------------------------------------------------------------- 160 DO i=1,LEN_TRIM(str) 161 ic = IACHAR(str(i:i)) 162 IF ( (ic >= 97).AND.(ic <= 122) ) str(i:i) = ACHAR(ic-32) 163 ENDDO 164 !-------------------------- 165 END SUBROUTINE struppercase 166 !=== 167 SUBROUTINE gensig (str,sig) 172 168 !--------------------------------------------------------------------- 173 169 !- Generate a signature from the first 30 characters of the string … … 175 171 !- one needs to also verify the string. 176 172 !--------------------------------------------------------------------- 177 IMPLICIT NONE 178 !- 179 CHARACTER(LEN=*) :: str 180 INTEGER :: sig 181 !- 182 INTEGER :: i 183 !--------------------------------------------------------------------- 184 sig = 0 185 DO i=1,MIN(len_trim(str),30) 186 sig = sig + prime(i)*IACHAR(str(i:i)) 187 ENDDO 188 !----------------------------- 189 END SUBROUTINE gensig 190 != 191 !------------------ 192 SUBROUTINE find_sig (nb_sig, str_tab, str, sig_tab, sig, pos) 173 IMPLICIT NONE 174 !- 175 CHARACTER(LEN=*) :: str 176 INTEGER :: sig 177 !- 178 INTEGER :: i 179 !--------------------------------------------------------------------- 180 sig = 0 181 DO i=1,MIN(LEN_TRIM(str),30) 182 sig = sig + prime(i)*IACHAR(str(i:i)) 183 ENDDO 184 !-------------------- 185 END SUBROUTINE gensig 186 !=== 187 SUBROUTINE find_sig (nb_sig,str_tab,str,sig_tab,sig,pos) 193 188 !--------------------------------------------------------------------- 194 189 !- Find the string signature in a list of signatures … … 197 192 !- nb_sig : length of table of signatures 198 193 !- str_tab : Table of strings 199 !- str : Target string we are looking for 194 !- str : Target string we are looking for 200 195 !- sig_tab : Table of signatures 201 196 !- sig : Target signature we are looking for … … 203 198 !- pos : -1 if str not found, else value in the table 204 199 !--------------------------------------------------------------------- 205 IMPLICIT NONE 206 !- 207 INTEGER :: nb_sig 208 CHARACTER(LEN=*),DIMENSION(nb_sig) :: str_tab 209 CHARACTER(LEN=*) :: str 210 INTEGER, DIMENSION(nb_sig) :: sig_tab 211 INTEGER :: sig 212 !- 213 INTEGER :: pos 214 INTEGER, DIMENSION(nb_sig) :: loczeros 215 !- 216 INTEGER :: il, len 217 INTEGER, DIMENSION(1) :: minpos 218 !--------------------------------------------------------------------- 219 !- 220 pos = -1 221 il = LEN_TRIM(str) 222 !- 223 IF ( nb_sig > 0 ) THEN 224 ! 225 loczeros = ABS(sig_tab(1:nb_sig)-sig) 226 ! 227 IF ( COUNT(loczeros < 1) == 1 ) THEN 228 ! 229 minpos = MINLOC(loczeros) 230 len = LEN_TRIM(str_tab(minpos(1))) 231 IF ( (INDEX(str_tab(minpos(1)),str(1:il)) > 0) & 232 .AND.(len == il) ) THEN 233 pos = minpos(1) 234 ENDIF 235 ! 236 ELSE IF ( COUNT(loczeros < 1) > 1 ) THEN 237 ! 238 DO WHILE (COUNT(loczeros < 1) >= 1 .AND. pos < 0 ) 239 minpos = MINLOC(loczeros) 240 len = LEN_TRIM(str_tab(minpos(1))) 241 IF ( (INDEX(str_tab(minpos(1)),str(1:il)) > 0) & 242 .AND.(len == il) ) THEN 243 pos = minpos(1) 244 ELSE 245 loczeros(minpos(1)) = 99999 246 ENDIF 247 ENDDO 248 ! 200 IMPLICIT NONE 201 !- 202 INTEGER :: nb_sig 203 CHARACTER(LEN=*),DIMENSION(nb_sig) :: str_tab 204 CHARACTER(LEN=*) :: str 205 INTEGER,DIMENSION(nb_sig) :: sig_tab 206 INTEGER :: sig 207 !- 208 INTEGER :: pos 209 INTEGER,DIMENSION(nb_sig) :: loczeros 210 !- 211 INTEGER :: il,len 212 INTEGER,DIMENSION(1) :: minpos 213 !--------------------------------------------------------------------- 214 pos = -1 215 il = LEN_TRIM(str) 216 !- 217 IF ( nb_sig > 0 ) THEN 218 loczeros = ABS(sig_tab(1:nb_sig)-sig) 219 IF ( COUNT(loczeros < 1) == 1 ) THEN 220 minpos = MINLOC(loczeros) 221 len = LEN_TRIM(str_tab(minpos(1))) 222 IF ( (INDEX(str_tab(minpos(1)),str(1:il)) > 0) & 223 .AND.(len == il) ) THEN 224 pos = minpos(1) 249 225 ENDIF 250 ! 251 ENDIF 252 !- 226 ELSE IF ( COUNT(loczeros < 1) > 1 ) THEN 227 DO WHILE (COUNT(loczeros < 1) >= 1 .AND. pos < 0 ) 228 minpos = MINLOC(loczeros) 229 len = LEN_TRIM(str_tab(minpos(1))) 230 IF ( (INDEX(str_tab(minpos(1)),str(1:il)) > 0) & 231 .AND.(len == il) ) THEN 232 pos = minpos(1) 233 ELSE 234 loczeros(minpos(1)) = 99999 235 ENDIF 236 ENDDO 237 ENDIF 238 ENDIF 239 !----------------------- 253 240 END SUBROUTINE find_sig 254 != 241 !=== 255 242 !------------------ 256 243 END MODULE ioipsl_stringop -
LMDZ4/branches/LMDZ4-dev/libf/bibio/write_field.F90
r772 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 module write_field … … 72 72 73 73 subroutine WriteField_gen(name,Field,dimx,dimy,dimz) 74 USE ioipsl75 74 implicit none 76 75 include 'netcdf.inc' … … 109 108 110 109 subroutine CreateNewField(name,dimx,dimy,dimz) 111 USE ioipsl112 110 implicit none 113 111 include 'netcdf.inc' … … 229 227 write (id,spacing) 230 228 else 231 write (id,' ')229 write (id,'("")') 232 230 write (id,spacing) 233 231 endif -
LMDZ4/branches/LMDZ4-dev/libf/bibio/writedynav.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine writedynav( histid, time, vcov, 5 5 , ucov,teta,ppk,phi,q,masse,ps,phis) 6 6 7 #ifdef CPP_IOIPSL 7 8 USE ioipsl 9 #endif 8 10 USE infotrac, ONLY : nqtot, ttext 9 11 implicit none … … 45 47 #include "description.h" 46 48 #include "serre.h" 49 #include "iniprint.h" 47 50 48 51 C … … 59 62 60 63 64 #ifdef CPP_IOIPSL 65 ! This routine needs IOIPSL to work 61 66 C Variables locales 62 67 C … … 138 143 C 139 144 if (ok_sync) call histsync(histid) 145 146 #else 147 ! tell the user this routine should be run with ioipsl 148 write(lunout,*)"writedynav: Warning this routine should not be", 149 & " used without ioipsl" 150 #endif 151 ! of #ifdef CPP_IOIPSL 140 152 return 141 153 end -
LMDZ4/branches/LMDZ4-dev/libf/dyn3d/bilan_dyn.F
r693 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 SUBROUTINE bilan_dyn (ntrac,dt_app,dt_cum, … … 10 10 c vQ..A=Cp T + L * ... 11 11 12 #ifdef CPP_IOIPSL 12 13 USE IOIPSL 14 #endif 13 15 14 16 IMPLICIT NONE -
LMDZ4/branches/LMDZ4-dev/libf/dyn3d/diagedyn.F
r1140 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 … … 315 315 C 316 316 #else 317 write(lunout,*) ,'diagedyn: Needs Earth physics to function'317 write(lunout,*)'diagedyn: Needs Earth physics to function' 318 318 #endif 319 319 ! #endif of #ifdef CPP_EARTH -
LMDZ4/branches/LMDZ4-dev/libf/dyn3d/dynredem.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 c 5 5 SUBROUTINE dynredem0(fichnom,iday_end,phis) 6 #ifdef CPP_IOIPSL 6 7 USE IOIPSL 8 #endif 7 9 USE infotrac 8 10 IMPLICIT NONE … … 55 57 56 58 c----------------------------------------------------------------------- 57 modname='dynredem' 58 59 modname='dynredem0' 60 61 #ifdef CPP_IOIPSL 59 62 call ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) 60 63 call ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) 61 64 #else 65 ! set yyears0, mmois0, jjour0 to 0,1,1 (hours is not used) 66 yyears0=0 67 mmois0=1 68 jjour0=1 69 #endif 62 70 63 71 DO l=1,length -
LMDZ4/branches/LMDZ4-dev/libf/dyn3d/getparam.F90
r524 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 MODULE getparam 5 #ifdef CPP_IOIPSL 5 6 USE IOIPSL 7 #else 8 ! if not using IOIPSL, we still need to use (a local version of) getin 9 USE ioipsl_getincom 10 #endif 11 6 12 INTERFACE getpar 7 13 MODULE PROCEDURE ini_getparam,fin_getparam,getparamr,getparami,getparaml -
LMDZ4/branches/LMDZ4-dev/libf/dyn3d/guide_mod.F90
r1170 r1186 1 1 ! 2 ! $ Header: /home/cvsroot/LMDZ4/libf/dyn3d/guide.F,v 1.3.4.1 2006/11/06 15:51:16 fairhead Exp$2 ! $Id$ 3 3 ! 4 4 MODULE guide_mod … … 9 9 !======================================================================= 10 10 11 USE ioipsl12 11 USE getparam 13 12 USE Write_Field -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/bilan_dyn_p.F
r985 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 SUBROUTINE bilan_dyn_p (ntrac,dt_app,dt_cum, … … 10 10 c vQ..A=Cp T + L * ... 11 11 12 #ifdef CPP_IOIPSL 12 13 USE IOIPSL 14 #endif 13 15 USE parallel 14 16 USE mod_hallo -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/diagedyn.F
r1140 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 … … 315 315 C 316 316 #else 317 write(lunout,*) ,'diagedyn: Needs Earth physics to function'317 write(lunout,*)'diagedyn: Needs Earth physics to function' 318 318 #endif 319 319 ! #endif of #ifdef CPP_EARTH -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/dynredem.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 c 5 5 SUBROUTINE dynredem0(fichnom,iday_end,phis) 6 #ifdef CPP_IOIPSL 6 7 USE IOIPSL 8 #endif 7 9 USE infotrac 8 10 IMPLICIT NONE … … 55 57 56 58 c----------------------------------------------------------------------- 57 modname='dynredem' 58 59 modname='dynredem0' 60 61 #ifdef CPP_IOIPSL 59 62 call ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) 60 63 call ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) 61 64 #else 65 ! set yyears0, mmois0, jjour0 to 0,1,1 (hours is not used) 66 yyears0=0 67 mmois0=1 68 jjour0=1 69 #endif 62 70 63 71 DO l=1,length … … 457 465 dims4(3) = idim_s 458 466 dims4(4) = idim_tim 459 467 IF(nqtot.GE.1) THEN 460 468 DO iq=1,nqtot 461 469 cIM 220306 BEG … … 468 476 ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,ttext(iq)) 469 477 ENDDO 478 ENDIF 470 479 c 471 480 dims4(1) = idim_rlonv … … 631 640 END IF 632 641 642 IF(nqtot.GE.1) THEN 633 643 do iq=1,nqtot 634 644 … … 701 711 702 712 ENDDO 713 ENDIF 703 714 c 704 715 ierr = NF_INQ_VARID(nid, "masse", nvarid) -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/dynredem_p.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 c 5 5 SUBROUTINE dynredem0_p(fichnom,iday_end,phis) 6 #ifdef CPP_IOIPSL 6 7 USE IOIPSL 8 #endif 7 9 USE parallel 8 10 USE infotrac … … 57 59 if (mpi_rank==0) then 58 60 59 modname='dynredem' 60 61 modname='dynredem0_p' 62 63 #ifdef CPP_IOIPSL 61 64 call ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) 62 65 call ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) 63 66 #else 67 ! set yyears0, mmois0, jjour0 to 0,1,1 (hours is not used) 68 yyears0=0 69 mmois0=1 70 jjour0=1 71 #endif 64 72 65 73 DO l=1,length -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/getparam.F90
r774 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 MODULE getparam 5 #ifdef CPP_IOIPSL 5 6 USE IOIPSL 7 #else 8 ! if not using IOIPSL, we still need to use (a local version of) getin 9 USE ioipsl_getincom 10 #endif 11 6 12 INTERFACE getpar 7 13 MODULE PROCEDURE ini_getparam,fin_getparam,getparamr,getparami,getparaml -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/initdynav_p.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 c5 c6 4 subroutine initdynav_p(infile,day0,anne0,tstep,t_ops,t_wrt,fileid) 7 5 6 #ifdef CPP_IOIPSL 7 ! This routine needs IOIPSL 8 8 USE IOIPSL 9 #endif 9 10 use parallel 10 11 use Write_field … … 50 51 #include "description.h" 51 52 #include "serre.h" 53 #include "iniprint.h" 52 54 53 55 C Arguments … … 57 59 real tstep, t_ops, t_wrt 58 60 integer fileid 61 62 #ifdef CPP_IOIPSL 63 ! This routine needs IOIPSL 64 C Variables locales 65 C 59 66 integer thoriid, zvertiid 60 61 C Variables locales62 C63 67 integer tau0 64 68 real zjulian … … 193 197 C 194 198 call histend(fileid) 199 #else 200 write(lunout,*)'initdynav_p: Needs IOIPSL to function' 201 #endif 202 ! #endif of #ifdef CPP_IOIPSL 195 203 return 196 204 end -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/initfluxsto_p.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine initfluxsto_p … … 6 6 . fileid,filevid,filedid) 7 7 8 #ifdef CPP_IOIPSL 9 ! This routine needs IOIPSL 8 10 USE IOIPSL 11 #endif 9 12 use parallel 10 13 use Write_field … … 50 53 #include "description.h" 51 54 #include "serre.h" 55 #include "iniprint.h" 52 56 53 57 C Arguments 54 58 C 55 59 character*(*) infile 56 integer*4 itau57 60 real tstep, t_ops, t_wrt 58 61 integer fileid, filevid,filedid 59 integer ndex(1) 62 63 #ifdef CPP_IOIPSL 64 ! This routine needs IOIPSL 65 C Variables locales 66 C 60 67 real nivd(1) 61 62 C Variables locales63 C64 68 integer tau0 65 69 real zjulian … … 285 289 endif 286 290 291 #else 292 write(lunout,*)'initfluxsto_p: Needs IOIPSL to function' 293 #endif 294 ! #endif of #ifdef CPP_IOIPSL 287 295 return 288 296 end -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/inithist_p.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine inithist_p(infile,day0,anne0,tstep,t_ops,t_wrt, 5 5 . fileid,filevid) 6 6 7 #ifdef CPP_IOIPSL 8 ! This routine needs IOIPSL 7 9 USE IOIPSL 10 #endif 8 11 use parallel 9 12 use Write_field … … 50 53 #include "description.h" 51 54 #include "serre.h" 55 #include "iniprint.h" 52 56 53 57 C Arguments … … 58 62 integer fileid, filevid 59 63 64 #ifdef CPP_IOIPSL 65 ! This routine needs IOIPSL 60 66 C Variables locales 61 67 C … … 244 250 call histend(fileid) 245 251 call histend(filevid) 252 #else 253 write(lunout,*)'inithist_p: Needs IOIPSL to function' 254 #endif 255 ! #endif of #ifdef CPP_IOIPSL 246 256 return 247 257 end -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/mod_const_para.F90
r1014 r1186 1 ! 2 ! $Id$ 3 ! 1 4 MODULE mod_const_mpi 2 5 … … 8 11 9 12 SUBROUTINE Init_const_mpi 13 #ifdef CPP_IOIPSL 10 14 USE IOIPSL 15 #else 16 ! if not using IOIPSL, we still need to use (a local version of) getin 17 USE ioipsl_getincom 18 #endif 11 19 12 20 IMPLICIT NONE -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/writedynav_p.F
r1118 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine writedynav_p( histid, time, vcov, 5 5 , ucov,teta,ppk,phi,q,masse,ps,phis) 6 6 7 #ifdef CPP_IOIPSL 8 ! This routine needs IOIPSL 7 9 USE ioipsl 10 #endif 8 11 USE parallel 9 12 USE misc_mod … … 47 50 #include "description.h" 48 51 #include "serre.h" 52 #include "iniprint.h" 49 53 50 54 C … … 61 65 62 66 67 #ifdef CPP_IOIPSL 68 ! This routine needs IOIPSL 63 69 C Variables locales 64 70 C … … 156 162 C 157 163 if (ok_sync) call histsync(histid) 164 #else 165 write(lunout,*)'writedynav_p: Needs IOIPSL to function' 166 #endif 167 ! #endif of #ifdef CPP_IOIPSL 158 168 return 159 169 end -
LMDZ4/branches/LMDZ4-dev/libf/dyn3dpar/writehist_p.F
r1114 r1186 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 subroutine writehist_p( histid, histvid, time, vcov, 5 5 , ucov,teta,phi,q,masse,ps,phis) 6 6 7 #ifdef CPP_IOIPSL 8 ! This routine needs IOIPSL 7 9 USE ioipsl 10 #endif 8 11 USE parallel 9 12 USE misc_mod … … 48 51 #include "description.h" 49 52 #include "serre.h" 53 #include "iniprint.h" 50 54 51 55 C … … 61 65 integer time 62 66 63 67 #ifdef CPP_IOIPSL 68 ! This routine needs IOIPSL 64 69 C Variables locales 65 70 C … … 144 149 call histsync(histvid) 145 150 endif 151 #else 152 write(lunout,*)'writehist_p: Needs IOIPSL to function' 153 #endif 154 ! #endif of #ifdef CPP_IOIPSL 146 155 return 147 156 end
Note: See TracChangeset
for help on using the changeset viewer.