Changeset 20 for readTracFiles_mod.f90


Ignore:
Timestamp:
Jul 4, 2022, 11:49:29 PM (2 years ago)
Author:
dcugnet
Message:
  • Modifications in readSections to allow a continuation line character "\": in both "tracer.def" and "isotopes_params.def", information for a single tracer or isotope can now be stored on several lines.
  • Modifications in "dispTable" and associated routines to allow too wide tables to be displayed as several shorter sub-tables: each sub-table is at most "nMaxCol" characters wide (typically: number of characters displayable in a tandard screen window) and the first "nHead" columns (typically: name, index, etc.) are duplicated in each sub-table. A default value for nMaxCol, called maxTableWidth (currently = 192) is available in readTracFiles_mod.
  • Subroutine "readIsotopesFile" becomes a function with a boolean returned error value "lerr" used to trigger an external aborting function (no STOP).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • readTracFiles_mod.f90

    r19 r20  
    2121
    2222  PUBLIC :: tran0, idxAncestor, ancestor                             !--- GENERATION 0 TRACER + TOOLS FOR GENERATIONS
     23  PUBLIC :: maxTableWidth
    2324!------------------------------------------------------------------------------------------------------------------------------
    2425  TYPE :: dataBase_type                                              !=== TYPE FOR TRACERS SECTION
     
    5960  CHARACTER(LEN=maxlen), SAVE :: newH2OIso(5) = ['H2[16]O', 'H[2]HO ', 'H2[18]O', 'H2[17]O', 'H[3]HO ']
    6061
    61 
    6262  !=== LOCAL COPIES OF THE TRACERS AND ISOTOPES DESCRIPTORS, USED BY getKey (INITIALIZED IN getKey_init)
    6363  TYPE(trac_type), ALLOCATABLE, TARGET, SAVE ::  tracers(:)
    6464  TYPE(isot_type), ALLOCATABLE, TARGET, SAVE :: isotopes(:)
    6565
     66  INTEGER,    PARAMETER :: maxTableWidth = 192                       !--- Maximum width of a table displayed with "dispTable"
    6667  CHARACTER(LEN=maxlen) :: modname
    6768
     
    267268  TYPE(trac_type),       ALLOCATABLE :: tt(:)
    268269  TYPE(trac_type)       :: tmp
    269   CHARACTER(LEN=1024)   :: str
     270  CHARACTER(LEN=1024)   :: str, str2
    270271  CHARACTER(LEN=maxlen) :: secn
    271272  INTEGER               :: ierr, n
     
    273274  IF(.NOT.ALLOCATED(dBase)) ALLOCATE(dBase(0))
    274275  OPEN(90, FILE=fnam, FORM='formatted', STATUS='old')
    275   DO; READ(90,'(a)', IOSTAT=ierr)str
     276  DO; str=''
     277    DO
     278      READ(90,'(a)', IOSTAT=ierr)str2                                !--- Read a full line
     279      str=TRIM(str)//' '//TRIM(str2)                                 !--- Append "str" with the current line
     280      n=LEN_TRIM(str); IF(n == 0) EXIT                               !--- Empty line (probably end of file)
     281      IF(IACHAR(str(n:n))  /= 92) EXIT                               !--- No "\" continuing line symbol found => end of line
     282      str = str(1:n-1)                                               !--- Remove the "\" continuing line symbol
     283    END DO
     284    str = ADJUSTL(str)                                               !--- Remove the front space
    276285    IF(ierr    /= 0 ) EXIT                                           !--- Finished: error or end of file
    277286    IF(str(1:1)=='#') CYCLE                                          !--- Skip comments lines
     
    777786  phas =         [(fgetKey(iq, 'phases',tm(:)%keys, 'g' ), iq=1, nq)]
    778787  CALL msg(TRIM(message)//':', modname)
    779   IF(tm(1)%parent == '') THEN
    780     IF(test(dispTable('iiiss',   ['iq    ','hadv  ','vadv  ','name  ','phase '], cat(tm%name, phas), cat([(iq, iq=1, nq)], &
    781                                             hadv,    vadv),                sub=modname), lerr)) RETURN
     788  IF(ALL(tm(:)%parent == '')) THEN
     789    IF(test(dispTable('iiiss',   ['iq    ','hadv  ','vadv  ','name  ','phase '], cat(tm%name, phas), &
     790                 cat([(iq, iq=1, nq)], hadv, vadv),                 nColMax=maxTableWidth, nHead=2, sub=modname), lerr)) RETURN
    782791  ELSE
    783792    IF(test(dispTable('iiissis', ['iq    ','hadv  ','vadv  ','name  ','parent','igen  ','phase '], cat(tm%name, tm%parent, &
    784            tm%phase), cat([(iq, iq=1, nq)], hadv,    vadv, tm%iGeneration), sub=modname), lerr)) RETURN
     793      tm%phase), cat([(iq, iq=1, nq)], hadv, vadv, tm%iGeneration), nColMax=maxTableWidth, nHead=2, sub=modname), lerr)) RETURN
    785794  END IF
    786795END FUNCTION dispTraSection
     
    933942  CALL get_in('ok_iso_verif', isot(strIdx(isot%parent, 'H2O'))%check, .FALSE.)
    934943
    935   lerr = dispIsotopes(isot, 'Isotopes parameters read from file', modname)
     944  lerr = dispIsotopes(isot, 'Isotopes parameters read from file "'//TRIM(fnam)//'"', modname)
    936945
    937946END FUNCTION readIsotopesFile
     
    945954!===      NOTE: THIS IS DONE HERE (IN A ROUTINE CALLED BY THE DYNAMIC), BECAUSE THE DYNAMIC NEEDS FEW PHYSICAL PARAMETERS.  ===
    946955!==============================================================================================================================
    947 SUBROUTINE initIsotopes(trac, isot)
     956LOGICAL FUNCTION initIsotopes(trac, isot) RESULT(lerr)
    948957  TYPE(trac_type), ALLOCATABLE, TARGET, INTENT(INOUT) :: trac(:)
    949958  TYPE(isot_type), ALLOCATABLE, TARGET, INTENT(INOUT) :: isot(:)
     
    955964  TYPE(trac_type), POINTER   ::  t(:), t1
    956965  TYPE(isot_type), POINTER   ::  i
     966  lerr = .FALSE.
    957967
    958968  t => trac
     
    10191029  !=== READ PHYSICAL PARAMETERS FROM "isotopes_params.def" FILE
    10201030  !    DONE HERE, AND NOT ONLY IN "infotrac_phy", BECAUSE SOME PHYSICAL PARAMS ARE NEEDED FOR RESTARTS (tnat AND alpha_ideal)
    1021   IF(readIsotopesFile('isotopes_params.def',isot)) CALL abort_gcm(modname,'Problem when reading isotopes parameters',1)
    1022 
    1023 END SUBROUTINE initIsotopes
     1031  lerr = readIsotopesFile('isotopes_params.def',isot)
     1032
     1033END FUNCTION initIsotopes
    10241034!==============================================================================================================================
    10251035
     
    10461056      END DO
    10471057    END DO
    1048     IF(test(fmsg('Problem with the table content', modname, dispTable(prf, ttl, val, cat([(it,it=1,nt)]), rFmt='(EN8.4)',     &
    1049        sub=modname)), lerr)) RETURN
     1058    IF(test(fmsg('Problem with the table content', modname, dispTable(prf, ttl, val, &
     1059            cat([(it,it=1,nt)]), rFmt='(EN8.4)', nColMax=maxTableWidth, nHead=2, sub=modname)), lerr)) RETURN
    10501060    DEALLOCATE(ttl, val)
    10511061  END DO       
Note: See TracChangeset for help on using the changeset viewer.