模块和传统的Fortran 77代码

时间:2015-07-02 20:10:45

标签: compiler-errors fortran fortran90 gfortran

我有一套来自NETLIB网站的blas / lapack函数。我想将这些函数放在Fortran模块中。我的其余代码是在Fortran 90中。所以我要这样做:

public class GroupActivity extends ActionBarActivity {
Context context;
RecyclerView groupRecyclerView;
GroupAdapter groupAdapter;
private Toolbar toolbar;

public List<Group> list;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group);

    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayShowHomeEnabled(true);

    getSupportActionBar().setTitle("POLICE APP");

    context = this;
    Helpers.setTabs(context, this, 2);

    groupRecyclerView = (RecyclerView) findViewById(R.id.ui_Groups_RecyclerView);
    this.GetData();
    groupAdapter = new GroupAdapter(this, list);

    groupRecyclerView.setAdapter(groupAdapter);
    groupRecyclerView.setLayoutManager(new LinearLayoutManager(this));


}

public void addGroups(List<Group> grps) {

    this.list = grps;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_group, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

public void GetData() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Group");

    query.findInBackground(new FindCallback<ParseObject>() {
        List<Group> sList = new ArrayList<Group>();

        public void done(List<ParseObject> groupList, ParseException e) {
            if (e == null) {
                for (int i = 0; i < groupList.size(); i++) {
                    try {
                        Group grp1 = new Group("1", groupList.get(i).getString("Name"), " Turn in your time sheets", "d");
                        sList.add(grp1);
                        Log.d("group1:", "inserted the group");
                    } catch (Exception c) {
                        c.printStackTrace();
                        Log.d("group1:", c.getMessage().toString());
                    }
                }
                addGroups(sList);
                Log.d("groups1", "Retrieved " + groupList.size() + " groups");
            } else {
                Log.d("groups1", "Error: " + e.getMessage());
            }


        }
    });

}
}

当我使用

编译时
module modname
contains


double precision function ddot(n,dx,incx,dy,incy)
.
.
.
end function 


subroutine dpofa(a,lda,n,info) 
.
.
        double precision ddot
.
end subroutine dopfa
end module

我收到以下错误:

  

/tmp/ccC2EUFj.o:在函数gfortran modname.f90 ddot _'

我忽略了关于__temp_MOD_dpofa': temp.f90:(.text+0x11c): undefined reference to的错误,我意识到这是因为我没有程序..文件中的结束程序语句。

但是,如果我删除了Undefined reference to mainmodule modnamecontains的行,则编译器会编译而没有任何问题。

可能是什么问题?

1 个答案:

答案 0 :(得分:3)

在非模块方法中,您有许多外部函数和子例程。也就是说,如果这些是在模块外部定义的,那么一个过程对另一个过程没有任何线索。您可以使用声明语句dpofa告诉子例程ddot有关函数double precision ddot的信息。编译器将该名称伪装成ddot_(有关详细信息,请参见其他地方),并且还会破坏您所拥有的真实函数的名称。链接器在需要时将一个符号解析为另一个符号。

当您使用模块时,您仍然拥有此外部函数声明,但现在您在同一模块中的实际功能不再是外部的。相反,有一个模块程序被修改为__temp_MOD_ddot之类的东西。您不再创建具有错位名称ddot_的函数。

您可能会在ddot中引用dpofa函数,但在模块版本中会引用未定义的符号ddot_

您希望删除现在在同一模块中定义但不再是外部的那些函数的函数声明。

相关问题