zoukankan      html  css  js  c++  java
  • Fortran数组、函数--xdd

    1.数组的声明

    integer,parameter::num=5
    integer::student(num)
    或者 integer a(10)
    或者 integer a(10,6)
    student(1)=5    !第一个元素值为5,默认索引值从1开始
    赋初值
    integer A(5)
    data /1,2,3,4,5/
    data /5*0/     !5个0
    data(A(i),i=2,4,1)  /2,2,3/        !隐do循环

    2.数组操作

    3.where...elsewhere...endwhere 《fortran95 程序设计》彭国伦 p138

    将数组中符合某一特征(比如小于3)的元素重新形成一个数组

    4.声明一个可变大小的数组

    integer,allocatable::A(:)    !A是一个可变大小的一维数组
    write(*,*)"how many syudents"
    read(*,*)num
    allocate(a(num))              !配置内存空间 


    5.函数

    5.1子程序subroutine

    program ex
    ...
    call subroutine sub1()
    ...
    end program
    
    subroutine sub1()
    ...
    end subroutine sub1
    
    子程序中遇到return即返回到调用处,如在子程序最后可以省略

    5.2全局变量common

    common a,b
    a=1
    b=2

    转载仅为学习,不会商用。
    欢迎转载原创,附文链接。
  • 相关阅读:
    poj 1026 Cipher
    python中的global
    基于DL的文本分类综述
    K近邻算法学习
    聚类评价指标学习
    pytorch自动求导学习
    反向传播的推导
    二分搜索常用【转载】
    《Attention is all you need》论文学习
    5-28日|5-30日
  • 原文地址:https://www.cnblogs.com/xdd1997/p/11563504.html
Copyright © 2011-2022 走看看