Changeset 12 for readTracFiles_mod.f90
- Timestamp:
- Feb 4, 2022, 3:39:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
readTracFiles_mod.f90
r11 r12 33 33 INTERFACE idxAncestor; MODULE PROCEDURE idxAncestor_1, idxAncestor_m; END INTERFACE idxAncestor 34 34 INTERFACE ancestor; MODULE PROCEDURE ancestor_1, ancestor_m; END INTERFACE ancestor 35 INTERFACE addPhase; MODULE PROCEDURE addPhase_1, addPhase_m; END INTERFACEaddPhase35 INTERFACE addPhase; MODULE PROCEDURE addPhase_s1, addPhase_sm, addPhase_i1, addPhase_im; END INTERFACE addPhase 36 36 !------------------------------------------------------------------------------------------------------------------------------ 37 37 … … 152 152 CLOSE(90) 153 153 DO ip = 1, nphases !--- Deal with old water names 154 oldH2O = 'H2O'//old_phases(ip:ip)155 newH2O = 'H2O'//phases_sep//known_phases(ip:ip)154 oldH2O = addPhase('H2O', ip, '') 155 newH2O = addPhase('H2O', ip) 156 156 ix = strIdx(tracs(:)%name, oldH2O) 157 157 IF(ix == 0) CYCLE … … 565 565 trn=TRIM(tr(iq)%name); nam=trn !--- Tracer name (regular case) 566 566 IF(lTg) nam = TRIM(tr(iq)%parent) !--- Parent name (tagging case) 567 IF(lEx) nam = TRIM(nam)//phases_sep//pha(ip:ip)!--- Phase extension needed567 IF(lEx) nam = addPhase(nam, ip) !--- Phase extension needed 568 568 IF(lTg) nam = TRIM(nam)//'_'//TRIM(trn) !--- <parent>_<name> for tags 569 569 ttr(it) = tr(iq) !--- Same <key>=<val> pairs … … 572 572 ttr(it)%phase = pha(ip:ip) !--- Single phase entry 573 573 IF(lEx.AND.tr(iq)%iGeneration>1) THEN 574 ttr(it)%parent = TRIM(ttr(it)%parent)//phases_sep//pha(ip:ip)575 ttr(it)%gen0Name = TRIM(ttr(it)%gen0Name)//phases_sep//pha(ip:ip)574 ttr(it)%parent = addPhase(ttr(it)%parent, ip) !--- Modify parent name 575 ttr(it)%gen0Name = addPhase(ttr(it)%gen0Name, ip) !--- Modify generation 0 ancestor name 576 576 END IF 577 577 it=it+1 … … 602 602 iy = [(k, k=1, nq)] 603 603 DO ip = nphases, 1, -1 604 iq = strIdx(tr acers(:)%name, 'H2O'//phases_sep//known_phases(ip:ip))605 IF(iq/=0) iy = [iq, iy(1:iq-1), iy(iq :nq)]604 iq = strIdx(tr(:)%name, addPhase('H2O', ip)) 605 IF(iq/=0) iy = [iq, iy(1:iq-1), iy(iq+1:nq)] 606 606 END DO 607 607 tr = tr(iy) !--- Water displaces at first positions … … 724 724 tnam = TRIM(t1(iq)%name) !--- Original name 725 725 IF(COUNT(t1%name == tnam) == 1) CYCLE !--- Current tracer is not duplicated: finished 726 tnam_new = TRIM(tnam)// phases_sep//TRIM(sections(is)%name)!--- Same with section extension726 tnam_new = TRIM(tnam)//'_'//TRIM(sections(is)%name) !--- Same with section extension 727 727 nq = SUM(nt(1:is-1)) !--- Number of tracers in previous sections 728 728 ns = nt(is) !--- Number of tracers in the current section … … 1154 1154 lerr = .FALSE. 1155 1155 IF(PRESENT(ky)) THEN 1156 val = getKeyByName_prv(keyn, tname , ky); IF(val /= '') RETURN!--- "ky" and "tnam"1156 val = getKeyByName_prv(keyn, tname, ky); IF(val /= '') RETURN !--- "ky" and "tnam" 1157 1157 val = getKeyByName_prv(keyn, delPhase(strHead(tname,'_')), ky) !--- "ky" and "tnam" without phase 1158 1158 ELSE … … 1186 1186 CHARACTER(LEN=*), TARGET, OPTIONAL, INTENT(IN) :: tnam(:) 1187 1187 TYPE(keys_type), TARGET, OPTIONAL, INTENT(IN) :: ky(:) 1188 CHARACTER(LEN=maxlen), POINTER :: n(:) 1188 TYPE(keys_type), POINTER :: k(:) 1189 CHARACTER(LEN=maxlen), POINTER :: n(:) 1189 1190 INTEGER :: iq 1190 n => tracers(:)%keys%name; IF(PRESENT(tnam)) n => tnam(:) 1191 k => tracers(:)%keys; IF(PRESENT(ky )) k => ky 1192 n => k(:)%name; IF(PRESENT(tnam)) n => tnam 1191 1193 ALLOCATE(val(SIZE(n))) 1192 IF( PRESENT(ky)) lerr = ANY([(getKeyByName_s1(keyn, val(iq), n(iq), ky), iq=1, SIZE(n))]) 1193 IF(.NOT.PRESENT(ky)) lerr = ANY([(getKeyByName_s1(keyn, val(iq), n(iq)), iq=1, SIZE(n))]) 1194 lerr = ANY([(getKeyByName_s1(keyn, val(iq), n(iq), k), iq=1, SIZE(n))]) 1194 1195 END FUNCTION getKeyByName_sm 1195 1196 !============================================================================================================================== … … 1213 1214 CHARACTER(LEN=*), TARGET, OPTIONAL, INTENT(IN) :: tnam(:) 1214 1215 TYPE(keys_type), TARGET, OPTIONAL, INTENT(IN) :: ky(:) 1216 TYPE(keys_type), POINTER :: k(:) 1215 1217 CHARACTER(LEN=maxlen), POINTER :: n(:) 1216 1218 INTEGER :: iq 1217 n => tracers(:)%name; IF(PRESENT(tnam)) n => tnam(:) 1219 k => tracers(:)%keys; IF(PRESENT(ky )) k => ky 1220 n => k(:)%name; IF(PRESENT(tnam)) n => tnam 1218 1221 ALLOCATE(val(SIZE(n))) 1219 IF( PRESENT(ky)) lerr = ANY([(getKeyByName_i1(keyn, val(iq), n(iq), ky), iq=1, SIZE(n))]) 1220 IF(.NOT.PRESENT(ky)) lerr = ANY([(getKeyByName_i1(keyn, val(iq), n(iq)), iq=1, SIZE(n))]) 1222 lerr = ANY([(getKeyByName_i1(keyn, val(iq), n(iq), k), iq=1, SIZE(n))]) 1221 1223 END FUNCTION getKeyByName_im 1222 1224 !============================================================================================================================== … … 1240 1242 CHARACTER(LEN=*), TARGET, OPTIONAL, INTENT(IN) :: tnam(:) 1241 1243 TYPE(keys_type), TARGET, OPTIONAL, INTENT(IN) :: ky(:) 1244 TYPE(keys_type), POINTER :: k(:) 1242 1245 CHARACTER(LEN=maxlen), POINTER :: n(:) 1243 1246 INTEGER :: iq 1244 n => tracers(:)%name; IF(PRESENT(tnam)) n => tnam(:) 1247 k => tracers(:)%keys; IF(PRESENT(ky )) k => ky 1248 n => k(:)%name; IF(PRESENT(tnam)) n => tnam 1245 1249 ALLOCATE(val(SIZE(n))) 1246 IF( PRESENT(ky)) lerr = ANY([(getKeyByName_r1(keyn, val(iq), n(iq), ky), iq=1, SIZE(n))]) 1247 IF(.NOT.PRESENT(ky)) lerr = ANY([(getKeyByName_r1(keyn, val(iq), n(iq)), iq=1, SIZE(n))]) 1250 lerr = ANY([(getKeyByName_r1(keyn, val(iq), n(iq), k), iq=1, SIZE(n))]) 1248 1251 END FUNCTION getKeyByName_rm 1249 1252 !============================================================================================================================== … … 1276 1279 END FUNCTION delPhase 1277 1280 !------------------------------------------------------------------------------------------------------------------------------ 1278 CHARACTER(LEN=maxlen) FUNCTION addPhase_ 1(s,pha,ph_sep) RESULT(out)1281 CHARACTER(LEN=maxlen) FUNCTION addPhase_s1(s,pha,ph_sep) RESULT(out) 1279 1282 CHARACTER(LEN=*), INTENT(IN) :: s 1280 1283 CHARACTER(LEN=1), INTENT(IN) :: pha … … 1289 1292 IF(i == 0) out = TRIM(s)//TRIM(psep)//pha !--- <var> => return <var><sep><pha> 1290 1293 IF(i /= 0) out = s(1:i-1)//TRIM(psep)//pha//'_'//s(i+1:l) !--- <var>_<tag> => return <var><sep><pha>_<tag> 1291 END FUNCTION addPhase_ 11292 !------------------------------------------------------------------------------------------------------------------------------ 1293 FUNCTION addPhase_ m(s,pha,ph_sep) RESULT(out)1294 END FUNCTION addPhase_s1 1295 !------------------------------------------------------------------------------------------------------------------------------ 1296 FUNCTION addPhase_sm(s,pha,ph_sep) RESULT(out) 1294 1297 CHARACTER(LEN=*), INTENT(IN) :: s(:) 1295 1298 CHARACTER(LEN=1), INTENT(IN) :: pha … … 1299 1302 INTEGER :: k 1300 1303 psep = phases_sep; IF(PRESENT(ph_sep)) psep = ph_sep 1301 out = [( addPhase_1(s(k), pha, psep), k=1, SIZE(s) )] 1302 END FUNCTION addPhase_m 1304 out = [( addPhase_s1(s(k), pha, psep), k=1, SIZE(s) )] 1305 END FUNCTION addPhase_sm 1306 !------------------------------------------------------------------------------------------------------------------------------ 1307 CHARACTER(LEN=maxlen) FUNCTION addPhase_i1(s,ipha,ph_sep) RESULT(out) 1308 CHARACTER(LEN=*), INTENT(IN) :: s 1309 INTEGER, INTENT(IN) :: ipha 1310 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: ph_sep 1311 CHARACTER(LEN=1) :: psep 1312 out = s 1313 IF(s == '') RETURN !--- Empty string: nothing to do 1314 psep = phases_sep; IF(PRESENT(ph_sep)) psep = ph_sep 1315 IF(psep == '') out = addPhase_s1(s, old_phases(ipha:ipha), psep) 1316 IF(psep /= '') out = addPhase_s1(s, known_phases(ipha:ipha), psep) 1317 END FUNCTION addPhase_i1 1318 !------------------------------------------------------------------------------------------------------------------------------ 1319 FUNCTION addPhase_im(s,ipha,ph_sep) RESULT(out) 1320 CHARACTER(LEN=*), INTENT(IN) :: s(:) 1321 INTEGER, INTENT(IN) :: ipha 1322 CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: ph_sep 1323 CHARACTER(LEN=maxlen), ALLOCATABLE :: out(:) 1324 CHARACTER(LEN=1) :: psep 1325 INTEGER :: k 1326 psep = phases_sep; IF(PRESENT(ph_sep)) psep = ph_sep 1327 out = [( addPhase_i1(s(k), ipha, psep), k=1, SIZE(s) )] 1328 END FUNCTION addPhase_im 1303 1329 !------------------------------------------------------------------------------------------------------------------------------ 1304 1330 … … 1372 1398 1373 1399 END MODULE readTracFiles_mod 1374
Note: See TracChangeset
for help on using the changeset viewer.