调用函数或子程序

时间:2019-08-26 21:26:05

标签: fortran gfortran

我对于fortran还是很陌生,我正在尝试执行一个函数/子例程,但是却遇到错误workbench.action.toggleEditorWidths

这是我的代码:

import React, { useState, useEffect } from 'react';
import * as firebase from "firebase/app";
import "firebase/auth";

declare global {
  interface Window { recaptchaVerifier: any; }
}

const PhoneVerification = () => {
  const firebaseConfig = {
    apiKey: "...",
    authDomain: "...",
    databaseURL: "...",
    projectId: "...",
    storageBucket: "...",
    messagingSenderId: "...",
    appId: "..."
  };
  useEffect(()=> {
    if (!firebase.apps.length) firebase.initializeApp(firebaseConfig);

    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', {
      'size': 'normal',
      'callback': function(response: any) {
        // reCAPTCHA solved, allow signInWithPhoneNumber.
        // ...
        console.log('callback executed');
        console.log(response);
      },
      'expired-callback': function() {
        // Response expired. Ask user to solve reCAPTCHA again.
        // ...
        console.log('expired');
      }
    });
  })

  return (
    <div id="main">
      main
      <div id="recaptcha-container">

      </div>
    </div>

)};

export default PhoneVerification;

但是当我执行它时,我得到:

Explicit interface required

有什么想法吗?我尝试将其包装到模块中,但是当我在程序中使用“使用模块名”时,它给了我一个错误(尝试从具有相同名称的文件中读取它)

1 个答案:

答案 0 :(得分:1)

如果要与subroutine一起使用,请将其包装到模块中并使其成为CALL

module printmat_module
contains
  subroutine printmat(m)
    integer, dimension(:,:) :: m
    integer :: row,col
    row = size(m,1)
    col = size(m,2)
    do k=1,row
       print *, m(k,1:col)
    enddo
  end subroutine printmat
end module printmat_module

program test
  use printmat_module
  integer, dimension(5, 5) :: mat
  integer :: i,j
  do i=1,5
     do j=1,5
        mat(j,i) = real(i)/real(j)
     enddo
  enddo
  call printmat(mat)
end program test

或者,您也可以执行编译器告诉您的操作,并向program添加一个显式接口。

subroutine printmat(m)
  integer, dimension(:,:) :: m
  integer :: row,col
  row = size(m,1)
  col = size(m,2)
  do k=1,row
     print *, m(k,1:col)
  enddo
end subroutine printmat

program test
  interface
     subroutine printmat(m)
       integer, dimension(:,:) :: m
     end subroutine printmat
  end interface
  integer, dimension(5, 5) :: mat
  integer :: i,j
  do i=1,5
     do j=1,5
        mat(j,i) = real(i)/real(j)
     enddo
  enddo
  call printmat(mat)
end program test