%
% DESCRIPTION: Program to create the Well Position GDF file in the Matlab format.
%
% [TimeZone] and [Description] have text format so the values give in ''


clear;clc;
[FormatName] = 'GDF';
[FormatVersion] = 2.1;
[CRS] = 'n/a'%['EPSG:' num2str(input('[CRS] EPSG code (just number) = '))];
[TimeZone] = 'UTC';%input('TimeZone (char) = ');
[Description] = 'Description of dataset'; %input('Description of data (char) = ');

[FieldDescription] = {
    'Well_codename','Code name of the well'
    'Lat','Latitude of the well'
    'Long','Longitude of the well'
    
    'Depth','Depth of the well'
    'Operator_name','Well operator name'
    'Well_number','Well number'
    'Lease_name','Lease name'
    'Year_drilling','Year of drilling'
    'Well_type','Type of well'
    'District','District'
    'Status','Well status'
    'Status_code','Well status code'
    'Section','Section'
    'Township','Township'
    'Range','Range'
    'Base_meridian','Base meridian'
    'Source_code','Source code'
    'Well_name','Well name'
    'Formation_code','Code of the formation'
    'Formation_name','Name of the formation'
    'Formation_bottom_depth','Depth of the bottom of the formation'
    'Formation_top_depth','Depth of the top of the formation'
    };
[FieldType] = {
    'Well_codename',3
    'Lat',124
    'Long',134
    
    'Depth',34
    'Operator_name',3
    'Well_number',3
    'Lease_name',3
    'Year_drilling',2
    'Well_type',3
    'District',2
    'Status',3
    'Status_code',3
    'Section',2
    'Township',3
    'Range',3
    'Base_meridian',3
    'Source_code',3
    'Well_name',3
    'Formation_code',3
    'Formation_name',3
    'Formation_bottom_depth',24
    'Formation_top_depth',24
    };
[FieldUnit] = {
    'Well_codename','char'
    'Lat','deg'
    'Long','deg'
    
    'Depth','km'
    'Operator_name','char'
    'Well_number','char'
    'Lease_name','char'
    'Year_drilling','year'
    'Well_type','char'
    'District','dimensionless'
    'Status','char'
    'Status_code','char'
    'Section','dimensionless'
    'Township','char'
    'Range','char'
    'Base_meridian','char'
    'Source_code','char'
    'Well_name','char'
    'Formation_code','char'
    'Formation_name','char'
    'Formation_bottom_depth','km'
    'Formation_top_depth','km'
    };
[d] = struct();

k=1
d(k).Well_codename=[];
d(k).Lat=[];
d(k).Long=[];

d(k).Depth=[];
d(k).Operator_name=[];
d(k).Well_number=[];
d(k).Lease_name=[];
d(k).Year_drilling=[];
d(k).Well_type=[];
d(k).District=[];
d(k).Status=[];
d(k).Status_code=[];
d(k).Section=[];
d(k).Township=[];
d(k).Range=[];
d(k).Base_meridian=[];
d(k).Source_code=[];
d(k).Well_name=[];
d(k).Formation_code=[];
d(k).Formation_name=[];
d(k).Formation_bottom_depth=[];
d(k).Formation_top_depth=[];


k=2
d(k).Well_codename=[];
d(k).Lat=[];
d(k).Long=[];

d(k).Depth=[];
d(k).Operator_name=[];
d(k).Well_number=[];
d(k).Lease_name=[];
d(k).Year_drilling=[];
d(k).Well_type=[];
d(k).District=[];
d(k).Status=[];
d(k).Status_code=[];
d(k).Section=[];
d(k).Township=[];
d(k).Range=[];
d(k).Base_meridian=[];
d(k).Source_code=[];
d(k).Well_name=[];
d(k).Formation_code=[];
d(k).Formation_name=[];
d(k).Formation_bottom_depth=[];
d(k).Formation_top_depth=[];

k=3
d(k).Well_codename=[];
d(k).Lat=[];
d(k).Long=[];

d(k).Depth=[];
d(k).Operator_name=[];
d(k).Well_number=[];
d(k).Lease_name=[];
d(k).Year_drilling=[];
d(k).Well_type=[];
d(k).District=[];
d(k).Status=[];
d(k).Status_code=[];
d(k).Section=[];
d(k).Township=[];
d(k).Range=[];
d(k).Base_meridian=[];
d(k).Source_code=[];
d(k).Well_name=[];
d(k).Formation_code=[];
d(k).Formation_name=[];
d(k).Formation_bottom_depth=[];
d(k).Formation_top_depth=[];

k=4
d(k).Well_codename=[];
d(k).Lat=[];
d(k).Long=[];

d(k).Depth=[];
d(k).Operator_name=[];
d(k).Well_number=[];
d(k).Lease_name=[];
d(k).Year_drilling=[];
d(k).Well_type=[];
d(k).District=[];
d(k).Status=[];
d(k).Status_code=[];
d(k).Section=[];
d(k).Township=[];
d(k).Range=[];
d(k).Base_meridian=[];
d(k).Source_code=[];
d(k).Well_name=[];
d(k).Formation_code=[];
d(k).Formation_name=[];
d(k).Formation_bottom_depth=[];
d(k).Formation_top_depth=[];

k=5
d(k).Well_codename=[];
d(k).Lat=[];
d(k).Long=[];

d(k).Depth=[];
d(k).Operator_name=[];
d(k).Well_number=[];
d(k).Lease_name=[];
d(k).Year_drilling=[];
d(k).Well_type=[];
d(k).District=[];
d(k).Status=[];
d(k).Status_code=[];
d(k).Section=[];
d(k).Township=[];
d(k).Range=[];
d(k).Base_meridian=[];
d(k).Source_code=[];
d(k).Well_name=[];
d(k).Formation_code=[];
d(k).Formation_name=[];
d(k).Formation_bottom_depth=[];
d(k).Formation_top_depth=[];


clear k 
save('GDF_EpisodeName_Well_Position_example.mat')
