Skip to content

Commit

Permalink
Updated notebooks with Quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
gmao-ckung committed May 13, 2024
1 parent 6b2c877 commit 91e5631
Show file tree
Hide file tree
Showing 5 changed files with 940 additions and 598 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## **Serialbox Tutorial : Extracting Data from Fortran**\n",
"## **Serialbox Tutorial : Serializing Fortran Data**\n",
"\n",
"This notebook will cover the basics on extracting data within a Fortran program using [Serialbox](https://gridtools.github.io/serialbox/).\n",
"\n",
Expand Down Expand Up @@ -53,22 +53,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"env: SERIALBOX_EXAMPLE_PATH=/home/ckung/Documents/Code/SMT-Nebulae-Tutorial/tutorial/Fortran_porting\n",
"env: SERIALBOX_INSTALL_PATH=/home/ckung/Documents/Code/SMT-Nebulae/sw_stack_path/install/serialbox/\n"
]
}
],
"source": [
"# Change SERIALBOX_EXAMPLE_PATH and SERIALBOX_INSTALL_PATH to appropriate paths\n",
"%env SERIALBOX_EXAMPLE_PATH=/home/ckung/Documents/Code/NDSL/examples/serialbox\n",
"%env SERIALBOX_EXAMPLE_PATH=/home/ckung/Documents/Code/SMT-Nebulae-Tutorial/tutorial/Fortran_porting\n",
"%env SERIALBOX_INSTALL_PATH=/home/ckung/Documents/Code/SMT-Nebulae/sw_stack_path/install/serialbox/"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "shellscript"
Expand Down Expand Up @@ -99,13 +108,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing testSerialBox.F90\n"
]
}
],
"source": [
"%%writefile testSerialBox.F90\n",
"\n",
Expand Down Expand Up @@ -181,7 +198,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"vscode": {
"languageId": "shellscript"
Expand Down Expand Up @@ -217,13 +234,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing file testSerialBox.F90\n"
]
}
],
"source": [
"%%bash\n",
"\n",
Expand All @@ -247,13 +272,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 16\n",
"drwxrwxr-x 2 ckung ckung 4096 May 13 10:08 .\n",
"drwxrwxr-x 3 ckung ckung 4096 May 13 10:08 ..\n",
"-rw-rw-r-- 1 ckung ckung 5033 May 13 10:08 testSerialBox.F90\n"
]
}
],
"source": [
"%%bash\n",
"\n",
Expand Down Expand Up @@ -284,7 +320,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"vscode": {
"languageId": "shellscript"
Expand Down Expand Up @@ -317,13 +353,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" sum(Qin_out) = 58.7446289 \n",
" sum(MASS) = 62.1698570 \n",
" >>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<\n",
" >>> WARNING: SERIALIZATION IS ON <<<\n",
" >>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<\n",
" sum(Qin_out) = 58.7851906 \n",
" sum(FILLQ_out) = 0.252184689 \n"
]
}
],
"source": [
"%%bash\n",
"\n",
Expand All @@ -340,13 +390,33 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 1028\n",
"drwxrwxr-x 2 ckung ckung 4096 May 13 10:08 .\n",
"drwxrwxr-x 3 ckung ckung 4096 May 13 10:08 ..\n",
"-rw-rw-r-- 1 ckung ckung 872 May 13 10:08 ArchiveMetaData-FILLQ2ZERO_InOut.json\n",
"-rw-rw-r-- 1 ckung ckung 100 May 13 10:08 FILLQ2ZERO_InOut_fq_in.dat\n",
"-rw-rw-r-- 1 ckung ckung 100 May 13 10:08 FILLQ2ZERO_InOut_fq_out.dat\n",
"-rw-rw-r-- 1 ckung ckung 500 May 13 10:08 FILLQ2ZERO_InOut_m_in.dat\n",
"-rw-rw-r-- 1 ckung ckung 500 May 13 10:08 FILLQ2ZERO_InOut_m_out.dat\n",
"-rw-rw-r-- 1 ckung ckung 500 May 13 10:08 FILLQ2ZERO_InOut_q_in.dat\n",
"-rw-rw-r-- 1 ckung ckung 500 May 13 10:08 FILLQ2ZERO_InOut_q_out.dat\n",
"-rw-rw-r-- 1 ckung ckung 7157 May 13 10:08 MetaData-FILLQ2ZERO_InOut.json\n",
"-rwxrwxr-x 1 ckung ckung 997608 May 13 10:08 testSerialBox.bin\n",
"-rw-rw-r-- 1 ckung ckung 5033 May 13 10:08 testSerialBox.F90\n"
]
}
],
"source": [
"%%bash\n",
"\n",
Expand All @@ -373,7 +443,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {
"vscode": {
"languageId": "shellscript"
Expand All @@ -395,13 +465,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing testSerialBox_ts.F90\n"
]
}
],
"source": [
"%%writefile testSerialBox_ts.F90\n",
"\n",
Expand Down Expand Up @@ -482,13 +560,57 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing file testSerialBox_ts.F90\n",
" >>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<\n",
" >>> WARNING: SERIALIZATION IS ON <<<\n",
" >>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<\n",
" sum(Qin_out) = 61.9121895 \n",
" sum(MASS) = 59.9121780 \n",
" sum(Qin_out) = 56.1568756 \n",
" sum(MASS) = 64.7800751 \n",
" sum(Qin_out) = 61.0407639 \n",
" sum(MASS) = 63.4687958 \n",
" sum(Qin_out) = 58.9772873 \n",
" sum(MASS) = 62.4764175 \n",
" sum(Qin_out) = 62.8103752 \n",
" sum(MASS) = 63.0623398 \n",
" sum(Qin_out) = 64.0034027 \n",
" sum(MASS) = 59.7669296 \n",
" sum(Qin_out) = 66.0840454 \n",
" sum(MASS) = 58.6753502 \n",
" sum(Qin_out) = 60.5121956 \n",
" sum(MASS) = 62.7025185 \n",
" sum(Qin_out) = 65.6868591 \n",
" sum(MASS) = 70.1329956 \n",
" sum(Qin_out) = 60.6698227 \n",
" sum(MASS) = 63.8359032 \n",
"total 1052\n",
"drwxrwxr-x 2 ckung ckung 4096 May 13 10:08 .\n",
"drwxrwxr-x 3 ckung ckung 4096 May 13 10:08 ..\n",
"-rw-rw-r-- 1 ckung ckung 6457 May 13 10:08 ArchiveMetaData-FILLQ2ZERO_InOut.json\n",
"-rw-rw-r-- 1 ckung ckung 1000 May 13 10:08 FILLQ2ZERO_InOut_fq_in.dat\n",
"-rw-rw-r-- 1 ckung ckung 1000 May 13 10:08 FILLQ2ZERO_InOut_fq_out.dat\n",
"-rw-rw-r-- 1 ckung ckung 5000 May 13 10:08 FILLQ2ZERO_InOut_m_in.dat\n",
"-rw-rw-r-- 1 ckung ckung 5000 May 13 10:08 FILLQ2ZERO_InOut_m_out.dat\n",
"-rw-rw-r-- 1 ckung ckung 5000 May 13 10:08 FILLQ2ZERO_InOut_q_in.dat\n",
"-rw-rw-r-- 1 ckung ckung 5000 May 13 10:08 FILLQ2ZERO_InOut_q_out.dat\n",
"-rw-rw-r-- 1 ckung ckung 9456 May 13 10:08 MetaData-FILLQ2ZERO_InOut.json\n",
"-rwxrwxr-x 1 ckung ckung 997648 May 13 10:08 testSerialBox_ts.bin\n",
"-rw-rw-r-- 1 ckung ckung 5117 May 13 10:08 testSerialBox_ts.F90\n"
]
}
],
"source": [
"%%bash\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sum of Qin_out = 58.74463748931885\n",
"Sum of mass = 62.169867515563965\n",
"Sum of fq_out = 0.0\n"
]
}
],
"source": [
"import sys\n",
"# Appends the Serialbox python path to PYTHONPATH. If needed, change to appropriate path containing serialbox installation\n",
Expand Down Expand Up @@ -75,9 +85,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sum of Qin_out = 58.78519535064697\n",
"Sum of fq_out = 0.25218469463288784\n",
"True\n",
"True\n"
]
}
],
"source": [
"def fillq2zero1(Q, MASS, FILLQ):\n",
" IM = Q.shape[0]\n",
Expand Down Expand Up @@ -121,9 +142,46 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Current savepoint = sp1 {\"timestep\": 1}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 2}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 3}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 4}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 5}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 6}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 7}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 8}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 9}\n",
"True\n",
"True\n",
"Current savepoint = sp1 {\"timestep\": 10}\n",
"True\n",
"True\n"
]
}
],
"source": [
"# If needed, change the path in second parameter of ser.Serializer to appropriate path that contains Fortran data via Serialbox from 01.ipynb\n",
"serializer = ser.Serializer(ser.OpenModeKind.Read,\"./Fortran_ts/sb/\",\"FILLQ2ZERO_InOut\")\n",
Expand Down
Loading

0 comments on commit 91e5631

Please sign in to comment.