- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi, I am not a Fortran expert by any means but have been searching for a solution to a particular problem that I'm having and have not had any success in finding a solution. Any help or feedback would be much appreciated.
Problem: character string has gone after ~ in namelist read
! test_nml.f90
program test_nml
implicit none
type t_ty
character(10) :: a = '~/a.txt'
character(10) :: b = '~/b.txt'
end type
integer u
type(t_ty) t
namelist /mynml/ t
print mynml
open ( u, file = 'test.nml' )
write ( u, nml = mynml )
close ( u )
t%a = 'NA'
t%b = 'NA'
open ( u, file = 'test.nml' )
read ( u, nml = mynml )
close ( u )
print mynml
end program
!=============================
! Outputs
!-------------------------------------------
! ifx test_nml.f90 && ./a.out
! &MYNML
! T%A = ~/a.txt ,
! T%B = ~/b.txt
! /
! &MYNML
! T%A = ~ , (<- character string has gone after ~)
! T%B = NA (<- Not available)
! /
!
!-----------------------------------------
! ifx --version
! ifx (IFX) 2024.2.1 20240711
!-----------------------------------------
! OS:
! Ubuntu 24.04.1 LTS
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Just as for list directed input, a bare slash terminates namelist input there and then.
Character objects need to be delimited to generally survive being written and read by namelist statements.
write ( u, nml = mynml, delim = 'quote' )
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
As a workaround, I used '"~/a.txt"' instead of '~/a.txt'.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Just as for list directed input, a bare slash terminates namelist input there and then.
Character objects need to be delimited to generally survive being written and read by namelist statements.
write ( u, nml = mynml, delim = 'quote' )
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thank you very much IanH! It works!
I did not notice such option for namelist write.
