---
title: 编译gfortran提示Nonnegative width required in format string at (1)的解决方法
description: "通过gfortran对Makefile执行make编译时报“Error: Nonnegative width required in format string at (1)”错误，详细报错类似如下："
url: https://www.hikunpeng.com/document/detail/zh/kunpenggrf/trouble/kunpenggeneral_troublecase_048.html
sourcePath: /source/zh/kunpenggrf/trouble/kunpenggeneral_troublecase_048.html
indexId: 79e8da0c3537a3fab8a10a371d61205fa3eb66730f0ff72fa4470547950b604d65
---
# 编译gfortran提示Nonnegative width required in format string at (1)的解决方法

#### 问题现象描述

通过gfortran对Makefile执行make编译时报“Error: Nonnegative width required in format string at (1)”错误，详细报错类似如下：

```
test_MyFile.f:1156:51:
read( Test_OutputParamterVal(test_para, '(I)')
Error: Nonnegative width required in format string at (1)
```


#### 关键过程、根本原因分析

因为需要对字符指定非负的位宽，未指定情况下使用gfortran编译会报错。


#### 结论、解决方案及效果

1. 修改test_MyFile.f文件。
  将read( Test_OutputParamterVal(test_para, '(I)')修改为read( Test_OutputParamterVal(test_para, '(I5)')。

  对于动态位宽的字符（及定长位宽的字符）可以统一使用*替换，read和write都可以用*替换（*不带括号和引号）。 例如： 原写法：READ(test1,'(I)') 替换后写法：READ(test1,*)

2. 执行make即可正常编译通过。
