Calling Fortran lawyers:
```
integer :: isp
character(len=15), dimension(10) :: species_name
....
associate(spec_name => trim(species_name(isp)))
print *, spec_name
end associate
```
Even without the print statement, gfortran (11.3.0) gives me a SIGABRT at runtime here (though seemingly only if I have read from a namelist file before).
ifort seems happy (different machine).

Is the code legal? gfortran's associate limitations? Am I missing something? Text encoding?
#F90 #Fortran

@hattom hmmm, associating with the result of TRIM seems fishy, what about

print *,trim(spec_name)

@mennodeij

Switching from
```
do isp = 1,nspecies
associate(spec_name => trim(species_name(isp)))
print *, spec_name
end associate
enddo
```
to
```
do isp = 1,nspecies
associate(spec_name => species_name(isp))
print *, trim(spec_name)
end associate
enddo
```
solves the error, but gets rid of approximately 50% of the reason I wanted to use associate in the first place (simplifying strings).

@hattom glad that it’s solved; my experience is that strings and Fortran is always awkward, esp. compared to other languages like C++ or Python. Haven’t found a good solution I’m afraid…
@mennodeij I was still fairly sure it should be allowed. At least I am until convined otherwise.
I'd also like to know why the error goes away if I remove the namelist reading a few lines further up. Seems awfully suspicious.
@mennodeij Removing the associate entirely (not much point if I can't have the trim() there) was always going to fix it.
I'd just really like to know if this is forbidden by the standard, or an implementation issue.
@hattom Curious what Compiler Explorer shows for that code: https://godbolt.org/
Compiler Explorer

Compiler Explorer is an interactive online compiler which shows the assembly output of compiled C++, Rust, Go (and many more) code.

Compiler Explorer - Fortran (x86-64 gfortran 13.2)

! Type your code here, or load an example. subroutine test_assoc() implicit none integer :: isp character(len=64), dimension(5) :: species_name species_name = "dummy" do isp=1,5 associate(spec_name => trim(species_name(isp))) print *, spec_name end associate enddo end subroutine test_assoc