Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Read Error

JohnNichols
Valued Contributor III
431 Views

I just added this subroutine to my FE generator.  It reads the file, but the fifth line is not read causing an error.  ID(5,1) is incorrect. 

I checked the textfile in VEDIT, EXCEL and NOTEPAD++, it appears ok. 

I pulled the code out and put it into this console program and it still misses. 

No idea what I have done wrong. 

 

!  Console2.f90 
!
!  FUNCTIONS:
!  Console2 - Entry point of console application.
!

!****************************************************************************
!
!  PROGRAM: Console2
!
!  PURPOSE:  Entry point for the console application.
!
!****************************************************************************

    program Console2
    
    implicit none
   
    Integer M,N
    Integer ID(12,20), ID1(12),I,J
    
    M = 12
    N = 20
    open(25,file = "Element20.txt",STATUS= "OLD")
    do 1 I = 1, M
    
    read(25,*)ID1(I),(ID(I,j),j=1,N)
    
1 end do    
    
    print *, 'Hello World'

    end program Console2

 

Screenshot 2023-06-05 132140.png

5 Replies
JohnNichols
Valued Contributor III
423 Views

Turned out to be a simple error, lost a number 57 from the second entry on the 5th line.  Bit weird as it was a straight block copy.  

Anyway, somethings can be tricky.  

0 Kudos
MWind2
New Contributor III
407 Views
0 Kudos
JohnNichols
Valued Contributor III
389 Views

Actually yes.  

The error appears to show up from the 5th line, just the luck of the draw, checking is troublesome. 

Terrible blasted subroutine trying to draw 12 HEX20 FE objects for a rod in a block of concrete, FE does not do round well.  

 

 

0 Kudos
MWind2
New Contributor III
384 Views

If you do this a lot, such may help

 

using namespace System;
using namespace System::IO;
int main(array<System::String ^> ^args){
    //String^ sF = "d:\\c\\vs2022\\fConsole20\\Console20\\Element20err.txt";
    String^ sF = "d:\\c\\vs2022\\fConsole20\\Console20\\Element20.txt";
    StreamReader^ SR = gcnew StreamReader(sF);
    String^ sf = SR->ReadToEnd();
    SR->Close();
    array <Char>^ ac = gcnew array <Char>(1) { ('\n') };
    array<String^>^ as_n = sf->Split( ac,  StringSplitOptions::RemoveEmptyEntries);
    //array<String^>^ as_n = sf->Split(ac, StringSplitOptions::None);//catch "...,,..."
    array<int>^ ai = gcnew array<int>(as_n->Length);
    ac[0] = ',';
    for (int i = 0; i < as_n->Length; i++) {
        array <String^>^ asx = as_n[i]->Split(ac, StringSplitOptions::RemoveEmptyEntries);
        ai[i] = asx->Length;
    }
    return 0;
}
0 Kudos
JohnNichols
Valued Contributor III
351 Views

@MWind2 , thanks.   Yes, one can do something similar in C#.  I was just lazy, I should have realized there was a mistake in the numbers sooner, but it was a bulk copy from Stand7 to EXCEL and then into VS Editor, strange how one entry in the middle of the entries got lost.  

Screenshot 2023-06-05 161126.png

 

It is a 70 mm rod buried in concrete blocks.  It is easy to create beams with 100 mm cubes in Fortran and read them into Strand7, much better than any other method of quickly generating models that are not filled with random 3D polygons that one cannot check.  it has 119 nodes and 12 elements.  Now to add correct properties.  Luckily most engineers in metric use round 100 mm numbers.  

 

 

0 Kudos
Reply