CGPT2_1w_World: : CGPT2_1w_World ()
{
Pgrid=new double * [64800];
Tgrid=new double * [64800];
Qgrid=new double * [64800];
DTgrid=new double * [64800];
U=new double [64800].
The Hs=new double [64800];
Ahgrid=new double * [64800];
Awgrid=new double * [64800];
Lagrid=new double * [64800];
Tmgrid=new double * [64800];
for(int i=0; i<64800; I++)
{
Pgrid [I]=new double [5].
Tgrid [I]=new double [5].
Qgrid [I]=new double [5].
DTgrid [I]=new double [5].
Ahgrid [I]=new double [5].
Awgrid [I]=new double [5].
Lagrid [I]=new double [5].
Tmgrid [I]=new double [5].
}
}
CGPT2_1w_World: : ~ CGPT2_1w_World ()
{
for(int i=0; i<64800; I++)//the number of columns
{
The delete [] pgrid [I];
The delete [] Tgrid [I];
The delete [] Qgrid [I];
The delete [] dTgrid [I];
The delete [] ahgrid [I];
The delete [] awgrid [I];
The delete [] lagrid [I];
The delete [] Tmgrid [I];
}
The delete [] pgrid;
The delete [] Tgrid.
The delete [] Qgrid;
The delete [] dTgrid;
The delete [] u.
The delete [] the Hs;
The delete [] ahgrid;
The delete [] awgrid;
The delete [] lagrid;
The delete [] Tmgrid;
}
Int CGPT2_1w_World: : sign2 (double x)
{
If (x> 0)
return 1;
The else
return -1;
}
Void CGPT2_1w_World: : init_trop ()
{
QString filename=QFileDialog: : getOpenFileName (nullptr, "open", "E: \ \ gpt2_1wA_World TXT");
QTextCodec * codec=QTextCodec: : codecForName (" utf-8 ");
QFile file (filename);
if (! File. The open (QIODevice: : ReadOnly)) {
//failed to open the file
return;
}
Int n=0;
While (true)
{
Char STR [4096].
Qint64 lineLength=file. ReadLine (STR, sizeof (STR));
If (lineLength==1) {
break;
}
//char * STR=strLine. GetBufferSetLength (strLine. GetLength ());
Const char * d="";
Char * p=strtok (STR, d);
Double vel [44].
Int CNT=0;
While (p)
{
Vel [cnt++]=atof (p);
P=strtok (NULL, d);
}
for(int i=0; i<5; I++)
{
Pgrid [n] [I]=vel [I + 2];
Double temp=pgrid [n] [I];
Tgrid [n] [I]=vel [I + 7),
Qgrid [n] [I]=vel [I] + 12/1000;
DTgrid [n] [I]=vel [I + 17]/1000;
Ahgrid [n] [I]=vel [24] I +/1000;
Awgrid [n] [I]=vel [29] I +/1000;
Lagrid [n] [I]=vel + 34 [I];
Tmgrid [n] [I]=vel + 39 [I];
}
U=vel [n] [22].
The Hs [n]=vel [23].
n++;
//strLine ReleaseBuffer (strLine GetLength ());
}
File. The close ();
}
CodePudding user response:
QFileDialog: : the third parameter is the folder path of getOpenFileName method, should be a hint to find: E: \ \ gpt2_1wA_World TXT this folderCodePudding user response:
Are you sure this TXT in the path, you wrote the "E: \ \ gpt2_1wA_World TXT" to "E:/gpt2_1wA_World. TXT" have a look at,CodePudding user response:
You just to read the file content:That's fine directly
QFile file (" E: \ \ gpt2_1wA_World TXT ");
if (! File. The open (QIODevice: : ReadOnly)) {
//failed to open the file
return;
}
QDebug () & lt;