Create a github repository under github.com/annefou
https://github.com/annefou/hackathon-south-africa
Open cocalc.com and create a terminal
console.cloud.google.com seems to be free and we can run
Try out to update the console:
Get the code:
Then compile and run the code:
And to run
You may need to install additional packages (on ubuntu):
And then
Let's try an existing Fortran test with pfUnit:
https://coderefinery.github.io/testing/test-design/
We create test-cr.f90 (use any of your favourite editor vi, nano, etc.) with:
Compile:
Action: Anne to create a makefile to test the code (and that can be reused for interpolate_sub.f90)
What kind of tests should we do?
Plan:
Create mybinder environment & badge snippet:
test mybinder to create test environment
Open your web browser and go to https://github.com/annefou/hackathon-south-africa
When compiling with mybinder terminal/console, we use $FC
environment variable to compile (because the compiler name is weird/difficult to remember /srv/conda/envs/notebook/bin/x86_64-conda-linux-gnu-gfortran
)
There is a very nice repository with examples on how to run/use pFUNIT:
https://github.com/Goddard-Fortran-Ecosystem/pFUnit_demos
We will now test one example in Trivial folder:
Edit the Makefile and add -lgomp
in my_tests_OTHER_LIBRARIES
:
And then:
First we need to set pFUNIT environment variable:
Then we can compile test and run it:
It should return:
For instance, change square.F90:
Then without changing the test, I check if my changes are correct:
And it returns:
The expected value is still 9.0 but now I got 27.0. so the changes I implemented in square.F90
is not correct.
BREAK: 10mn –> 11:45 SA Time
Register your changes with git:
git add interpolate_sub.f90
git add inter_mod.f90
Then we need to setup username and email address for git:
configure git:
Sor for me:
Then we "commit":
On github: https://github.com/annefou/hackathon-south-africa
we still do not have this change yet so we need to "push" the changes to github:
Ask you for username (maryjanebopape) and password.
Then it is updated on github.
For everyone else, we need to update our local copy:
Do you get Mary-Jane's changes on your local "copy"?
And we can now check our local copy works:
Compile:
And run:
Values at 4 points: 29, 30, 31 and 32
Answer: 30.5
Latitude: south point: -33, north point: -31
Longitude: west point: 20, east point: 22
Station point: 21; -32
replaced by
update test_Inter_mod.pf
but we got an error because we need to define PFUNIT_DIR
Failed with an error with lonstat because we did not define it as an array of 1. So let's update it:
update test_Inter_mod.pf
We also need to update makefile:
but then the test is failing so we need to investigate why:
We chose to test the function itself (it is a bit of a hack e.g. we had to remove pure, etc. but at least we can check the values)
The value returned is still 30.25. Now we see that the interpolation may not be as
simple as we though when we built the test.
We chose to add a tolerance in our test. When interpolation to a station location, we could use different interpolation method but the value should be withi 0.25 C.
Then it worked.
When designing your test:
Now let's clean Inter_mod.F90