#include #include #include #include #include #include using namespace std; #include "ini.h" dats d; static const float zoff=1948.07; struct ini{ ini(){ { // initialize random numbers int size; ifstream inFile; inFile.open("rnd.txt", ifstream::in); vector rx; if(!inFile.fail()){ unsigned int a; unsigned long long b,c; while(inFile>>a>>b>>c) rx.push_back(a); if(rx.size()<1){ cerr<<"File rnd.txt did not contain valid data"< float dh, hdh, rdh, hmin; // step, 1/step, min and max depth ifstream inFile; bool flag=true; inFile.open("wv.dat", ifstream::in); vector wx, wy; if(!inFile.fail()){ float xa, ya, xo=0, yo=0; int num=0; while(inFile>>xa>>ya){ if(( xa<0 || 10 && ( xa<=xo || ya<=yo )){ flag=false; break; } wx.push_back(xa); wy.push_back(ya); xo=xa; yo=ya; num++; } if(xo!=1 || wx.size()<2) flag=false; inFile.close(); if(flag){ cerr<<"Loaded "< dp, be, ba, td; inFile.open("icemodel.par", ifstream::in); if(flag=!inFile.fail()){ if(flag) flag=(inFile >> a >> ae); if(flag) flag=(inFile >> k >> ke); if(flag) flag=(inFile >> A >> Ae); if(flag) flag=(inFile >> B >> Be); if(flag) flag=(inFile >> D >> De); if(flag) flag=(inFile >> E >> Ee); if(!flag) cerr << "File icemodel.par found, but is corrupt" << endl; inFile.close(); if(!flag) exit(1); } else{ cerr << "File icemodel.par was not found" << endl; exit(1); } inFile.open("icemodel.dat", ifstream::in); if(!inFile.fail()){ size=0; float dpa, bea, baa, tda; while(inFile >> dpa >> bea >> baa >> tda){ dp.push_back(dpa); be.push_back(bea); ba.push_back(baa); td.push_back(tda); size++; } inFile.close(); if(size<2){ cerr << "File icemodel.dat found, but is corrupt" << endl; exit(1); } } else{ cerr << "File icemodel.dat was not found" << endl; exit(1); } dh=dp[1]-dp[0]; if(dh<=0){ cerr << "Ice table does not use increasing depth spacing" << endl; exit(1); } for(int i=0; i0) if(fabsf(dp[i]-dp[i-1]-dh)>dh*xx){ cerr << "Ice table does not use uniform depth spacing" << endl; exit(1); } cerr<<"Loaded "<MAXLYS){ fprintf(stderr, "Error: too many layers (%d), truncating to %d\n", size, MAXLYS); size=MAXLYS; } hdh=dh/2; rdh=1/dh; hmin=zoff-dp[size-1]; g=0.8; { d.g=g; d.size=size; d.dh=dh; d.hdh=hdh; d.rdh=rdh; d.hmin=hmin; } int nfla; float wfla=405, fmin; for(int n=0; nz[i].sca=be[j]*l_a/(1-g); w->z[i].abs=(D*ba[j]+E)*l_k+ABl*(1+0.01*td[j]); if(w->z[i].sca<=0 || w->z[i].abs<=0){ cerr << "Invalid value of ice parameter, cannot proceed" << endl; exit(1); } } float wv=wva*1.e-3; float wv2=wv*wv; float wv3=wv*wv2; float wv4=wv*wv3; float np=1.55749-1.57988*wv+3.99993*wv2-4.68271*wv3+2.09354*wv4; float ng=np*(1+0.227106-0.954648*wv+1.42568*wv2-0.711832*wv3); float c=0.299792458; d.ocv=1/c; w->ocm=ng/c; w->coschr=1/np; w->sinchr=sqrt(1-w->coschr*w->coschr); } d.nfla=nfla; } { // initialize geometry ifstream inFile; inFile.open("geo-f2k", ifstream::in); vector oms; vector names; if(!inFile.fail()){ DOM dom; name n; string mbid; int om, str; unsigned long long omid; while(inFile>>mbid>>hex>>omid>>dec>>dom.r[0]>>dom.r[1]>>dom.r[2]>>str>>om) if(str>0 && om>=1 && om<=60){ dom.r[2]+=zoff; n.dom=om; n.str=str; oms.push_back(dom); names.push_back(n); } inFile.close(); } int gsize = oms.size(); if(gsize>MAXGEO){ fprintf(stderr, "Error: too many OMs (%d), truncating to %d\n", gsize, MAXGEO); gsize=MAXGEO; } d.oms = new DOM[gsize]; d.names = new name[gsize]; for(int n=0; n cells[cx][cy][cz]; for(int i=0; ich[m]) ch[m]=oms[n].r[m]; } for(int m=0; m<3; m++){ float diff=ch[m]-cl[m], s=R*(d.cn[m]-1); if(diff<2*s){ cerr<<"Error in cell["<=d.cn[m]){ cerr<<"Error in cell initialization"<