- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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' )
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
As a workaround, I used '"~/a.txt"' instead of '~/a.txt'.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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' )
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Thank you very much IanH! It works!
I did not notice such option for namelist write.

- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora