Changeset 3318 for trunk/LMDZ.TITAN/libf/muphytitan/fsystem.F90
- Timestamp:
- Apr 26, 2024, 4:27:26 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.TITAN/libf/muphytitan/fsystem.F90
r3090 r3318 428 428 CHARACTER(len=:), ALLOCATABLE :: opath 429 429 !! A Fortran allocated string with the parent directory path or an empty string if method fails 430 CHARACTER(len=:), ALLOCATABLE :: cpath 430 431 TYPE(C_PTR) :: zpath 431 432 IF (LEN_TRIM(path) == 0) THEN … … 433 434 RETURN 434 435 ENDIF 435 zpath = dirname_c(cstring(ADJUSTL(path))) 436 cpath = cstring(ADJUSTL(path)) 437 zpath = dirname_c(cpath) 436 438 IF (.NOT.C_ASSOCIATED(zpath)) THEN 437 439 opath = "" … … 448 450 CHARACTER(len=:), ALLOCATABLE :: opath 449 451 !! The basename of the path or an empty string if method fails 452 CHARACTER(len=:), ALLOCATABLE :: cpath 450 453 TYPE(C_PTR) :: zpath 451 454 IF (LEN_TRIM(path) == 0) THEN … … 453 456 RETURN 454 457 ENDIF 455 zpath = basename_c(cstring(ADJUSTL(path))) 458 cpath = cstring(ADJUSTL(path)) 459 zpath = basename_c(cpath) 456 460 IF (.NOT.C_ASSOCIATED(zpath)) THEN 457 461 opath = "" … … 472 476 CHARACTER(len=:), ALLOCATABLE :: opath 473 477 !! The absolute of the path or an empty string if method fails 478 CHARACTER(len=:), ALLOCATABLE :: cpath 474 479 TYPE(C_PTR) :: zpath 475 zpath = realpath_c(cstring(ADJUSTL(path))) 480 cpath = cstring(ADJUSTL(path)) 481 zpath = realpath_c(cpath) 476 482 IF (.NOT.C_ASSOCIATED(zpath)) THEN 477 483 opath = "" … … 490 496 reldir !! A directory path from which output should be relative to 491 497 CHARACTER(len=:), ALLOCATABLE :: res !! An allocated string with the resulting path 498 CHARACTER(len=:), ALLOCATABLE :: cpath1,cpath2 492 499 TYPE(C_PTR) :: zpath 493 zpath = relpath_c(cstring(ADJUSTL(path)),cstring(ADJUSTL(reldir))) 500 cpath1 = cstring(ADJUSTL(path)) 501 cpath2 = cstring(ADJUSTL(reldir)) 502 zpath = relpath_c(cpath1,cpath2) 494 503 IF (.NOT.C_ASSOCIATED(zpath)) THEN 495 504 res = TRIM(ADJUSTL(path)) … … 520 529 CHARACTER(len=*), INTENT(in) :: output !! Output file path destination. 521 530 LOGICAL :: ret !! True on success, false otherwise. 531 CHARACTER(len=:), ALLOCATABLE :: cpath1,cpath2 532 522 533 IF (LEN_TRIM(input) == 0 .OR. LEN_TRIM(output) == 0 .OR. input == output) THEN 523 534 ret = .false. 524 535 ELSE 525 ret = INT(copy_c(cstring(ADJUSTL(output)),cstring(ADJUSTL(input)))) == 0 536 cpath1 = cstring(ADJUSTL(output)) 537 cpath2 = cstring(ADJUSTL(input)) 538 ret = INT(copy_c(cpath1,cpath2)) == 0 526 539 ENDIF 527 540 RETURN … … 532 545 CHARACTER(len=*), INTENT(in) :: path !! A string with the (valid) file path to delete 533 546 LOGICAL :: ret !! True on success, false otherwise. 547 CHARACTER(len=:), ALLOCATABLE :: cpath 534 548 IF (LEN_TRIM(path) == 0) THEN 535 549 ret = .false. 536 550 ELSE 537 ret = INT(remove_c(cstring(ADJUSTL(path)))) == 0 551 cpath = cstring(ADJUSTL(path)) 552 ret = INT(remove_c(cpath)) == 0 538 553 ENDIF 539 554 RETURN … … 545 560 new !! A string with the new name of the path 546 561 LOGICAL :: ret !! True on success, false otherwise. 562 CHARACTER(len=:), ALLOCATABLE :: cpath1,cpath2 547 563 IF (LEN_TRIM(old) == 0.OR.LEN_TRIM(new) == 0) THEN 548 564 ret = .false. 549 565 ELSE 550 ret = INT(rename_c(cstring(ADJUSTL(old)),cstring(ADJUSTL(new)))) == 0 566 cpath1 = cstring(ADJUSTL(old)) 567 cpath2 = cstring(ADJUSTL(new)) 568 ret = INT(rename_c(cpath1,cpath2)) == 0 551 569 ENDIF 552 570 RETURN … … 559 577 LOGICAL :: ret !! True on success, false otherwise. 560 578 INTEGER(kind=C_INT) :: zmode 579 CHARACTER(len=:), ALLOCATABLE :: cpath 561 580 IF (LEN_TRIM(path) == 0) THEN 562 581 ret = .false. 563 582 ELSE 564 583 zmode = INT(oct_2_dec(mode),kind=C_INT) 565 ret = INT(chmod_c(cstring(ADJUSTL(path)), zmode)) == 0 584 cpath = cstring(ADJUSTL(path)) 585 ret = INT(chmod_c(cpath, zmode)) == 0 566 586 ENDIF 567 587 RETURN … … 572 592 CHARACTER(len=*), INTENT(in) :: path !! Path of the new working directory 573 593 LOGICAL :: ret !! True on success, false otherwise. 594 CHARACTER(len=:), ALLOCATABLE :: cpath 574 595 IF (LEN_TRIM(path) == 0) THEN 575 596 ret = .false. 576 597 ELSE 577 ret = INT(chdir_c(cstring(ADJUSTL(path)))) == 0 598 cpath = cstring(ADJUSTL(path)) 599 ret = INT(chdir_c(cpath)) == 0 578 600 ENDIF 579 601 RETURN … … 595 617 INTEGER :: zmode 596 618 LOGICAL :: zperm 619 CHARACTER(len=:), ALLOCATABLE :: cpath 620 597 621 IF (LEN_TRIM(path) == 0) THEN 598 622 ret = .false. … … 605 629 zmode = oct_2_dec(mode) 606 630 ENDIF 631 cpath = cstring(ADJUSTL(path)) 607 632 zperm = .false. ; IF (PRESENT(permissive)) zperm = permissive 608 633 IF (zperm) THEN 609 ret = INT(mkdirp_c(c string(ADJUSTL(path)),INT(zmode,kind=C_INT))) == 0634 ret = INT(mkdirp_c(cpath,INT(zmode,kind=C_INT))) == 0 610 635 ELSE 611 ret = INT(mkdir_c(c string(ADJUSTL(path)),INT(zmode,kind=C_INT))) == 0636 ret = INT(mkdir_c(cpath,INT(zmode,kind=C_INT))) == 0 612 637 ENDIF 613 638 ENDIF … … 627 652 !! True on success, false otherwise. 628 653 LOGICAL :: zforce 654 CHARACTER(len=:), ALLOCATABLE :: cpath 629 655 IF (LEN_TRIM(path) == 0) THEN 630 656 ret = .false. 631 657 ELSE 632 658 zforce = .false. ; IF (PRESENT(forced)) zforce = forced 659 cpath = cstring(ADJUSTL(path)) 633 660 IF (.NOT.zforce) THEN 634 ret = INT(rmdir_c(c string(ADJUSTL(path)))) == 0661 ret = INT(rmdir_c(cpath)) == 0 635 662 ELSE 636 ret = INT(rmdirf_c(c string(ADJUSTL(path)))) == 0663 ret = INT(rmdirf_c(cpath)) == 0 637 664 ENDIF 638 665 ENDIF … … 668 695 INTEGER(kind=c_long) :: f 669 696 CHARACTER(len=20,kind=C_CHAR) :: ta,tm,tc 697 CHARACTER(len=:), ALLOCATABLE :: cpath 670 698 IF (LEN_TRIM(path) == 0) THEN 671 699 ret = .false.; RETURN … … 677 705 ! set default values 678 706 pe=-1 ; ty=-1 ; ud=-1 ; gd=-1 ; fs=-1 ; at="" ; mt="" ; ct="" 679 ret = INT(fstat_c(cstring(ADJUSTL(path)),p,l,t,u,g,f,ta,tm,tc)) == 0 707 cpath = cstring(ADJUSTL(path)) 708 ret = INT(fstat_c(cpath,p,l,t,u,g,f,ta,tm,tc)) == 0 680 709 IF (ret) THEN 681 710 pe=INT(p) ; ln=INT(l) ; ty=INT(t) ; ud=INT(u) ; gd=INT(g) … … 752 781 LOGICAL :: ret !! True on success, false otherwise. 753 782 INTEGER(kind=C_INT) :: zp 783 CHARACTER(len=:), ALLOCATABLE :: cpath 754 784 IF (LEN_TRIM(path) == 0) THEN 755 785 ret = .false. … … 757 787 zp = 0 ; IF (PRESENT(permission)) zp = INT(permission,kind=C_INT) 758 788 ! Defaults are set in the C function. 759 ret = INT(access_c(cstring(ADJUSTL(path)),zp)) == 0 789 cpath = cstring(ADJUSTL(path)) 790 ret = INT(access_c(cpath,zp)) == 0 760 791 ENDIF 761 792 RETURN … … 822 853 INTEGER :: zmd,zt,zp 823 854 CHARACTER(len=:), ALLOCATABLE :: b,e 855 CHARACTER(len=:), ALLOCATABLE :: cpath 824 856 ret = .false. 825 857 ! Checking for existence … … 856 888 ENDIF 857 889 zp = 0 ; IF(PRESENT(permissive)) THEN ; IF(permissive) zp=1 ; ENDIF 858 ret = INT(create_c(cstring(ADJUSTL(path)),INT(zmd,kind=C_INT),INT(zt,kind=C_INT),INT(zp,kind=C_INT))) == 0 890 891 cpath = cstring(ADJUSTL(path)) 892 ret = INT(create_c(cpath,INT(zmd,kind=C_INT),INT(zt,kind=C_INT),INT(zp,kind=C_INT))) == 0 859 893 RETURN 860 894 END FUNCTION fs_create
Note: See TracChangeset
for help on using the changeset viewer.