# Gfortran lowercasing all symbols

**URL:** <https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941>\
**Category:** GNU\
**Created:** [April 30, 2024, 6:17pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941 "2024-04-30T18:17:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamestpp](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jamestpp](https://fortran-lang.discourse.group/u/jamestpp)\
**Post date:** [April 30, 2024, 6:17pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/1 "2024-04-30T18:17:14Z")

</div>

Hello community

When I compiled the code using gfortran it generates all symbols in lowercase. in ifx/ifort there is a flag to change this behavior (-names uppercase). What is the best way to make this happen in gfortran? This is a problem when we are dealing in a mixed language projects.

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [April 30, 2024, 6:33pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/2 "2024-04-30T18:33:04Z")

</div>

If you have only a relatively few name conflicts, then you might consider using the `bind()` clause. This allows you to define the external symbol however you want for that subprogram. To be useful, this should be done only for module subroutines which have automatic explicit interfaces, otherwise you will need to define also interface blocks wherever the routines are referenced.

---

<div class="post-metadata">

**Author:** ![jamestpp](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jamestpp](https://fortran-lang.discourse.group/u/jamestpp)\
**Post date:** [April 30, 2024, 7:00pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/3 "2024-04-30T19:00:32Z")

</div>

Our code base is huge and manually making these changes are almost impossible. We maintain forks of LAPACK, BLAS and Sparse utility 🙂

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [April 30, 2024, 7:35pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/4 "2024-04-30T19:35:47Z")

</div>

There is no command-line option in (modern) GNU Fortran anymore, [like g77 had it](https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Case-Sensitivity.html).

---

<div class="post-metadata">

**Author:** ![jamestpp](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jamestpp](https://fortran-lang.discourse.group/u/jamestpp)\
**Post date:** [April 30, 2024, 7:43pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/5 "2024-04-30T19:43:54Z")

</div>

I have created a function in Makefile to capitalize symbols but the problem is it capitalize the library functions as well (eg: pow) and the linker will complain that it couldn’t find such symbols.

# Define a function for capitalizing symbols

define capitalize\_symbols  
@nm $(1) | grep ’ [UT] ’ | while read -r line; do   
symbol=$$(echo “$$line” | awk ‘{print $$NF}’);   
if [! -z “$$symbol”]; then   
upper\_symbol=$$(echo “$$symbol” | tr ‘[:lower:]’ ‘[:upper:]’);   
objcopy --redefine-sym $$symbol=$$upper\_symbol $(1);   
fi   
done  
endef

This sort of rigid stuff make it so hard to compile for ARM64 ☹

I know Intel is not going to support ARM64.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [April 30, 2024, 9:07pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/6 "2024-04-30T21:07:17Z")

</div>

> [@interkosmos](#):
>
> There is no command-line option in (modern) GNU Fortran anymore, [like g77 had it](https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Case-Sensitivity.html).

How you could not quote the text at your link 🙂 ? Below “GNU Fortran” refers to g77.

> GNU Fortran offers the programmer way too much flexibility in deciding how source files are to be treated vis-a-vis uppercase and lowercase characters. There are 66 useful settings that affect case sensitivity, plus 10 settings that are nearly useless, with the remaining 116 settings being either redundant or useless.

---

<div class="post-metadata">

**Author:** ![themos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/themos/32/521_2.png) [@themos](https://fortran-lang.discourse.group/u/themos)\
**Post date:** [May 1, 2024, 9:24am UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/7 "2024-05-01T09:24:06Z")

</div>

`nm --extern-only --defined-only`

---

<div class="post-metadata">

**Author:** ![jamestpp](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jamestpp](https://fortran-lang.discourse.group/u/jamestpp)\
**Post date:** [May 1, 2024, 4:53pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/8 "2024-05-01T16:53:26Z")

</div>

Finally I could solve this problem!!

An updated function to capitalize the symbols.

Compiler flags used _-std=legacy -g -cpp -fPIC -Werror_

```auto
# Define a function for capitalizing symbols
define capitalize_symbols
	@echo "Processing file: $(1)"
	@nm $(1) -j -g | while read -r symbol; do \
		if echo "$$symbol" | grep -q '_$$' && [! -z "$$symbol"]; then \
			modified_symbol=$$(echo "$$symbol" | sed 's/_$$//' | tr '[:lower:]' '[:upper:]'); \
			echo "Capitalizing and modifying $$symbol to $$modified_symbol"; \
			objcopy --redefine-sym $$symbol=$$modified_symbol $(1); \
		fi \
	done
endef

```

---

<div class="post-metadata">

**Author:** ![wspector](https://avatars.discourse-cdn.com/v4/letter/w/47e85d/32.png) [@wspector](https://fortran-lang.discourse.group/u/wspector)\
**Post date:** [May 1, 2024, 5:35pm UTC](https://fortran-lang.discourse.group/t/gfortran-lowercasing-all-symbols/7941/9 "2024-05-01T17:35:44Z")

</div>

You might consider going the other direction.

The gfortran compiler, like most Fortran compilers nowadays, follows the original AT&T Unix f77 compiler convention from the 1970s. That is, external names are lower case and have a single trailing underscore. (See: [http://squoze.net/UNIX/v7/files/doc/21\_f77.pdf](http://squoze.net/UNIX/v7/files/doc/21_f77.pdf))

There used to be a number of compilers with other conventions - some inherited from non-Unix systems that didn’t handle lower case well. But these seem to have largely fallen by the wayside. C pretty much forced the issue 30+ years ago.
