Ignore:
Timestamp:
12/16/19 14:33:26 (4 years ago)
Author:
jgipsl
Message:

Following changes have been done by A.Jornet/LSCE. No change is results and no change in usage have been seen. Some more error checking might stop the model for example if dimensions are not correct in call to histcom module.

Restcom:

  • Define a new var size length (20 to 100 )→ pbs found without no errors
  • Raise an error when var name is too long
  • Deallocate any buffer at the end of all restput/restcget calls → buffers only increase size. After loading/saving nothing is done with this memory

Histcom:

  • Raise an error if given history declared variables do not match with given dimensions from histwrite

getincom and stringop:

  • Enable any length character for the run.def → useful for long filepaths

flincom

  • Enable filenames longer than 80 chars to any
  • Deallocate buffers at the end of any flinget subroutine
File:
1 edited

Legend:

Unmodified
Added
Removed
  • IOIPSL/trunk/src/getincom.f90

    r3279 r4863  
    88USE errioipsl, ONLY : ipslerr,ipsldbg,ipslout 
    99USE stringop, & 
    10  &   ONLY : nocomma,cmpblank,strlowercase 
     10 &   ONLY : nocomma,cmpblank,strlowercase,nocomment, COMMENT_TAG 
    1111!- 
    1212IMPLICIT NONE 
     
    436436  CHARACTER(LEN=*) :: ret_val 
    437437!- 
    438   CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val 
    439   INTEGER :: pos,status=0,fileorig,size_of_in 
    440 !--------------------------------------------------------------------- 
     438  CHARACTER(LEN=:),ALLOCATABLE,DIMENSION(:) :: tmp_ret_val 
     439  INTEGER :: pos,status=0,fileorig,size_of_in,ier 
     440  INTEGER :: inlength 
     441!--------------------------------------------------------------------- 
     442!- 
     443  inlength = LEN(ret_val) 
     444  ALLOCATE(CHARACTER(inlength) :: tmp_ret_val(1), stat=ier) 
     445  IF (ier /= 0) CALL ipslerr(3, 'getincs', 'Allocation memory problem for', & 
     446                             'tmp_ret_val' ,'') 
    441447!- 
    442448! Do we have this targetname in our database ? 
     
    458464  ENDIF 
    459465  ret_val = tmp_ret_val(1) 
     466!-- 
     467  DEALLOCATE(tmp_ret_val) 
    460468!--------------------- 
    461469END SUBROUTINE getincs 
     
    717725  INTEGER :: k_typ,it,pos,len_str,status_cnt,io_err 
    718726  CHARACTER(LEN=n_d_fmt)  :: cnt 
    719   CHARACTER(LEN=80) :: str_READ,str_READ_lower 
     727  CHARACTER(LEN=:), ALLOCATABLE :: str_READ,str_READ_lower 
    720728  CHARACTER(LEN=9)  :: c_vtyp 
    721729  LOGICAL,DIMENSION(:),ALLOCATABLE :: found 
     
    11231131  INTEGER :: current 
    11241132!- 
    1125   CHARACTER(LEN=300) :: READ_str,NEW_str,last_key,key_str 
     1133  CHARACTER(LEN=:), ALLOCATABLE :: READ_str, NEW_str 
     1134  CHARACTER(LEN=300) :: last_key,key_str 
    11261135  CHARACTER(LEN=n_d_fmt) :: cnt 
    11271136  CHARACTER(LEN=10) :: c_fmt 
     
    12621271!- 
    12631272  INTEGER :: len_str,blk,nbve,starpos 
    1264   CHARACTER(LEN=300) :: tmp_str,new_key,mult 
     1273  CHARACTER(LEN=:), ALLOCATABLE :: tmp_str,new_key,mult 
    12651274  CHARACTER(LEN=n_d_fmt) :: cnt 
    12661275  CHARACTER(LEN=10) :: c_fmt 
     
    14881497!=== 
    14891498!- 
    1490 SUBROUTINE getin_skipafew (unit,out_string,eof,nb_lastkey) 
    1491 !--------------------------------------------------------------------- 
    1492   IMPLICIT NONE 
    1493 !- 
    1494   INTEGER :: unit,eof,nb_lastkey 
    1495   CHARACTER(LEN=300) :: dummy 
    1496   CHARACTER(LEN=300),INTENT(out) :: out_string 
     1499SUBROUTINE getin_readline(unitf, out_string, is_eof) 
     1500!--------------------------------------------------------------------- 
     1501  USE ISO_FORTRAN_ENV,ONLY : IOSTAT_EOR,IOSTAT_END 
     1502!- 
     1503  IMPLICIT NONE 
     1504!- 
     1505  INTEGER, PARAMETER :: CHARLEN = 100     ! buffer size 
     1506  INTEGER, INTENT(in) :: unitf 
     1507  INTEGER, INTENT(out) :: is_eof 
     1508  CHARACTER(LEN=:),INTENT(out),ALLOCATABLE :: out_string 
     1509!- 
     1510  CHARACTER(LEN=CHARLEN)  :: dummy 
     1511!- 
     1512  CHARACTER(LEN=:), ALLOCATABLE :: buff1  ! buffer 
     1513  INTEGER :: ioerr                  ! error code 
     1514  INTEGER :: readlength                   ! number of chars read from file  
     1515  LOGICAL :: is_eol, is_first_ite         ! end of line?  
     1516 
     1517  is_eof = 0 
     1518  is_eol = .FALSE. 
     1519  buff1 = "" 
     1520 
     1521  DO WHILE (.NOT. is_eol) 
     1522!- 
     1523      dummy = "" 
     1524      READ (UNIT=unitf,FMT='(A)', ADVANCE='NO', SIZE=readlength,ERR=9998,END=7778,IOSTAT=ioerr) dummy 
     1525      IF ((ioerr==IOSTAT_EOR).OR.(ioerr==IOSTAT_END)) ioerr = 0 
     1526!- 
     1527      ! keep looping if line is commented 
     1528      dummy = TRIM(ADJUSTL(dummy)) 
     1529!- 
     1530      ! is end of line? 
     1531      is_eol = (readlength .LT. CHARLEN) 
     1532!- 
     1533      ! merge with previous buffer 
     1534      buff1 = TRIM(buff1)//TRIM(dummy) 
     1535  ENDDO 
     1536!- 
     1537  out_string=TRIM(buff1) 
     1538!- 
     1539  RETURN 
     1540!- 
     15419998 CONTINUE 
     1542  CALL ipslerr (3,'getin_readline','Error while reading file',' ',' ') 
     1543!- 
     15447778 CONTINUE 
     1545  out_string = TRIM(dummy) 
     1546  is_eof = 1 
     1547     
     1548END SUBROUTINE getin_readline 
     1549!- 
     1550! getin_skipafew: reads   
     1551!- 
     1552SUBROUTINE getin_skipafew (unit,out_string,is_eof,nb_lastkey) 
     1553!--------------------------------------------------------------------- 
     1554  USE ISO_FORTRAN_ENV,ONLY : IOSTAT_EOR,IOSTAT_END 
     1555!- 
     1556  IMPLICIT NONE 
     1557!- 
     1558  INTEGER :: unit,is_eof,nb_lastkey 
     1559  CHARACTER(LEN=:),INTENT(out),ALLOCATABLE :: out_string 
     1560!- 
    14971561  CHARACTER(LEN=1) :: first 
    1498 !--------------------------------------------------------------------- 
    1499   first="#" 
    1500   eof = 0 
    1501   out_string = "    " 
    1502 !- 
    1503   DO WHILE (first == "#") 
    1504     READ (UNIT=unit,FMT='(A)',ERR=9998,END=7778) dummy 
    1505     dummy = TRIM(ADJUSTL(dummy)) 
    1506     first=dummy(1:1) 
    1507     IF (first == "#") THEN 
    1508       nb_lastkey = 0 
    1509     ENDIF 
     1562  CHARACTER(LEN=:), ALLOCATABLE :: dummy 
     1563!--------------------------------------------------------------------- 
     1564  first=COMMENT_TAG 
     1565  is_eof = 0 
     1566  dummy = "" 
     1567!- 
     1568! Loop until a non commented line is found 
     1569  DO WHILE (first == COMMENT_TAG .AND. is_eof == 0) 
     1570!- 
     1571     CALL getin_readline(unit, dummy, is_eof) 
     1572!- 
     1573!    Is first char a comment? # 
     1574     IF (LEN(dummy) > 0) THEN 
     1575         first=dummy(1:1) 
     1576         IF (first == COMMENT_TAG) THEN 
     1577           nb_lastkey = 0 
     1578         ENDIF 
     1579     ENDIF 
     1580!- 
    15101581  ENDDO 
    1511   out_string=dummy 
     1582!- 
     1583  CALL nocomment(dummy) 
     1584  out_string = TRIM(dummy) 
    15121585!- 
    15131586  RETURN 
     
    15171590!- 
    151815917778 CONTINUE 
    1519   eof = 1 
     1592  CALL nocomment(dummy) 
     1593  out_string = TRIM(dummy) 
     1594  is_eof = 1 
    15201595!---------------------------- 
    15211596END SUBROUTINE getin_skipafew 
Note: See TracChangeset for help on using the changeset viewer.